Modified the file name 23/183923/2 submit/tizen/20180716.052318
authortaesub kim <taesub.kim@samsung.com>
Thu, 12 Jul 2018 09:28:21 +0000 (18:28 +0900)
committertaesub.kim <taesub.kim@samsung.com>
Mon, 16 Jul 2018 04:52:24 +0000 (13:52 +0900)
Change-Id: I3f16c24bf2a29ffe6158037c9fcd3914a79613e7
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
109 files changed:
include/inm-connman.h [new file with mode: 0644]
include/inm-daemon-log.h [new file with mode: 0644]
include/inm-daemon.h [new file with mode: 0644]
include/inm-dump.h [new file with mode: 0644]
include/inm-error.h [new file with mode: 0644]
include/inm-gdbus.h [new file with mode: 0644]
include/inm-iface-mon.h [new file with mode: 0644]
include/inm-ip-conflict.h [new file with mode: 0644]
include/inm-mobileap.h [new file with mode: 0644]
include/inm-net-access.h [new file with mode: 0644]
include/inm-statistics.h [new file with mode: 0644]
include/inm-stc-manager.h [new file with mode: 0644]
include/inm-supplicant.h [new file with mode: 0644]
include/inm-telephony.h [new file with mode: 0644]
include/inm-util.h [new file with mode: 0644]
include/inm-wfd-manager.h [new file with mode: 0644]
include/nm-connman.h [deleted file]
include/nm-daemon-log.h [deleted file]
include/nm-daemon.h [deleted file]
include/nm-dump.h [deleted file]
include/nm-error.h [deleted file]
include/nm-gdbus.h [deleted file]
include/nm-iface-mon.h [deleted file]
include/nm-ip-conflict.h [deleted file]
include/nm-mobileap.h [deleted file]
include/nm-net-access.h [deleted file]
include/nm-statistics.h [deleted file]
include/nm-stc-manager.h [deleted file]
include/nm-supplicant.h [deleted file]
include/nm-telephony.h [deleted file]
include/nm-util.h [deleted file]
include/nm-wfd-manager.h [deleted file]
inm-manager.manifest [new file with mode: 0755]
nm-daemon.manifest [deleted file]
packaging/dbus-inm-manager.conf [new file with mode: 0644]
packaging/dbus-nm-daemon.conf [deleted file]
packaging/inm-manager.service [new file with mode: 0644]
packaging/inm-manager.spec [new file with mode: 0755]
packaging/net.inm_manager.service [new file with mode: 0644]
packaging/net.nm_daemon.service [deleted file]
packaging/nm-daemon.service [deleted file]
packaging/nm-daemon.spec [deleted file]
src/CMakeLists.txt
src/inm-apagent.c [new file with mode: 0644]
src/inm-congestion-mon.c [new file with mode: 0644]
src/inm-connman-internal.h [new file with mode: 0644]
src/inm-connman-mgr.c [new file with mode: 0644]
src/inm-connman-service.c [new file with mode: 0755]
src/inm-connman-tech.c [new file with mode: 0644]
src/inm-connman.c [new file with mode: 0644]
src/inm-daemon-main.c [new file with mode: 0644]
src/inm-daemon.c [new file with mode: 0644]
src/inm-dump.c [new file with mode: 0644]
src/inm-error.c [new file with mode: 0644]
src/inm-gdbus.c [new file with mode: 0644]
src/inm-iface-mon.c [new file with mode: 0644]
src/inm-ip-conflict.c [new file with mode: 0644]
src/inm-mobileap.c [new file with mode: 0644]
src/inm-net-access.c [new file with mode: 0644]
src/inm-netaccess.c [new file with mode: 0644]
src/inm-netlink.c [new file with mode: 0644]
src/inm-statistics.c [new file with mode: 0644]
src/inm-stc-manager.c [new file with mode: 0644]
src/inm-supplicant-bss.c [new file with mode: 0644]
src/inm-supplicant-iface.c [new file with mode: 0644]
src/inm-supplicant-internal.h [new file with mode: 0644]
src/inm-supplicant-network.c [new file with mode: 0644]
src/inm-supplicant-p2p.c [new file with mode: 0644]
src/inm-supplicant-wps.c [new file with mode: 0644]
src/inm-supplicant.c [new file with mode: 0644]
src/inm-telephony.c [new file with mode: 0644]
src/inm-util.c [new file with mode: 0644]
src/inm-wfd-manager.c [new file with mode: 0644]
src/inm-wfdmanager.c [new file with mode: 0644]
src/nm-apagent.c [deleted file]
src/nm-congestion-mon.c [deleted file]
src/nm-connman-internal.h [deleted file]
src/nm-connman-mgr.c [deleted file]
src/nm-connman-service.c [deleted file]
src/nm-connman-tech.c [deleted file]
src/nm-connman.c [deleted file]
src/nm-daemon-main.c [deleted file]
src/nm-daemon.c [deleted file]
src/nm-dump.c [deleted file]
src/nm-error.c [deleted file]
src/nm-gdbus.c [deleted file]
src/nm-iface-mon.c [deleted file]
src/nm-ip-conflict.c [deleted file]
src/nm-mobileap.c [deleted file]
src/nm-net-access.c [deleted file]
src/nm-netaccess.c [deleted file]
src/nm-netlink.c [deleted file]
src/nm-statistics.c [deleted file]
src/nm-stc-manager.c [deleted file]
src/nm-supplicant-bss.c [deleted file]
src/nm-supplicant-iface.c [deleted file]
src/nm-supplicant-internal.h [deleted file]
src/nm-supplicant-network.c [deleted file]
src/nm-supplicant-p2p.c [deleted file]
src/nm-supplicant-wps.c [deleted file]
src/nm-supplicant.c [deleted file]
src/nm-telephony.c [deleted file]
src/nm-util.c [deleted file]
src/nm-wfd-manager.c [deleted file]
src/nm-wfdmanager.c [deleted file]
test/CMakeLists.txt
test/inm-test.c [new file with mode: 0644]
test/nm-test.c [deleted file]
unittest/CMakeLists.txt

diff --git a/include/inm-connman.h b/include/inm-connman.h
new file mode 100644 (file)
index 0000000..7dfa659
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macro and declares functions for handling signal from connman.
+ *
+ * @file        nm-connman.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#ifndef __NM_CONNMAN_H__
+#define __NM_CONNMAN_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CONNMAN_SERVICE                                        "net.connman"
+#define CONNMAN_PATH                                   "/net/connman"
+
+#define CONNMAN_CLOCK_INTERFACE                        CONNMAN_SERVICE ".Clock"
+#define CONNMAN_ERROR_INTERFACE                        CONNMAN_SERVICE ".Error"
+#define CONNMAN_MANAGER_INTERFACE              CONNMAN_SERVICE ".Manager"
+#define CONNMAN_SERVICE_INTERFACE              CONNMAN_SERVICE ".Service"
+#define CONNMAN_TECHNOLOGY_INTERFACE   CONNMAN_SERVICE ".Technology"
+
+typedef enum {
+       NM_CONNMAN_ERROR_NONE = 0,
+       NM_CONNMAN_ERROR_NOT_INITIALIZED,
+       NM_CONNMAN_ERROR_INVALID_PARAM,
+       NM_CONNMAN_ERROR_ALREADY_EXIST,
+       NM_CONNMAN_ERROR_OPERATION_FAILED,
+       NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED,
+       NM_CONNMAN_ERROR_METHOD_CALL_FAILED,
+       NM_CONNMAN_ERROR_TECH_INIT_FAILED,
+       NM_CONNMAN_ERROR_SRV_INIT_FAILED,
+       NM_CONNMAN_ERROR_NO_CONNECTION,
+
+} nm_connman_error_e;
+
+typedef enum {
+       CONNMAN_TECH_STATE_UNKNOWN,
+       CONNMAN_TECH_STATE_POWER_OFF,
+       CONNMAN_TECH_STATE_POWER_ON,
+       CONNMAN_TECH_STATE_CONNECTED,
+} connman_tech_state_e;
+
+typedef enum {
+       CONNMAN_SERVICE_TYPE_UNKNOWN,
+       CONNMAN_SERVICE_TYPE_SYSTEM,
+       CONNMAN_SERVICE_TYPE_ETHERNET,
+       CONNMAN_SERVICE_TYPE_WIFI,
+       CONNMAN_SERVICE_TYPE_BLUETOOTH,
+       CONNMAN_SERVICE_TYPE_CELLULAR,
+       CONNMAN_SERVICE_TYPE_GPS,
+       CONNMAN_SERVICE_TYPE_VPN,
+       CONNMAN_SERVICE_TYPE_GADGET,
+       CONNMAN_SERVICE_TYPE_P2P,
+} connman_service_type_e;
+
+typedef enum {
+       CONNMAN_SERVICE_ERROR_UNKNOWN,
+       CONNMAN_SERVICE_ERROR_OUT_OF_RANGE,
+       CONNMAN_SERVICE_ERROR_PIN_MISSING,
+       CONNMAN_SERVICE_ERROR_DHCP_FAILED,
+       CONNMAN_SERVICE_ERROR_CONNECT_FAILED,
+       CONNMAN_SERVICE_ERROR_LOGIN_FAILED,
+       CONNMAN_SERVICE_ERROR_AUTH_FAILED,
+       CONNMAN_SERVICE_ERROR_INVALID_KEY,
+} connman_service_error_e;
+
+int nm_connman_init();
+int nm_connman_deinit();
+
+typedef void (*nm_connman_tech_changed_cb)(connman_service_type_e type,
+               connman_tech_state_e state);
+
+int nm_connman_set_tech_changed_callback(nm_connman_tech_changed_cb cb);
+int nm_connman_unset_tech_changed_callback();
+
+typedef void (*nm_connman_conn_changed_cb)(GVariant *signal_args);
+
+int nm_connman_set_conn_changed_callback(nm_connman_conn_changed_cb cb);
+int nm_connman_unset_conn_changed_callback();
+
+typedef void (*nm_connman_error_cb)(connman_service_error_e error);
+
+int nm_connman_set_conn_error_callback(nm_connman_error_cb cb);
+int nm_connman_unset_conn_error_callback();
+
+int nm_connman_get_connection(gpointer user_data, GVariant **connection);
+int nm_connman_get_current_connection(GVariant **current_conn);
+int nm_connman_get_connections(GVariant **connections);
+
+int nm_connman_tech_get_state(connman_service_type_e type,
+               connman_tech_state_e *state);
+
+int nm_connman_mgr_get_properties();
+int nm_connman_mgr_get_technologies();
+int nm_connman_mgr_get_services();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_CONNMAN_H__ */
diff --git a/include/inm-daemon-log.h b/include/inm-daemon-log.h
new file mode 100644 (file)
index 0000000..7744dbf
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file declares macros for logging.
+ *
+ * @file        nm-daemon-log.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#ifndef __NM_DAEMON_LOG_H__
+#define __NM_DAEMON_LOG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef USE_DLOG
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "NM_DAEMON"
+
+#define NM_LOGV(format, args...) LOGV(format, ##args)
+#define NM_LOGD(format, args...) LOGD(format, ##args)
+#define NM_LOGI(format, args...) LOGI(format, ##args)
+#define NM_LOGW(format, args...) LOGW(format, ##args)
+#define NM_LOGE(format, args...) LOGE(format, ##args)
+#define NM_LOGF(format, args...) LOGF(format, ##args)
+
+#define __NM_FUNC_ENTER__ LOGD("Enter")
+#define __NM_FUNC_EXIT__ LOGD("Quit")
+
+#define NM_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)
+#define NM_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)
+
+#else /* USE_DLOG */
+
+#define NM_LOGV(format, args...)
+#define NM_LOGD(format, args...)
+#define NM_LOGI(format, args...)
+#define NM_LOGW(format, args...)
+#define NM_LOGE(format, args...)
+#define NM_LOGF(format, args...)
+
+#define __NM_FUNC_ENTER__
+#define __NM_FUNC_EXIT__
+
+#define NM_SECLOGI(format, args...)
+#define NM_SECLOGD(format, args...)
+
+#endif /* USE_DLOG */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_DAEMON_LOG_H__ */
diff --git a/include/inm-daemon.h b/include/inm-daemon.h
new file mode 100644 (file)
index 0000000..8577c76
--- /dev/null
@@ -0,0 +1,231 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macros and declares funcitons for Network Monitoring Daemon.
+ *
+ * @file        nm-daemon.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __NM_DAEMON_H__
+#define __NM_DAEMON_H__
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef IFNAMSIZ
+#define IFNAMSIZ 16
+#endif
+
+#define NL80211_CMD_GET_STATION                17
+#define NL80211_CMD_GET_SCAN           32
+#define NL80211_CMD_GET_SURVEY         50
+
+#define NL80211_STA_INFO_INACTIVE_TIME 1
+#define NL80211_STA_INFO_TX_BITRATE    8
+#define NL80211_STA_INFO_TX_PACKETS    10
+#define NL80211_STA_INFO_TX_RETRIES    11
+#define NL80211_STA_INFO_TX_FAILED     12
+#define NL80211_STA_INFO_MAX           34
+
+#define NL80211_ATTR_IFINDEX           3
+#define NL80211_ATTR_MAC               6
+#define NL80211_ATTR_STA_INFO          21
+#define NL80211_ATTR_BSS               47
+#define NL80211_ATTR_SURVEY_INFO       84
+#define NL80211_ATTR_MAX               264
+
+#define SEC_OFFSET_LEN                 16
+
+typedef enum {
+       NM_DAEMON_ERROR_NONE = 0,
+       NM_DAEMON_ERROR_NOT_INITIALIZED,
+       NM_DAEMON_ERROR_INVALID_PARAM,
+       NM_DAEMON_ERROR_NOT_PERMITTED,
+       NM_DAEMON_ERROR_OUT_OF_MEMORY,
+       NM_DAEMON_ERROR_OPERATION_FAILED,
+       NM_DAEMON_ERROR_IN_PROGRESS,
+} nm_daemon_error_e;
+
+typedef enum {
+       __NL80211_SURVEY_INFO_INVALID,
+       NL80211_SURVEY_INFO_FREQUENCY,
+       NL80211_SURVEY_INFO_NOISE,
+       NL80211_SURVEY_INFO_IN_USE,
+       NL80211_SURVEY_INFO_TIME,
+       NL80211_SURVEY_INFO_TIME_BUSY,
+       NL80211_SURVEY_INFO_TIME_EXT_BUSY,
+       NL80211_SURVEY_INFO_TIME_RX,
+       NL80211_SURVEY_INFO_TIME_TX,
+       NL80211_SURVEY_INFO_TIME_SCAN,
+       NL80211_SURVEY_INFO_PAD,
+
+       /* keep last */
+       __NL80211_SURVEY_INFO_AFTER_LAST,
+       NL80211_SURVEY_INFO_MAX = __NL80211_SURVEY_INFO_AFTER_LAST - 1
+} nl80211_survey_info_e;
+
+typedef enum {
+       __NL80211_BSS_INVALID,
+       NL80211_BSS_BSSID,
+       NL80211_BSS_FREQUENCY,
+       NL80211_BSS_TSF,
+       NL80211_BSS_BEACON_INTERVAL,
+       NL80211_BSS_CAPABILITY,
+       NL80211_BSS_INFORMATION_ELEMENTS,
+       NL80211_BSS_SIGNAL_MBM,
+       NL80211_BSS_SIGNAL_UNSPEC,
+       NL80211_BSS_STATUS,
+       NL80211_BSS_SEEN_MS_AGO,
+       NL80211_BSS_BEACON_IES,
+       NL80211_BSS_CHAN_WIDTH,
+       NL80211_BSS_BEACON_TSF,
+       NL80211_BSS_PRESP_DATA,
+       NL80211_BSS_LAST_SEEN_BOOTTIME,
+       NL80211_BSS_PAD,
+       NL80211_BSS_PARENT_TSF,
+       NL80211_BSS_PARENT_BSSID,
+       NL80211_BSS_CHAIN_SIGNAL,
+
+       /* keep last */
+       __NL80211_BSS_AFTER_LAST,
+       NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
+} nl80211_bss_e;
+
+enum nl80211_bss_status {
+       NL80211_BSS_STATUS_AUTHENTICATED,
+       NL80211_BSS_STATUS_ASSOCIATED,
+       NL80211_BSS_STATUS_IBSS_JOINED,
+};
+
+enum nl80211_rate_info {
+       __NL80211_RATE_INFO_INVALID,
+       NL80211_RATE_INFO_BITRATE,
+       NL80211_RATE_INFO_MCS,
+       NL80211_RATE_INFO_40_MHZ_WIDTH,
+       NL80211_RATE_INFO_SHORT_GI,
+       NL80211_RATE_INFO_BITRATE32,
+       NL80211_RATE_INFO_VHT_MCS,
+       NL80211_RATE_INFO_VHT_NSS,
+       NL80211_RATE_INFO_80_MHZ_WIDTH,
+       NL80211_RATE_INFO_80P80_MHZ_WIDTH,
+       NL80211_RATE_INFO_160_MHZ_WIDTH,
+
+       /* keep last */
+       __NL80211_RATE_INFO_AFTER_LAST,
+       NL80211_RATE_INFO_MAX = __NL80211_RATE_INFO_AFTER_LAST - 1
+};
+
+typedef enum
+{
+       NMDAEMON_MONITOR_TYPE_UNKNOWN,
+       NMDAEMON_MONITOR_TYPE_DEVICE_STATE,
+       NMDAEMON_MONITOR_TYPE_CONGESTION,
+       NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE,
+       NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE,
+       NMDAEMON_MONITOR_TYPE_MAX
+} nmdaemon_request_type_e;
+
+typedef enum {
+       NMDAEMON_HTMODE_HTNONE = 0,
+       NMDAEMON_HTMODE_HT20,
+       NMDAEMON_HTMODE_HT40,
+       NMDAEMON_HTMODE_HT80,
+       NMDAEMON_HTMODE_HT160,
+       NMDAEMON_HTMODE_UNKNOWN
+} nmdaemon_htmode_e;
+
+typedef void (*nm_retry_tx_rate_callback)(int retry_rate, void *user_data);
+typedef void (*nm_channel_interference_callback)(int freq, double channel_intf, void *user_data);
+
+typedef struct
+{
+       gboolean is_initialized;
+       GHashTable *mon_table;
+} nmdaemon_request_table_s;
+
+typedef struct {
+       int id;
+       int if_index;
+       int cmd;
+       struct nl_cb *cb;
+       struct nl_sock *socket;
+} nmdaemon_nl_global_s;
+
+typedef struct {
+       int freq;
+       double intf_factor;
+} nmdaemon_chan_info_s;
+
+typedef struct {
+       nmdaemon_chan_info_s chan[24];
+       gboolean is_2_4Ghz_band;
+       nmdaemon_htmode_e htmode;
+       int cur_pos;
+       int home_channel_pos;
+       int home_channel_freq;
+} nmdaemon_chan_intf_info_s;
+
+typedef struct {
+       guint timer_source_id;
+       nm_retry_tx_rate_callback tx_cb;
+       nm_channel_interference_callback ch_cb;
+       nmdaemon_nl_global_s *nl_global;
+       nmdaemon_chan_intf_info_s *intf_info;
+       int freq;
+       double total_intf;
+       char sec_chan_offset[SEC_OFFSET_LEN];
+       gpointer cb_user_data;
+} nmdaemon_mon_data_s;
+
+int nm_retry_tx_rate_monitor_start(nm_retry_tx_rate_callback cb, void *user_data);
+int nm_retry_tx_rate_monitor_stop(void);
+
+int nm_channel_interference_monitor_start(nm_channel_interference_callback cb, void *user_data);
+int nm_channel_interference_monitor_stop();
+
+int nm_daemon_set_tcpdump(gboolean state);
+int nm_daemon_get_tcpdump_state(gboolean *state);
+
+int nm_daemon_set_ip_conflict_detect(gboolean detect);
+int nm_daemon_get_ip_conflict_detect(gboolean *detect);
+int nm_daemon_get_ip_conflict_state(gboolean *state);
+
+int nm_daemon_get_ethernet_cable_state(gboolean *state);
+int nm_daemon_get_wifi_module_state(gboolean *state);
+
+int nm_daemon_get_congestion_level(int *level);
+int nm_daemon_get_retry_tx_rate(int *rate);
+int nm_daemon_get_channel_interference(double *ch_interference);
+
+int nm_daemon_get_cellular_state(int *state);
+int nm_daemon_get_wifi_state(int *state);
+int nm_daemon_get_ethernet_state(int *state);
+
+int nm_daemon_get_wifi_scan_state(gboolean *state);
+
+void nm_daemon_set_loop(GMainLoop *loop);
+void nm_daemon_unset_loop();
+
+int nm_daemon_init();
+int nm_daemon_deinit();
diff --git a/include/inm-dump.h b/include/inm-dump.h
new file mode 100644 (file)
index 0000000..b08e9e1
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macros and declares functions for dump.
+ *
+ * @file        nm-dump.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __NM_DUMP_H__
+#define __NM_DUMP_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+       NM_DUMP_ERROR_NONE = 0,
+       NM_DUMP_NOT_INITIALIZED,
+       NM_DUMP_INVALID_PARAMETER,
+       NM_DUMP_OPERATION_FAILED,
+       NM_DUMP_IN_PROGRESS,
+} nm_dump_error_e;
+
+int nm_dump_start_tcpdump();
+int nm_dump_stop_tcpdump();
+int nm_dump_get_tcpdump_state(gboolean *is_running);
+int nm_dump_log(gchar *dump_path);
+int nm_dump_check_state_and_start();
+
+int nm_dump_init();
+int nm_dump_deinit();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_DUMP_H__ */
diff --git a/include/inm-error.h b/include/inm-error.h
new file mode 100644 (file)
index 0000000..7d78e10
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+/**
+ * This file declares network monitoring deamon dbus error functions.
+ *
+ * @file        nm-error.h
+ * @author      Yu Jiung (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __NM_ERROR_H__
+#define __NM_ERROR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <tizen.h>
+
+void nm_error_set_gerror(nm_daemon_error_e error_code, GError **error);
+void nm_error_register(void);
+void nm_error_deregister(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_ERROR_H__ */
diff --git a/include/inm-gdbus.h b/include/inm-gdbus.h
new file mode 100644 (file)
index 0000000..de39583
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file declares functions for operating GDBus.
+ *
+ * @file        nm-gdbus.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#ifndef __NM_GDBUS_H__
+#define __NM_GDBUS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define DBUS_OBJECT_PATH_MAX 150
+#define DBUS_SERVICE_DBUS                      "org.freedesktop.DBus"
+#define DBUS_INTERFACE_DBUS                    "org.freedesktop.DBus"
+
+#define DBUS_PROPERTIES_INTERFACE      DBUS_INTERFACE_DBUS ".Properties"
+#define DBUS_PROPERTIES_METHOD_GETALL "GetAll"
+
+#define DBUS_SIGNAL_NAME_CHANGED               "NameOwnerChanged"
+#define DBUS_SIGNAL_PROPERTY_CHANGED   "PropertyChanged"
+#define DBUS_SIGNAL_PROPERTIES_CHANGED "PropertiesChanged"
+
+#define NM_DAEMON_SERVICE "net.nm_damon"
+#define NM_DAEMON_OBJ "/net.nm_damon"
+
+#define NM_WIFI_SERVICE NM_DAEMON_SERVICE ".wifi"
+#define NM_WIFI_IFACE NM_DAEMON_SERVICE ".wifi"
+#define NM_WIFI_OBJ NM_DAEMON_OBJ "/wifi"
+
+#define NM_CONN_SERVICE NM_DAEMON_SERVICE ".conn"
+#define NM_CONN_IFACE NM_DAEMON_SERVICE ".conn"
+#define NM_CONN_OBJ NM_DAEMON_OBJ "/conn"
+
+#define DECLARE_DBUS_SIGNAL_HANDLER(name) void __##name(\
+               const gchar *sender_name,\
+               const gchar *object_path,\
+               const gchar *interface_name,\
+               const gchar *signal,\
+               GVariant *parameters,\
+               gpointer user_data)
+
+#define DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(name) void __##name(\
+               gpointer connection,\
+               const gchar *sender_name,\
+               const gchar *object_path,\
+               const gchar *interface_name,\
+               const gchar *signal,\
+               GVariant *parameters,\
+               gpointer user_data)
+
+typedef enum {
+       NM_GDBUS_ERROR_NONE = 0,
+       NM_GDBUS_ERROR_NOT_INITIALIZED,
+       NM_GDBUS_ERROR_INVALID_PARAM,
+       NM_GDBUS_ERROR_ALREADY_EXIST,
+       NM_GDBUS_ERROR_OPERATION_FAILED,
+       NM_GDBUS_ERROR_HAS_NO_OWNER,
+
+} nm_gdbus_error_e;
+
+typedef void (*bus_aquired_callback)(void);
+typedef void (*name_lost_callback)(void);
+
+typedef void (*handle_signal) (
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+typedef void (*handle_signal_with_data) (
+               gpointer connection,
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+typedef void (*handle_reply) (GVariant *value, void *user_data);
+
+typedef struct{
+       const gchar *sender;
+       const gchar *interface_name;
+       const gchar *member;
+       const gchar *object_path;
+       const gchar *arg0;
+       handle_signal callback;
+       handle_signal_with_data callback_with_data;
+       guint subscriber_id;
+} signal_param_s;
+
+typedef struct {
+       const gchar *bus_name;
+       const gchar *object_path;
+    const gchar *interface_name;
+    const gchar *method_name;
+    GVariant *parameters;
+} method_param_s;
+
+int nm_gdbus_method_call(method_param_s *params,
+               handle_reply function, void *user_data);
+
+int nm_gdbus_subscribe_signal(signal_param_s *param);
+int nm_gdbus_subscribe_signal_with_data(signal_param_s *param, gpointer user_data);
+int nm_gdbus_unsubscribe_signal(signal_param_s *param);
+
+gboolean nm_gdbus_emit_signal(const gchar *destination_bus_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *params);
+
+void nm_gdbus_emit_ip_conflicted(int state, gchar *if_name, gchar *ip);
+void nm_gdbus_emit_ethernet_cable_state(gboolean state);
+void nm_gdbus_emit_wifi_module_state(gboolean state);
+void nm_gdbus_emit_retry_tx_rate_changed(int retry_tx_rate);
+void nm_gdbus_emit_congestion_level_changed(int congestion_level);
+void nm_gdbus_emit_channel_interference(int freq, double channel_intf);
+void nm_gdbus_emit_cellular_state(int state);
+void nm_gdbus_emit_wifi_state(int state);
+void nm_gdbus_emit_ethernet_state(int state);
+void nm_gdbus_emit_connections_changed(GVariant *signal_args);
+
+void nm_gdbus_emit_conn_ipv4_state_changed(gchar *path, GVariant *signal_args);
+void nm_gdbus_emit_conn_ipv6_state_changed(gchar *path, GVariant *signal_args);
+void nm_gdbus_emit_conn_ip_changed(gchar *path, GVariant *signal_args);
+void nm_gdbus_emit_conn_dns_changed(gchar *path, GVariant *signal_args);
+
+void nm_gdbus_emit_wifi_scanning_changed(gboolean scanning);
+
+int nm_gdbus_register_conn_iface(gchar *conn_obj,
+               guint *conn_obj_id,
+               gpointer conn);
+void nm_gdbus_deregister_conn_iface(guint nm_conn_obj_id);
+
+int nm_gdbus_register_daemon_iface(void);
+int nm_gdbus_register_wifi_iface(void);
+
+int nm_gdbus_is_wpasupplicant_enabled(gboolean *enabled);
+int nm_gdbus_is_connman_enabled(gboolean *enabled);
+int nm_gdbus_is_telephony_enabled(gboolean *enabled);
+int nm_gdbus_is_wfd_manager_enabled(gboolean *enabled);
+int nm_gdbus_is_mobileap_enabled(gboolean *enabled);
+int nm_gdbus_is_stc_manager_enabled(gboolean *enabled);
+
+typedef void (*nm_gdbus_watching_bus_callback)(gboolean appeared);
+int nm_gdbus_set_wpasupplicant_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
+int nm_gdbus_unset_wpasupplicant_bus_watching_callback();
+int nm_gdbus_set_connman_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
+int nm_gdbus_unset_connman_bus_watching_callback();
+int nm_gdbus_set_telephony_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
+int nm_gdbus_unset_telephony_bus_watching_callback();
+int nm_gdbus_set_wfd_manager_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
+int nm_gdbus_unset_wfd_manager_bus_watching_callback();
+int nm_gdbus_set_mobileap_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
+int nm_gdbus_unset_mobileap_bus_watching_callback();
+int nm_gdbus_set_stc_manager_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
+int nm_gdbus_unset_stc_manager_bus_watching_callback();
+
+int nm_gdbus_init(bus_aquired_callback bus_acquired_cb,
+                                 name_lost_callback name_lost_cb);
+int nm_gdbus_deinit();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_GDBUS_H__ */
diff --git a/include/inm-iface-mon.h b/include/inm-iface-mon.h
new file mode 100644 (file)
index 0000000..e75fc69
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macros and declares functions for monitoring interface.
+ *
+ * @file        nm-iface-mon.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __NM_IFACE_MON_H__
+#define __NM_IFACE_MON_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+       NM_IFACE_MON_ERROR_NONE = 0,
+       NM_IFACE_MON_NOT_INITIALIZED,
+       NM_IFACE_MON_INVALID_PARAMETER,
+       NM_IFACE_MON_OPERATION_FAILED,
+} nm_iface_mon_error_e;
+
+typedef void (*nm_iface_mon_callback)(char *iface_name, int state, void *user_data);
+
+typedef struct {
+       gchar iface_name[16];
+       guint timer_source_id;
+       nm_iface_mon_callback cb;
+       gpointer cb_user_data;
+}iface_mon_data_s;
+
+int nm_iface_mon_start_monitor(char *iface_name, nm_iface_mon_callback cb, void *user_data);
+int nm_iface_mon_stop_monitor(char *iface_name);
+int nm_iface_mon_get_iface_state(char *iface_name, int *state);
+
+int nm_iface_mon_init();
+int nm_iface_mon_deinit();
+int nm_rtnl_init(gpointer user_data);
+void nm_rtnl_cleanup(void);
+
+/** Congestion Network */
+typedef enum {
+       NM_CONG_MON_ERROR_NONE = 0,
+       NM_CONG_MON_NOT_INITIALIZED,
+       NM_CONG_MON_ALREADY_STARTED,
+       NM_CONG_MON_INVALID_PARAMETER,
+       NM_CONG_MON_OPERATION_FAILED,
+} nm_cong_mon_error_e;
+
+typedef void (*nm_congestion_mon_callback)(int status, void *user_data);
+
+int nm_congestion_monitor_start(nm_congestion_mon_callback cb, void *user_data);
+int nm_congestion_monitor_stop(void);
+
+int nm_congestion_mon_init(void);
+int nm_congestion_mon_deinit(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_IFACE_MON_H__ */
diff --git a/include/inm-ip-conflict.h b/include/inm-ip-conflict.h
new file mode 100644 (file)
index 0000000..faacf3b
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+
+ * This file declares functions for detecting IP conflict.
+ *
+ * @file        nm-ip-conflict.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#ifndef __NM_IP_CONFLICT_H__
+#define __NM_IP_CONFLICT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+       NM_IP_CONFLICT_ERROR_NONE = 0,
+       NM_IP_CONFLICT_ERROR_NOT_INITIALIZED,
+       NM_IP_CONFLICT_ERROR_INVALID_PARAM,
+       NM_IP_CONFLICT_ERROR_ALREADY_EXIST,
+       NM_IP_CONFLICT_ERROR_OPERATION_FAILED,
+       NM_IP_CONFLICT_ERROR_IN_PROGRESS,
+
+} nm_ip_conflict_error_e;
+
+typedef enum {
+       IP_CONFLICT_STATE_UNKNOWN,
+       IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED,
+       IP_CONFLICT_STATE_CONFLICT_DETECTED
+} nm_ip_conflict_state_e;
+
+typedef void (*ip_conflict_callback) (int state, gchar *if_name,  guchar *ip, gpointer user_data);
+
+int nm_ip_conflict_enable_detection(gchar *if_name, gboolean enable);
+int nm_ip_conflict_get_detection_period(guint *period);
+int nm_ip_conflict_set_detection_period(guint period);
+int nm_ip_conflict_get_state(gchar *if_name, guint *state);
+int nm_ip_conflict_is_detection_enabled(gchar *if_name, gboolean *enabled);
+
+int ip_conflict_detection_init();
+int ip_conflict_detection_deinit();
+int ip_conflict_set_callback(gchar *if_name, ip_conflict_callback cb, gpointer user_data);
+int ip_conflict_unset_callback(gchar *if_name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_IP_CONFLICT_H__ */
diff --git a/include/inm-mobileap.h b/include/inm-mobileap.h
new file mode 100644 (file)
index 0000000..0452f7b
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macro and declares functions for handling signal from MobileAP-agent.
+ *
+ * @file        nm-mobileap.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#ifndef __NM_MOBILEAP_H__
+#define __NM_MOBILEAP_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MOBILEAP_SERVICE                       "org.tizen.MobileapAgent"
+#define MOBILEAP_PATH                          "/MobileapAgent"
+
+#define SOFTAP_INTERFACE                       "org.tizen.softap"
+#define TETHERING_INTERFACE                    "org.tizen.tethering"
+
+#define DNSMASQ_INTERFACE                      "uk.org.thekelleys.dnsmasq"
+
+typedef enum {
+       NM_MOBILEAP_ERROR_NONE = 0,
+       NM_MOBILEAP_ERROR_NOT_INITIALIZED,
+       NM_MOBILEAP_ERROR_INVALID_PARAM,
+       NM_MOBILEAP_ERROR_ALREADY_EXIST,
+       NM_MOBILEAP_ERROR_OPERATION_FAILED,
+       NM_MOBILEAP_ERROR_SIGNAL_SUBSCRIBE_FAILED,
+       NM_MOBILEAP_ERROR_METHOD_CALL_FAILED,
+} nm_mobileap_error_e;
+
+int nm_mobileap_init();
+int nm_mobileap_deinit();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_MOBILEAP_H__ */
diff --git a/include/inm-net-access.h b/include/inm-net-access.h
new file mode 100644 (file)
index 0000000..e292fd2
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macros and declares functions get internet accessibility.
+ *
+ * @file        nm-net-access.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __NM_NET_ACCESS_H__
+#define __NM_NET_ACCESS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void nm_net_access_init(void);
+void nm_net_access_deinit(void);
+
+void nm_net_access_start_checking(void);
+void nm_net_access_stop_checking(void);
+
+/* Alert: Please do not use nm_net_access_get_status() API to get the
+ * status of Internet availability on general Wifi access points, as this module
+ * primarily checks for Internet availability on portal enabled Wifi access
+ * points, so we only check for below criteria in server's response to conclude
+ * whether Internet is accessible.
+ * 1) If the HTTP status != 302
+ * 2) If the HTTP status != (200 with redirection),
+*/
+gboolean nm_net_access_get_status();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_NET_ACCESS_H__ */
diff --git a/include/inm-statistics.h b/include/inm-statistics.h
new file mode 100644 (file)
index 0000000..230c09d
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macros and declares functions get network_statistics.
+ *
+ * @file        nm-statistics.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __NM_STATISTICS_H__
+#define __NM_STATISTICS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef IFNAMSIZ
+#define IFNAMSIZ 16
+#endif
+
+typedef enum {
+       NM_STATISTICS_ERROR_NONE = 0,
+       NM_STATISTICS_ERROR_NOT_INITIALIZED,
+       NM_STATISTICS_ERROR_INVALID_PARAM,
+       NM_STATISTICS_ERROR_OPERATION_FAILED,
+} nm_statistics_error_e;
+
+typedef struct {
+       gchar ifname[IFNAMSIZ + 1];
+       guint64 rx_bytes;
+       guint64 rx_packets;
+       gulong rx_errs;
+       gulong rx_drop;
+       gulong rx_fifo;
+       gulong rx_frame;
+       gulong rx_compressed;
+       gulong rx_multicast;
+       guint64 tx_bytes;
+       guint64 tx_packets;
+       gulong tx_errs;
+       gulong tx_drop;
+       gulong tx_fifo;
+       gulong tx_cols;
+       gulong tx_carrier;
+       gulong tx_compressed;
+} nm_statistic_s;
+
+typedef void (*nm_statistics_callback)(nm_statistic_s* stats, void *user_data);
+
+int nm_statistics_start_monitor(nm_statistics_callback cb, void *user_data);
+int nm_statistics_stop_monitor();
+int nm_statistics_is_enabled(gboolean *enabled);
+
+int nm_statistics_init();
+int nm_statistics_deinit();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_STATISTICS_H__ */
diff --git a/include/inm-stc-manager.h b/include/inm-stc-manager.h
new file mode 100644 (file)
index 0000000..dc2c6f6
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macro and declares functions for handling signal from STC-manager.
+ *
+ * @file        nm-stc-manager.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#ifndef __NM_STC_MANAGER_H__
+#define __NM_STC_MANAGER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define STC_MANAGER_SERVICE                                    "net.stc"
+#define STC_MANAGER_STATS_INTERFACE                    STC_MANAGER_SERVICE ".statistics"
+#define STC_MANAGER_RESTRICTION_INTERFACE      STC_MANAGER_SERVICE ".restriction"
+
+#define STC_MANAGER_STATS_PATH                         "/net/stc/statistics"
+#define STC_MANAGER_RESTRICTION_PATH           "/net/stc/restriction"
+
+typedef enum {
+       NM_STC_ERROR_NONE = 0,
+       NM_STC_ERROR_NOT_INITIALIZED,
+       NM_STC_ERROR_INVALID_PARAM,
+       NM_STC_ERROR_ALREADY_EXIST,
+       NM_STC_ERROR_OPERATION_FAILED,
+       NM_STC_ERROR_SIGNAL_SUBSCRIBE_FAILED,
+       NM_STC_ERROR_METHOD_CALL_FAILED,
+} nm_stc_error_e;
+
+int nm_stc_manager_init();
+int nm_stc_manager_deinit();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_STC_MANAGER_H__ */
diff --git a/include/inm-supplicant.h b/include/inm-supplicant.h
new file mode 100644 (file)
index 0000000..8f91c20
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macro and declares functions for handling signal from WPA Supplicant.
+ *
+ * @file        nm-supplicant.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#ifndef __NM_SUPPLICANT_H__
+#define __NM_SUPPLICANT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BSSID_LEN 6
+#define SSID_LEN 32
+#define IFNAME_MAX 32
+
+typedef enum {
+       NM_SUPPLICANT_ERROR_NONE = 0,
+       NM_SUPPLICANT_ERROR_NOT_INITIALIZED,
+       NM_SUPPLICANT_ERROR_INVALID_PARAM,
+       NM_SUPPLICANT_ERROR_ALREADY_EXIST,
+       NM_SUPPLICANT_ERROR_OPERATION_FAILED,
+       NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED,
+       NM_SUPPLICANT_ERROR_METHOD_CALL_FAILED,
+       NM_SUPPLICANT_ERROR_IFACE_INIT_FAILED,
+       NM_SUPPLICANT_ERROR_BSS_INIT_FAILED,
+
+} nm_supplicant_error_e;
+
+typedef enum {
+       NM_SUPPLICANT_IFACE_PROPERTY_NONE = 0,
+       NM_SUPPLICANT_IFACE_PROPERTY_STATE = 1,
+       NM_SUPPLICANT_IFACE_PROPERTY_SCANNING = 2,
+} nm_supplicant_iface_property_e;
+
+typedef enum {
+       IFACE_SIGNAL_SCANDONE,
+       IFACE_SIGNAL_BSSADDED,
+       IFACE_SIGNAL_BSSREMOVED,
+       IFACE_SIGNAL_BLOBADDED,
+       IFACE_SIGNAL_BLOBREMOVED,
+       IFACE_SIGNAL_NETWORKADDED,
+       IFACE_SIGNAL_NETWORKREMOVED,
+       IFACE_SIGNAL_NETWORKSELECTED,
+       IFACE_SIGNAL_STAAUTHORIZED,
+       IFACE_SIGNAL_STADEAUTHORIZED,
+       IFACE_SIGNAL_PROPERTIESCHANGED,
+       IFACE_SIGNAL_CERTIFICATION,
+       IFACE_SIGNAL_EAP,
+       IFACE_SIGNAL_NETWORKREQUEST,
+       IFACE_SIGNAL_PROBEREQUEST,
+       IFACE_SIGNAL_MAX,
+} nm_supplicant_iface_signal_e;
+
+typedef struct {
+       /*
+        * BSSID of the BSS.
+        */
+       guchar bssid[BSSID_LEN];
+       /*
+        * SSID of the BSS.
+        */
+       gchar ssid[SSID_LEN + 1];
+       /*
+        * Frequency of the BSS in MHz.
+        */
+       guint16 frequency;
+
+       /*
+        * Signal strength of the BSS.
+        */
+       gint16 signal;
+} nm_supplicant_bss_s;
+
+typedef struct {
+       guint pairwise;
+       guint group;
+       guint key_mgmt;
+       guint proto;
+       guint auth_alg;
+       guint scan;
+       guint modes;
+
+} supplicant_iface_cap_s;
+
+typedef struct {
+       /*
+        * Capabilities of the interface
+        */
+       supplicant_iface_cap_s cap;
+       /*
+        * A state of the interface
+        */
+       guint state;
+       /*
+        * Determines if the interface is already scanning or not
+        */
+       gboolean scanning;
+       /*
+        * Name of network interface controlled by the interface, e.g., wlan0.
+        */
+       gchar Ifname[IFNAME_MAX];
+       /*
+        * This variable holds the subscriber id which is
+        * subscribing property changed signal of the technology.
+        */
+       guint subscriber_id[IFACE_SIGNAL_MAX];
+       /*
+        * BSS which wpa_supplicant is associated with.
+        */
+       gpointer current_bss;
+       /*
+        * configured network which wpa_supplicant uses at the moment
+        */
+       gpointer current_network;
+       /*
+        * List of BSSs known to the interface
+        */
+       GHashTable *bss_tbl;
+       /*
+        * Wi-Fi P2P properties of the interface
+        */
+       gpointer p2p;
+} nm_supplicant_iface_s;
+
+typedef void (*nm_supplicant_iface_changed_callback)(
+               nm_supplicant_iface_property_e property,
+               nm_supplicant_iface_s *iface,
+               gpointer user_data);
+
+int nm_supplicant_init();
+int nm_supplicant_deinit();
+int nm_supplicant_get_properties();
+
+int nm_supplicant_iface_set_prop_changed_cb(nm_supplicant_iface_changed_callback cb, gpointer user_data);
+int nm_supplicant_iface_unset_prop_changed_cb();
+int nm_supplicant_iface_get_iface(gchar *iface_name, nm_supplicant_iface_s **iface);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_SUPPLICANT_H__ */
diff --git a/include/inm-telephony.h b/include/inm-telephony.h
new file mode 100644 (file)
index 0000000..e73afd4
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macro and declares functions to get information from telephony module.
+ *
+ * @file        nm-telephony.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#ifndef __NM_TELEPHONY_H__
+#define __NM_TELEPHONY_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Profile name max length */
+#define NM_PROFILE_NAME_LEN_MAX 512
+
+/** Home URL max length in profile account */
+#define NM_HOME_URL_LEN_MAX 512
+
+/** Maximum length of APN in PDP profile [3GPP Defined variable] */
+#define NM_PDP_APN_LEN_MAX 100
+
+/** Maximum length of username in PDP profile. (used in authentication parameters) [3GPP Defined variable] */
+#define NM_PDP_AUTH_USERNAME_LEN_MAX 32
+
+/** Maximum length of password in PDP profile (used in authentication parameters) [3GPP Defined variable] */
+#define NM_PDP_AUTH_PASSWORD_LEN_MAX 32
+
+/** Maximum length of proxy string */
+#define NET_PROXY_LEN_MAX 64
+
+typedef enum {
+       NM_TELEPHONY_ERROR_NONE = 0,
+       NM_TELEPHONY_ERROR_NOT_INITIALIZED,
+       NM_TELEPHONY_ERROR_INVALID_PARAM,
+       NM_TELEPHONY_ERROR_ALREADY_EXIST,
+       NM_TELEPHONY_ERROR_OPERATION_FAILED,
+       NM_TELEPHONY_ERROR_SIGNAL_SUBSCRIBE_FAILED,
+       NM_TELEPHONY_ERROR_METHOD_CALL_FAILED,
+} nm_telephony_error_e;
+
+
+/**
+* @enum net_service_type_e
+* This enum indicates network connection type
+*/
+typedef enum
+{
+       /** Unknown type \n
+       */
+       NET_SERVICE_UNKNOWN = 0x00,
+
+       /** Mobile Internet Type \n
+               Network connection is established in Cellular network for Internet \n
+       */
+       NET_SERVICE_INTERNET = 0x01,
+
+       /** Mobile MMS Type \n
+               Network connection is established in Cellular network for MMS \n
+       */
+       NET_SERVICE_MMS = 0x02,
+
+       /** Prepaid Mobile Internet Type \n
+               Network connection is established in Cellular network for prepaid internet service.\n
+               This service supports to establish network connection in prepaid sim case\n
+       */
+       NET_SERVICE_PREPAID_INTERNET = 0x03,
+
+       /** Prepaid Mobile MMS Type \n
+               Network Connection is established in Cellular network for prepaid MMS service. \n
+               This profile supports to establish network connection in prepaid sim case\n
+       */
+       NET_SERVICE_PREPAID_MMS = 0x04,
+
+       /** Mobile Tethering Type \n
+               Network connection is established in Cellular network for Tethering \n
+       */
+       NET_SERVICE_TETHERING = 0x05,
+
+       /** Specific application Type \n
+               Network connection is established in Cellular network for Specific applications \n
+       */
+       NET_SERVICE_APPLICATION = 0x06,
+
+       /** Deprecated type
+        */
+       NET_SERVICE_WAP = 0x06,
+} net_service_type_e;
+
+/**
+ * @enum net_pdn_type_e
+ * This enumeration defines the pdn type.
+ */
+typedef enum
+{
+       NET_PDN_TYPE_UNKNOWN    = 0x00,
+       NET_PDN_TYPE_IPV4               = 0x02,
+       NET_PDN_TYPE_IPV6               = 0x05,
+       NET_PDN_TYPE_IPV4_IPV6  = 0x06,
+} net_pdn_type_e;
+
+/**
+ * @enum net_auth_type_t
+ * PDP Authentication Type
+ */
+typedef enum
+{
+       /** No authentication */
+       NET_PDP_AUTH_NONE       = 0x0,
+
+       /** PAP authentication */
+       NET_PDP_AUTH_PAP        = 0x1,
+
+       /** CHAP authentication */
+       NET_PDP_AUTH_CHAP       = 0x2,
+} net_auth_type_e;
+
+
+/**
+ * PDP Authentication Information
+ */
+typedef struct
+{
+       /** Authentication type  */
+       net_auth_type_e auth_type;
+
+       /** UserName to be used during authentication */
+       char user_name[NM_PDP_AUTH_USERNAME_LEN_MAX + 1];
+
+       /** Password to be used during authentication */
+       char password[NM_PDP_AUTH_PASSWORD_LEN_MAX + 1];
+} net_auth_info_s;
+
+/**
+ * This is the profile structure exposed from modman.
+ */
+typedef struct
+{
+       gint type;
+       gboolean setup_required;
+       /** Profile name(path) */
+       char profile_name[NM_PROFILE_NAME_LEN_MAX + 1];
+       /** Service type of this profile context */
+       net_service_type_e service_type;
+       /** Pdn type of this profile context */
+       net_pdn_type_e pdn_type;
+       /** Roam Pdn type of this profile context */
+       net_pdn_type_e roam_pdn_type;
+       /** Network Access Point Name */
+       char apn[NM_PDP_APN_LEN_MAX + 1];
+       /** Authentication info of the PDP profile */
+       net_auth_info_s auth_info;
+       /**Proxy address */
+       char proxy_addr[NET_PROXY_LEN_MAX + 1];
+       /** Browser Home URL or MMS server URL */
+       char home_url[NM_HOME_URL_LEN_MAX + 1];
+       char keyword[NM_PDP_APN_LEN_MAX + 1];
+       gboolean default_conn;
+       gboolean editable;
+       gboolean hidden;
+} nm_telephony_profile_s;
+
+int nm_telephony_get_pdp_profile(gchar *path, nm_telephony_profile_s *profile_info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_TELEPHONY_H__ */
diff --git a/include/inm-util.h b/include/inm-util.h
new file mode 100644 (file)
index 0000000..7d41449
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file declares utility functions.
+ *
+ * @file        nm-util.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __NM_UTIL_H__
+#define __NM_UTIL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAC_ADDR_LEN 6
+#define MAX_SIZE_ERROR_BUFFER 128
+#define TIME_STR_LEN 128
+#define WIFI_IFNAME    "wlan0"
+
+void get_current_time(gchar *time_str);
+
+int nm_execute_file(const char *file_path,
+               char *const args[], char *const envs[]);
+
+int nm_execute_file_no_wait(const char *file_path, char *const args[]);
+
+int nm_check_cable_status(const char *file_path, int *status);
+
+gboolean nm_get_byte_statistics(const char *ifname, guint64 *tx, guint *rx);
+
+int nmdaemon_get_interface_index(const char *interface_name);
+void nmdaemon_convert_byte_to_string(char *bssid, unsigned char *user_data);
+
+gchar* nm_util_get_default_proxy();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_UTIL_H__ */
+
diff --git a/include/inm-wfd-manager.h b/include/inm-wfd-manager.h
new file mode 100644 (file)
index 0000000..255ae0c
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macro and declares functions for handling signal from wfd-manager.
+ *
+ * @file        nm-wfd-manager.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#ifndef __NM_WFD_MANAGER_H__
+#define __NM_WFD_MANAGER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define WFD_MANAGER_SERVICE                     "net.wifidirect"
+#define WFD_MANAGER_PATH                        "/net/wifidirect"
+#define WFD_MANAGER_MANAGE_INTERFACE            WFD_MANAGER_SERVICE
+#define WFD_MANAGER_GROUP_INTERFACE             WFD_MANAGER_SERVICE ".group"
+#define WFD_MANAGER_CONFIG_INTERFACE            WFD_MANAGER_SERVICE ".config"
+
+typedef enum {
+       NM_WFD_ERROR_NONE = 0,
+       NM_WFD_ERROR_NOT_INITIALIZED,
+       NM_WFD_ERROR_INVALID_PARAM,
+       NM_WFD_ERROR_ALREADY_EXIST,
+       NM_WFD_ERROR_OPERATION_FAILED,
+       NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED,
+       NM_WFD_ERROR_METHOD_CALL_FAILED,
+} nm_wfd_error_e;
+
+typedef enum {
+       NM_WFD_DEVICE_NONE,
+       NM_WFD_DEVICE_GC,
+       NM_WFD_DEVICE_GO,
+} nm_wfd_device_role_e;
+
+int nm_wfd_manager_init();
+int nm_wfd_manager_deinit();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_WFD_MANAGER_H__ */
diff --git a/include/nm-connman.h b/include/nm-connman.h
deleted file mode 100644 (file)
index 7dfa659..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macro and declares functions for handling signal from connman.
- *
- * @file        nm-connman.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#ifndef __NM_CONNMAN_H__
-#define __NM_CONNMAN_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define CONNMAN_SERVICE                                        "net.connman"
-#define CONNMAN_PATH                                   "/net/connman"
-
-#define CONNMAN_CLOCK_INTERFACE                        CONNMAN_SERVICE ".Clock"
-#define CONNMAN_ERROR_INTERFACE                        CONNMAN_SERVICE ".Error"
-#define CONNMAN_MANAGER_INTERFACE              CONNMAN_SERVICE ".Manager"
-#define CONNMAN_SERVICE_INTERFACE              CONNMAN_SERVICE ".Service"
-#define CONNMAN_TECHNOLOGY_INTERFACE   CONNMAN_SERVICE ".Technology"
-
-typedef enum {
-       NM_CONNMAN_ERROR_NONE = 0,
-       NM_CONNMAN_ERROR_NOT_INITIALIZED,
-       NM_CONNMAN_ERROR_INVALID_PARAM,
-       NM_CONNMAN_ERROR_ALREADY_EXIST,
-       NM_CONNMAN_ERROR_OPERATION_FAILED,
-       NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED,
-       NM_CONNMAN_ERROR_METHOD_CALL_FAILED,
-       NM_CONNMAN_ERROR_TECH_INIT_FAILED,
-       NM_CONNMAN_ERROR_SRV_INIT_FAILED,
-       NM_CONNMAN_ERROR_NO_CONNECTION,
-
-} nm_connman_error_e;
-
-typedef enum {
-       CONNMAN_TECH_STATE_UNKNOWN,
-       CONNMAN_TECH_STATE_POWER_OFF,
-       CONNMAN_TECH_STATE_POWER_ON,
-       CONNMAN_TECH_STATE_CONNECTED,
-} connman_tech_state_e;
-
-typedef enum {
-       CONNMAN_SERVICE_TYPE_UNKNOWN,
-       CONNMAN_SERVICE_TYPE_SYSTEM,
-       CONNMAN_SERVICE_TYPE_ETHERNET,
-       CONNMAN_SERVICE_TYPE_WIFI,
-       CONNMAN_SERVICE_TYPE_BLUETOOTH,
-       CONNMAN_SERVICE_TYPE_CELLULAR,
-       CONNMAN_SERVICE_TYPE_GPS,
-       CONNMAN_SERVICE_TYPE_VPN,
-       CONNMAN_SERVICE_TYPE_GADGET,
-       CONNMAN_SERVICE_TYPE_P2P,
-} connman_service_type_e;
-
-typedef enum {
-       CONNMAN_SERVICE_ERROR_UNKNOWN,
-       CONNMAN_SERVICE_ERROR_OUT_OF_RANGE,
-       CONNMAN_SERVICE_ERROR_PIN_MISSING,
-       CONNMAN_SERVICE_ERROR_DHCP_FAILED,
-       CONNMAN_SERVICE_ERROR_CONNECT_FAILED,
-       CONNMAN_SERVICE_ERROR_LOGIN_FAILED,
-       CONNMAN_SERVICE_ERROR_AUTH_FAILED,
-       CONNMAN_SERVICE_ERROR_INVALID_KEY,
-} connman_service_error_e;
-
-int nm_connman_init();
-int nm_connman_deinit();
-
-typedef void (*nm_connman_tech_changed_cb)(connman_service_type_e type,
-               connman_tech_state_e state);
-
-int nm_connman_set_tech_changed_callback(nm_connman_tech_changed_cb cb);
-int nm_connman_unset_tech_changed_callback();
-
-typedef void (*nm_connman_conn_changed_cb)(GVariant *signal_args);
-
-int nm_connman_set_conn_changed_callback(nm_connman_conn_changed_cb cb);
-int nm_connman_unset_conn_changed_callback();
-
-typedef void (*nm_connman_error_cb)(connman_service_error_e error);
-
-int nm_connman_set_conn_error_callback(nm_connman_error_cb cb);
-int nm_connman_unset_conn_error_callback();
-
-int nm_connman_get_connection(gpointer user_data, GVariant **connection);
-int nm_connman_get_current_connection(GVariant **current_conn);
-int nm_connman_get_connections(GVariant **connections);
-
-int nm_connman_tech_get_state(connman_service_type_e type,
-               connman_tech_state_e *state);
-
-int nm_connman_mgr_get_properties();
-int nm_connman_mgr_get_technologies();
-int nm_connman_mgr_get_services();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_CONNMAN_H__ */
diff --git a/include/nm-daemon-log.h b/include/nm-daemon-log.h
deleted file mode 100644 (file)
index 7744dbf..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file declares macros for logging.
- *
- * @file        nm-daemon-log.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#ifndef __NM_DAEMON_LOG_H__
-#define __NM_DAEMON_LOG_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef USE_DLOG
-#include <dlog.h>
-
-#undef LOG_TAG
-#define LOG_TAG "NM_DAEMON"
-
-#define NM_LOGV(format, args...) LOGV(format, ##args)
-#define NM_LOGD(format, args...) LOGD(format, ##args)
-#define NM_LOGI(format, args...) LOGI(format, ##args)
-#define NM_LOGW(format, args...) LOGW(format, ##args)
-#define NM_LOGE(format, args...) LOGE(format, ##args)
-#define NM_LOGF(format, args...) LOGF(format, ##args)
-
-#define __NM_FUNC_ENTER__ LOGD("Enter")
-#define __NM_FUNC_EXIT__ LOGD("Quit")
-
-#define NM_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)
-#define NM_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)
-
-#else /* USE_DLOG */
-
-#define NM_LOGV(format, args...)
-#define NM_LOGD(format, args...)
-#define NM_LOGI(format, args...)
-#define NM_LOGW(format, args...)
-#define NM_LOGE(format, args...)
-#define NM_LOGF(format, args...)
-
-#define __NM_FUNC_ENTER__
-#define __NM_FUNC_EXIT__
-
-#define NM_SECLOGI(format, args...)
-#define NM_SECLOGD(format, args...)
-
-#endif /* USE_DLOG */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_DAEMON_LOG_H__ */
diff --git a/include/nm-daemon.h b/include/nm-daemon.h
deleted file mode 100644 (file)
index 8577c76..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macros and declares funcitons for Network Monitoring Daemon.
- *
- * @file        nm-daemon.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#ifndef __NM_DAEMON_H__
-#define __NM_DAEMON_H__
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef IFNAMSIZ
-#define IFNAMSIZ 16
-#endif
-
-#define NL80211_CMD_GET_STATION                17
-#define NL80211_CMD_GET_SCAN           32
-#define NL80211_CMD_GET_SURVEY         50
-
-#define NL80211_STA_INFO_INACTIVE_TIME 1
-#define NL80211_STA_INFO_TX_BITRATE    8
-#define NL80211_STA_INFO_TX_PACKETS    10
-#define NL80211_STA_INFO_TX_RETRIES    11
-#define NL80211_STA_INFO_TX_FAILED     12
-#define NL80211_STA_INFO_MAX           34
-
-#define NL80211_ATTR_IFINDEX           3
-#define NL80211_ATTR_MAC               6
-#define NL80211_ATTR_STA_INFO          21
-#define NL80211_ATTR_BSS               47
-#define NL80211_ATTR_SURVEY_INFO       84
-#define NL80211_ATTR_MAX               264
-
-#define SEC_OFFSET_LEN                 16
-
-typedef enum {
-       NM_DAEMON_ERROR_NONE = 0,
-       NM_DAEMON_ERROR_NOT_INITIALIZED,
-       NM_DAEMON_ERROR_INVALID_PARAM,
-       NM_DAEMON_ERROR_NOT_PERMITTED,
-       NM_DAEMON_ERROR_OUT_OF_MEMORY,
-       NM_DAEMON_ERROR_OPERATION_FAILED,
-       NM_DAEMON_ERROR_IN_PROGRESS,
-} nm_daemon_error_e;
-
-typedef enum {
-       __NL80211_SURVEY_INFO_INVALID,
-       NL80211_SURVEY_INFO_FREQUENCY,
-       NL80211_SURVEY_INFO_NOISE,
-       NL80211_SURVEY_INFO_IN_USE,
-       NL80211_SURVEY_INFO_TIME,
-       NL80211_SURVEY_INFO_TIME_BUSY,
-       NL80211_SURVEY_INFO_TIME_EXT_BUSY,
-       NL80211_SURVEY_INFO_TIME_RX,
-       NL80211_SURVEY_INFO_TIME_TX,
-       NL80211_SURVEY_INFO_TIME_SCAN,
-       NL80211_SURVEY_INFO_PAD,
-
-       /* keep last */
-       __NL80211_SURVEY_INFO_AFTER_LAST,
-       NL80211_SURVEY_INFO_MAX = __NL80211_SURVEY_INFO_AFTER_LAST - 1
-} nl80211_survey_info_e;
-
-typedef enum {
-       __NL80211_BSS_INVALID,
-       NL80211_BSS_BSSID,
-       NL80211_BSS_FREQUENCY,
-       NL80211_BSS_TSF,
-       NL80211_BSS_BEACON_INTERVAL,
-       NL80211_BSS_CAPABILITY,
-       NL80211_BSS_INFORMATION_ELEMENTS,
-       NL80211_BSS_SIGNAL_MBM,
-       NL80211_BSS_SIGNAL_UNSPEC,
-       NL80211_BSS_STATUS,
-       NL80211_BSS_SEEN_MS_AGO,
-       NL80211_BSS_BEACON_IES,
-       NL80211_BSS_CHAN_WIDTH,
-       NL80211_BSS_BEACON_TSF,
-       NL80211_BSS_PRESP_DATA,
-       NL80211_BSS_LAST_SEEN_BOOTTIME,
-       NL80211_BSS_PAD,
-       NL80211_BSS_PARENT_TSF,
-       NL80211_BSS_PARENT_BSSID,
-       NL80211_BSS_CHAIN_SIGNAL,
-
-       /* keep last */
-       __NL80211_BSS_AFTER_LAST,
-       NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
-} nl80211_bss_e;
-
-enum nl80211_bss_status {
-       NL80211_BSS_STATUS_AUTHENTICATED,
-       NL80211_BSS_STATUS_ASSOCIATED,
-       NL80211_BSS_STATUS_IBSS_JOINED,
-};
-
-enum nl80211_rate_info {
-       __NL80211_RATE_INFO_INVALID,
-       NL80211_RATE_INFO_BITRATE,
-       NL80211_RATE_INFO_MCS,
-       NL80211_RATE_INFO_40_MHZ_WIDTH,
-       NL80211_RATE_INFO_SHORT_GI,
-       NL80211_RATE_INFO_BITRATE32,
-       NL80211_RATE_INFO_VHT_MCS,
-       NL80211_RATE_INFO_VHT_NSS,
-       NL80211_RATE_INFO_80_MHZ_WIDTH,
-       NL80211_RATE_INFO_80P80_MHZ_WIDTH,
-       NL80211_RATE_INFO_160_MHZ_WIDTH,
-
-       /* keep last */
-       __NL80211_RATE_INFO_AFTER_LAST,
-       NL80211_RATE_INFO_MAX = __NL80211_RATE_INFO_AFTER_LAST - 1
-};
-
-typedef enum
-{
-       NMDAEMON_MONITOR_TYPE_UNKNOWN,
-       NMDAEMON_MONITOR_TYPE_DEVICE_STATE,
-       NMDAEMON_MONITOR_TYPE_CONGESTION,
-       NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE,
-       NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE,
-       NMDAEMON_MONITOR_TYPE_MAX
-} nmdaemon_request_type_e;
-
-typedef enum {
-       NMDAEMON_HTMODE_HTNONE = 0,
-       NMDAEMON_HTMODE_HT20,
-       NMDAEMON_HTMODE_HT40,
-       NMDAEMON_HTMODE_HT80,
-       NMDAEMON_HTMODE_HT160,
-       NMDAEMON_HTMODE_UNKNOWN
-} nmdaemon_htmode_e;
-
-typedef void (*nm_retry_tx_rate_callback)(int retry_rate, void *user_data);
-typedef void (*nm_channel_interference_callback)(int freq, double channel_intf, void *user_data);
-
-typedef struct
-{
-       gboolean is_initialized;
-       GHashTable *mon_table;
-} nmdaemon_request_table_s;
-
-typedef struct {
-       int id;
-       int if_index;
-       int cmd;
-       struct nl_cb *cb;
-       struct nl_sock *socket;
-} nmdaemon_nl_global_s;
-
-typedef struct {
-       int freq;
-       double intf_factor;
-} nmdaemon_chan_info_s;
-
-typedef struct {
-       nmdaemon_chan_info_s chan[24];
-       gboolean is_2_4Ghz_band;
-       nmdaemon_htmode_e htmode;
-       int cur_pos;
-       int home_channel_pos;
-       int home_channel_freq;
-} nmdaemon_chan_intf_info_s;
-
-typedef struct {
-       guint timer_source_id;
-       nm_retry_tx_rate_callback tx_cb;
-       nm_channel_interference_callback ch_cb;
-       nmdaemon_nl_global_s *nl_global;
-       nmdaemon_chan_intf_info_s *intf_info;
-       int freq;
-       double total_intf;
-       char sec_chan_offset[SEC_OFFSET_LEN];
-       gpointer cb_user_data;
-} nmdaemon_mon_data_s;
-
-int nm_retry_tx_rate_monitor_start(nm_retry_tx_rate_callback cb, void *user_data);
-int nm_retry_tx_rate_monitor_stop(void);
-
-int nm_channel_interference_monitor_start(nm_channel_interference_callback cb, void *user_data);
-int nm_channel_interference_monitor_stop();
-
-int nm_daemon_set_tcpdump(gboolean state);
-int nm_daemon_get_tcpdump_state(gboolean *state);
-
-int nm_daemon_set_ip_conflict_detect(gboolean detect);
-int nm_daemon_get_ip_conflict_detect(gboolean *detect);
-int nm_daemon_get_ip_conflict_state(gboolean *state);
-
-int nm_daemon_get_ethernet_cable_state(gboolean *state);
-int nm_daemon_get_wifi_module_state(gboolean *state);
-
-int nm_daemon_get_congestion_level(int *level);
-int nm_daemon_get_retry_tx_rate(int *rate);
-int nm_daemon_get_channel_interference(double *ch_interference);
-
-int nm_daemon_get_cellular_state(int *state);
-int nm_daemon_get_wifi_state(int *state);
-int nm_daemon_get_ethernet_state(int *state);
-
-int nm_daemon_get_wifi_scan_state(gboolean *state);
-
-void nm_daemon_set_loop(GMainLoop *loop);
-void nm_daemon_unset_loop();
-
-int nm_daemon_init();
-int nm_daemon_deinit();
diff --git a/include/nm-dump.h b/include/nm-dump.h
deleted file mode 100644 (file)
index b08e9e1..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macros and declares functions for dump.
- *
- * @file        nm-dump.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#ifndef __NM_DUMP_H__
-#define __NM_DUMP_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
-       NM_DUMP_ERROR_NONE = 0,
-       NM_DUMP_NOT_INITIALIZED,
-       NM_DUMP_INVALID_PARAMETER,
-       NM_DUMP_OPERATION_FAILED,
-       NM_DUMP_IN_PROGRESS,
-} nm_dump_error_e;
-
-int nm_dump_start_tcpdump();
-int nm_dump_stop_tcpdump();
-int nm_dump_get_tcpdump_state(gboolean *is_running);
-int nm_dump_log(gchar *dump_path);
-int nm_dump_check_state_and_start();
-
-int nm_dump_init();
-int nm_dump_deinit();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_DUMP_H__ */
diff --git a/include/nm-error.h b/include/nm-error.h
deleted file mode 100644 (file)
index 7d78e10..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2015 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.
- *
- */
-
-/**
- * This file declares network monitoring deamon dbus error functions.
- *
- * @file        nm-error.h
- * @author      Yu Jiung (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#ifndef __NM_ERROR_H__
-#define __NM_ERROR_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <tizen.h>
-
-void nm_error_set_gerror(nm_daemon_error_e error_code, GError **error);
-void nm_error_register(void);
-void nm_error_deregister(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_ERROR_H__ */
diff --git a/include/nm-gdbus.h b/include/nm-gdbus.h
deleted file mode 100644 (file)
index 1398f22..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file declares functions for operating GDBus.
- *
- * @file        nm-gdbus.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#ifndef __NM_GDBUS_H__
-#define __NM_GDBUS_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#define DBUS_OBJECT_PATH_MAX 150
-#define DBUS_SERVICE_DBUS                      "org.freedesktop.DBus"
-#define DBUS_INTERFACE_DBUS                    "org.freedesktop.DBus"
-
-#define DBUS_PROPERTIES_INTERFACE      DBUS_INTERFACE_DBUS ".Properties"
-#define DBUS_PROPERTIES_METHOD_GETALL "GetAll"
-
-#define DBUS_SIGNAL_NAME_CHANGED               "NameOwnerChanged"
-#define DBUS_SIGNAL_PROPERTY_CHANGED   "PropertyChanged"
-#define DBUS_SIGNAL_PROPERTIES_CHANGED "PropertiesChanged"
-
-#define NM_DAEMON_SERVICE "net.nm_daemon"
-#define NM_DAEMON_OBJ "/net/nm_daemon"
-
-#define NM_WIFI_SERVICE NM_DAEMON_SERVICE ".wifi"
-#define NM_WIFI_IFACE NM_DAEMON_SERVICE ".wifi"
-#define NM_WIFI_OBJ NM_DAEMON_OBJ "/wifi"
-
-#define NM_CONN_SERVICE NM_DAEMON_SERVICE ".conn"
-#define NM_CONN_IFACE NM_DAEMON_SERVICE ".conn"
-#define NM_CONN_OBJ NM_DAEMON_OBJ "/conn"
-
-#define DECLARE_DBUS_SIGNAL_HANDLER(name) void __##name(\
-               const gchar *sender_name,\
-               const gchar *object_path,\
-               const gchar *interface_name,\
-               const gchar *signal,\
-               GVariant *parameters,\
-               gpointer user_data)
-
-#define DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(name) void __##name(\
-               gpointer connection,\
-               const gchar *sender_name,\
-               const gchar *object_path,\
-               const gchar *interface_name,\
-               const gchar *signal,\
-               GVariant *parameters,\
-               gpointer user_data)
-
-typedef enum {
-       NM_GDBUS_ERROR_NONE = 0,
-       NM_GDBUS_ERROR_NOT_INITIALIZED,
-       NM_GDBUS_ERROR_INVALID_PARAM,
-       NM_GDBUS_ERROR_ALREADY_EXIST,
-       NM_GDBUS_ERROR_OPERATION_FAILED,
-       NM_GDBUS_ERROR_HAS_NO_OWNER,
-
-} nm_gdbus_error_e;
-
-typedef void (*bus_aquired_callback)(void);
-typedef void (*name_lost_callback)(void);
-
-typedef void (*handle_signal) (
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-typedef void (*handle_signal_with_data) (
-               gpointer connection,
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-typedef void (*handle_reply) (GVariant *value, void *user_data);
-
-typedef struct{
-       const gchar *sender;
-       const gchar *interface_name;
-       const gchar *member;
-       const gchar *object_path;
-       const gchar *arg0;
-       handle_signal callback;
-       handle_signal_with_data callback_with_data;
-       guint subscriber_id;
-} signal_param_s;
-
-typedef struct {
-       const gchar *bus_name;
-       const gchar *object_path;
-    const gchar *interface_name;
-    const gchar *method_name;
-    GVariant *parameters;
-} method_param_s;
-
-int nm_gdbus_method_call(method_param_s *params,
-               handle_reply function, void *user_data);
-
-int nm_gdbus_subscribe_signal(signal_param_s *param);
-int nm_gdbus_subscribe_signal_with_data(signal_param_s *param, gpointer user_data);
-int nm_gdbus_unsubscribe_signal(signal_param_s *param);
-
-gboolean nm_gdbus_emit_signal(const gchar *destination_bus_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *params);
-
-void nm_gdbus_emit_ip_conflicted(int state, gchar *if_name, gchar *ip);
-void nm_gdbus_emit_ethernet_cable_state(gboolean state);
-void nm_gdbus_emit_wifi_module_state(gboolean state);
-void nm_gdbus_emit_retry_tx_rate_changed(int retry_tx_rate);
-void nm_gdbus_emit_congestion_level_changed(int congestion_level);
-void nm_gdbus_emit_channel_interference(int freq, double channel_intf);
-void nm_gdbus_emit_cellular_state(int state);
-void nm_gdbus_emit_wifi_state(int state);
-void nm_gdbus_emit_ethernet_state(int state);
-void nm_gdbus_emit_connections_changed(GVariant *signal_args);
-
-void nm_gdbus_emit_conn_ipv4_state_changed(gchar *path, GVariant *signal_args);
-void nm_gdbus_emit_conn_ipv6_state_changed(gchar *path, GVariant *signal_args);
-void nm_gdbus_emit_conn_ip_changed(gchar *path, GVariant *signal_args);
-void nm_gdbus_emit_conn_dns_changed(gchar *path, GVariant *signal_args);
-
-void nm_gdbus_emit_wifi_scanning_changed(gboolean scanning);
-
-int nm_gdbus_register_conn_iface(gchar *conn_obj,
-               guint *conn_obj_id,
-               gpointer conn);
-void nm_gdbus_deregister_conn_iface(guint nm_conn_obj_id);
-
-int nm_gdbus_register_daemon_iface(void);
-int nm_gdbus_register_wifi_iface(void);
-
-int nm_gdbus_is_wpasupplicant_enabled(gboolean *enabled);
-int nm_gdbus_is_connman_enabled(gboolean *enabled);
-int nm_gdbus_is_telephony_enabled(gboolean *enabled);
-int nm_gdbus_is_wfd_manager_enabled(gboolean *enabled);
-int nm_gdbus_is_mobileap_enabled(gboolean *enabled);
-int nm_gdbus_is_stc_manager_enabled(gboolean *enabled);
-
-typedef void (*nm_gdbus_watching_bus_callback)(gboolean appeared);
-int nm_gdbus_set_wpasupplicant_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
-int nm_gdbus_unset_wpasupplicant_bus_watching_callback();
-int nm_gdbus_set_connman_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
-int nm_gdbus_unset_connman_bus_watching_callback();
-int nm_gdbus_set_telephony_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
-int nm_gdbus_unset_telephony_bus_watching_callback();
-int nm_gdbus_set_wfd_manager_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
-int nm_gdbus_unset_wfd_manager_bus_watching_callback();
-int nm_gdbus_set_mobileap_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
-int nm_gdbus_unset_mobileap_bus_watching_callback();
-int nm_gdbus_set_stc_manager_bus_watching_callback(nm_gdbus_watching_bus_callback cb);
-int nm_gdbus_unset_stc_manager_bus_watching_callback();
-
-int nm_gdbus_init(bus_aquired_callback bus_acquired_cb,
-                                 name_lost_callback name_lost_cb);
-int nm_gdbus_deinit();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_GDBUS_H__ */
diff --git a/include/nm-iface-mon.h b/include/nm-iface-mon.h
deleted file mode 100644 (file)
index e75fc69..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macros and declares functions for monitoring interface.
- *
- * @file        nm-iface-mon.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#ifndef __NM_IFACE_MON_H__
-#define __NM_IFACE_MON_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
-       NM_IFACE_MON_ERROR_NONE = 0,
-       NM_IFACE_MON_NOT_INITIALIZED,
-       NM_IFACE_MON_INVALID_PARAMETER,
-       NM_IFACE_MON_OPERATION_FAILED,
-} nm_iface_mon_error_e;
-
-typedef void (*nm_iface_mon_callback)(char *iface_name, int state, void *user_data);
-
-typedef struct {
-       gchar iface_name[16];
-       guint timer_source_id;
-       nm_iface_mon_callback cb;
-       gpointer cb_user_data;
-}iface_mon_data_s;
-
-int nm_iface_mon_start_monitor(char *iface_name, nm_iface_mon_callback cb, void *user_data);
-int nm_iface_mon_stop_monitor(char *iface_name);
-int nm_iface_mon_get_iface_state(char *iface_name, int *state);
-
-int nm_iface_mon_init();
-int nm_iface_mon_deinit();
-int nm_rtnl_init(gpointer user_data);
-void nm_rtnl_cleanup(void);
-
-/** Congestion Network */
-typedef enum {
-       NM_CONG_MON_ERROR_NONE = 0,
-       NM_CONG_MON_NOT_INITIALIZED,
-       NM_CONG_MON_ALREADY_STARTED,
-       NM_CONG_MON_INVALID_PARAMETER,
-       NM_CONG_MON_OPERATION_FAILED,
-} nm_cong_mon_error_e;
-
-typedef void (*nm_congestion_mon_callback)(int status, void *user_data);
-
-int nm_congestion_monitor_start(nm_congestion_mon_callback cb, void *user_data);
-int nm_congestion_monitor_stop(void);
-
-int nm_congestion_mon_init(void);
-int nm_congestion_mon_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_IFACE_MON_H__ */
diff --git a/include/nm-ip-conflict.h b/include/nm-ip-conflict.h
deleted file mode 100644 (file)
index faacf3b..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
-
- * This file declares functions for detecting IP conflict.
- *
- * @file        nm-ip-conflict.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#ifndef __NM_IP_CONFLICT_H__
-#define __NM_IP_CONFLICT_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
-       NM_IP_CONFLICT_ERROR_NONE = 0,
-       NM_IP_CONFLICT_ERROR_NOT_INITIALIZED,
-       NM_IP_CONFLICT_ERROR_INVALID_PARAM,
-       NM_IP_CONFLICT_ERROR_ALREADY_EXIST,
-       NM_IP_CONFLICT_ERROR_OPERATION_FAILED,
-       NM_IP_CONFLICT_ERROR_IN_PROGRESS,
-
-} nm_ip_conflict_error_e;
-
-typedef enum {
-       IP_CONFLICT_STATE_UNKNOWN,
-       IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED,
-       IP_CONFLICT_STATE_CONFLICT_DETECTED
-} nm_ip_conflict_state_e;
-
-typedef void (*ip_conflict_callback) (int state, gchar *if_name,  guchar *ip, gpointer user_data);
-
-int nm_ip_conflict_enable_detection(gchar *if_name, gboolean enable);
-int nm_ip_conflict_get_detection_period(guint *period);
-int nm_ip_conflict_set_detection_period(guint period);
-int nm_ip_conflict_get_state(gchar *if_name, guint *state);
-int nm_ip_conflict_is_detection_enabled(gchar *if_name, gboolean *enabled);
-
-int ip_conflict_detection_init();
-int ip_conflict_detection_deinit();
-int ip_conflict_set_callback(gchar *if_name, ip_conflict_callback cb, gpointer user_data);
-int ip_conflict_unset_callback(gchar *if_name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_IP_CONFLICT_H__ */
diff --git a/include/nm-mobileap.h b/include/nm-mobileap.h
deleted file mode 100644 (file)
index 0452f7b..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macro and declares functions for handling signal from MobileAP-agent.
- *
- * @file        nm-mobileap.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#ifndef __NM_MOBILEAP_H__
-#define __NM_MOBILEAP_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MOBILEAP_SERVICE                       "org.tizen.MobileapAgent"
-#define MOBILEAP_PATH                          "/MobileapAgent"
-
-#define SOFTAP_INTERFACE                       "org.tizen.softap"
-#define TETHERING_INTERFACE                    "org.tizen.tethering"
-
-#define DNSMASQ_INTERFACE                      "uk.org.thekelleys.dnsmasq"
-
-typedef enum {
-       NM_MOBILEAP_ERROR_NONE = 0,
-       NM_MOBILEAP_ERROR_NOT_INITIALIZED,
-       NM_MOBILEAP_ERROR_INVALID_PARAM,
-       NM_MOBILEAP_ERROR_ALREADY_EXIST,
-       NM_MOBILEAP_ERROR_OPERATION_FAILED,
-       NM_MOBILEAP_ERROR_SIGNAL_SUBSCRIBE_FAILED,
-       NM_MOBILEAP_ERROR_METHOD_CALL_FAILED,
-} nm_mobileap_error_e;
-
-int nm_mobileap_init();
-int nm_mobileap_deinit();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_MOBILEAP_H__ */
diff --git a/include/nm-net-access.h b/include/nm-net-access.h
deleted file mode 100644 (file)
index e292fd2..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macros and declares functions get internet accessibility.
- *
- * @file        nm-net-access.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#ifndef __NM_NET_ACCESS_H__
-#define __NM_NET_ACCESS_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void nm_net_access_init(void);
-void nm_net_access_deinit(void);
-
-void nm_net_access_start_checking(void);
-void nm_net_access_stop_checking(void);
-
-/* Alert: Please do not use nm_net_access_get_status() API to get the
- * status of Internet availability on general Wifi access points, as this module
- * primarily checks for Internet availability on portal enabled Wifi access
- * points, so we only check for below criteria in server's response to conclude
- * whether Internet is accessible.
- * 1) If the HTTP status != 302
- * 2) If the HTTP status != (200 with redirection),
-*/
-gboolean nm_net_access_get_status();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_NET_ACCESS_H__ */
diff --git a/include/nm-statistics.h b/include/nm-statistics.h
deleted file mode 100644 (file)
index 230c09d..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macros and declares functions get network_statistics.
- *
- * @file        nm-statistics.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#ifndef __NM_STATISTICS_H__
-#define __NM_STATISTICS_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef IFNAMSIZ
-#define IFNAMSIZ 16
-#endif
-
-typedef enum {
-       NM_STATISTICS_ERROR_NONE = 0,
-       NM_STATISTICS_ERROR_NOT_INITIALIZED,
-       NM_STATISTICS_ERROR_INVALID_PARAM,
-       NM_STATISTICS_ERROR_OPERATION_FAILED,
-} nm_statistics_error_e;
-
-typedef struct {
-       gchar ifname[IFNAMSIZ + 1];
-       guint64 rx_bytes;
-       guint64 rx_packets;
-       gulong rx_errs;
-       gulong rx_drop;
-       gulong rx_fifo;
-       gulong rx_frame;
-       gulong rx_compressed;
-       gulong rx_multicast;
-       guint64 tx_bytes;
-       guint64 tx_packets;
-       gulong tx_errs;
-       gulong tx_drop;
-       gulong tx_fifo;
-       gulong tx_cols;
-       gulong tx_carrier;
-       gulong tx_compressed;
-} nm_statistic_s;
-
-typedef void (*nm_statistics_callback)(nm_statistic_s* stats, void *user_data);
-
-int nm_statistics_start_monitor(nm_statistics_callback cb, void *user_data);
-int nm_statistics_stop_monitor();
-int nm_statistics_is_enabled(gboolean *enabled);
-
-int nm_statistics_init();
-int nm_statistics_deinit();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_STATISTICS_H__ */
diff --git a/include/nm-stc-manager.h b/include/nm-stc-manager.h
deleted file mode 100644 (file)
index dc2c6f6..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macro and declares functions for handling signal from STC-manager.
- *
- * @file        nm-stc-manager.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#ifndef __NM_STC_MANAGER_H__
-#define __NM_STC_MANAGER_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define STC_MANAGER_SERVICE                                    "net.stc"
-#define STC_MANAGER_STATS_INTERFACE                    STC_MANAGER_SERVICE ".statistics"
-#define STC_MANAGER_RESTRICTION_INTERFACE      STC_MANAGER_SERVICE ".restriction"
-
-#define STC_MANAGER_STATS_PATH                         "/net/stc/statistics"
-#define STC_MANAGER_RESTRICTION_PATH           "/net/stc/restriction"
-
-typedef enum {
-       NM_STC_ERROR_NONE = 0,
-       NM_STC_ERROR_NOT_INITIALIZED,
-       NM_STC_ERROR_INVALID_PARAM,
-       NM_STC_ERROR_ALREADY_EXIST,
-       NM_STC_ERROR_OPERATION_FAILED,
-       NM_STC_ERROR_SIGNAL_SUBSCRIBE_FAILED,
-       NM_STC_ERROR_METHOD_CALL_FAILED,
-} nm_stc_error_e;
-
-int nm_stc_manager_init();
-int nm_stc_manager_deinit();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_STC_MANAGER_H__ */
diff --git a/include/nm-supplicant.h b/include/nm-supplicant.h
deleted file mode 100644 (file)
index 8f91c20..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macro and declares functions for handling signal from WPA Supplicant.
- *
- * @file        nm-supplicant.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#ifndef __NM_SUPPLICANT_H__
-#define __NM_SUPPLICANT_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define BSSID_LEN 6
-#define SSID_LEN 32
-#define IFNAME_MAX 32
-
-typedef enum {
-       NM_SUPPLICANT_ERROR_NONE = 0,
-       NM_SUPPLICANT_ERROR_NOT_INITIALIZED,
-       NM_SUPPLICANT_ERROR_INVALID_PARAM,
-       NM_SUPPLICANT_ERROR_ALREADY_EXIST,
-       NM_SUPPLICANT_ERROR_OPERATION_FAILED,
-       NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED,
-       NM_SUPPLICANT_ERROR_METHOD_CALL_FAILED,
-       NM_SUPPLICANT_ERROR_IFACE_INIT_FAILED,
-       NM_SUPPLICANT_ERROR_BSS_INIT_FAILED,
-
-} nm_supplicant_error_e;
-
-typedef enum {
-       NM_SUPPLICANT_IFACE_PROPERTY_NONE = 0,
-       NM_SUPPLICANT_IFACE_PROPERTY_STATE = 1,
-       NM_SUPPLICANT_IFACE_PROPERTY_SCANNING = 2,
-} nm_supplicant_iface_property_e;
-
-typedef enum {
-       IFACE_SIGNAL_SCANDONE,
-       IFACE_SIGNAL_BSSADDED,
-       IFACE_SIGNAL_BSSREMOVED,
-       IFACE_SIGNAL_BLOBADDED,
-       IFACE_SIGNAL_BLOBREMOVED,
-       IFACE_SIGNAL_NETWORKADDED,
-       IFACE_SIGNAL_NETWORKREMOVED,
-       IFACE_SIGNAL_NETWORKSELECTED,
-       IFACE_SIGNAL_STAAUTHORIZED,
-       IFACE_SIGNAL_STADEAUTHORIZED,
-       IFACE_SIGNAL_PROPERTIESCHANGED,
-       IFACE_SIGNAL_CERTIFICATION,
-       IFACE_SIGNAL_EAP,
-       IFACE_SIGNAL_NETWORKREQUEST,
-       IFACE_SIGNAL_PROBEREQUEST,
-       IFACE_SIGNAL_MAX,
-} nm_supplicant_iface_signal_e;
-
-typedef struct {
-       /*
-        * BSSID of the BSS.
-        */
-       guchar bssid[BSSID_LEN];
-       /*
-        * SSID of the BSS.
-        */
-       gchar ssid[SSID_LEN + 1];
-       /*
-        * Frequency of the BSS in MHz.
-        */
-       guint16 frequency;
-
-       /*
-        * Signal strength of the BSS.
-        */
-       gint16 signal;
-} nm_supplicant_bss_s;
-
-typedef struct {
-       guint pairwise;
-       guint group;
-       guint key_mgmt;
-       guint proto;
-       guint auth_alg;
-       guint scan;
-       guint modes;
-
-} supplicant_iface_cap_s;
-
-typedef struct {
-       /*
-        * Capabilities of the interface
-        */
-       supplicant_iface_cap_s cap;
-       /*
-        * A state of the interface
-        */
-       guint state;
-       /*
-        * Determines if the interface is already scanning or not
-        */
-       gboolean scanning;
-       /*
-        * Name of network interface controlled by the interface, e.g., wlan0.
-        */
-       gchar Ifname[IFNAME_MAX];
-       /*
-        * This variable holds the subscriber id which is
-        * subscribing property changed signal of the technology.
-        */
-       guint subscriber_id[IFACE_SIGNAL_MAX];
-       /*
-        * BSS which wpa_supplicant is associated with.
-        */
-       gpointer current_bss;
-       /*
-        * configured network which wpa_supplicant uses at the moment
-        */
-       gpointer current_network;
-       /*
-        * List of BSSs known to the interface
-        */
-       GHashTable *bss_tbl;
-       /*
-        * Wi-Fi P2P properties of the interface
-        */
-       gpointer p2p;
-} nm_supplicant_iface_s;
-
-typedef void (*nm_supplicant_iface_changed_callback)(
-               nm_supplicant_iface_property_e property,
-               nm_supplicant_iface_s *iface,
-               gpointer user_data);
-
-int nm_supplicant_init();
-int nm_supplicant_deinit();
-int nm_supplicant_get_properties();
-
-int nm_supplicant_iface_set_prop_changed_cb(nm_supplicant_iface_changed_callback cb, gpointer user_data);
-int nm_supplicant_iface_unset_prop_changed_cb();
-int nm_supplicant_iface_get_iface(gchar *iface_name, nm_supplicant_iface_s **iface);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_SUPPLICANT_H__ */
diff --git a/include/nm-telephony.h b/include/nm-telephony.h
deleted file mode 100644 (file)
index e73afd4..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macro and declares functions to get information from telephony module.
- *
- * @file        nm-telephony.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#ifndef __NM_TELEPHONY_H__
-#define __NM_TELEPHONY_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** Profile name max length */
-#define NM_PROFILE_NAME_LEN_MAX 512
-
-/** Home URL max length in profile account */
-#define NM_HOME_URL_LEN_MAX 512
-
-/** Maximum length of APN in PDP profile [3GPP Defined variable] */
-#define NM_PDP_APN_LEN_MAX 100
-
-/** Maximum length of username in PDP profile. (used in authentication parameters) [3GPP Defined variable] */
-#define NM_PDP_AUTH_USERNAME_LEN_MAX 32
-
-/** Maximum length of password in PDP profile (used in authentication parameters) [3GPP Defined variable] */
-#define NM_PDP_AUTH_PASSWORD_LEN_MAX 32
-
-/** Maximum length of proxy string */
-#define NET_PROXY_LEN_MAX 64
-
-typedef enum {
-       NM_TELEPHONY_ERROR_NONE = 0,
-       NM_TELEPHONY_ERROR_NOT_INITIALIZED,
-       NM_TELEPHONY_ERROR_INVALID_PARAM,
-       NM_TELEPHONY_ERROR_ALREADY_EXIST,
-       NM_TELEPHONY_ERROR_OPERATION_FAILED,
-       NM_TELEPHONY_ERROR_SIGNAL_SUBSCRIBE_FAILED,
-       NM_TELEPHONY_ERROR_METHOD_CALL_FAILED,
-} nm_telephony_error_e;
-
-
-/**
-* @enum net_service_type_e
-* This enum indicates network connection type
-*/
-typedef enum
-{
-       /** Unknown type \n
-       */
-       NET_SERVICE_UNKNOWN = 0x00,
-
-       /** Mobile Internet Type \n
-               Network connection is established in Cellular network for Internet \n
-       */
-       NET_SERVICE_INTERNET = 0x01,
-
-       /** Mobile MMS Type \n
-               Network connection is established in Cellular network for MMS \n
-       */
-       NET_SERVICE_MMS = 0x02,
-
-       /** Prepaid Mobile Internet Type \n
-               Network connection is established in Cellular network for prepaid internet service.\n
-               This service supports to establish network connection in prepaid sim case\n
-       */
-       NET_SERVICE_PREPAID_INTERNET = 0x03,
-
-       /** Prepaid Mobile MMS Type \n
-               Network Connection is established in Cellular network for prepaid MMS service. \n
-               This profile supports to establish network connection in prepaid sim case\n
-       */
-       NET_SERVICE_PREPAID_MMS = 0x04,
-
-       /** Mobile Tethering Type \n
-               Network connection is established in Cellular network for Tethering \n
-       */
-       NET_SERVICE_TETHERING = 0x05,
-
-       /** Specific application Type \n
-               Network connection is established in Cellular network for Specific applications \n
-       */
-       NET_SERVICE_APPLICATION = 0x06,
-
-       /** Deprecated type
-        */
-       NET_SERVICE_WAP = 0x06,
-} net_service_type_e;
-
-/**
- * @enum net_pdn_type_e
- * This enumeration defines the pdn type.
- */
-typedef enum
-{
-       NET_PDN_TYPE_UNKNOWN    = 0x00,
-       NET_PDN_TYPE_IPV4               = 0x02,
-       NET_PDN_TYPE_IPV6               = 0x05,
-       NET_PDN_TYPE_IPV4_IPV6  = 0x06,
-} net_pdn_type_e;
-
-/**
- * @enum net_auth_type_t
- * PDP Authentication Type
- */
-typedef enum
-{
-       /** No authentication */
-       NET_PDP_AUTH_NONE       = 0x0,
-
-       /** PAP authentication */
-       NET_PDP_AUTH_PAP        = 0x1,
-
-       /** CHAP authentication */
-       NET_PDP_AUTH_CHAP       = 0x2,
-} net_auth_type_e;
-
-
-/**
- * PDP Authentication Information
- */
-typedef struct
-{
-       /** Authentication type  */
-       net_auth_type_e auth_type;
-
-       /** UserName to be used during authentication */
-       char user_name[NM_PDP_AUTH_USERNAME_LEN_MAX + 1];
-
-       /** Password to be used during authentication */
-       char password[NM_PDP_AUTH_PASSWORD_LEN_MAX + 1];
-} net_auth_info_s;
-
-/**
- * This is the profile structure exposed from modman.
- */
-typedef struct
-{
-       gint type;
-       gboolean setup_required;
-       /** Profile name(path) */
-       char profile_name[NM_PROFILE_NAME_LEN_MAX + 1];
-       /** Service type of this profile context */
-       net_service_type_e service_type;
-       /** Pdn type of this profile context */
-       net_pdn_type_e pdn_type;
-       /** Roam Pdn type of this profile context */
-       net_pdn_type_e roam_pdn_type;
-       /** Network Access Point Name */
-       char apn[NM_PDP_APN_LEN_MAX + 1];
-       /** Authentication info of the PDP profile */
-       net_auth_info_s auth_info;
-       /**Proxy address */
-       char proxy_addr[NET_PROXY_LEN_MAX + 1];
-       /** Browser Home URL or MMS server URL */
-       char home_url[NM_HOME_URL_LEN_MAX + 1];
-       char keyword[NM_PDP_APN_LEN_MAX + 1];
-       gboolean default_conn;
-       gboolean editable;
-       gboolean hidden;
-} nm_telephony_profile_s;
-
-int nm_telephony_get_pdp_profile(gchar *path, nm_telephony_profile_s *profile_info);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_TELEPHONY_H__ */
diff --git a/include/nm-util.h b/include/nm-util.h
deleted file mode 100644 (file)
index 7d41449..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file declares utility functions.
- *
- * @file        nm-util.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#ifndef __NM_UTIL_H__
-#define __NM_UTIL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MAC_ADDR_LEN 6
-#define MAX_SIZE_ERROR_BUFFER 128
-#define TIME_STR_LEN 128
-#define WIFI_IFNAME    "wlan0"
-
-void get_current_time(gchar *time_str);
-
-int nm_execute_file(const char *file_path,
-               char *const args[], char *const envs[]);
-
-int nm_execute_file_no_wait(const char *file_path, char *const args[]);
-
-int nm_check_cable_status(const char *file_path, int *status);
-
-gboolean nm_get_byte_statistics(const char *ifname, guint64 *tx, guint *rx);
-
-int nmdaemon_get_interface_index(const char *interface_name);
-void nmdaemon_convert_byte_to_string(char *bssid, unsigned char *user_data);
-
-gchar* nm_util_get_default_proxy();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_UTIL_H__ */
-
diff --git a/include/nm-wfd-manager.h b/include/nm-wfd-manager.h
deleted file mode 100644 (file)
index 255ae0c..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macro and declares functions for handling signal from wfd-manager.
- *
- * @file        nm-wfd-manager.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#ifndef __NM_WFD_MANAGER_H__
-#define __NM_WFD_MANAGER_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define WFD_MANAGER_SERVICE                     "net.wifidirect"
-#define WFD_MANAGER_PATH                        "/net/wifidirect"
-#define WFD_MANAGER_MANAGE_INTERFACE            WFD_MANAGER_SERVICE
-#define WFD_MANAGER_GROUP_INTERFACE             WFD_MANAGER_SERVICE ".group"
-#define WFD_MANAGER_CONFIG_INTERFACE            WFD_MANAGER_SERVICE ".config"
-
-typedef enum {
-       NM_WFD_ERROR_NONE = 0,
-       NM_WFD_ERROR_NOT_INITIALIZED,
-       NM_WFD_ERROR_INVALID_PARAM,
-       NM_WFD_ERROR_ALREADY_EXIST,
-       NM_WFD_ERROR_OPERATION_FAILED,
-       NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED,
-       NM_WFD_ERROR_METHOD_CALL_FAILED,
-} nm_wfd_error_e;
-
-typedef enum {
-       NM_WFD_DEVICE_NONE,
-       NM_WFD_DEVICE_GC,
-       NM_WFD_DEVICE_GO,
-} nm_wfd_device_role_e;
-
-int nm_wfd_manager_init();
-int nm_wfd_manager_deinit();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_WFD_MANAGER_H__ */
diff --git a/inm-manager.manifest b/inm-manager.manifest
new file mode 100755 (executable)
index 0000000..81ace0c
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
+
diff --git a/nm-daemon.manifest b/nm-daemon.manifest
deleted file mode 100755 (executable)
index 81ace0c..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<manifest>
-       <request>
-               <domain name="_"/>
-       </request>
-</manifest>
-
diff --git a/packaging/dbus-inm-manager.conf b/packaging/dbus-inm-manager.conf
new file mode 100644 (file)
index 0000000..affd8a8
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+       "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+       <policy user="network_fw">
+               <allow own="net.nm_damon"/>
+               <allow send_destination="net.nm_damon"/>
+               <allow receive_sender="net.nm_damon"/>
+       </policy>
+       <policy user="root">
+               <allow own="net.nm_damon"/>
+               <allow send_destination="net.nm_damon"/>
+               <allow receive_sender="net.nm_damon"/>
+       </policy>
+       <policy context="default">
+       </policy>
+</busconfig>
diff --git a/packaging/dbus-nm-daemon.conf b/packaging/dbus-nm-daemon.conf
deleted file mode 100644 (file)
index b5bb769..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
-       "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
-       <policy user="network_fw">
-               <allow own="net.nm_daemon"/>
-               <allow send_destination="net.nm_daemon"/>
-               <allow receive_sender="net.nm_daemon"/>
-       </policy>
-       <policy user="root">
-               <allow own="net.nm_daemon"/>
-               <allow send_destination="net.nm_daemon"/>
-               <allow receive_sender="net.nm_daemon"/>
-       </policy>
-       <policy context="default">
-       </policy>
-</busconfig>
diff --git a/packaging/inm-manager.service b/packaging/inm-manager.service
new file mode 100644 (file)
index 0000000..f4aa589
--- /dev/null
@@ -0,0 +1,13 @@
+[Unit]
+Description=Intelligent Network Monitoring service
+Requires=dbus.socket
+After=dbus.socket
+
+[Service]
+Type=dbus
+BusName=net.nm_damon
+SmackProcessLabel=System
+ExecStart=/usr/bin/nm-daemon
+User=root
+Group=root
+
diff --git a/packaging/inm-manager.spec b/packaging/inm-manager.spec
new file mode 100755 (executable)
index 0000000..66f9c54
--- /dev/null
@@ -0,0 +1,105 @@
+Name:       inm-manager
+Summary:    NM(network monitoring) daemon
+Version:    0.0.1
+Release:    1
+Group:      Network & Connectivity/Other
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+Source1:    dbus-%{name}.conf
+Source2:    net.inm_manager.service
+Source3:       %{name}.service
+
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(gio-2.0)
+BuildRequires:  pkgconfig(gobject-2.0)
+BuildRequires:  pkgconfig(gio-unix-2.0)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(libnl-2.0)
+BuildRequires:  python
+BuildRequires:  python-xml
+Requires:       security-config
+%if 0%{?gtests:1}
+BuildRequires: pkgconfig(gmock)
+%endif
+
+%description
+An application service platform manager to manage services and sessions
+
+%prep
+%setup -q
+chmod 644 %{SOURCE0}
+chmod 644 %{SOURCE1}
+chmod 644 %{SOURCE2}
+chmod 644 %{SOURCE3}
+cp -a %{SOURCE1} ./inm-manager.conf
+cp -a %{SOURCE2} .
+cp -a %{SOURCE3} .
+
+%build
+
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export FFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
+%endif
+
+%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+       -DBIN_DIR=%{_bindir} \
+       -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
+       -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \
+       -DBUILD_TEST_APP=%{?test_app:1}%{!?test_app:0}
+
+make %{?_smp_mflags}
+
+%install
+rm -rf %{buildroot}
+
+%make_install
+
+mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/
+cp net.inm_manager.service %{buildroot}%{_datadir}/dbus-1/system-services/
+
+#DBus DAC (net-config.manifest enables DBus SMACK)
+mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
+cp inm-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/inm-manager.conf
+mkdir -p %{buildroot}%{_libdir}/systemd/system/
+cp inm-manager.service %{buildroot}%{_libdir}/systemd/system/inm-manager.service
+%if "%{?_lib}" == "lib64"
+mkdir -p %{buildroot}%{_unitdir}
+cp inm-manager.service %{buildroot}%{_unitdir}/inm-manager.service
+%endif
+
+#log dump
+mkdir -p %{buildroot}/opt/etc/dump.d/module.d
+#udev rules for wlan module attach/detach event
+mkdir -p %{buildroot}%{_libdir}/udev/rules.d/
+cp resources/usr/lib/udev/rules.d/99-wifiusb-dev.rules %{buildroot}%{_libdir}/udev/rules.d/99-wifiusb-dev.rules
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%defattr(-,network_fw,network_fw,-)
+%attr(500,network_fw,network_fw) %{_bindir}/*
+%attr(500,root,root) /opt/etc/dump.d/module.d/network_dump.sh
+%attr(644,network_fw,network_fw) %{_libdir}/udev/rules.d/99-wifiusb-dev.rules
+%if 0%{?gtests:1}
+       %{_bindir}/gtest*
+%endif
+%if 0%{?test_app:1}
+       %{_bindir}/network_monitoring_test
+%endif
+
+#DBus DAC
+%attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/inm-manager.conf
+%attr(644,root,root) %{_datadir}/dbus-1/system-services/net.inm_manager.service
+%attr(644,root,root) %{_libdir}/systemd/system/*
+%if "%{?_lib}" == "lib64"
+%attr(644,root,root) %{_unitdir}/inm-manager.service
+%endif
diff --git a/packaging/net.inm_manager.service b/packaging/net.inm_manager.service
new file mode 100644 (file)
index 0000000..04834c4
--- /dev/null
@@ -0,0 +1,7 @@
+[D-BUS Service]
+Name=net.nm_damon
+
+Exec=/bin/false
+User=root
+Group=root
+SystemdService=nm-daemon.service
diff --git a/packaging/net.nm_daemon.service b/packaging/net.nm_daemon.service
deleted file mode 100644 (file)
index 2a22bca..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-[D-BUS Service]
-Name=net.nm_daemon
-
-Exec=/bin/false
-User=root
-Group=root
-SystemdService=nm-daemon.service
diff --git a/packaging/nm-daemon.service b/packaging/nm-daemon.service
deleted file mode 100644 (file)
index 4378817..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=Intelligent Network Monitoring service
-Requires=dbus.socket
-After=dbus.socket
-
-[Service]
-Type=dbus
-BusName=net.nm_daemon
-SmackProcessLabel=System
-ExecStart=/usr/bin/nm-daemon
-User=root
-Group=root
-
diff --git a/packaging/nm-daemon.spec b/packaging/nm-daemon.spec
deleted file mode 100755 (executable)
index 3b418bf..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-Name:       nm-daemon
-Summary:    NM(network monitoring) daemon
-Version:    0.0.1
-Release:    1
-Group:      Network & Connectivity/Other
-License:    Apache-2.0
-Source0:    %{name}-%{version}.tar.gz
-Source1:    dbus-nm-daemon.conf
-Source2:    net.nm_daemon.service
-Source3:       nm-daemon.service
-
-BuildRequires:  cmake
-BuildRequires:  pkgconfig(glib-2.0)
-BuildRequires:  pkgconfig(gio-2.0)
-BuildRequires:  pkgconfig(gobject-2.0)
-BuildRequires:  pkgconfig(gio-unix-2.0)
-BuildRequires:  pkgconfig(dlog)
-BuildRequires:  pkgconfig(libtzplatform-config)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(libnl-2.0)
-BuildRequires:  python
-BuildRequires:  python-xml
-Requires:       security-config
-%if 0%{?gtests:1}
-BuildRequires: pkgconfig(gmock)
-%endif
-
-%description
-An application service platform manager to manage services and sessions
-
-%prep
-%setup -q
-chmod 644 %{SOURCE0}
-chmod 644 %{SOURCE1}
-chmod 644 %{SOURCE2}
-chmod 644 %{SOURCE3}
-cp -a %{SOURCE1} ./nm-daemon.conf
-cp -a %{SOURCE2} .
-cp -a %{SOURCE3} .
-
-%build
-
-export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
-export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
-export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
-%if 0%{?gcov:1}
-export CFLAGS+=" -fprofile-arcs -ftest-coverage"
-export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
-export FFLAGS+=" -fprofile-arcs -ftest-coverage"
-export LDFLAGS+=" -lgcov"
-%endif
-
-%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-       -DBIN_DIR=%{_bindir} \
-       -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
-       -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \
-       -DBUILD_TEST_APP=%{?test_app:1}%{!?test_app:0}
-
-make %{?_smp_mflags}
-
-%install
-rm -rf %{buildroot}
-
-%make_install
-
-mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/
-cp net.nm_daemon.service %{buildroot}%{_datadir}/dbus-1/system-services/
-
-#DBus DAC (net-config.manifest enables DBus SMACK)
-mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
-cp nm-daemon.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/nm-daemon.conf
-mkdir -p %{buildroot}%{_libdir}/systemd/system/
-cp nm-daemon.service %{buildroot}%{_libdir}/systemd/system/nm-daemon.service
-%if "%{?_lib}" == "lib64"
-mkdir -p %{buildroot}%{_unitdir}
-cp nm-daemon.service %{buildroot}%{_unitdir}/nm-daemon.service
-%endif
-
-#log dump
-mkdir -p %{buildroot}/opt/etc/dump.d/module.d
-#udev rules for wlan module attach/detach event
-mkdir -p %{buildroot}%{_libdir}/udev/rules.d/
-cp resources/usr/lib/udev/rules.d/99-wifiusb-dev.rules %{buildroot}%{_libdir}/udev/rules.d/99-wifiusb-dev.rules
-
-%files
-%manifest %{name}.manifest
-%license LICENSE
-%defattr(-,network_fw,network_fw,-)
-%attr(500,network_fw,network_fw) %{_bindir}/*
-%attr(500,root,root) /opt/etc/dump.d/module.d/network_dump.sh
-%attr(644,network_fw,network_fw) %{_libdir}/udev/rules.d/99-wifiusb-dev.rules
-%if 0%{?gtests:1}
-       %{_bindir}/gtest*
-%endif
-%if 0%{?test_app:1}
-       %{_bindir}/network_monitoring_test
-%endif
-
-#DBus DAC
-%attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/nm-daemon.conf
-%attr(644,root,root) %{_datadir}/dbus-1/system-services/net.nm_daemon.service
-%attr(644,root,root) %{_libdir}/systemd/system/*
-%if "%{?_lib}" == "lib64"
-%attr(644,root,root) %{_unitdir}/nm-daemon.service
-%endif
index c19451fe43297057ea6ec8196fe063d9d84185f8..5ea96df1184c00d0710a8914f4eb966a1cad3528 100644 (file)
@@ -36,31 +36,31 @@ ENDFOREACH(flag)
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 
 SET(SRCS
-       ${CMAKE_SOURCE_DIR}/src/nm-gdbus.c
-       ${CMAKE_SOURCE_DIR}/src/nm-connman.c
-       ${CMAKE_SOURCE_DIR}/src/nm-connman-mgr.c
-       ${CMAKE_SOURCE_DIR}/src/nm-connman-service.c
-       ${CMAKE_SOURCE_DIR}/src/nm-connman-tech.c
-       ${CMAKE_SOURCE_DIR}/src/nm-error.c
-       ${CMAKE_SOURCE_DIR}/src/nm-supplicant.c
-       ${CMAKE_SOURCE_DIR}/src/nm-supplicant-iface.c
-       ${CMAKE_SOURCE_DIR}/src/nm-supplicant-wps.c
-       ${CMAKE_SOURCE_DIR}/src/nm-supplicant-bss.c
-       ${CMAKE_SOURCE_DIR}/src/nm-supplicant-network.c
-       ${CMAKE_SOURCE_DIR}/src/nm-supplicant-p2p.c
-       ${CMAKE_SOURCE_DIR}/src/nm-telephony.c
-       ${CMAKE_SOURCE_DIR}/src/nm-wfd-manager.c
-       ${CMAKE_SOURCE_DIR}/src/nm-mobileap.c
-       ${CMAKE_SOURCE_DIR}/src/nm-daemon.c
-       ${CMAKE_SOURCE_DIR}/src/nm-daemon-main.c
-       ${CMAKE_SOURCE_DIR}/src/nm-ip-conflict.c
-       ${CMAKE_SOURCE_DIR}/src/nm-iface-mon.c
-       ${CMAKE_SOURCE_DIR}/src/nm-net-access.c
-       ${CMAKE_SOURCE_DIR}/src/nm-statistics.c
-       ${CMAKE_SOURCE_DIR}/src/nm-dump.c
-       ${CMAKE_SOURCE_DIR}/src/nm-util.c
-       ${CMAKE_SOURCE_DIR}/src/nm-netlink.c
-       ${CMAKE_SOURCE_DIR}/src/nm-congestion-mon.c
+       ${CMAKE_SOURCE_DIR}/src/inm-gdbus.c
+       ${CMAKE_SOURCE_DIR}/src/inm-connman.c
+       ${CMAKE_SOURCE_DIR}/src/inm-connman-mgr.c
+       ${CMAKE_SOURCE_DIR}/src/inm-connman-service.c
+       ${CMAKE_SOURCE_DIR}/src/inm-connman-tech.c
+       ${CMAKE_SOURCE_DIR}/src/inm-error.c
+       ${CMAKE_SOURCE_DIR}/src/inm-supplicant.c
+       ${CMAKE_SOURCE_DIR}/src/inm-supplicant-iface.c
+       ${CMAKE_SOURCE_DIR}/src/inm-supplicant-wps.c
+       ${CMAKE_SOURCE_DIR}/src/inm-supplicant-bss.c
+       ${CMAKE_SOURCE_DIR}/src/inm-supplicant-network.c
+       ${CMAKE_SOURCE_DIR}/src/inm-supplicant-p2p.c
+       ${CMAKE_SOURCE_DIR}/src/inm-telephony.c
+       ${CMAKE_SOURCE_DIR}/src/inm-wfd-manager.c
+       ${CMAKE_SOURCE_DIR}/src/inm-mobileap.c
+       ${CMAKE_SOURCE_DIR}/src/inm-daemon.c
+       ${CMAKE_SOURCE_DIR}/src/inm-daemon-main.c
+       ${CMAKE_SOURCE_DIR}/src/inm-ip-conflict.c
+       ${CMAKE_SOURCE_DIR}/src/inm-iface-mon.c
+       ${CMAKE_SOURCE_DIR}/src/inm-net-access.c
+       ${CMAKE_SOURCE_DIR}/src/inm-statistics.c
+       ${CMAKE_SOURCE_DIR}/src/inm-dump.c
+       ${CMAKE_SOURCE_DIR}/src/inm-util.c
+       ${CMAKE_SOURCE_DIR}/src/inm-netlink.c
+       ${CMAKE_SOURCE_DIR}/src/inm-congestion-mon.c
        )
 
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic -Wall -Werror-implicit-function-declaration -fvisibility=hidden")
diff --git a/src/inm-apagent.c b/src/inm-apagent.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/inm-congestion-mon.c b/src/inm-congestion-mon.c
new file mode 100644 (file)
index 0000000..41cada3
--- /dev/null
@@ -0,0 +1,292 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for monitoring congestion in network.
+ *
+ * @file        nm-congestion-mon.c
+ * @author      Niraj Kumar Goit (niraj.g@samsung.com)
+ * @version     0.1
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "inm-daemon-log.h"
+#include "inm-iface-mon.h"
+#include "inm-util.h"
+
+#define NETWORK_CONGESTION_MON         "/proc/net/snmp"
+#define NETWORK_CONG_MON_INTERVAL      10*1000
+
+typedef struct {
+       gboolean is_initialized;
+       GHashTable *monitoring_cbs;
+} congestion_mon_s;
+
+typedef struct {
+       guint timer_source_id;
+       nm_congestion_mon_callback cb;
+       gpointer cb_user_data;
+}congestion_mon_data_s;
+
+congestion_mon_s cong_mon;
+static __thread congestion_mon_data_s *data = NULL;
+static __thread gboolean g_cong_mon_started;
+
+static void __destroy_cong_mon_data(gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       congestion_mon_data_s *mon_data = (congestion_mon_data_s *)user_data;
+
+       g_source_remove(mon_data->timer_source_id);
+       g_free(mon_data);
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static int __nm_check_congestion_status(int *status)
+{
+       double prev_transmit = -1;
+       double curr_transmit = -1;
+       double prev_retrans = -1;
+       double curr_retrans = -1;
+       double retrans_rate = 0 ;
+       int ret = 0;
+       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0,};
+       FILE * fd = NULL;
+
+       errno = 0;
+       ret = access(NETWORK_CONGESTION_MON, F_OK);
+       if (ret < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               NM_LOGE("Could not access %s, error:[%s]", NETWORK_CONGESTION_MON, error_buf);
+               return -1;
+       }
+       fd = fopen(NETWORK_CONGESTION_MON, "r" );
+       if (!fd) {
+               NM_LOGE("Failed to open file: [%s]", NETWORK_CONGESTION_MON);
+               return -1;
+       }
+
+       char *buffer;
+       size_t buf_size = 0;
+       int  i = 0;
+       while (getline(&buffer, &buf_size, fd) != -1) {
+               if (strstr(buffer, "Tcp"))
+                       i++;
+               if (i == 2) {
+                       int j = 0, u = 0;
+                       while (j < 10 && u < (int)buf_size) {
+                               if(buffer[u] == ' ') {
+                                       j++;
+                               }
+                               u++;
+                       }
+
+                       char *token1, *token2;
+                       token1 = strtok_r(buffer+u, " ", &token2);
+                       /** Transmitted data */
+                       strtok_r(token2, " ", &token1);
+                       double transmit = atof(token2);
+
+                       /** Retransmitted data */
+                       strtok_r(token1 , " ", &token2);
+                       double retransmit = atof(token1);
+
+                       if(prev_transmit == -1 || transmit < prev_transmit) {
+                               prev_transmit = transmit;
+                               curr_transmit = transmit;
+                       } else {
+                               prev_transmit = curr_transmit;
+                               curr_transmit = transmit;
+
+                       }
+
+                       if (prev_retrans == -1 || prev_retrans > retransmit) {
+                               curr_retrans = retransmit;
+                               prev_retrans = retransmit;
+                       } else {
+                               prev_retrans = curr_retrans;
+                               curr_retrans = retransmit ;
+                       }
+
+                       break;
+               }
+
+       }
+
+       fclose(fd);
+
+       double tcp_retrans_data =   curr_retrans - prev_retrans ;
+       double tcp_trans_data = curr_transmit - prev_transmit;
+
+       NM_LOGI("transmitted %lf retarnsmitted %lf after 10 seconds", tcp_trans_data, tcp_retrans_data);
+
+       if(tcp_retrans_data == 0 && tcp_trans_data == 0) {
+               NM_LOGI("Tcp data is not transmitted yet.");
+       } else if(tcp_trans_data == 0) {
+               retrans_rate = (curr_retrans/curr_transmit) * 100;
+       } else {
+               retrans_rate = (tcp_retrans_data/tcp_trans_data) * 100;
+       }
+
+       *status = retrans_rate;
+       return 0;
+}
+
+static gboolean __nm_cong_mon_status_callback(gpointer user_data)
+{
+       int status;
+
+       if (!g_cong_mon_started) {
+               NM_LOGE("congestion monitor is stopped");
+               return FALSE;
+       }
+
+       if (__nm_check_congestion_status(&status) < 0) {
+               __NM_FUNC_EXIT__;
+               return TRUE;
+       }
+       NM_LOGI("Network Congestion Status:[%d]", status);
+
+       if (data->cb)
+               data->cb(status, data->cb_user_data);
+
+       return TRUE;
+}
+
+static int __nm_attatch_cong_mon_file(congestion_mon_data_s *data)
+{
+       __NM_FUNC_ENTER__;
+
+       data->timer_source_id = g_timeout_add(NETWORK_CONG_MON_INTERVAL,
+                       __nm_cong_mon_status_callback, data);
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_congestion_monitor_start(nm_congestion_mon_callback cb, void *user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       if (!cong_mon.is_initialized) {
+               NM_LOGE("congestion monitor is not initialized");
+               __NM_FUNC_EXIT__;
+               return NM_CONG_MON_NOT_INITIALIZED;
+       }
+
+       if (g_cong_mon_started) {
+               NM_LOGE("congestion monitor is already started");
+               __NM_FUNC_EXIT__;
+               return NM_CONG_MON_ALREADY_STARTED;
+       }
+
+       if (!cb) {
+               NM_LOGE("Invalid parameter");
+               __NM_FUNC_EXIT__;
+               return NM_CONG_MON_INVALID_PARAMETER;
+       }
+
+       data = (congestion_mon_data_s*)g_try_malloc0(sizeof(congestion_mon_data_s));
+       if (!data) {
+               NM_LOGE("Failed to allocate memory");
+               __NM_FUNC_EXIT__;
+               return NM_CONG_MON_OPERATION_FAILED;
+       }
+
+       data->cb = cb;
+       data->cb_user_data = user_data;
+
+       if (__nm_attatch_cong_mon_file(data) < 0) {
+               NM_LOGE("Failed to attach congestion monitor file");
+               __NM_FUNC_EXIT__;
+               return NM_CONG_MON_OPERATION_FAILED;
+       }
+       g_cong_mon_started = TRUE;
+
+       __NM_FUNC_EXIT__;
+       return NM_CONG_MON_ERROR_NONE;
+}
+
+int nm_congestion_monitor_stop()
+{
+       int ret = NM_CONG_MON_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!cong_mon.is_initialized) {
+               NM_LOGE("congestion monitor is not initialized");
+               __NM_FUNC_EXIT__;
+               return NM_CONG_MON_NOT_INITIALIZED;
+       }
+       g_cong_mon_started = FALSE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_congestion_mon_init()
+{
+       int ret = NM_CONG_MON_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       memset(&cong_mon, 0x00, sizeof(cong_mon));
+       cong_mon.is_initialized = TRUE;
+
+       cong_mon.monitoring_cbs = g_hash_table_new_full(g_str_hash,
+                       g_str_equal,
+                       g_free,
+                       __destroy_cong_mon_data
+                       );
+
+       if (!cong_mon.monitoring_cbs) {
+               cong_mon.is_initialized = FALSE;
+               __NM_FUNC_EXIT__;
+               return NM_CONG_MON_OPERATION_FAILED;
+       }
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_congestion_mon_deinit()
+{
+       int ret = NM_CONG_MON_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!cong_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_CONG_MON_NOT_INITIALIZED;
+       }
+
+       cong_mon.is_initialized = FALSE;
+       g_hash_table_remove_all(cong_mon.monitoring_cbs);
+       g_hash_table_unref(cong_mon.monitoring_cbs);
+       cong_mon.monitoring_cbs = NULL;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-connman-internal.h b/src/inm-connman-internal.h
new file mode 100644 (file)
index 0000000..405ea80
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macro and declares functions for handling signal from connman.
+ *
+ * @file        nm-connman-internal.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#ifndef __NM_CONNMAN_INTERNAL_H__
+#define __NM_CONNMAN_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CONNMAN_CLOCK_INTERFACE                        CONNMAN_SERVICE ".Clock"
+#define CONNMAN_ERROR_INTERFACE                        CONNMAN_SERVICE ".Error"
+#define CONNMAN_MANAGER_PATH                   "/"
+
+typedef enum {
+       /*
+        * If the device is in offline mode
+        */
+       MANAGER_STATE_OFFLINE,
+       /*
+        * If no service is in either "ready" or "online" state
+        */
+       MANAGER_STATE_IDLE,
+       /*
+        * If at least one service is in "ready" state and
+        *  no service is in "online" state
+        */
+       MANAGER_STATE_READY,
+       /*
+        *  When at least one service is in "online" state
+        */
+       MANAGER_STATE_ONLINE,
+} connman_manager_state_e;
+
+typedef enum {
+       /*
+        * IPV4 Address type
+        */
+       CONNMAN_ADDR_IPV4,
+       /*
+        * IPV6 Address type
+        */
+       CONNMAN_ADDR_IPV6,
+} connman_addr_type_e;
+
+typedef enum {
+       CONNMAN_SERVICE_STATE_UNKNOWN,
+       CONNMAN_SERVICE_STATE_IDLE,
+       CONNMAN_SERVICE_STATE_ASSOCIATION,
+       CONNMAN_SERVICE_STATE_CONFIGURATION,
+       CONNMAN_SERVICE_STATE_READY,
+       CONNMAN_SERVICE_STATE_ONLINE,
+       CONNMAN_SERVICE_STATE_DISCONNECT,
+       CONNMAN_SERVICE_STATE_FAILURE,
+
+} connman_service_state_e;
+
+typedef enum {
+       CONNMAN_SERVICE_SECURITY_UNKNOWN,
+       CONNMAN_SERVICE_SECURITY_NONE,
+       CONNMAN_SERVICE_SECURITY_WEP,
+       CONNMAN_SERVICE_SECURITY_PSK,
+       CONNMAN_SERVICE_SECURITY_8021X,
+       CONNMAN_SERVICE_SECURITY_WPA,
+       CONNMAN_SERVICE_SECURITY_RSN,
+} connman_service_security_e;
+
+typedef enum {
+       CONNMAN_IPCONFIG_METHOD_UNKNOWN,
+       CONNMAN_IPCONFIG_METHOD_OFF,
+       CONNMAN_IPCONFIG_METHOD_FIXED,
+       CONNMAN_IPCONFIG_METHOD_MANUAL,
+       CONNMAN_IPCONFIG_METHOD_DHCP,
+       CONNMAN_IPCONFIG_METHOD_AUTO,
+} connman_ipconfig_method_e;
+
+typedef enum {
+       /*
+        * Not defined
+        */
+       CONNMAN_DNS_CONFIG_TYPE_UNKNOWN,
+       /*
+        * Manual DNS configuration
+        */
+       CONNMAN_DNS_CONFIG_TYPE_STATIC,
+       /*
+        * Config DNS using DHCP client
+        */
+       CONNMAN_DNS_CONFIG_TYPE_DYNAMIC,
+} connman_dns_config_type_e;
+
+typedef enum {
+       /*
+        * Not defined
+        */
+       CONNMAN_PROXY_TYPE_UNKNOWN,
+       /*
+        * Direct connection
+        */
+       CONNMAN_PROXY_TYPE_DIRECT,
+       /*
+        * Auto configuration(Use PAC file) If URL property is not set,
+        * DHCP/WPAD auto-discover will be tried
+        */
+       CONNMAN_PROXY_TYPE_AUTO,
+       /*
+        * Manual configuration
+        */
+       CONNMAN_PROXY_TYPE_MANUAL,
+} connman_proxy_type_e;
+
+typedef enum {
+
+       /** Not defined */
+       CONNMAN_PDP_TYPE_NONE   = 0x00,
+       /** PDP-GPRS type */
+       CONNMAN_PDP_TYPE_GPRS,
+       /** PDP-EDGE type */
+       CONNMAN_PDP_TYPE_EDGE,
+       /** PDP-UMTS type */
+       CONNMAN_PDP_TYPE_UMTS,
+} connman_pdp_type_e;
+
+typedef enum {
+
+       /** auto connection mode */
+       CONNMAN_WLAN_MODE_AUTO = 0x01,
+       /** Connection mode Adhoc  */
+       CONNMAN_WLAN_MODE_ADHOC,
+       /** Infra connection mode */
+       CONNMAN_WLAN_MODE_INFRA,
+} connman_wlan_mode_e;
+
+void nm_connman_mgr_tech_added(
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data);
+
+void nm_connman_mgr_tech_removed(
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data);
+
+void nm_connman_mgr_service_changed(
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data);
+
+void nm_connman_mgr_property_changed(
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data);
+
+int nm_connman_tech_init();
+int nm_connman_tech_deinit();
+void nm_connman_tech_add(gchar *path, GVariantIter *iter);
+void nm_connman_tech_remove(GVariant *parameters);
+
+int nm_connman_service_init();
+int nm_connman_service_deinit();
+void nm_connman_service_get_from_reply(GVariant *reply, gpointer user_data);
+void nm_connman_service_add(gchar *path, GVariantIter *iter, GVariantBuilder *added);
+void nm_connman_service_remove(gchar *path, GVariantBuilder *removed);
+void nm_connman_service_change(GVariant *parameters);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_CONNMAN_INTERNAL_H__ */
+
diff --git a/src/inm-connman-mgr.c b/src/inm-connman-mgr.c
new file mode 100644 (file)
index 0000000..8282d70
--- /dev/null
@@ -0,0 +1,326 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling connman manager DBus interface.
+ *
+ * @file        nm-connman-mgr.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <glib.h>
+#include <gio/gio.h>
+
+
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-connman.h"
+#include "inm-connman-internal.h"
+
+typedef enum {
+       MANAGER_CMD_GET_PROP,
+       MANAGER_CMD_GET_TECH,
+       MANAGER_CMD_GET_SERVICE,
+
+} manager_cmd_e;
+
+typedef struct {
+       /*
+        * The global connection state of a system
+        */
+       int state;
+       /* The offline mode indicates the global setting for
+        * switching all radios on or off. Changing offline mode
+        * to true results in powering down all devices.
+        */
+       gboolean offline_mode;
+       /*
+        * deprecated
+        */
+       gboolean session_mode;
+       gboolean auto_connect_mode;
+} connman_manager_s;
+
+static method_param_s connman_method_params[] = {
+               {
+                               .bus_name = CONNMAN_SERVICE,
+                               .object_path = CONNMAN_MANAGER_PATH,
+                               .interface_name = CONNMAN_MANAGER_INTERFACE,
+                               .method_name = "GetProperties",
+                               .parameters = NULL,
+               },
+               {
+                               .bus_name = CONNMAN_SERVICE,
+                               .object_path = CONNMAN_MANAGER_PATH,
+                               .interface_name = CONNMAN_MANAGER_INTERFACE,
+                               .method_name = "GetTechnologies",
+                               .parameters = NULL,
+               },
+               {
+                               .bus_name = CONNMAN_SERVICE,
+                               .object_path = CONNMAN_MANAGER_PATH,
+                               .interface_name = CONNMAN_MANAGER_INTERFACE,
+                               .method_name = "GetServices",
+                               .parameters = NULL,
+               },
+};
+
+connman_manager_s connman_manager = {
+               .state  = 0,
+               .offline_mode = FALSE,
+               .session_mode = FALSE,
+               .auto_connect_mode  = FALSE,
+};
+
+void nm_connman_mgr_tech_added(
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       GVariantIter *iter = NULL;
+       gchar *path = NULL;
+
+       g_variant_get(parameters, "(&oa{sv})", &path, &iter);
+       nm_connman_tech_add(path, iter);
+
+       g_variant_iter_free(iter);
+       return;
+       __NM_FUNC_EXIT__;
+}
+
+void nm_connman_mgr_tech_removed(
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       nm_connman_tech_remove(parameters);
+
+       return;
+       __NM_FUNC_EXIT__;
+
+}
+
+void nm_connman_mgr_service_changed(
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       nm_connman_service_change(parameters);
+
+       return;
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __set_manager_state(const gchar *state)
+{
+       if (g_strcmp0(state, "offline") == 0)
+               connman_manager.state = MANAGER_STATE_OFFLINE;
+       else if (g_strcmp0(state, "idle") == 0)
+               connman_manager.state = MANAGER_STATE_IDLE;
+       else if (g_strcmp0(state, "ready") == 0)
+               connman_manager.state = MANAGER_STATE_READY;
+       else if (g_strcmp0(state, "online") == 0)
+               connman_manager.state = MANAGER_STATE_ONLINE;
+
+       return;
+}
+
+static inline void __mgr_get_property(gchar *key, GVariant *value)
+{
+       if (g_strcmp0(key, "State") == 0) {
+               const char *state = NULL;
+
+               g_variant_get(value, "&s", &state);
+               __set_manager_state(state);
+
+       } else if (g_strcmp0(key, "OfflineMode") == 0){
+               g_variant_get(value, "b", &connman_manager.offline_mode);
+       } else if (g_strcmp0(key, "SessionMode") == 0){
+               g_variant_get(value, "b", &connman_manager.session_mode);
+       }  else if (g_strcmp0(key, "AutoConnectMode") == 0){
+               g_variant_get(value, "b", &connman_manager.auto_connect_mode);
+       }
+}
+
+static void __mgr_property_changed(GVariant *property)
+{
+       gchar *key = NULL;
+       GVariant *value = NULL;
+       g_variant_get(property, "(&sv)", &key, &value);
+
+       if (key)
+               __mgr_get_property(key, value);
+}
+
+static void __get_manager_properties(GVariant *reply, gpointer user_data)
+{
+       GVariantIter *iter = NULL;
+       gchar *key = NULL;
+       GVariant *value = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (!reply) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       g_variant_get(reply, "(a{sv})", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &value))
+               __mgr_get_property(key, value);
+
+       g_variant_iter_free(iter);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __get_technologies(GVariant *reply, gpointer user_data)
+{
+       GVariantIter *iter_outer = NULL;
+       GVariantIter *iter_inner = NULL;
+       gchar *path = NULL;
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(reply, "(a(oa{sv}))", &iter_outer);
+
+       while (g_variant_iter_loop(iter_outer, "(&oa{sv})", &path, &iter_inner)) {
+
+               if (path == NULL || iter_inner == NULL)
+                       continue;
+               nm_connman_tech_add(path, iter_inner);
+       }
+
+       g_variant_iter_free(iter_outer);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+void nm_connman_mgr_property_changed(
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __mgr_property_changed(parameters);
+
+       return;
+       __NM_FUNC_EXIT__;
+}
+
+int nm_connman_mgr_get_properties()
+{
+       int ret = NM_CONNMAN_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       ret = nm_gdbus_method_call(
+                       &(connman_method_params[MANAGER_CMD_GET_PROP]),
+                       __get_manager_properties,
+                       NULL);
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_METHOD_CALL_FAILED;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_CONNMAN_ERROR_NONE;
+}
+
+int nm_connman_mgr_get_state(int *state)
+{
+       int ret = NM_CONNMAN_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       *state = connman_manager.state;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_connman_mgr_get_offline_mode(gboolean *offline_mode)
+{
+       int ret = NM_CONNMAN_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       *offline_mode = connman_manager.offline_mode;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+
+}
+int nm_connman_mgr_get_technologies()
+{
+       int ret = NM_CONNMAN_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       ret = nm_gdbus_method_call(
+                       &(connman_method_params[MANAGER_CMD_GET_TECH]),
+                       __get_technologies,
+                       NULL);
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_METHOD_CALL_FAILED;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_CONNMAN_ERROR_NONE;
+}
+
+int nm_connman_mgr_get_services()
+{
+       int ret = NM_CONNMAN_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       ret = nm_gdbus_method_call(
+                       &(connman_method_params[MANAGER_CMD_GET_SERVICE]),
+                       nm_connman_service_get_from_reply,
+                       NULL);
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_METHOD_CALL_FAILED;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_CONNMAN_ERROR_NONE;
+}
diff --git a/src/inm-connman-service.c b/src/inm-connman-service.c
new file mode 100755 (executable)
index 0000000..f5ee78b
--- /dev/null
@@ -0,0 +1,2940 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling connman service DBus interface.
+ *
+ * @file        nm-connman-service.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdlib.h>
+
+#include <arpa/inet.h>
+
+#include <glib.h>
+
+#include "inm-connman.h"
+#include "inm-connman-internal.h"
+#include "inm-telephony.h"
+#include "inm-gdbus.h"
+#include "inm-daemon-log.h"
+
+#define IP_LEN 4
+#define IPV6_LEN 16
+#define MAC_LEN 6
+
+/* Maximum length of device name  */
+#define        MAX_DEVICE_NAME_LEN 32
+
+/* Maximum length of IPv6 Privacy  ["enabled", "disabled", "preferred"] */
+#define        IPV6_MAX_PRIVACY_LEN 9
+
+/* Maximum length of proxy string */
+#define MAX_PROXY_LEN 64
+
+/** MAX number of DNS Address */
+#define        MAX_DNS_ADDR 3
+
+#define IPV6_LEN 16
+
+/** Length of essid */
+#define WLAN_ESSID_LEN      128
+
+/** Length of bssid */
+#define WLAN_BSSID_LEN      17
+
+/**
+ * Length of WPS PIN code
+ * WPS PIN code should be 4 or 8 digits
+ */
+#define WLAN_MAX_PIN_LEN               8
+
+/**
+ * Passphrase length should be between 8..63,
+ * If we plan to use encrypted key(hex value generated by wpa_passphrase),
+ * then we have to set this value to some higher number
+ *
+ */
+#define WLAN_MAX_PSK_PASSPHRASE_LEN 65
+
+/**
+ * Length of WEP Key
+ * Max of 10 Hex digits allowed in case of 64 bit encryption
+ * Max of 26 Hex digits allowed in case of 128 bit encryption
+ */
+#define WLAN_MAX_WEP_KEY_LEN        26
+
+/**
+ * These lengths depends on authentication server being used,
+ * In case of freeradius server Max allowed length for username/password is 255
+ * Let us restrict this value to some optimal value say 50.
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define WLAN_USERNAME_LEN               50
+
+/**
+ * These lengths depends on authentication server being used,
+ * In case of freeradius server Max allowed length for username/password is 255
+ * Let us restrict this value to some optimal value say 50.
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define WLAN_PASSWORD_LEN               50
+
+/**
+ * length of CA Cert file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define WLAN_CA_CERT_FILENAME_LEN       128
+
+/**
+ * length of Client Cert file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define WLAN_CLIENT_CERT_FILENAME_LEN   128
+
+/**
+ * length of private key file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define WLAN_PRIVATE_KEY_FILENAME_LEN   128
+
+/**
+ * length of Private key password
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define WLAN_PRIVATE_KEY_PASSWD_LEN     50
+
+/**
+ * @enum wlan_security_mode_type_e
+ * Below security modes are used in infrastructure and ad-hoc mode
+ * For now all EAP security mechanisms are provided only in infrastructure mode
+ */
+typedef enum
+{
+       /** Security disabled */
+       WLAN_SEC_MODE_NONE = 0x01,
+       /** WEP */
+       WLAN_SEC_MODE_WEP,
+       /** EAP */
+       WLAN_SEC_MODE_IEEE8021X,
+       /** WPA-PSK */
+       WLAN_SEC_MODE_WPA_PSK,
+       /** WPA2-PSK */
+       WLAN_SEC_MODE_WPA2_PSK,
+       WLAN_SEC_MODE_WPA_FT_PSK,
+} wlan_security_mode_type_e;
+
+/**
+ * @enum wlan_encryption_mode_type_e
+ * Below encryption modes are used in infrastructure and ad-hoc mode
+ */
+typedef enum
+{
+       /** Encryption disabled */
+       WLAN_ENC_MODE_NONE = 0x01,
+       /** WEP */
+       WLAN_ENC_MODE_WEP,
+       /** TKIP */
+       WLAN_ENC_MODE_TKIP,
+       /** AES */
+       WLAN_ENC_MODE_AES,
+       /** TKIP and AES are both supported */
+       WLAN_ENC_MODE_TKIP_AES_MIXED,
+} wlan_encryption_mode_type_e;
+
+/**
+ * @enum wlan_eap_type_e
+ * EAP type
+ * @see wlan_eap_info_e
+ */
+typedef enum {
+       /** EAP PEAP type */
+       WLAN_SEC_EAP_TYPE_PEAP = 0x01,
+       /** EAP TLS type */
+       WLAN_SEC_EAP_TYPE_TLS,
+       /** EAP TTLS type */
+       WLAN_SEC_EAP_TYPE_TTLS,
+       /** EAP SIM type */
+       WLAN_SEC_EAP_TYPE_SIM,
+       /** EAP AKA type */
+       WLAN_SEC_EAP_TYPE_AKA,
+} wlan_eap_type_e;
+
+/**
+ * @enum wlan_eap_auth_type_e
+ * EAP phase2 authentication type
+ * @see wlan_eap_info_e
+ */
+typedef enum {
+       /** EAP phase2 authentication none */
+       WLAN_SEC_EAP_AUTH_NONE = 0x01,
+       /** EAP phase2 authentication PAP */
+       WLAN_SEC_EAP_AUTH_PAP,
+       /** EAP phase2 authentication MSCHAP */
+       WLAN_SEC_EAP_AUTH_MSCHAP,
+       /** EAP phase2 authentication MSCHAPv2 */
+       WLAN_SEC_EAP_AUTH_MSCHAPV2,
+       /** EAP phase2 authentication GTC */
+       WLAN_SEC_EAP_AUTH_GTC,
+       /** EAP phase2 authentication MD5 */
+       WLAN_SEC_EAP_AUTH_MD5,
+} wlan_eap_auth_type_e;
+
+/**
+ * @enum wlan_eap_keymgmt_type_e
+ * EAP keymgmt type
+ * @see wlan_eap_info_e
+ */
+typedef enum {
+       WLAN_SEC_EAP_KEYMGMT_UNKNOWN = 0x00,
+       WLAN_SEC_EAP_KEYMGMT_NONE,
+       WLAN_SEC_EAP_KEYMGMT_FT,
+       WLAN_SEC_EAP_KEYMGMT_CCKM,
+       WLAN_SEC_EAP_KEYMGMT_OKC,
+} wlan_eap_keymgmt_type_e;
+
+typedef struct {
+       /*
+        * Possible values are "dhcp", "manual", "auto"
+        * and "off".
+        */
+       gint method;
+       /*
+        * The current configured IPv4 address.
+        */
+       struct in_addr address;
+       /*
+        * The current configured IPv4 netmask.
+        */
+       struct in_addr netmask;
+       /*
+        * The current configured IPv4 gateway.
+        */
+       struct in_addr gateway;
+       /*
+        * The current configured IPv4 DHCP server IP.
+        */
+       struct in_addr dhcp_server_ip;
+       /*
+        * The current configured IPv4 DHCP lease duration.
+        */
+       gint dhcp_lease_duration;
+} connman_ipv4_s;
+
+typedef struct {
+       /*
+        * Possible values are "auto", "manual", "6to4" and "off".
+        */
+       gint method;
+
+       /*
+        * The current configured IPv6 address.
+        */
+       struct in6_addr address;
+       /*
+        * The prefix length of the IPv6 address.
+        */
+       gint prefix_length;
+       /*
+        * The current configured IPv6 gateway.
+        */
+       struct in6_addr gateway;
+       /*
+        * Enable or disable IPv6 privacy extension
+        * that is described in RFC 4941. The value
+        * has only meaning if Method is set to "auto".
+        * Value "disabled" means that privacy extension
+        * is disabled and normal autoconf addresses are
+        * used.
+        *
+        * Value "enabled" means that privacy extension is
+        * enabled and system prefers to use public
+        * addresses over temporary addresses.
+        * Value "prefered" means that privacy extension is
+        * enabled and system prefers temporary addresses
+        * over public addresses.
+        * Default value is "disabled".
+        */
+       gchar privacy[IPV6_MAX_PRIVACY_LEN + 1];
+
+} connman_ipv6_s;
+
+typedef union {
+       /*
+        * IP Version 4 address
+        */
+       struct in_addr ip;
+       /*
+        * IP Version 6 address
+        */
+       struct in6_addr ipv6;
+} connman_ip_addr_u;
+
+typedef struct {
+       gint addr_type;
+       connman_ip_addr_u addr;
+} connman_dns_addr;
+
+typedef struct {
+       /*
+        * Possible values are "direct", "auto" and "manual".
+        */
+       gint method;
+       /*
+        * Automatic proxy configuration URL. Used by "auto" method.
+        */
+       gchar addr[MAX_PROXY_LEN + 1];
+
+} connman_proxy_s;
+
+typedef struct {
+       /*
+        * Possible values are "auto" and "manual".
+        */
+       gint method;
+       /*
+        * Interface name (for example eth0).
+        */
+       gchar interface[MAX_DEVICE_NAME_LEN];
+       /*
+        * Ethernet device address (MAC address).
+        */
+       guint8 address[MAC_LEN];
+       /*
+        * The Ethernet MTU (default is 1500).
+        */
+       gint mtu;
+} connman_eth_s;
+
+typedef struct {
+       /* TODO: fill eth specific info */
+} connman_eth_priv_s;
+
+typedef struct {
+       /* TODO: fill bt specific info */
+
+} connman_bt_priv_s;
+
+/**
+ * Below structure is used to export essid
+ */
+typedef struct
+{
+       /** ESSID */
+       char essid[WLAN_ESSID_LEN+1];
+} net_essid_s;
+
+/**
+ * Below structure is used by WPA-PSK or WPA2-PSK
+ * @remark To see the maximum length of PSK passphrase key.
+ * @see wlan_auth_info_t
+ */
+typedef struct
+{
+       /** key value for WPA-PSK or WPA2-PSK */
+       gchar pskKey[WLAN_MAX_PSK_PASSPHRASE_LEN + 1];
+} wlan_psk_info_s;
+
+/**
+ * Below structure is used by WEP
+ * @remark To see the maximum length of WEP key.
+ * @see wlan_auth_info_s
+ */
+typedef struct
+{
+       /** key value for WEP */
+       gchar wepKey[WLAN_MAX_WEP_KEY_LEN + 1];
+} wlan_wep_info_s;
+
+/**
+ * Below structure is used by EAP
+ * @see wlan_auth_info_s
+ */
+typedef struct
+{
+       /** User name */
+       gchar username[WLAN_USERNAME_LEN+1];
+       /** Password */
+       gchar password[WLAN_PASSWORD_LEN+1];
+
+       /**
+        * Following fields are mandatory for EAP-TLS,
+        * Optional for EAP-TTLS and EAP-PEAP
+        */
+       /**
+        * For EAP-TTLS and EAP-PEAP only ca_cert_filename[] can also be provided
+        */
+       /* Used to authenticate server */
+       gchar ca_cert_filename[WLAN_CA_CERT_FILENAME_LEN+1];
+       /** client certificate file name */
+       gchar client_cert_filename[WLAN_CLIENT_CERT_FILENAME_LEN+1];
+       /** private key file name */
+       gchar private_key_filename[WLAN_PRIVATE_KEY_FILENAME_LEN+1];
+       /** private key password */
+       gchar private_key_passwd[WLAN_PRIVATE_KEY_PASSWD_LEN+1];
+
+       /** eap type */
+       wlan_eap_type_e eap_type;
+       /** eap phase2 authentication type */
+       wlan_eap_auth_type_e eap_auth;
+       /** eap keymgmt type */
+       wlan_eap_keymgmt_type_e eap_keymgmt_type;
+} wlan_eap_info_s;
+
+/**
+ * At any point of time only one security mechanism is supported
+ * @see wlan_sec_info_s
+ */
+typedef union
+{
+       /** Wep Authentication */
+       wlan_wep_info_s wep;
+       /** psk Authentication */
+       wlan_psk_info_s psk;
+       /** eap Authentication */
+       wlan_eap_info_s eap;
+} wlan_auth_info_u;
+
+/**
+ * This is main security information structure
+ * @see connman_wlan_priv_s
+ */
+typedef struct
+{
+       /** security mode type */
+       wlan_security_mode_type_e sec_mode;
+       /** encryption mode type */
+       wlan_encryption_mode_type_e enc_mode;
+       /** authentication information */
+       wlan_auth_info_u auth_info;
+       /** If WPS is supported, then this property will be set to TRUE */
+       gboolean wps_support;
+       /** keymgmt */
+       unsigned int keymgmt;
+} wlan_sec_info_s;
+
+typedef struct {
+
+       /** Infrastucture / ad-hoc / auto mode */
+       connman_wlan_mode_e mode;
+
+       /** ESSID */
+       gchar essid[WLAN_ESSID_LEN + 1];
+
+       /** Basic service set identification */
+       gchar bssid[WLAN_BSSID_LEN + 1];
+
+       /**  Strength : between 0 and 100 */
+       guchar strength;
+       /** Frequency band(MHz) */
+       guint frequency;
+       /** Maximum speed of the line(bps) */
+       guint max_rate;
+       /** If a passphrase has been set already or if no
+               passphrase is needed, then this property will
+               be set to FALSE. */
+       gchar passphrase_required;
+
+       /** Security mode and authentication info */
+       wlan_sec_info_s sec_info;
+
+       /** Passpoint AP or not */
+       gboolean passpoint;
+
+       /** Hidden network */
+       gboolean is_hidden;
+       gint reason;
+       gint assoc_status;
+
+} connman_wlan_priv_s;
+
+typedef union {
+       connman_eth_priv_s eth;
+       connman_bt_priv_s bt;
+       nm_telephony_profile_s cell;
+       connman_wlan_priv_s wlan;
+
+} connman_srv_priv_u;
+
+typedef struct {
+       /*
+        * The service state information.
+        * The "ready" state signals a successfully
+        * connected device. "online" signals that an
+        * Internet connection is available and has been
+        * verified.
+        */
+       gint state;
+       gint state_ipv6;
+       /*
+        * The service error status details.
+        * This property is only valid when the service is in
+        * the "failure" state. Otherwise it might be empty or
+        * not present at all.
+        */
+       gint error;
+       /*
+        * The service name (for example "Wireless" etc.)
+        * For Ethernet devices and hidden WiFi networks this
+        * property is not present.
+        */
+       gchar *name;
+       /*
+        * The service type (for example "ethernet", "wifi" etc.)
+        * Together with a missing Name property, this can
+        * be used to identify hidden WiFi networks.
+        */
+       gint type;
+       /*
+        * If the service type is WiFi, then this property is
+        * present security methods or key management settings.
+        */
+       gint security;
+       /*
+        * Indicates the signal strength of the service. This
+        * is a normalized value between 0 and 100.
+        * This property will not be present for Ethernet devices.
+        */
+       guint8 strength;
+       /*
+        * Will be true if a cable is plugged in or the user
+        * selected and successfully connected to this service.
+        */
+       gboolean favorite;
+       /*
+        * This value will be set to true if the service is
+        * configured externally via a configuration file.
+        */
+       gboolean immutable;
+       /*
+        * If set to true, this service will auto-connect
+        * when no other connection is available.
+        * The service won't auto-connect while roaming.
+        */
+       gboolean auto_connect;
+       /*
+        * This property indicates if this service is roaming.
+        */
+       gboolean roaming;
+       /*
+        * The list of currently active nameservers for this
+        * service. If the server is not in READY or ONLINE
+        * state than this list will be empty.
+        *
+        */
+       GSList *name_servers;
+       /*
+        * The list of manually configured domain name
+        * servers. Some cellular networks don't provide
+        * correct name servers and this allows for an
+        * override.
+        */
+       GSList *configured_name_servers;
+       /*
+        * The list of currently active timeservers for this
+        * service. If the server is not in READY or ONLINE
+        * state than this list will be empty.
+        */
+       GSList *time_servers;
+       /*
+        * The list of manually configured time servers.
+        */
+       GSList *configured_time_servers;
+
+       /*
+        * IPv4 Dns configuration type
+        */
+       gint dns_conf_type;
+       /*
+        * IPv6 Dns configuration type
+        */
+       gint dns_conf_type_v6;
+       /*
+        * No of IPv4 DNS Address for the connection link
+        */
+       gint dns_cnt;
+       /*
+        * No of IPv6 DNS Address for the connection link
+        */
+       gint dns_cnt_v6;
+       /*
+        * IPv4 Dns Server Address of the connection link
+        */
+       connman_dns_addr dns_addr[MAX_DNS_ADDR];
+
+       /*
+        * IPv6 Dns Server Address of the connection link
+        */
+       connman_dns_addr dns_addr_v6[MAX_DNS_ADDR];
+
+       connman_ipv4_s ip;
+       /*
+        * Same values as IPv4 property. The IPv4 represents
+        * the actual system configuration while this allows
+        * user configuration.
+        */
+       connman_ipv4_s configured_ip;
+
+       connman_ipv6_s ipv6;
+       /*
+        * Same values as IPv6 property. The IPv6 represents
+        * the actual system configuration while this allows
+        * user configuration.
+        */
+       connman_ipv6_s configured_ipv6;
+
+       connman_proxy_s proxy;
+
+       connman_eth_s eth;
+       /*
+        * Whether or not mDNS support is enabled.
+        */
+       gboolean mdns;
+       /*
+        * Same values as mDNS property. The mDNS
+        * represents the actual system configuration
+        * while this allows user configuration.
+        */
+       gboolean configured_mdns;
+       guint subscriber_id;
+
+       guint conn_obj_id;
+       gchar obj_path[DBUS_OBJECT_PATH_MAX + 1];
+
+       connman_srv_priv_u priv_info;
+} connman_service_s;
+
+static void __service_property_changed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+typedef struct {
+       int num;
+       char *str;
+} str_map_s;
+
+str_map_s conn_type[] = {
+       {CONNMAN_SERVICE_TYPE_UNKNOWN, "Unknown"},
+       {CONNMAN_SERVICE_TYPE_SYSTEM, "system"},
+       {CONNMAN_SERVICE_TYPE_ETHERNET, "ethernet"},
+       {CONNMAN_SERVICE_TYPE_WIFI, "wifi"},
+       {CONNMAN_SERVICE_TYPE_BLUETOOTH, "bluetooth"},
+       {CONNMAN_SERVICE_TYPE_CELLULAR, "cellular"},
+       {CONNMAN_SERVICE_TYPE_GPS, "gps"},
+       {CONNMAN_SERVICE_TYPE_VPN, "vpn"},
+       {CONNMAN_SERVICE_TYPE_GADGET, "gadget"},
+       {CONNMAN_SERVICE_TYPE_P2P, "p2p"},
+       {0, NULL},
+};
+
+str_map_s conn_state[] = {
+       {CONNMAN_SERVICE_STATE_UNKNOWN, "Unknown"},
+       {CONNMAN_SERVICE_STATE_IDLE, "idle"},
+       {CONNMAN_SERVICE_STATE_ASSOCIATION, "association"},
+       {CONNMAN_SERVICE_STATE_CONFIGURATION, "configuration"},
+       {CONNMAN_SERVICE_STATE_READY, "ready"},
+       {CONNMAN_SERVICE_STATE_ONLINE, "online"},
+       {CONNMAN_SERVICE_STATE_DISCONNECT, "disconnect"},
+       {CONNMAN_SERVICE_STATE_FAILURE, "failure"},
+       {0, NULL},
+};
+
+str_map_s conn_ip_config[] = {
+       {CONNMAN_IPCONFIG_METHOD_UNKNOWN, "unknown"},
+       {CONNMAN_IPCONFIG_METHOD_OFF, "off"},
+       {CONNMAN_IPCONFIG_METHOD_FIXED, "fixed"},
+       {CONNMAN_IPCONFIG_METHOD_MANUAL, "manual"},
+       {CONNMAN_IPCONFIG_METHOD_DHCP, "dhcp"},
+       {CONNMAN_IPCONFIG_METHOD_AUTO, "auto"},
+       {0, NULL},
+};
+
+str_map_s conn_dns_config[] = {
+       {CONNMAN_DNS_CONFIG_TYPE_UNKNOWN, "unknown"},
+       {CONNMAN_DNS_CONFIG_TYPE_STATIC, "static"},
+       {CONNMAN_DNS_CONFIG_TYPE_DYNAMIC, "dynamic"},
+       {0, NULL},
+};
+
+str_map_s conn_proxy_type[] = {
+       {CONNMAN_PROXY_TYPE_UNKNOWN, "unknown"},
+       {CONNMAN_PROXY_TYPE_DIRECT, "direct"},
+       {CONNMAN_PROXY_TYPE_AUTO, "auto"},
+       {CONNMAN_PROXY_TYPE_MANUAL, "manul"},
+       {0, NULL},
+};
+
+str_map_s conn_sec_type[] = {
+               {0, NULL},
+               {WLAN_SEC_MODE_NONE, "none"},
+               {WLAN_SEC_MODE_WEP, "wep"},
+               {WLAN_SEC_MODE_IEEE8021X, "ieee8021x"},
+               {WLAN_SEC_MODE_WPA_PSK, "psk"},
+               {WLAN_SEC_MODE_WPA2_PSK, "rsn"},
+               {WLAN_SEC_MODE_WPA_FT_PSK, "ft_psk"},
+               {0, NULL},
+};
+
+str_map_s conn_enc_type[] = {
+               {0, NULL},
+               {WLAN_ENC_MODE_NONE, "none"},
+               {WLAN_ENC_MODE_WEP, "wep"},
+               {WLAN_ENC_MODE_TKIP, "tkip"},
+               {WLAN_ENC_MODE_AES, "aes"},
+               {WLAN_ENC_MODE_TKIP_AES_MIXED, "mixed"},
+               {0, NULL},
+};
+
+str_map_s conn_eap_type[] = {
+               {0, NULL},
+               {WLAN_SEC_EAP_TYPE_PEAP, "peap"},
+               {WLAN_SEC_EAP_TYPE_TLS, "tls"},
+               {WLAN_SEC_EAP_TYPE_TTLS, "ttls"},
+               {WLAN_SEC_EAP_TYPE_SIM, "sim"},
+               {WLAN_SEC_EAP_TYPE_AKA, "aka"},
+               {0, NULL},
+};
+
+str_map_s conn_eap_auth_type[] = {
+               {0, NULL},
+               {WLAN_SEC_EAP_AUTH_NONE, "none"},
+               {WLAN_SEC_EAP_AUTH_PAP, "pap"},
+               {WLAN_SEC_EAP_AUTH_MSCHAP, "mschap"},
+               {WLAN_SEC_EAP_AUTH_MSCHAPV2, "mschapv2"},
+               {WLAN_SEC_EAP_AUTH_GTC, "gtc"},
+               {WLAN_SEC_EAP_AUTH_MD5, "md5"},
+               {0, NULL},
+};
+
+GHashTable *service_tbl = NULL;
+nm_connman_conn_changed_cb g_conn_changed_cb = NULL;
+nm_connman_error_cb g_conn_error_cb = NULL;
+
+static signal_param_s service_signal_param = {
+               .sender = CONNMAN_SERVICE,
+               .interface_name = CONNMAN_SERVICE_INTERFACE,
+               .member = DBUS_SIGNAL_PROPERTY_CHANGED,
+               .object_path = NULL,
+               .arg0 = NULL,
+               .callback = __service_property_changed,
+               .subscriber_id  = 0,
+};
+
+static GVariant *__nm_connman_service_get_ip(connman_service_s *service);
+static GVariant *__nm_connman_service_get_dns(connman_service_s *service);
+static GVariant *__nm_connman_service_get_ipv4_state(connman_service_s *service);
+static GVariant *__nm_connman_service_get_ipv6_state(connman_service_s *service);
+
+static int __ws_txt_to_mac(const gchar *txt, guchar *mac)
+{
+       int i = 0;
+
+       if (!txt || !mac) {
+               NM_LOGI("Invalid parameter");
+               return -1;
+       }
+
+       for (;;) {
+               mac[i++] = (char) strtoul((char *)txt, (char **)&txt, 16);
+               if (!*txt++ || i == 6)
+                       break;
+       }
+
+       if (i != MAC_LEN)
+               return -1;
+
+       return 0;
+}
+
+static inline void __get_state(connman_service_s *service, GVariant *value)
+{
+       const gchar *state_str = NULL;
+       state_str =  g_variant_get_string(value, NULL);
+
+       if (g_strcmp0(state_str, "idle") == 0)
+               service->state = CONNMAN_SERVICE_STATE_IDLE;
+       else if (g_strcmp0(state_str, "failure") == 0)
+               service->state = CONNMAN_SERVICE_STATE_FAILURE;
+       else if (g_strcmp0(state_str, "association") == 0)
+               service->state = CONNMAN_SERVICE_STATE_ASSOCIATION;
+       else if (g_strcmp0(state_str, "configuration") == 0)
+               service->state = CONNMAN_SERVICE_STATE_CONFIGURATION;
+       else if (g_strcmp0(state_str, "ready") == 0)
+               service->state = CONNMAN_SERVICE_STATE_READY;
+       else if (g_strcmp0(state_str, "disconnect") == 0)
+               service->state = CONNMAN_SERVICE_STATE_DISCONNECT;
+       else if (g_strcmp0(state_str, "online") == 0)
+               service->state = CONNMAN_SERVICE_STATE_ONLINE;
+       else
+               service->state = CONNMAN_SERVICE_STATE_UNKNOWN;
+
+       nm_gdbus_emit_conn_ipv4_state_changed(service->obj_path,
+                       __nm_connman_service_get_ipv4_state(service));
+
+       NM_LOGI("State [%s]", state_str);
+}
+
+static inline void __get_state_ipv6(connman_service_s *service, GVariant *value)
+{
+       const gchar *state_str = NULL;
+       state_str =  g_variant_get_string(value, NULL);
+
+       if (g_strcmp0(state_str, "idle") == 0)
+               service->state_ipv6 = CONNMAN_SERVICE_STATE_IDLE;
+       else if (g_strcmp0(state_str, "failure") == 0)
+               service->state_ipv6 = CONNMAN_SERVICE_STATE_FAILURE;
+       else if (g_strcmp0(state_str, "association") == 0)
+               service->state_ipv6 = CONNMAN_SERVICE_STATE_ASSOCIATION;
+       else if (g_strcmp0(state_str, "configuration") == 0)
+               service->state_ipv6 = CONNMAN_SERVICE_STATE_CONFIGURATION;
+       else if (g_strcmp0(state_str, "ready") == 0)
+               service->state_ipv6 = CONNMAN_SERVICE_STATE_READY;
+       else if (g_strcmp0(state_str, "disconnect") == 0)
+               service->state_ipv6 = CONNMAN_SERVICE_STATE_DISCONNECT;
+       else if (g_strcmp0(state_str, "online") == 0)
+               service->state_ipv6 = CONNMAN_SERVICE_STATE_ONLINE;
+       else
+               service->state_ipv6 = CONNMAN_SERVICE_STATE_UNKNOWN;
+
+       nm_gdbus_emit_conn_ipv6_state_changed(service->obj_path,
+                       __nm_connman_service_get_ipv6_state(service));
+
+       NM_LOGI("IP V6 state [%s]", state_str);
+}
+
+static inline void __get_error(connman_service_s *service, GVariant *value)
+{
+       const gchar *err_str = NULL;
+       err_str =  g_variant_get_string(value, NULL);
+
+       if (g_strcmp0(err_str, "invalid-key") == 0)
+               service->error = CONNMAN_SERVICE_ERROR_INVALID_KEY;
+       else if (g_strcmp0(err_str, "connect-failed") == 0)
+               service->error = CONNMAN_SERVICE_ERROR_CONNECT_FAILED;
+       else if (g_strcmp0(err_str, "auth-failed") == 0)
+               service->error = CONNMAN_SERVICE_ERROR_AUTH_FAILED;
+       else if (g_strcmp0(err_str, "login-failed") == 0)
+               service->error = CONNMAN_SERVICE_ERROR_LOGIN_FAILED;
+       else if (g_strcmp0(err_str, "dhcp-failed") == 0)
+               service->error = CONNMAN_SERVICE_ERROR_DHCP_FAILED;
+       else if (g_strcmp0(err_str, "out-of-range") == 0)
+               service->error = CONNMAN_SERVICE_ERROR_OUT_OF_RANGE;
+       else if (g_strcmp0(err_str, "pin-missing") == 0)
+               service->error = CONNMAN_SERVICE_ERROR_PIN_MISSING;
+       else
+               service->error = CONNMAN_SERVICE_ERROR_UNKNOWN;
+
+       NM_LOGI("error [%s]", err_str);
+
+       if (g_conn_error_cb)
+               g_conn_error_cb(service->error);
+}
+
+static inline void __get_name(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+       str =  g_variant_get_string(value, NULL);
+
+       if (str) {
+               g_free(service->name);
+               service->name = g_strdup(str);
+       }
+
+}
+
+static inline void __get_type(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+       str =  g_variant_get_string(value, NULL);
+
+       if (g_strcmp0(str, "ethernet") == 0)
+               service->type = CONNMAN_SERVICE_TYPE_ETHERNET;
+       else if (g_strcmp0(str, "gadget") == 0)
+               service->type = CONNMAN_SERVICE_TYPE_GADGET;
+       else if (g_strcmp0(str, "wifi") == 0)
+               service->type = CONNMAN_SERVICE_TYPE_WIFI;
+       else if (g_strcmp0(str, "cellular") == 0)
+               service->type = CONNMAN_SERVICE_TYPE_CELLULAR;
+       else if (g_strcmp0(str, "bluetooth") == 0)
+               service->type = CONNMAN_SERVICE_TYPE_BLUETOOTH;
+       else if (g_strcmp0(str, "vpn") == 0)
+               service->type = CONNMAN_SERVICE_TYPE_VPN;
+       else if (g_strcmp0(str, "gps") == 0)
+               service->type = CONNMAN_SERVICE_TYPE_GPS;
+       else if (g_strcmp0(str, "system") == 0)
+               service->type = CONNMAN_SERVICE_TYPE_SYSTEM;
+       else if (g_strcmp0(str, "p2p") == 0)
+               service->type = CONNMAN_SERVICE_TYPE_P2P;
+       else
+               service->type = CONNMAN_SERVICE_TYPE_UNKNOWN;
+
+       NM_LOGI("type [%s]", str);
+}
+
+static inline void __get_strength(connman_service_s *service, GVariant *value)
+{
+       g_variant_get(value, "y", &(service->strength));
+
+       NM_LOGI("strength [%u]", service->strength);
+}
+
+static inline void __get_favorite(connman_service_s *service, GVariant *value)
+{
+       g_variant_get(value, "b", &(service->favorite));
+}
+
+static inline void __get_immutable(connman_service_s *service, GVariant *value)
+{
+       g_variant_get(value, "b", &(service->immutable));
+}
+
+static inline void __get_auto_connect(connman_service_s *service, GVariant *value)
+{
+       g_variant_get(value, "b", &(service->auto_connect));
+}
+
+static inline void __get_roaming(connman_service_s *service, GVariant *value)
+{
+       g_variant_get(value, "b", &(service->roaming));
+}
+
+static inline gboolean __check_address_type(int address_family, const char *address)
+{
+       unsigned char buf[sizeof(struct in6_addr)] = {0, };
+       int err = 0;
+
+       err = inet_pton(address_family, address, buf);
+       if (err > 0)
+               return TRUE;
+
+       return FALSE;
+}
+
+static inline void __get_dns_type(const char *type, connman_service_s *service)
+{
+       if (g_strcmp0(type, "ipv4.manual") == 0)
+               service->dns_conf_type =
+                               CONNMAN_DNS_CONFIG_TYPE_STATIC;
+       else if (g_strcmp0(type, "ipv4.dhcp") == 0)
+               service->dns_conf_type =
+                               CONNMAN_DNS_CONFIG_TYPE_DYNAMIC;
+       if (g_strcmp0(type, "ipv6.manual") == 0)
+               service->dns_conf_type_v6 =
+                               CONNMAN_DNS_CONFIG_TYPE_STATIC;
+       else if (g_strcmp0(type, "ipv6.dhcp") == 0)
+               service->dns_conf_type_v6 =
+                               CONNMAN_DNS_CONFIG_TYPE_DYNAMIC;
+       return;
+}
+
+static inline void __set_dns_addr(gchar *dns, connman_service_s *service, int *cnt)
+{
+       if (*cnt  >= MAX_DNS_ADDR)
+               return;
+
+       service->dns_addr[*cnt].addr_type =
+               CONNMAN_ADDR_IPV4;
+       inet_pton(AF_INET, dns,
+                       &service->dns_addr[*cnt].addr.ip);
+       (*cnt)++;
+       return;
+}
+
+static inline void __set_dns_addr_v6(gchar *dns, connman_service_s *service,  int *cnt)
+{
+       if (*cnt  >= MAX_DNS_ADDR)
+               return;
+
+       service->dns_addr[*cnt].addr_type =
+               CONNMAN_ADDR_IPV6;
+       inet_pton(AF_INET6, dns,
+                       &service->dns_addr[*cnt].addr.ipv6);
+       (*cnt)++;
+       return;
+}
+
+static inline void __get_name_servers(connman_service_s *service, GVariant *value)
+{
+       GVariantIter *iter = NULL;
+       int dns_cnt = 0;
+       int dns_cnt_v6 = 0;
+       gchar *dns_value = NULL;
+
+       memset(&(service->dns_addr), 0, sizeof(connman_dns_addr) * MAX_DNS_ADDR);
+
+       g_variant_get(value, "as", &iter);
+
+       while (g_variant_iter_loop(iter, "s", &dns_value)) {
+               /* Check Type of DNS Address */
+               if (__check_address_type(AF_INET6, dns_value)) {
+                       /* IPv6 */
+                       __set_dns_addr_v6(dns_value, service, &dns_cnt_v6);
+               } else if (__check_address_type(AF_INET, dns_value)) {
+                       /* IPv4 */
+                       __set_dns_addr(dns_value, service, &dns_cnt);
+               } else { /* DNS Type */
+                       __get_dns_type(dns_value, service);
+               }
+       }
+       g_variant_iter_free(iter);
+
+       service->dns_cnt= dns_cnt;
+       service->dns_cnt_v6 = dns_cnt_v6;
+
+       nm_gdbus_emit_conn_dns_changed(service->obj_path,
+                       __nm_connman_service_get_dns(service));
+}
+
+static inline void __get_conf_name_servers(connman_service_s *service, GVariant *value)
+{
+       GVariantIter *iter = NULL;
+       int dns_cnt = service->dns_cnt;
+       int dns_cnt_v6 = service->dns_cnt_v6;
+       gchar *dns_value = NULL;
+
+       g_variant_get(value, "as", &iter);
+
+       while (g_variant_iter_loop(iter, "s", &dns_value)) {
+               /* Check Type of DNS Address */
+               if (__check_address_type(AF_INET6, dns_value)) {
+                       /* IPv6 */
+                       __set_dns_addr_v6(dns_value, service, &dns_cnt_v6);
+               } else if (__check_address_type(AF_INET, dns_value)) {
+                       /* IPv4 */
+                       __set_dns_addr(dns_value, service, &dns_cnt);
+               } else { /* DNS Type */
+                       __get_dns_type(dns_value, service);
+               }
+       }
+       g_variant_iter_free(iter);
+
+       service->dns_cnt= dns_cnt;
+       service->dns_cnt_v6 = dns_cnt_v6;
+}
+
+static inline void __get_method(GVariant *value, connman_service_s *service)
+{
+       const gchar *str = NULL;
+       str = g_variant_get_string(value, NULL);
+
+       if (g_strcmp0(str, "dhcp") == 0)
+               service->ip.method = CONNMAN_IPCONFIG_METHOD_DHCP;
+       else if (g_strcmp0(str, "manual") == 0)
+               service->ip.method = CONNMAN_IPCONFIG_METHOD_MANUAL;
+       else if (g_strcmp0(str, "fixed") == 0)
+               service->ip.method = CONNMAN_IPCONFIG_METHOD_FIXED;
+       else if (g_strcmp0(str, "off") == 0)
+               service->ip.method = CONNMAN_IPCONFIG_METHOD_OFF;
+}
+
+static inline void __get_ip(connman_service_s *service, GVariant *value)
+{
+       GVariantIter *iter = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+       const gchar *str = NULL;
+
+       memset(&(service->ip), 0, sizeof(connman_ipv4_s));
+
+       g_variant_get(value, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (g_strcmp0(key, "Method") == 0) {
+                       __get_method(var, service);
+
+               } else if (g_strcmp0(key, "Address") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       inet_aton(str, &service->ip.address);
+               } else if (g_strcmp0(key, "Netmask") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       inet_aton(str, &service->ip.netmask);
+               } else if (g_strcmp0(key, "Gateway") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       inet_aton(str, &service->ip.gateway);
+               } else if (g_strcmp0(key, "DHCPServerIP") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       inet_aton(str, &service->ip.dhcp_server_ip);
+               } else if (g_strcmp0(key, "DHCPLeaseDuration") == 0) {
+                       service->ip.dhcp_lease_duration = g_variant_get_int32(var);
+               }
+       }
+       g_variant_iter_free(iter);
+
+       nm_gdbus_emit_conn_ip_changed(service->obj_path,
+                       __nm_connman_service_get_ip(service));
+}
+
+static inline void __get_conf_ip(connman_service_s *service, GVariant *value)
+{
+       GVariantIter *iter = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+       const gchar *str = NULL;
+
+       g_variant_get(value, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (g_strcmp0(key, "Method") == 0) {
+                       __get_method(var, service);
+
+               } else if (g_strcmp0(key, "Address") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       inet_aton(str, &service->ip.address);
+               } else if (g_strcmp0(key, "Netmask") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       inet_aton(str, &service->ip.netmask);
+               } else if (g_strcmp0(key, "Gateway") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       inet_aton(str, &service->ip.gateway);
+               }
+       }
+       g_variant_iter_free(iter);
+}
+
+static inline void __get_ipv6_method(GVariant *value, connman_service_s *service)
+{
+       const gchar *str = NULL;
+       str = g_variant_get_string(value, NULL);
+
+       if (g_strcmp0(str, "manual") == 0)
+               service->ipv6.method = CONNMAN_IPCONFIG_METHOD_MANUAL;
+       else if (g_strcmp0(str, "off") == 0)
+               service->ipv6.method = CONNMAN_IPCONFIG_METHOD_OFF;
+       else if (g_strcmp0(str, "auto") == 0)
+               service->ipv6.method = CONNMAN_IPCONFIG_METHOD_AUTO;
+}
+
+static inline void __get_ipv6(connman_service_s *service, GVariant *value)
+{
+       GVariantIter *iter = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+       const gchar *str = NULL;
+
+       memset(&(service->ipv6), 0, sizeof(connman_ipv6_s));
+
+       g_variant_get(value, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (g_strcmp0(key, "Method") == 0) {
+                       __get_ipv6_method(var, service);
+
+               } else if (g_strcmp0(key, "Address") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       inet_pton(AF_INET6, str, &service->ipv6.address);
+               } else if (g_strcmp0(key, "PrefixLength") == 0) {
+                       service->ipv6.prefix_length = g_variant_get_byte(var);
+               } else if (g_strcmp0(key, "Gateway") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       inet_pton(AF_INET6, str, &service->ipv6.gateway);
+               } else if (g_strcmp0(key, "Privacy") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       if (str != NULL)
+                               g_strlcpy(service->ipv6.privacy, str, IPV6_MAX_PRIVACY_LEN);
+               }
+       }
+       g_variant_iter_free(iter);
+
+}
+static inline void __get_conf_ipv6(connman_service_s *service, GVariant *value)
+{
+       GVariantIter *iter = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+       const gchar *str = NULL;
+
+       g_variant_get(value, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (g_strcmp0(key, "Method") == 0) {
+                       __get_ipv6_method(var, service);
+
+               } else if (g_strcmp0(key, "Address") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       inet_pton(AF_INET6, str, &service->ipv6.address);
+               } else if (g_strcmp0(key, "PrefixLength") == 0) {
+                       service->ipv6.prefix_length = g_variant_get_byte(var);
+               } else if (g_strcmp0(key, "Gateway") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       inet_pton(AF_INET6, str, &service->ipv6.gateway);
+               } else if (g_strcmp0(key, "Privacy") == 0) {
+                       str = g_variant_get_string(var, NULL);
+
+                       if (str != NULL)
+                               g_strlcpy(service->ipv6.privacy, str, IPV6_MAX_PRIVACY_LEN);
+               }
+       }
+       g_variant_iter_free(iter);
+
+       nm_gdbus_emit_conn_ip_changed(service->obj_path,
+                       __nm_connman_service_get_ip(service));
+}
+
+static inline void __get_proxy_method(const gchar *type, connman_service_s *service)
+{
+       if (g_strcmp0(type, "direct") == 0)
+               service->proxy.method = CONNMAN_PROXY_TYPE_DIRECT;
+       else if (g_strcmp0(type, "auto") == 0)
+               service->proxy.method = CONNMAN_PROXY_TYPE_AUTO;
+       else if (g_strcmp0(type, "manual") == 0)
+               service->proxy.method = CONNMAN_PROXY_TYPE_MANUAL;
+       else
+               service->proxy.method = CONNMAN_PROXY_TYPE_UNKNOWN;
+
+}
+
+static inline void __get_proxy(connman_service_s *service, GVariant *value)
+{
+       GVariantIter *iter = NULL;
+       GVariantIter *iter_inner = NULL;
+       GVariant *var = NULL;
+       const gchar *url = NULL;
+       const gchar *str = NULL;
+       gchar *servers = NULL;
+       gchar *key = NULL;
+
+       g_variant_get(value, "a{sv}", &iter);
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (g_strcmp0(key, "Method") == 0) {
+                       str = g_variant_get_string(var, NULL);
+                       __get_proxy_method(str, service);
+
+               } else if (g_strcmp0(key, "URL") == 0) {
+                       url = g_variant_get_string(var, NULL);
+               } else if (g_strcmp0(key, "Servers") == 0) {
+                       GVariantIter *iter_sub = NULL;
+
+                       g_variant_get(var, "as", &iter_inner);
+                       if (!g_variant_iter_loop(iter_inner, "s", &servers))
+                               NM_LOGI("There was no value");
+                       g_variant_iter_free(iter_sub);
+               }
+       }
+       g_variant_iter_free(iter);
+
+       if (service->proxy.method == CONNMAN_PROXY_TYPE_AUTO && url != NULL)
+               g_strlcpy(service->proxy.addr, url, MAX_PROXY_LEN);
+       else if (service->proxy.method == CONNMAN_PROXY_TYPE_MANUAL && servers != NULL)
+               g_strlcpy(service->proxy.addr, servers, MAX_PROXY_LEN);
+       else {
+               service->proxy.method = CONNMAN_PROXY_TYPE_UNKNOWN;
+               memset(service->proxy.addr, 0, MAX_PROXY_LEN + 1);
+               memset(service->proxy.addr, 0, MAX_PROXY_LEN + 1);
+       }
+
+       if (servers)
+               g_free(servers);
+
+       nm_gdbus_emit_conn_ip_changed(service->obj_path,
+                       __nm_connman_service_get_ip(service));
+
+}
+
+static inline void __get_eth(connman_service_s *service, GVariant *value)
+{
+       GVariantIter *iter = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+
+       g_variant_get(value, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (g_strcmp0(key, "Interface") == 0) {
+                       const gchar *str = NULL;
+                       str = g_variant_get_string(var, NULL);
+
+                       if (str != NULL)
+                               g_strlcpy(service->eth.interface, str, MAX_DEVICE_NAME_LEN);
+               } else if (g_strcmp0(key, "Address") == 0) {
+                       const gchar *str = NULL;
+                       str = g_variant_get_string(var, NULL);
+
+                       if (str != NULL)
+                               __ws_txt_to_mac(str, service->eth.address);
+               }
+       }
+       g_variant_iter_free(iter);
+}
+
+static inline void __get_mdns(connman_service_s *service, GVariant *value)
+{
+       g_variant_get(value, "b", &(service->mdns));
+}
+
+static inline void __get_conf_mdns(connman_service_s *service, GVariant *value)
+{
+       g_variant_get(value, "b", &(service->configured_mdns));
+}
+
+static void __destroy_service_data(gpointer user_data)
+{
+       connman_service_s *service_data = (connman_service_s *)user_data;
+       __NM_FUNC_ENTER__;
+
+       service_signal_param.subscriber_id = service_data->subscriber_id;
+       nm_gdbus_unsubscribe_signal(&(service_signal_param));
+       nm_gdbus_deregister_conn_iface(service_data->conn_obj_id);
+
+       NM_LOGI("[%s] removed", service_data->name);
+
+       g_free(service_data->name);
+       g_free(service_data);
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline void __get_mode(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+
+       str = g_variant_get_string(value, NULL);
+
+       if (g_strcmp0(str, "managed") == 0)
+               service->priv_info.wlan.mode = CONNMAN_WLAN_MODE_INFRA;
+       else if (g_strcmp0(str, "adhoc") == 0)
+               service->priv_info.wlan.mode = CONNMAN_WLAN_MODE_ADHOC;
+       else if (g_strcmp0(str, "gprs") == 0)
+               service->priv_info.cell.type = CONNMAN_PDP_TYPE_GPRS;
+       else if (g_strcmp0(str, "edge") == 0)
+               service->priv_info.cell.type = CONNMAN_PDP_TYPE_EDGE;
+       else if (g_strcmp0(str, "utms") == 0)
+               service->priv_info.cell.type = CONNMAN_PDP_TYPE_UMTS;
+}
+
+static inline void __get_setup_required(connman_service_s *service, GVariant *value)
+{
+       service->priv_info.cell.setup_required = g_variant_get_boolean(value);
+}
+
+static inline void __get_security(connman_service_s *service, GVariant *value)
+{
+       GVariantIter *iter = NULL;
+       gchar *str = NULL;
+
+       g_variant_get(value, "as", &iter);
+       while (g_variant_iter_loop(iter, "s", &str)) {
+               if (g_strcmp0(str, "none") == 0 &&
+                       service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_NONE)
+                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_NONE;
+               else if (g_strcmp0(str, "wep") == 0 &&
+                                service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_WEP)
+                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_WEP;
+               else if (g_strcmp0(str, "psk") == 0 &&
+                                service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
+               else if (g_strcmp0(str, "ft_psk") == 0 &&
+                       service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_WPA_FT_PSK)
+                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_WPA_FT_PSK;
+               else if (g_strcmp0(str, "ieee8021x") == 0 &&
+                                service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_IEEE8021X)
+                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_IEEE8021X;
+               else if (g_strcmp0(str, "wpa") == 0 &&
+                                service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
+               else if (g_strcmp0(str, "rsn") == 0 &&
+                                service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_WPA2_PSK;
+               else if (g_strcmp0(str, "wps") == 0)
+                       service->priv_info.wlan.sec_info.wps_support = TRUE;
+               else if (service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_NONE)
+                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_NONE;
+       }
+
+       g_variant_iter_free(iter);
+}
+
+static inline void __get_enc_mode(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+       str = g_variant_get_string(value, NULL);
+
+       if (g_strcmp0(str, "none") == 0)
+               service->priv_info.wlan.sec_info.enc_mode = WLAN_ENC_MODE_NONE;
+       else if (g_strcmp0(str, "wep") == 0)
+               service->priv_info.wlan.sec_info.enc_mode = WLAN_ENC_MODE_WEP;
+       else if (g_strcmp0(str, "tkip") == 0)
+               service->priv_info.wlan.sec_info.enc_mode = WLAN_ENC_MODE_TKIP;
+       else if (g_strcmp0(str, "aes") == 0)
+               service->priv_info.wlan.sec_info.enc_mode = WLAN_ENC_MODE_AES;
+       else if (g_strcmp0(str, "mixed") == 0)
+               service->priv_info.wlan.sec_info.enc_mode = WLAN_ENC_MODE_TKIP_AES_MIXED;
+}
+
+static inline void __get_passpoint(connman_service_s *service, GVariant *value)
+{
+       service->priv_info.wlan.passpoint = g_variant_get_boolean(value);
+}
+
+static inline void __get_passphrase(connman_service_s *service, GVariant *value)
+{
+       wlan_sec_info_s *security_info = &(service->priv_info.wlan.sec_info);
+       const gchar *str = NULL;
+
+       str = g_variant_get_string(value, NULL);
+
+       if (security_info->sec_mode == WLAN_SEC_MODE_WEP && str != NULL)
+               g_strlcpy(security_info->auth_info.wep.wepKey,
+                               str, WLAN_MAX_WEP_KEY_LEN + 1);
+       else if ((security_info->sec_mode == WLAN_SEC_MODE_WPA_PSK ||
+                               security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK) &&
+                       str != NULL)
+               g_strlcpy(security_info->auth_info.psk.pskKey,
+                               str, WLAN_MAX_PSK_PASSPHRASE_LEN+1);
+}
+
+static inline void __get_passpharase_required(connman_service_s *service, GVariant *value)
+{
+       service->priv_info.wlan.passphrase_required = g_variant_get_boolean(value);
+}
+
+
+static inline void __get_bssid(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+
+       str = g_variant_get_string(value, NULL);
+
+       if (str != NULL)
+               g_strlcpy(service->priv_info.wlan.bssid, str, WLAN_BSSID_LEN + 1);
+}
+
+static inline void __get_max_rate(connman_service_s *service, GVariant *value)
+{
+       service->priv_info.wlan.max_rate = g_variant_get_uint32(value);
+}
+
+static inline void __get_frequency(connman_service_s *service, GVariant *value)
+{
+       service->priv_info.wlan.frequency = (guint)g_variant_get_uint16(value);
+}
+
+static inline wlan_eap_type_e __convert_eap_type_from_string(const char *eap_type)
+{
+       if (eap_type == NULL)
+               return WLAN_SEC_EAP_TYPE_PEAP;
+       else if (g_strcmp0(eap_type, "peap") == 0)
+               return WLAN_SEC_EAP_TYPE_PEAP;
+       else if (g_strcmp0(eap_type, "tls") == 0)
+               return WLAN_SEC_EAP_TYPE_TLS;
+       else if (g_strcmp0(eap_type, "ttls") == 0)
+               return WLAN_SEC_EAP_TYPE_TTLS;
+       else if (g_strcmp0(eap_type, "sim") == 0)
+               return WLAN_SEC_EAP_TYPE_SIM;
+       else if (g_strcmp0(eap_type, "aka") == 0)
+               return WLAN_SEC_EAP_TYPE_AKA;
+       else
+               return WLAN_SEC_EAP_TYPE_PEAP;
+}
+
+static inline wlan_eap_auth_type_e __convert_eap_auth_from_string(const char *eap_auth)
+{
+       if (eap_auth == NULL)
+               return WLAN_SEC_EAP_AUTH_NONE;
+       else if (g_strcmp0(eap_auth, "NONE") == 0)
+               return WLAN_SEC_EAP_AUTH_NONE;
+       else if (g_strcmp0(eap_auth, "PAP") == 0)
+               return WLAN_SEC_EAP_AUTH_PAP;
+       else if (g_strcmp0(eap_auth, "MSCHAP") == 0)
+               return WLAN_SEC_EAP_AUTH_MSCHAP;
+       else if (g_strcmp0(eap_auth, "MSCHAPV2") == 0)
+               return WLAN_SEC_EAP_AUTH_MSCHAPV2;
+       else if (g_strcmp0(eap_auth, "GTC") == 0)
+               return WLAN_SEC_EAP_AUTH_GTC;
+       else if (g_strcmp0(eap_auth, "MD5") == 0)
+               return WLAN_SEC_EAP_AUTH_MD5;
+       else
+               return WLAN_SEC_EAP_AUTH_NONE;
+}
+
+static inline void __get_eap(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+
+       str = g_variant_get_string(value, NULL);
+
+       if (str != NULL)
+               service->priv_info.wlan.sec_info.auth_info.eap.eap_type =
+                               __convert_eap_type_from_string(str);
+}
+
+static inline void __get_phase2(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+
+       str = g_variant_get_string(value, NULL);
+
+       if (str != NULL)
+               service->priv_info.wlan.sec_info.auth_info.eap.eap_auth =
+                               __convert_eap_auth_from_string(str);
+}
+
+static inline void __get_identity(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+
+       str = g_variant_get_string(value, NULL);
+
+       if (str != NULL)
+               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.username,
+                               str, WLAN_USERNAME_LEN + 1);
+}
+
+static inline void __get_password(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+
+       str = g_variant_get_string(value, NULL);
+
+       if (str != NULL)
+               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.password,
+                               str, WLAN_PASSWORD_LEN + 1);
+}
+
+static inline void __get_ca_cert(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+
+       str = g_variant_get_string(value, NULL);
+
+       if (str != NULL)
+               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.ca_cert_filename,
+                               str, WLAN_CA_CERT_FILENAME_LEN + 1);
+}
+
+static inline void __get_client_cert(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+
+       str = g_variant_get_string(value, NULL);
+
+       if (str != NULL)
+               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.client_cert_filename,
+                               str, WLAN_CLIENT_CERT_FILENAME_LEN + 1);
+}
+
+static inline void __get_private_key(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+
+       str = g_variant_get_string(value, NULL);
+
+       if (str != NULL)
+               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.private_key_filename,
+                               str, WLAN_PRIVATE_KEY_FILENAME_LEN + 1);
+}
+
+static inline void __get_private_key_passphrase(connman_service_s *service, GVariant *value)
+{
+       const gchar *str = NULL;
+
+       str = g_variant_get_string(value, NULL);
+
+       if (str != NULL)
+               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.private_key_passwd,
+                               str, WLAN_PRIVATE_KEY_PASSWD_LEN + 1);
+}
+
+static inline void __get_keymgmt(connman_service_s *service, GVariant *value)
+{
+       service->priv_info.wlan.sec_info.keymgmt = g_variant_get_uint32(value);
+}
+
+static inline void __get_reason(connman_service_s *service, GVariant *value)
+{
+       service->priv_info.wlan.reason = g_variant_get_int32(value);
+}
+
+static inline void __get_assoc_status(connman_service_s *service, GVariant *value)
+{
+       service->priv_info.wlan.assoc_status = g_variant_get_int32(value);
+}
+
+static void __service_get_property(connman_service_s *service,
+               const gchar *key,
+               GVariant *value)
+{
+       if (g_strcmp0(key, "State") == 0)
+               __get_state(service, value);
+       else if (g_strcmp0(key, "StateIPv6") == 0)
+               __get_state_ipv6(service, value);
+       else if (g_strcmp0(key, "Error") == 0)
+               __get_error(service, value);
+       else if (g_strcmp0(key, "Name") == 0)
+               __get_name(service, value);
+       else if (g_strcmp0(key, "Type") == 0)
+               __get_type(service, value);
+       else if (g_strcmp0(key, "Security") == 0)
+               __get_security(service, value);
+       else if (g_strcmp0(key, "Strength") == 0)
+               __get_strength(service, value);
+       else if (g_strcmp0(key, "Favorite") == 0)
+               __get_favorite(service, value);
+       else if (g_strcmp0(key, "Immutable") == 0)
+               __get_immutable(service, value);
+       else if (g_strcmp0(key, "AutoConnect") == 0)
+               __get_auto_connect(service, value);
+       else if (g_strcmp0(key, "Roaming") == 0)
+               __get_roaming(service, value);
+       else if (g_strcmp0(key, "Ethernet") == 0)
+               __get_eth(service, value);
+       else if (g_strcmp0(key, "IPv4") == 0)
+               __get_ip(service, value);
+       else if (g_strcmp0(key, "IPv4.Configuration") == 0)
+               __get_conf_ip(service, value);
+       else if (g_strcmp0(key, "IPv6") == 0)
+               __get_ipv6(service, value);
+       else if (g_strcmp0(key, "IPv6.Configuration") == 0)
+               __get_conf_ipv6(service, value);
+       else if (g_strcmp0(key, "Nameservers") == 0)
+               __get_name_servers(service, value);
+       else if (g_strcmp0(key, "Nameservers.Configuration") == 0)
+               __get_conf_name_servers(service, value);
+       else if (g_strcmp0(key, "Proxy") == 0)
+               __get_proxy(service, value);
+       else if (g_strcmp0(key, "Proxy.Configuration") == 0)
+               __get_proxy(service, value);
+       else if (g_strcmp0(key, "mDNS") == 0)
+               __get_mdns(service, value);
+       else if (g_strcmp0(key, "mDNS.Configuration") == 0)
+               __get_conf_mdns(service, value);
+
+/* Tizen extension */
+       else if (g_strcmp0(key, "Mode") == 0)
+               __get_mode(service, value);
+       else if (g_strcmp0(key, "SetupRequired") == 0)
+               __get_setup_required(service, value);
+       else if (g_strcmp0(key, "EncryptionMode") == 0)
+               __get_enc_mode(service, value);
+       else if (g_strcmp0(key, "Passpoint") == 0)
+               __get_passpoint(service, value);
+       else if (g_strcmp0(key, "Passphrase") == 0)
+               __get_passphrase(service, value);
+       else if (g_strcmp0(key, "PassphraseRequired") == 0)
+               __get_passpharase_required(service, value);
+       else if (g_strcmp0(key, "BSSID") == 0)
+               __get_bssid(service, value);
+       else if (g_strcmp0(key, "MaxRate") == 0)
+               __get_max_rate(service, value);
+       else if (g_strcmp0(key, "Frequency") == 0)
+               __get_frequency(service, value);
+       else if (g_strcmp0(key, "EAP") == 0)
+               __get_eap(service, value);
+       else if (g_strcmp0(key, "Phase2") == 0)
+               __get_phase2(service, value);
+       else if (g_strcmp0(key, "Identity") == 0)
+               __get_identity(service, value);
+       else if (g_strcmp0(key, "Password") == 0)
+               __get_password(service, value);
+       else if (g_strcmp0(key, "CACertFile") == 0)
+               __get_ca_cert(service, value);
+       else if (g_strcmp0(key, "ClientCertFile") == 0)
+               __get_client_cert(service, value);
+       else if (g_strcmp0(key, "PrivateKeyFile") == 0)
+               __get_private_key(service, value);
+       else if (g_strcmp0(key, "PrivateKeyPassphrase") == 0)
+               __get_private_key_passphrase(service, value);
+       else if (g_strcmp0(key, "Keymgmt") == 0)
+               __get_keymgmt(service, value);
+       else if (g_strcmp0(key, "DisconnectReason") == 0)
+               __get_reason(service, value);
+       else if (g_strcmp0(key, "AssocStatusCode") == 0)
+               __get_assoc_status(service, value);
+}
+
+static void __service_property_changed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       gchar *key = NULL;
+       GVariant *value = NULL;
+       connman_service_s *service = NULL;
+
+       __NM_FUNC_ENTER__;
+       service = g_hash_table_lookup(service_tbl, object_path);
+       if (!service) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("Service not found");
+               return;
+       }
+       g_variant_get(parameters, "(&sv)", &key, &value);
+
+       if (key)
+               __service_get_property(service, key, value);
+
+       NM_LOGI("[%s] property changed", object_path);
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __add_wifi_priv_info(connman_service_s *service)
+{
+       /* TODO: implement */
+       return;
+}
+
+static inline void __add_cell_priv_info(connman_service_s *service)
+{
+       nm_telephony_profile_s telephony_info = {0,};
+       int ret = 0;
+       __NM_FUNC_ENTER__;
+
+       if (!service)
+               return;
+
+       ret = nm_telephony_get_pdp_profile(service->name, &telephony_info);
+       if (ret < 0)
+               NM_LOGI("get pdp profile failed");
+       else
+               memcpy(&(service->priv_info.cell),
+                               &telephony_info,
+                               sizeof(nm_telephony_profile_s));
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline void __add_priv_info(connman_service_s *service)
+{
+       if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR)
+               __add_cell_priv_info(service);
+       else if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
+               __add_wifi_priv_info(service);
+
+       return;
+}
+
+static inline int __register_service_obj(gchar *path,  connman_service_s *service)
+{
+       int ret = 0;
+       /* TODO How to create Object path? */
+       g_snprintf(service->obj_path, DBUS_OBJECT_PATH_MAX, "%s/%p", NM_CONN_OBJ, service);
+
+       ret = nm_gdbus_register_conn_iface(service->obj_path,
+                       &(service->conn_obj_id),
+                       service);
+       if (ret != 0)
+               return -1;
+
+       return 0;
+}
+
+static inline void __get_service_data(gchar *path, connman_service_s **service, GVariantBuilder *added)
+{
+       connman_service_s *ret = NULL;
+
+       ret = g_hash_table_lookup(service_tbl, path);
+       if (ret) {
+               *service = ret;
+               return;
+       }
+
+       ret = (connman_service_s *)g_try_malloc0(sizeof(connman_service_s));
+       if (!ret) {
+               NM_LOGI("Error! Failed to allocate service");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       if (__register_service_obj(path, ret) != 0) {
+               g_free(ret);
+               NM_LOGI("Error! Failed to register service object");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       if (!g_hash_table_insert(service_tbl, g_strdup(path), ret)) {
+               g_free(ret);
+               NM_LOGI("Error! Failed to insert service");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       g_variant_builder_add(added,
+                             "o",
+                             ret->obj_path);
+
+       *service = ret;
+}
+
+static inline void __subscribe_connman_service_signal(gchar *path, connman_service_s *service)
+{
+       int ret = 0;
+
+       service_signal_param.object_path = path;
+       ret = nm_gdbus_subscribe_signal(&(service_signal_param));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               NM_LOGI("Error! Failed to subscribe signal");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       service->subscriber_id = service_signal_param.subscriber_id;
+       NM_LOGI("Subscribe [%s] signal", path);
+}
+
+void nm_connman_service_add(gchar *path, GVariantIter *iter, GVariantBuilder *added)
+{
+       GVariant *value = NULL;
+       connman_service_s *service = NULL;
+       gchar *key = NULL;
+
+       __NM_FUNC_ENTER__;
+
+       if (!path || ! iter) {
+               NM_LOGI("NULL path or iter");
+               return;
+       }
+
+       __get_service_data(path, &service, added);
+       if (!service) {
+               NM_LOGI("Failed to get service");
+               return;
+       }
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &value))
+               __service_get_property(service, key, value);
+
+       __add_priv_info(service);
+
+       if (service->subscriber_id == 0)
+               __subscribe_connman_service_signal(path, service);
+       else
+               NM_LOGI("[%s] changed", path);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+void nm_connman_service_remove(gchar *path, GVariantBuilder *removed)
+{
+       connman_service_s *service = NULL;
+
+       __NM_FUNC_ENTER__;
+
+       if (!path) {
+               NM_LOGI("NULL path");
+               return;
+       }
+
+       service = g_hash_table_lookup(service_tbl, path);
+       if (!service) {
+               return;
+       }
+
+       g_variant_builder_add(removed,
+                             "o",
+                                 service->obj_path);
+
+       if (!g_hash_table_remove(service_tbl, path)) {
+               NM_LOGI("service not found");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static GVariant *__nm_connman_service_get_id(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       NM_LOGI("get id");
+
+       ret = g_variant_new_string(service->name);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_get_name(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       NM_LOGI("get name");
+
+       ret = g_variant_new_string(service->name);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_get_interface(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       NM_LOGI("get interface");
+
+       ret = g_variant_new_string(service->eth.interface);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_get_type(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       NM_LOGI("get type");
+
+       ret = g_variant_new_string(conn_type[service->type].str);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_get_iface_name(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       NM_LOGI("get iface name");
+
+       ret = g_variant_new_string(service->name);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_get_ipv4_state(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       NM_LOGI("get iface ipv4 state");
+
+       ret = g_variant_new_string(conn_state[service->state].str);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_get_ipv6_state(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       NM_LOGI("get iface ipv6 state");
+
+       ret = g_variant_new_string(conn_state[service->state_ipv6].str);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_ipv4_to_var(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+       GVariantBuilder *builder = NULL;
+       char ip_str[INET_ADDRSTRLEN] = {0,};
+       char netmask_str[INET_ADDRSTRLEN] = {0,};
+       char gateway_str[INET_ADDRSTRLEN] = {0,};
+       char dhcp_server_ip_str[INET_ADDRSTRLEN] = {0,};
+
+       NM_LOGI("get ipv4\n");
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "IpConfigType",
+                             g_variant_new("s", conn_ip_config[service->ip.method].str));
+
+       inet_ntop(AF_INET, &(service->ip.address), ip_str, INET_ADDRSTRLEN);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "IpAddress",
+                             g_variant_new("s", ip_str));
+
+       inet_ntop(AF_INET, &(service->ip.netmask), netmask_str, INET_ADDRSTRLEN);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "SubnetMask",
+                             g_variant_new("s", netmask_str));
+
+       inet_ntop(AF_INET, &(service->ip.gateway), gateway_str, INET_ADDRSTRLEN);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Gateway",
+                             g_variant_new("s", gateway_str));
+
+       inet_ntop(AF_INET, &(service->ip.dhcp_server_ip),
+                       dhcp_server_ip_str,
+                       INET_ADDRSTRLEN);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "DhcpServer",
+                             g_variant_new("s", gateway_str));
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "DhcpLeaseDuration",
+                             g_variant_new("t", service->ip.dhcp_lease_duration));
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "ProxyType",
+                             g_variant_new("s", conn_proxy_type[service->proxy.method].str));
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "ProxyAddress",
+                             g_variant_new("s", service->proxy.addr));
+
+       ret = g_variant_new("a{sv}", builder);
+       g_variant_builder_unref(builder);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_ipv6_to_var(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+       GVariantBuilder *builder = NULL;
+       char ip_str[INET6_ADDRSTRLEN] = {0,};
+       char gateway_str[INET6_ADDRSTRLEN] = {0,};
+
+       NM_LOGI("get ipv6");
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "IpConfigType",
+                             g_variant_new("s", conn_ip_config[service->ipv6.method].str));
+
+       inet_ntop(AF_INET6, &(service->ipv6.address), ip_str, INET6_ADDRSTRLEN);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "IpAddress",
+                             g_variant_new("s", ip_str));
+
+       inet_ntop(AF_INET6, &(service->ipv6.gateway), gateway_str, INET6_ADDRSTRLEN);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Gateway",
+                             g_variant_new("s", gateway_str));
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "PrefixLength",
+                             g_variant_new("i", service->ipv6.prefix_length));
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Privacy",
+                             g_variant_new("s", service->ipv6.privacy));
+
+       ret = g_variant_new("a{sv}", builder);
+       g_variant_builder_unref(builder);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_get_ip(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+       GVariantBuilder *builder = NULL;
+
+       NM_LOGI("get ip");
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       if (service->ip.method != CONNMAN_IPCONFIG_METHOD_UNKNOWN)
+               g_variant_builder_add(builder,
+                                     "{sv}",
+                                     "Ipv4",
+                                         __nm_connman_service_ipv4_to_var(service));
+
+       if (service->ipv6.method != CONNMAN_IPCONFIG_METHOD_UNKNOWN)
+               g_variant_builder_add(builder,
+                                     "{sv}",
+                                     "Ipv6",
+                                         __nm_connman_service_ipv6_to_var(service));
+
+       ret = g_variant_new("a{sv}", builder);
+       g_variant_builder_unref(builder);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_ipv4_dns_to_var(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariantBuilder *dns_builder = NULL;
+       gchar ip_str[INET_ADDRSTRLEN] = {0,};
+       int cnt = 0;
+
+       NM_LOGI("get ipv4 dns");
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "ConfigType",
+                             g_variant_new("s", conn_dns_config[service->dns_conf_type].str));
+
+       dns_builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+       for (cnt = 0; cnt < service->dns_cnt; cnt++) {
+               inet_ntop(AF_INET, &(service->dns_addr[cnt].addr.ip), ip_str, INET_ADDRSTRLEN);
+               g_variant_builder_add(dns_builder, "s", ip_str);
+       }
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Ipv4",
+                             g_variant_new("as", dns_builder));
+       g_variant_builder_unref(dns_builder);
+
+       ret = g_variant_new("a{sv}", builder);
+       g_variant_builder_unref(builder);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_ipv6_dns_to_var(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariantBuilder *dns_builder = NULL;
+       gchar ip_str[INET6_ADDRSTRLEN] = {0,};
+       int cnt = 0;
+
+       NM_LOGI("get ipv6 dns");
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "ConfigType",
+                             g_variant_new("s", conn_dns_config[service->dns_conf_type_v6].str));
+
+       dns_builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+       for (cnt = 0; cnt < service->dns_cnt_v6; cnt++) {
+               inet_ntop(AF_INET6, &(service->dns_addr_v6[cnt].addr.ipv6), ip_str, INET_ADDRSTRLEN);
+               g_variant_builder_add(dns_builder, "s", ip_str);
+       }
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Ipv6",
+                             g_variant_new("as", dns_builder));
+       g_variant_builder_unref(dns_builder);
+
+       ret = g_variant_new("a{sv}", builder);
+       g_variant_builder_unref(builder);
+
+       return ret;
+}
+
+static GVariant *__nm_connman_service_get_dns(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+       GVariantBuilder *builder = NULL;
+
+       NM_LOGI("get dns");
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       if (service->dns_conf_type != CONNMAN_DNS_CONFIG_TYPE_UNKNOWN)
+               g_variant_builder_add(builder,
+                                     "{sv}",
+                                     "DnsIpv4",
+                                         __nm_connman_service_ipv4_dns_to_var(service));
+
+       if (service->dns_conf_type_v6 != CONNMAN_IPCONFIG_METHOD_UNKNOWN)
+               g_variant_builder_add(builder,
+                                     "{sv}",
+                                     "DnsIpv6",
+                                         __nm_connman_service_ipv6_dns_to_var(service));
+
+       ret = g_variant_new("a{sv}", builder);
+       g_variant_builder_unref(builder);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_essid(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_string(service->priv_info.wlan.essid);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_bssid(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_string(service->priv_info.wlan.bssid);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_rssi(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_byte(service->strength);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_frequency(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_uint32(service->priv_info.wlan.frequency);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_max_speed(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_uint32(service->priv_info.wlan.max_rate);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_is_favorite(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_boolean(service->favorite);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_is_passpoint(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_boolean(service->priv_info.wlan.passpoint);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_sec_type(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_string(conn_sec_type[service->priv_info.wlan.sec_info.sec_mode].str);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_enc_type(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_string(conn_enc_type[service->priv_info.wlan.sec_info.enc_mode].str);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_is_pass_req(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_boolean(service->priv_info.wlan.passphrase_required);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_is_wpa_sup(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_boolean(service->priv_info.wlan.sec_info.wps_support);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_eap_pass(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_string(service->priv_info.wlan.sec_info.auth_info.eap.username);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_ca_cert(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_string(service->priv_info.wlan.sec_info.auth_info.eap.ca_cert_filename);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_client_cert(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_string(service->priv_info.wlan.sec_info.auth_info.eap.client_cert_filename);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_priv_key(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_string(service->priv_info.wlan.sec_info.auth_info.eap.private_key_filename);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_eap_type(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_string(conn_eap_type[service->priv_info.wlan.sec_info.auth_info.eap.eap_type].str);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_eap_auth_type(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_string(conn_eap_auth_type[service->priv_info.wlan.sec_info.auth_info.eap.eap_auth].str);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_reason(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_int32(service->priv_info.wlan.reason);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_get_assoc_status(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+
+       ret = g_variant_new_int32(service->priv_info.wlan.assoc_status);
+
+       return ret;
+}
+
+static inline gboolean __is_eap_pass_exist(connman_service_s *service)
+{
+       return (service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
+                       (service->priv_info.wlan.sec_info.auth_info.eap.eap_type == WLAN_SEC_EAP_TYPE_PEAP ||
+                                       service->priv_info.wlan.sec_info.auth_info.eap.eap_type == WLAN_SEC_EAP_TYPE_TTLS)
+                                       && (strlen(service->priv_info.wlan.sec_info.auth_info.eap.username) > 0));
+}
+
+static inline gboolean __is_eap_ca_cert_exist(connman_service_s *service)
+{
+       return ((service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
+                       service->priv_info.wlan.sec_info.auth_info.eap.eap_type == WLAN_SEC_EAP_TYPE_TLS) &&
+                       (strlen(service->priv_info.wlan.sec_info.auth_info.eap.ca_cert_filename) > 0));
+
+}
+
+static inline gboolean __is_eap_client_cert_exist(connman_service_s *service)
+{
+       return ((service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
+                       service->priv_info.wlan.sec_info.auth_info.eap.eap_type == WLAN_SEC_EAP_TYPE_TLS) &&
+                       (strlen(service->priv_info.wlan.sec_info.auth_info.eap.client_cert_filename) > 0));
+
+}
+
+static inline gboolean __is_eap_priv_key_exist(connman_service_s *service)
+{
+       return ((service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
+                       service->priv_info.wlan.sec_info.auth_info.eap.eap_type == WLAN_SEC_EAP_TYPE_TLS) &&
+                       (strlen(service->priv_info.wlan.sec_info.auth_info.eap.private_key_filename) > 0));
+
+}
+
+static inline GVariant * __nm_connman_service_get_wifi_info(connman_service_s *service)
+{
+       GVariant *ret = NULL;
+       GVariantBuilder *builder = NULL;
+
+       NM_LOGI("get Wi-Fi info");
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       if (strlen(service->priv_info.wlan.essid) != 0)
+               g_variant_builder_add(builder,
+                               "{sv}",
+                               "Essid",
+                               __nm_connman_service_get_essid(service));
+
+       if (strlen(service->priv_info.wlan.bssid) != 0)
+               g_variant_builder_add(builder,
+                               "{sv}",
+                               "Bssid",
+                               __nm_connman_service_get_bssid(service));
+
+       g_variant_builder_add(builder,
+                       "{sv}",
+                       "Rssi",
+                       __nm_connman_service_get_rssi(service));
+
+       g_variant_builder_add(builder,
+                       "{sv}",
+                       "Frequency",
+                       __nm_connman_service_get_frequency(service));
+
+       g_variant_builder_add(builder,
+                       "{sv}",
+                       "MaxSpeed",
+                       __nm_connman_service_get_max_speed(service));
+
+       g_variant_builder_add(builder,
+                       "{sv}",
+                       "IsFavorite",
+                       __nm_connman_service_get_is_favorite(service));
+
+       g_variant_builder_add(builder,
+                       "{sv}",
+                       "IsPasspoint",
+                       __nm_connman_service_get_is_passpoint(service));
+
+       g_variant_builder_add(builder,
+                       "{sv}",
+                       "SecurityType",
+                       __nm_connman_service_get_sec_type(service));
+
+       g_variant_builder_add(builder,
+                       "{sv}",
+                       "EncrytionType",
+                       __nm_connman_service_get_enc_type(service));
+
+       g_variant_builder_add(builder,
+                       "{sv}",
+                       "IsPassphraseRequired",
+                       __nm_connman_service_get_is_pass_req(service));
+
+       g_variant_builder_add(builder,
+                       "{sv}",
+                       "IsWpaSupported",
+                       __nm_connman_service_get_is_wpa_sup(service));
+
+       if (__is_eap_pass_exist(service))
+               g_variant_builder_add(builder,
+                               "{sv}",
+                               "EapPassphrase",
+                               __nm_connman_service_get_eap_pass(service));
+
+       if (__is_eap_ca_cert_exist(service))
+               g_variant_builder_add(builder,
+                               "{sv}",
+                               "CaCert",
+                               __nm_connman_service_get_ca_cert(service));
+
+       if (__is_eap_client_cert_exist(service))
+               g_variant_builder_add(builder,
+                               "{sv}",
+                               "ClientCert",
+                               __nm_connman_service_get_client_cert(service));
+
+       if (__is_eap_priv_key_exist(service))
+               g_variant_builder_add(builder,
+                               "{sv}",
+                               "PrivateKey",
+                               __nm_connman_service_get_priv_key(service));
+
+       if (service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
+                       service->priv_info.wlan.sec_info.auth_info.eap.eap_type != 0)
+                       g_variant_builder_add(builder,
+                                       "{sv}",
+                                       "EapType",
+                                       __nm_connman_service_get_eap_type(service));
+
+       if (service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
+                       service->priv_info.wlan.sec_info.auth_info.eap.eap_auth != 0)
+                       g_variant_builder_add(builder,
+                                       "{sv}",
+                                       "EapAuthType",
+                                       __nm_connman_service_get_eap_auth_type(service));
+
+       if (service->priv_info.wlan.reason != 0)
+               g_variant_builder_add(builder,
+                               "{sv}",
+                               "DisconnectReason",
+                               __nm_connman_service_get_reason(service));
+
+       if (service->priv_info.wlan.assoc_status != 0)
+               g_variant_builder_add(builder,
+                               "{sv}",
+                               "AssocStatus",
+                               __nm_connman_service_get_assoc_status(service));
+
+
+       ret = g_variant_new("a{sv}", builder);
+
+       g_variant_builder_unref(builder);
+
+       return ret;
+}
+
+static void __nm_connman_service_get_connections(gpointer key,
+               gpointer value,
+               gpointer user_data)
+{
+       GVariantBuilder *outer = NULL;
+       GVariantBuilder *inner = NULL;
+       connman_service_s *service = NULL;
+       gchar *object_path = NULL;
+
+       outer = (GVariantBuilder *)user_data;
+       service = (connman_service_s *)value;
+       object_path = (gchar *)key;
+
+       NM_LOGI("get [%s]\n", object_path);
+
+       inner = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       if (service->name) {
+               g_variant_builder_add(inner,
+                                         "{sv}",
+                                         "Id",
+                                         __nm_connman_service_get_id(service));
+               g_variant_builder_add(inner,
+                                         "{sv}",
+                                         "Name",
+                                         __nm_connman_service_get_name(service));
+       }
+       g_variant_builder_add(inner,
+                             "{sv}",
+                             "Type",
+                                 __nm_connman_service_get_type(service));
+       g_variant_builder_add(inner,
+                             "{sv}",
+                             "Interface",
+                             __nm_connman_service_get_interface(service));
+       g_variant_builder_add(inner,
+                             "{sv}",
+                             "Ipv4State",
+                                 __nm_connman_service_get_ipv4_state(service));
+       g_variant_builder_add(inner,
+                             "{sv}",
+                             "Ipv6State",
+                                 __nm_connman_service_get_ipv6_state(service));
+
+       g_variant_builder_add(inner,
+                             "{sv}",
+                             "Ip",
+                                 __nm_connman_service_get_ip(service));
+
+       g_variant_builder_add(inner,
+                             "{sv}",
+                             "Dns",
+                                 __nm_connman_service_get_dns(service));
+
+       if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
+               g_variant_builder_add(inner,
+                                     "{sv}",
+                                     "WifiInfo",
+                                         __nm_connman_service_get_wifi_info(service));
+
+       g_variant_builder_add(outer,
+                             "(oa{sv})",
+                             service->obj_path,
+                             inner);
+
+       g_variant_builder_unref(inner);
+}
+
+static inline GVariant *__nm_connman_service_to_asv(connman_service_s *service)
+{
+       GVariantBuilder *builder = NULL;
+       GVariant *ret = NULL;
+
+       if (!service) {
+               NM_LOGI("There's no current conn");
+               return NULL;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       if (service->name) {
+               g_variant_builder_add(builder,
+                                         "{sv}",
+                                         "Id",
+                                         __nm_connman_service_get_id(service));
+               g_variant_builder_add(builder,
+                                         "{sv}",
+                                         "Name",
+                                         __nm_connman_service_get_name(service));
+       }
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Type",
+                             __nm_connman_service_get_type(service));
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Interface",
+                             __nm_connman_service_get_interface(service));
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Ipv4State",
+                                 __nm_connman_service_get_ipv4_state(service));
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Ipv6State",
+                                 __nm_connman_service_get_ipv6_state(service));
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Ip",
+                                 __nm_connman_service_get_ip(service));
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Dns",
+                                 __nm_connman_service_get_dns(service));
+
+       if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
+               g_variant_builder_add(builder,
+                                     "{sv}",
+                                     "WifiInfo",
+                                         __nm_connman_service_get_wifi_info(service));
+
+       ret = g_variant_new("(a{sv})",
+                       builder);
+       g_variant_builder_unref(builder);
+
+       return ret;
+}
+
+static inline GVariant *__nm_connman_service_to_oasv(connman_service_s *service)
+{
+       GVariantBuilder *builder = NULL;
+       GVariant *ret = NULL;
+
+       if (!service) {
+               NM_LOGI("There's no current conn");
+               return NULL;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       if (service->name) {
+               g_variant_builder_add(builder,
+                                         "{sv}",
+                                         "Id",
+                                         __nm_connman_service_get_id(service));
+               g_variant_builder_add(builder,
+                                         "{sv}",
+                                         "Name",
+                                         __nm_connman_service_get_name(service));
+       }
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Type",
+                             __nm_connman_service_get_type(service));
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Interface",
+                             __nm_connman_service_get_interface(service));
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Ipv4State",
+                                 __nm_connman_service_get_ipv4_state(service));
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Ipv6State",
+                                 __nm_connman_service_get_ipv6_state(service));
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Ip",
+                                 __nm_connman_service_get_ip(service));
+
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "Dns",
+                                 __nm_connman_service_get_dns(service));
+
+       if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
+               g_variant_builder_add(builder,
+                                     "{sv}",
+                                     "WifiInfo",
+                                         __nm_connman_service_get_wifi_info(service));
+
+       ret = g_variant_new("(oa{sv})",
+                       service->obj_path,
+                       builder);
+       g_variant_builder_unref(builder);
+
+       return ret;
+}
+
+void nm_connman_service_change(GVariant *parameters)
+{
+       __NM_FUNC_ENTER__;
+       GVariantIter *added = NULL;
+       GVariantIter *removed = NULL;
+       GVariantIter *variants = NULL;
+
+       GVariantBuilder *added_builder = NULL;
+       GVariantBuilder *removed_builder = NULL;
+       GVariant *signal_arg = NULL;
+       gchar *path = NULL;
+
+       added_builder = g_variant_builder_new(G_VARIANT_TYPE("ao"));
+       removed_builder = g_variant_builder_new(G_VARIANT_TYPE("ao"));
+
+       if(!parameters) {
+               NM_LOGI("Empty parameters");
+               return;
+       }
+
+       g_variant_get(parameters, "(a(oa{sv})ao)", &added, &removed);
+
+       /* handle added service */
+       while (g_variant_iter_loop(added, "(oa{sv})", &path, &variants)) {
+
+               if (!path || !variants) {
+                       NM_LOGI("NULL path or variants");
+                       continue;
+               }
+
+               nm_connman_service_add(path, variants, added_builder);
+       }
+
+       g_variant_iter_free(added);
+
+       /* handle removed service */
+       path = NULL;
+       while (g_variant_iter_loop(removed, "o", &path)) {
+
+               if (!path) {
+                       NM_LOGI("NULL path");
+                       continue;
+               }
+
+               nm_connman_service_remove(path, removed_builder);
+       }
+
+       g_variant_iter_free(removed);
+
+       if (g_conn_changed_cb) {
+               signal_arg = g_variant_new("(aoao)", added_builder, removed_builder);
+               g_conn_changed_cb(signal_arg);
+       }
+
+       g_variant_builder_unref(added_builder);
+       g_variant_builder_unref(removed_builder);
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+void nm_connman_service_get_from_reply(GVariant *reply, gpointer user_data)
+{
+       GVariantIter *iter_outer = NULL;
+       GVariantIter *iter_inner = NULL;
+
+       GVariantBuilder *added_builder = NULL;
+       GVariant *signal_arg = NULL;
+       gchar *path = NULL;
+       __NM_FUNC_ENTER__;
+
+       added_builder = g_variant_builder_new(G_VARIANT_TYPE("ao"));
+       g_variant_get(reply, "(a(oa{sv}))", &iter_outer);
+
+       while (g_variant_iter_loop(iter_outer, "(&oa{sv})", &path, &iter_inner)) {
+
+               if (path == NULL || iter_inner == NULL)
+                       continue;
+
+               nm_connman_service_add(path, iter_inner, added_builder);
+       }
+
+       g_variant_iter_free(iter_outer);
+
+
+       if (g_conn_changed_cb) {
+               signal_arg = g_variant_new("(aoao)", added_builder, NULL);
+               g_conn_changed_cb(signal_arg);
+       }
+
+       g_variant_builder_unref(added_builder);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+int nm_connman_get_connection(gpointer user_data, GVariant **connection)
+{
+       connman_service_s *service = NULL;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       if (!user_data)
+               return -1;
+
+       service = (connman_service_s *)user_data;
+       *connection = __nm_connman_service_to_asv(service);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+
+}
+
+int nm_connman_get_current_connection(GVariant **current_conn)
+{
+       GHashTableIter iter;
+       connman_service_s *service = NULL;
+       gpointer key, value;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+
+       g_hash_table_iter_init (&iter, service_tbl);
+       while (g_hash_table_iter_next(&iter, &key, &value)) {
+
+               if (!value)
+                       continue;
+
+               service = (connman_service_s *)value;
+               NM_LOGI("%s", service->name);
+               if (service->state == CONNMAN_SERVICE_STATE_ONLINE ||
+                               service->state == CONNMAN_SERVICE_STATE_READY) {
+                       *current_conn = __nm_connman_service_to_oasv(service);
+               }
+       }
+
+       if ((*current_conn) == NULL) {
+               NM_LOGI("No current connections");
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_NO_CONNECTION;
+       }
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_connman_get_connections(GVariant **connections)
+{
+       GVariantBuilder *builder = NULL;
+       int ret = NM_CONNMAN_ERROR_NONE;
+
+       __NM_FUNC_ENTER__;
+
+       if (g_hash_table_size(service_tbl) == 0) {
+               NM_LOGI("No connections");
+               return NM_CONNMAN_ERROR_NO_CONNECTION;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a(oa{sv})"));
+       g_hash_table_foreach(service_tbl,
+                       __nm_connman_service_get_connections,
+                       builder);
+
+       *connections = g_variant_new("(a(oa{sv}))", builder);
+       g_variant_builder_unref(builder);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+
+int nm_connman_set_conn_error_callback(nm_connman_error_cb cb)
+{
+       int ret = 0;
+
+       if (service_tbl) {
+               g_conn_error_cb = cb;
+       } else {
+               NM_LOGI("Service is not initialized!");
+               ret = -1;
+       }
+
+       return ret;
+}
+
+int nm_connman_unset_conn_error_callback()
+{
+       int ret = 0;
+
+       if (service_tbl) {
+               g_conn_error_cb = NULL;
+       } else {
+               NM_LOGI("Service is not initialized!");
+               ret = -1;
+       }
+
+       return ret;
+}
+
+int nm_connman_set_conn_changed_callback(nm_connman_conn_changed_cb cb)
+{
+       int ret = 0;
+
+       if (service_tbl) {
+               g_conn_changed_cb = cb;
+       } else {
+               NM_LOGI("Service is not initialized!");
+               ret = -1;
+       }
+
+       return ret;
+}
+
+int nm_connman_unset_conn_changed_callback()
+{
+       int ret = 0;
+
+       if (service_tbl) {
+               g_conn_changed_cb = NULL;
+       } else {
+               NM_LOGI("Service is not initialized!");
+               ret = -1;
+       }
+
+       return ret;
+}
+
+int nm_connman_service_init()
+{
+       int ret = NM_CONNMAN_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+       service_tbl = g_hash_table_new_full(g_str_hash,
+                       g_str_equal,
+                       g_free,
+                       __destroy_service_data
+                       );
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_connman_service_deinit()
+{
+       int ret = NM_CONNMAN_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       g_hash_table_remove_all(service_tbl);
+       g_hash_table_unref(service_tbl);
+       service_tbl = NULL;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-connman-tech.c b/src/inm-connman-tech.c
new file mode 100644 (file)
index 0000000..d0468e1
--- /dev/null
@@ -0,0 +1,419 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling connman technology DBus interface.
+ *
+ * @file        nm-connman-tech.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <glib.h>
+
+#include "inm-connman.h"
+#include "inm-connman-internal.h"
+#include "inm-gdbus.h"
+#include "inm-daemon-log.h"
+
+#define CONNMAN_TECH_PATH CONNMAN_PATH "/technology"
+
+#define CONNMAN_CELL_TECH_PATH CONNMAN_TECH_PATH "/cellular"
+#define CONNMAN_ETH_TECH_PATH CONNMAN_TECH_PATH "/ethernet"
+#define CONNMAN_WIFI_TECH_PATH CONNMAN_TECH_PATH "/wifi"
+
+typedef struct {
+       /*
+        * False means that the technology is
+        * off (and is available RF-Killed) while True means
+        * that the technology is enabled
+        */
+       gboolean powered;
+
+       /*
+        * If this property is True it means that at least one
+        * service of this technology is in ready state.
+        */
+       gboolean connected;
+
+       /*
+        * Name of this technology.
+        */
+       gchar *name;
+
+       /*
+        * The technology type (for example "ethernet" etc.)
+        */
+       gchar *type;
+
+       /*
+        * This option allows to enable or disable the support
+        * for tethering. When tethering is enabled then the
+        * default service is bridged to all clients connected
+        * through the technology.
+        */
+       gboolean tethering;
+
+       /*
+        * This variable holds the subscriber id which is
+        * subscribing property changed signal of the technology.
+        */
+       guint subscriber_id;
+} connman_tech_s;
+
+nm_connman_tech_changed_cb g_tech_changed_cb = NULL;
+GHashTable *tech_tbl = NULL;
+
+const int __connman_service_type2enum(gchar *type_str)
+{
+       int type = CONNMAN_SERVICE_TYPE_UNKNOWN;
+       if (g_strcmp0(type_str, "system") == 0)
+               type = CONNMAN_SERVICE_TYPE_SYSTEM;
+       else if (g_strcmp0(type_str, "ethernet") == 0)
+               type = CONNMAN_SERVICE_TYPE_ETHERNET;
+       else if (g_strcmp0(type_str, "wifi") == 0)
+               type = CONNMAN_SERVICE_TYPE_WIFI;
+       else if (g_strcmp0(type_str, "bluetooth") == 0)
+               type = CONNMAN_SERVICE_TYPE_BLUETOOTH;
+       else if (g_strcmp0(type_str, "cellular") == 0)
+               type = CONNMAN_SERVICE_TYPE_CELLULAR;
+       else if (g_strcmp0(type_str, "gps") == 0)
+               type = CONNMAN_SERVICE_TYPE_GPS;
+       else if (g_strcmp0(type_str, "vpn") == 0)
+               type = CONNMAN_SERVICE_TYPE_VPN;
+       else if (g_strcmp0(type_str, "gadget") == 0)
+               type = CONNMAN_SERVICE_TYPE_GADGET;
+       else if (g_strcmp0(type_str, "p2p") == 0)
+               type = CONNMAN_SERVICE_TYPE_P2P;
+
+       return type;
+}
+
+const int __connman_tech_get_state(gboolean powered, gboolean connected)
+{
+       int state = 0;
+       if (!powered && !connected)
+               state = CONNMAN_TECH_STATE_POWER_OFF;
+       else if (powered && !connected)
+               state = CONNMAN_TECH_STATE_POWER_ON;
+       else if (powered && connected)
+               state = CONNMAN_TECH_STATE_CONNECTED;
+       else
+               state = CONNMAN_TECH_STATE_UNKNOWN;
+
+       return state;
+}
+
+static void __tech_property_changed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static signal_param_s tech_signal_param = {
+               .sender = CONNMAN_SERVICE,
+               .interface_name = CONNMAN_TECHNOLOGY_INTERFACE,
+               .member = DBUS_SIGNAL_PROPERTY_CHANGED,
+               .object_path = NULL,
+               .arg0 = NULL,
+               .callback = __tech_property_changed,
+               .subscriber_id  = 0,
+};
+
+static void __destroy_tech_data(gpointer data)
+{
+       connman_tech_s *tech_data = (connman_tech_s *)data;
+       __NM_FUNC_ENTER__;
+
+       tech_signal_param.subscriber_id = tech_data->subscriber_id;
+       nm_gdbus_unsubscribe_signal(&(tech_signal_param));
+       g_free(tech_data->name);
+       g_free(tech_data->type);
+
+       g_free(tech_data);
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void inline __get_powered(GVariant *value, connman_tech_s *tech)
+{
+       g_variant_get(value, "b", &(tech->powered));
+       NM_LOGI("Powered %s", (tech->powered)?"On":"Off");
+}
+
+static void inline __get_connected(GVariant *value, connman_tech_s *tech)
+{
+       g_variant_get(value, "b", &(tech->connected));
+       NM_LOGI("%s", (tech->connected)?"Connected":"Not connected");
+}
+
+static void inline __get_name(GVariant *value, connman_tech_s *tech)
+{
+       const gchar *str = NULL;
+       g_variant_get(value, "&s", &str);
+
+       if (str) {
+               g_free(tech->name);
+               tech->name = g_strdup(str);
+       }
+}
+
+static void inline __get_type(GVariant *value, connman_tech_s *tech)
+{
+       const gchar *str = NULL;
+       g_variant_get(value, "&s", &str);
+
+       if (str) {
+               g_free(tech->type);
+               tech->type = g_strdup(str);
+       }
+}
+
+static void inline __get_tethering(GVariant *value, connman_tech_s *tech)
+{
+       g_variant_get(value, "b", &(tech->tethering));
+}
+
+static void inline __tech_get_property(gchar *key, GVariant *value, connman_tech_s *tech)
+{
+       if (g_strcmp0(key, "Powered") == 0)
+               __get_powered(value, tech);
+       else if (g_strcmp0(key, "Connected") == 0)
+               __get_connected(value, tech);
+       else if (g_strcmp0(key, "Name") == 0)
+               __get_name(value, tech);
+       else if (g_strcmp0(key, "Type") == 0)
+               __get_type(value, tech);
+       else if (g_strcmp0(key, "Tethering") == 0)
+               __get_tethering(value, tech);
+}
+
+static void __tech_property_changed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       gchar *key = NULL;
+       GVariant *value = NULL;
+       connman_tech_s *tech = NULL;
+       int prev_tech_state = 0;
+       int tech_type = 0;
+       int tech_state = 0;
+
+       __NM_FUNC_ENTER__;
+
+       tech = g_hash_table_lookup(tech_tbl, object_path);
+       if (!tech) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("Tech not found");
+               return;
+       }
+       prev_tech_state = __connman_tech_get_state(tech->powered, tech->connected);
+
+       g_variant_get(parameters, "(&sv)", &key, &value);
+
+       if (key)
+               __tech_get_property(key, value, tech);
+
+       tech_state = __connman_tech_get_state(tech->powered, tech->connected);
+       if (g_tech_changed_cb && (tech_state != prev_tech_state)) {
+               tech_type = __connman_service_type2enum(tech->type);
+               NM_LOGI("State changed");
+               NM_LOGI("Notify tech type %d state %d", tech_type, tech_state);
+               g_tech_changed_cb(tech_type, tech_state);
+       }
+
+       __NM_FUNC_EXIT__;
+}
+
+int nm_connman_tech_get_state(connman_service_type_e type,
+               connman_tech_state_e *state)
+{
+       connman_tech_s *tech = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!tech_tbl) {
+               NM_LOGI("Tech is not initialized!");
+               return -1;
+       }
+
+       *state = CONNMAN_TECH_STATE_UNKNOWN;
+
+       /* We can get only three type of tech. Please add more if we need */
+
+       if (type == CONNMAN_SERVICE_TYPE_ETHERNET)
+               tech = g_hash_table_lookup(tech_tbl, CONNMAN_ETH_TECH_PATH);
+       else if (type == CONNMAN_SERVICE_TYPE_WIFI)
+               tech = g_hash_table_lookup(tech_tbl, CONNMAN_WIFI_TECH_PATH);
+       else if (type == CONNMAN_SERVICE_TYPE_CELLULAR)
+               tech = g_hash_table_lookup(tech_tbl, CONNMAN_CELL_TECH_PATH);
+
+       if (tech)
+               *state = __connman_tech_get_state(tech->powered, tech->connected);
+       else
+               *state = CONNMAN_TECH_STATE_UNKNOWN;
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+void nm_connman_tech_add(gchar *path, GVariantIter *iter)
+{
+       GVariant *value = NULL;
+       connman_tech_s *tech = NULL;
+       gchar *key = NULL;
+       gint tech_type = 0;
+       gint tech_state = 0;
+       gint ret = 0;
+
+       __NM_FUNC_ENTER__;
+
+       if (!path)
+               return;
+
+       tech = g_hash_table_lookup(tech_tbl, path);
+       if (!tech) {
+               tech = (connman_tech_s *)g_try_malloc0(sizeof(connman_tech_s));
+               if (!tech) {
+                       NM_LOGI("Error! Failed to allocate tech");
+                       __NM_FUNC_EXIT__;
+                       return;
+               }
+
+               if (!g_hash_table_insert(tech_tbl, g_strdup(path), tech)) {
+                       g_free(tech);
+                       NM_LOGI("Error! Failed to insert tech");
+                       __NM_FUNC_EXIT__;
+                       return;
+               }
+       }
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &value))
+               __tech_get_property(key, value, tech);
+
+       tech_signal_param.object_path = path;
+       ret = nm_gdbus_subscribe_signal(&(tech_signal_param));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               NM_LOGI("Error! Failed to subscribe signal");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       tech->subscriber_id = tech_signal_param.subscriber_id;
+
+       if (g_tech_changed_cb) {
+               tech_type = __connman_service_type2enum(tech->type);
+               tech_state = __connman_tech_get_state(tech->powered, tech->connected);
+               NM_LOGI("Notify tech type %d state %d", tech_type, tech_state);
+               g_tech_changed_cb(tech_type, tech_state);
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+void nm_connman_tech_remove(GVariant *parameters)
+{
+       __NM_FUNC_ENTER__;
+       connman_tech_s *tech = NULL;
+       gchar *path = NULL;
+       gint tech_type = 0;
+
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(parameters, "(&o)", &path);
+
+       if (!path)
+               return;
+
+       tech = g_hash_table_lookup(tech_tbl, path);
+       if (!tech) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       if (g_tech_changed_cb) {
+               tech_type = __connman_service_type2enum(tech->type);
+               NM_LOGI("Notify tech type %d state %d", tech_type, CONNMAN_TECH_STATE_UNKNOWN);
+               g_tech_changed_cb(tech_type, CONNMAN_TECH_STATE_UNKNOWN);
+       }
+
+       g_hash_table_remove (tech_tbl, path);
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+int nm_connman_set_tech_changed_callback(nm_connman_tech_changed_cb cb)
+{
+       int ret = 0;
+
+       if (tech_tbl) {
+               g_tech_changed_cb = cb;
+       } else {
+               NM_LOGI("Tech is not initialized!");
+               ret = -1;
+       }
+
+       return ret;
+}
+
+int nm_connman_unset_tech_changed_callback()
+{
+       int ret = 0;
+
+       if (tech_tbl) {
+               g_tech_changed_cb = NULL;
+       } else {
+               NM_LOGI("Tech is not initialized!");
+               ret = -1;
+       }
+
+       return ret;
+}
+
+int nm_connman_tech_init()
+{
+       int ret = NM_CONNMAN_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+       tech_tbl = g_hash_table_new_full(g_str_hash,
+                       g_str_equal,
+                       g_free,
+                       __destroy_tech_data
+                       );
+       g_tech_changed_cb = NULL;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_connman_tech_deinit()
+{
+       int ret = NM_CONNMAN_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       g_hash_table_remove_all(tech_tbl);
+        g_hash_table_unref(tech_tbl);
+       tech_tbl = NULL;
+       g_tech_changed_cb = NULL;
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-connman.c b/src/inm-connman.c
new file mode 100644 (file)
index 0000000..6e2ee57
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling signal from connman.
+ *
+ * @file        nm-connman.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-connman.h"
+#include "inm-connman-internal.h"
+
+#define CONNMAN_SIGNAL_TECHNOLOGY_ADDED                "TechnologyAdded"
+#define CONNMAN_SIGNAL_TECHNOLOGY_REMOVED      "TechnologyRemoved"
+#define CONNMAN_SIGNAL_SERVICES_CHANGED                "ServicesChanged"
+
+typedef enum {
+       SIGNAL_MGR_TECH_ADDED,
+       SIGNAL_MGR_TECH_REMOVED,
+       SIGNAL_MGR_SERVICES_CHANGED,
+       SIGNAL_MGR_PROP_CHANGED,
+       SIGNAL_TECH,
+       SIGNAL_SERVICE_PROP_CHANGED,
+       SIGNAL_NAME_OWNER_CHANGED,
+
+} connman_signal_e;
+
+typedef struct {
+       gboolean is_initialized;
+       signal_param_s *params;
+
+} connman_mon_s;
+
+connman_mon_s connman_mon;
+
+
+static void __name_owner_changed_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       gchar *name = NULL;
+       gchar *old = NULL;
+       gchar *new = NULL;
+
+       if (parameters == NULL)
+               return;
+
+       g_variant_get(parameters, "(&s&s&s)", &name, &old, &new);
+
+       if (g_strcmp0(name, CONNMAN_SERVICE) == 0 && *new == '\0') {
+               NM_LOGI("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
+
+       }
+       return;
+}
+
+static signal_param_s signal_param[] = {
+               {
+                               .sender = CONNMAN_SERVICE,
+                               .interface_name = CONNMAN_MANAGER_INTERFACE,
+                               .member = CONNMAN_SIGNAL_TECHNOLOGY_ADDED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = nm_connman_mgr_tech_added,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = CONNMAN_SERVICE,
+                               .interface_name = CONNMAN_MANAGER_INTERFACE,
+                               .member = CONNMAN_SIGNAL_TECHNOLOGY_REMOVED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = nm_connman_mgr_tech_removed,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = CONNMAN_SERVICE,
+                               .interface_name = CONNMAN_MANAGER_INTERFACE,
+                               .member = CONNMAN_SIGNAL_SERVICES_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = nm_connman_mgr_service_changed,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = CONNMAN_SERVICE,
+                               .interface_name = CONNMAN_MANAGER_INTERFACE,
+                               .member = DBUS_SIGNAL_PROPERTY_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = nm_connman_mgr_property_changed,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = CONNMAN_SERVICE,
+                               .interface_name = CONNMAN_TECHNOLOGY_INTERFACE,
+                               .member = NULL,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = NULL /* TODO */,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = CONNMAN_SERVICE,
+                               .interface_name = CONNMAN_SERVICE_INTERFACE,
+                               .member = DBUS_SIGNAL_PROPERTY_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = NULL /* TODO */,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = DBUS_SERVICE_DBUS,
+                               .interface_name = DBUS_INTERFACE_DBUS,
+                               .member = DBUS_SIGNAL_NAME_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = CONNMAN_SERVICE,
+                               .callback = __name_owner_changed_cb,
+                               .subscriber_id  = 0,
+               },
+};
+
+int nm_connman_init()
+{
+       int ret = NM_CONNMAN_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       memset(&connman_mon, 0x00, sizeof(connman_mon));
+       connman_mon.params = signal_param;
+       connman_mon.is_initialized = TRUE;
+
+       ret = nm_gdbus_subscribe_signal(&(connman_mon.params[SIGNAL_MGR_TECH_ADDED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(connman_mon.params[SIGNAL_MGR_TECH_REMOVED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(connman_mon.params[SIGNAL_MGR_SERVICES_CHANGED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(connman_mon.params[SIGNAL_NAME_OWNER_CHANGED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_connman_tech_init();
+       if (ret != NM_CONNMAN_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_TECH_INIT_FAILED;
+       }
+
+       ret = nm_connman_service_init();
+       if (ret != NM_CONNMAN_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_SRV_INIT_FAILED;
+       }
+
+
+       __NM_FUNC_EXIT__;
+       return NM_CONNMAN_ERROR_NONE;
+}
+
+int nm_connman_deinit()
+{
+       int ret = NM_CONNMAN_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!connman_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_NOT_INITIALIZED;
+       }
+
+       nm_gdbus_unsubscribe_signal(&(connman_mon.params[SIGNAL_MGR_TECH_ADDED]));
+       nm_gdbus_unsubscribe_signal(&(connman_mon.params[SIGNAL_MGR_TECH_REMOVED]));
+       nm_gdbus_unsubscribe_signal(&(connman_mon.params[SIGNAL_MGR_SERVICES_CHANGED]));
+       nm_gdbus_unsubscribe_signal(&(connman_mon.params[SIGNAL_NAME_OWNER_CHANGED]));
+
+       ret = nm_connman_tech_deinit();
+       if (ret != NM_CONNMAN_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_TECH_INIT_FAILED;
+       }
+       ret = nm_connman_service_deinit();
+       if (ret != NM_CONNMAN_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_CONNMAN_ERROR_SRV_INIT_FAILED;
+       }
+
+       connman_mon.is_initialized = FALSE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-daemon-main.c b/src/inm-daemon-main.c
new file mode 100644 (file)
index 0000000..5532fac
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements Network Monitoring Daemon Main function.
+ *
+ * @file        nm-daemon-main.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <signal.h>
+#include <unistd.h>
+
+#include <glib.h>
+
+#include "inm-daemon.h"
+#include "inm-daemon-log.h"
+
+static GMainLoop *g_loop = NULL;
+
+static void __signal_handler(int sig)
+{
+       if (sig == SIGHUP) {
+               NM_LOGI("hangup signal catched");
+               g_main_loop_quit(g_loop);
+               return;
+       }
+
+       if (sig == SIGTERM) {
+               NM_LOGI("terminate signal catched");
+               g_main_loop_quit(g_loop);
+               return;
+       }
+}
+
+static void __add_signal_handler()
+{
+       signal(SIGCHLD, SIG_IGN); /* ignore child */
+       signal(SIGTSTP, SIG_IGN); /* ignore tty signals */
+       signal(SIGTTOU, SIG_IGN);
+       signal(SIGTTIN, SIG_IGN);
+       signal(SIGHUP, __signal_handler); /* catch hangup signal */
+       signal(SIGTERM, __signal_handler); /* catch kill signal */
+}
+
+int main(void)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+/*
+       ret = daemon(0, 0);
+       if (ret != 0) {
+               NM_LOGE("daemon function failure");
+               return -1;
+       }
+*/
+       __add_signal_handler();
+
+       g_loop = g_main_loop_new(NULL, FALSE);
+
+       ret = nm_daemon_init();
+       if (ret != 0) {
+               NM_LOGE("init daemon function failure");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       nm_daemon_set_loop(g_loop);
+
+       NM_LOGI("Run network monitoring");
+       g_main_loop_run(g_loop);
+       NM_LOGI("End network monitoring");
+
+       ret = nm_daemon_deinit();
+       if (ret != 0) {
+               NM_LOGE("deinit daemon function failure");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       g_main_loop_unref(g_loop);
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
diff --git a/src/inm-daemon.c b/src/inm-daemon.c
new file mode 100644 (file)
index 0000000..4c1c731
--- /dev/null
@@ -0,0 +1,856 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements Network Monitoring Daemon functions.
+ *
+ * @file        nm-daemon.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "inm-gdbus.h"
+#include "inm-dump.h"
+#include "inm-ip-conflict.h"
+#include "inm-iface-mon.h"
+#include "inm-supplicant.h"
+#include "inm-connman.h"
+#include "inm-daemon.h"
+#include "inm-daemon-log.h"
+#include "inm-error.h"
+
+#define IF_NAME_WLAN "wlan0"
+#define IF_NAME_ETH "eth0"
+
+typedef struct{
+       GMainLoop *loop;
+       int congestion_level;
+       int retry_tx_rate;
+       int freq;
+       double channel_interference;
+       gboolean tcpdump_state;
+       nm_ip_conflict_state_e ip_conflict_state;
+       gboolean is_wpasupplicant_enabled;
+       gboolean is_connman_enabled;
+       gboolean is_telephony_enabled;
+       gboolean is_wfd_manager_enabled;
+       gboolean is_mobileap_enabled;
+       gboolean is_stc_manager_enabled;
+} nm_daemon_s;
+
+nm_daemon_s *g_nm_daemon;
+
+void nm_daemon_set_loop(GMainLoop *loop)
+{
+       __NM_FUNC_ENTER__;
+       if (g_nm_daemon)
+               g_nm_daemon->loop = loop;
+       __NM_FUNC_EXIT__;
+}
+
+void nm_daemon_unset_loop()
+{
+       __NM_FUNC_ENTER__;
+       if (g_nm_daemon)
+               g_nm_daemon->loop = NULL;
+       __NM_FUNC_EXIT__;
+}
+
+int nm_daemon_set_tcpdump(gboolean state)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       if (state)
+               ret = nm_dump_start_tcpdump();
+       else
+               ret = nm_dump_stop_tcpdump();
+
+       if (ret == 0)
+               g_nm_daemon->tcpdump_state = state;
+
+       if (ret == NM_DUMP_IN_PROGRESS)
+               ret = NM_DAEMON_ERROR_IN_PROGRESS;
+       else if (ret == NM_DAEMON_ERROR_OPERATION_FAILED)
+               ret = NM_DAEMON_ERROR_OPERATION_FAILED;
+       else if (ret == NM_DUMP_ERROR_NONE)
+               ret = NM_DAEMON_ERROR_NONE;
+       else
+               ret = NM_DAEMON_ERROR_OPERATION_FAILED;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_daemon_get_tcpdump_state(gboolean *state)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_dump_get_tcpdump_state(state);
+
+       if (ret == NM_DUMP_ERROR_NONE)
+               ret = NM_DAEMON_ERROR_NONE;
+       else
+               ret = NM_DAEMON_ERROR_OPERATION_FAILED;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_daemon_get_ip_conflict_detect(gboolean *detect)
+{
+       __NM_FUNC_ENTER__;
+       gboolean detect_eth;
+       gboolean detect_wlan;
+       int ret = 0;
+
+
+       ret = nm_ip_conflict_is_detection_enabled(IF_NAME_ETH, &detect_eth);
+       if (ret != NM_IP_CONFLICT_ERROR_NONE)
+               return NM_DAEMON_ERROR_OPERATION_FAILED;
+
+       ret = nm_ip_conflict_is_detection_enabled(IF_NAME_WLAN, &detect_wlan);
+       if (ret != NM_IP_CONFLICT_ERROR_NONE)
+               return NM_DAEMON_ERROR_OPERATION_FAILED;
+
+       *detect = detect_eth || detect_wlan;
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_daemon_get_ip_conflict_state(gboolean *state)
+{
+       __NM_FUNC_ENTER__;
+       gboolean detect_eth;
+       gboolean detect_wlan;
+       int ret = 0;
+
+       ret = nm_ip_conflict_is_detection_enabled(IF_NAME_ETH, &detect_eth);
+       if (ret != NM_IP_CONFLICT_ERROR_NONE)
+               return NM_DAEMON_ERROR_OPERATION_FAILED;
+
+       ret = nm_ip_conflict_is_detection_enabled(IF_NAME_WLAN, &detect_wlan);
+       if (ret != NM_IP_CONFLICT_ERROR_NONE)
+               return NM_DAEMON_ERROR_OPERATION_FAILED;
+
+       if (!detect_eth && !detect_wlan)
+               *state = IP_CONFLICT_STATE_UNKNOWN;
+       else
+               *state = g_nm_daemon->ip_conflict_state;
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_daemon_get_ethernet_cable_state(gboolean *state)
+{
+       int value = 0;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_iface_mon_get_iface_state(IF_NAME_ETH, &value);
+       if (ret < 0) {
+               NM_LOGI("get iface %s state failed", IF_NAME_ETH);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       *state = value != 0;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_daemon_get_wifi_module_state(gboolean *state)
+{
+       int value = 0;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_iface_mon_get_iface_state(IF_NAME_WLAN, &value);
+       if (ret < 0) {
+               NM_LOGI("get iface %s state failed", IF_NAME_WLAN);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       *state = value != 0;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_daemon_get_congestion_level(int *level)
+{
+       __NM_FUNC_ENTER__;
+       *level = g_nm_daemon->congestion_level;
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_daemon_get_retry_tx_rate(int *rate)
+{
+       __NM_FUNC_ENTER__;
+       *rate = g_nm_daemon->retry_tx_rate;
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_daemon_get_channel_interference(double *ch_interference)
+{
+       __NM_FUNC_ENTER__;
+       *ch_interference = g_nm_daemon->channel_interference;
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_daemon_get_cellular_state(int *state)
+{
+       connman_tech_state_e value;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_connman_tech_get_state(CONNMAN_SERVICE_TYPE_CELLULAR, &value);
+       if (ret != 0) {
+               NM_LOGI("Failed to get cellular state");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+       *state = (int)value;
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_daemon_get_wifi_state(int *state)
+{
+       connman_tech_state_e value;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_connman_tech_get_state(CONNMAN_SERVICE_TYPE_WIFI, &value);
+       if (ret != 0) {
+               NM_LOGI("Failed to get wifi state");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+       *state = (int)value;
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_daemon_get_ethernet_state(int *state)
+{
+       connman_tech_state_e value;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_connman_tech_get_state(CONNMAN_SERVICE_TYPE_ETHERNET, &value);
+       if (ret != 0) {
+               NM_LOGI("Failed to get ethernet state");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+       *state = (int)value;
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_daemon_get_wifi_scan_state(gboolean *state)
+{
+       nm_supplicant_iface_s *iface = NULL;
+       int ret = 0;
+
+       ret = nm_supplicant_iface_get_iface(IF_NAME_WLAN, &iface);
+       if (ret != NM_SUPPLICANT_ERROR_NONE || iface == NULL)
+               *state = FALSE;
+       else
+               *state = iface->scanning;
+
+       return NM_DAEMON_ERROR_NONE;
+}
+
+static void __ip_conflict_cb(int state, gchar *if_name, guchar *ip, gpointer user_data)
+{
+       gchar *ip_str = NULL;
+       if (if_name)
+               NM_LOGI("User callback IP conflict %s state[%d] :", if_name, state);
+
+       ip_str = g_strdup_printf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
+       if (!ip_str)
+               return;
+
+       if (state != IP_CONFLICT_STATE_UNKNOWN)
+               g_nm_daemon->ip_conflict_state = state;
+
+       if (state == IP_CONFLICT_STATE_CONFLICT_DETECTED)
+               nm_gdbus_emit_ip_conflicted(state, if_name, ip_str);
+
+       g_free(ip_str);
+
+       return;
+}
+
+static inline void __init_ip_conflict_detect()
+{
+       __NM_FUNC_ENTER__;
+       if (ip_conflict_detection_init() < 0) {
+               NM_LOGI("ip conflict detection init failed");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       g_nm_daemon->ip_conflict_state = IP_CONFLICT_STATE_UNKNOWN;
+
+       ip_conflict_set_callback(IF_NAME_ETH, __ip_conflict_cb, NULL);
+       ip_conflict_set_callback(IF_NAME_WLAN, __ip_conflict_cb, NULL);
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __deinit_ip_conflict_detect()
+{
+       __NM_FUNC_ENTER__;
+       ip_conflict_unset_callback(IF_NAME_ETH);
+       ip_conflict_unset_callback(IF_NAME_WLAN);
+
+       if (ip_conflict_detection_deinit() < 0) {
+               NM_LOGI("ip conflict detection deinit failed");
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __ethernet_cable_state_changed_cb(char *iface_name, int state, void *user_data)
+{
+       gboolean is_attached = FALSE;
+
+       is_attached = state == 1;
+
+       NM_LOGI("%s is %s", IF_NAME_ETH, is_attached?"Attached":"Detached");
+       nm_gdbus_emit_ethernet_cable_state(is_attached);
+}
+
+
+static void __wifi_module_state_changed_cb(char *iface_name, int state, void *user_data)
+{
+       gboolean is_attached = FALSE;
+
+       is_attached = state == 1;
+
+       NM_LOGI("%s is %s", IF_NAME_WLAN, is_attached?"Attached":"Detached");
+       nm_gdbus_emit_wifi_module_state(is_attached);
+}
+
+static inline void __init_iface_monitor()
+{
+       __NM_FUNC_ENTER__;
+       if (nm_iface_mon_init() < 0) {
+               NM_LOGI("nm_iface_mon_init failed");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       if (nm_iface_mon_start_monitor(IF_NAME_ETH,
+                       __ethernet_cable_state_changed_cb,
+                       NULL) < 0)
+               NM_LOGI("nm_iface_mon_start_monitor %s failed", IF_NAME_ETH);
+
+       if (nm_iface_mon_start_monitor(IF_NAME_WLAN,
+                       __wifi_module_state_changed_cb,
+                       NULL) < 0)
+               NM_LOGI("nm_iface_mon_start_monitor %s failed", IF_NAME_WLAN);
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __deinit_iface_monitor()
+{
+       __NM_FUNC_ENTER__;
+
+       if (nm_iface_mon_stop_monitor(IF_NAME_ETH) < 0)
+               NM_LOGI("nm_iface_mon_start_monitor %s failed", IF_NAME_ETH);
+
+       if (nm_iface_mon_stop_monitor(IF_NAME_WLAN) < 0)
+               NM_LOGI("nm_iface_mon_start_monitor %s failed", IF_NAME_WLAN);
+
+       if (nm_iface_mon_deinit() < 0)
+               NM_LOGI("nm_iface_mon_deinit failed");
+
+       __NM_FUNC_EXIT__;
+}
+
+void __retry_tx_rate_cb(int retry_rate, gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       g_nm_daemon->retry_tx_rate = retry_rate;
+       nm_gdbus_emit_retry_tx_rate_changed(retry_rate);
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __init_retry_tx_rate_monitor()
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_retry_tx_rate_monitor_start(__retry_tx_rate_cb, NULL);
+       if (ret != NM_DAEMON_ERROR_NONE)
+               NM_LOGI("nm_retry_tx_rate_monitor_start failed");
+}
+
+static inline void __deinit_retry_tx_rate_monitor()
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_retry_tx_rate_monitor_stop();
+       if (ret != NM_DAEMON_ERROR_NONE)
+               NM_LOGI("nm_retry_tx_rate_monitor_stop failed");
+}
+
+void __channel_interference_cb(int freq, double channel_interference, gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       g_nm_daemon->freq = freq;
+       g_nm_daemon->channel_interference = channel_interference;
+       nm_gdbus_emit_channel_interference(freq, channel_interference);
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __init_channel_interference_monitor()
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_channel_interference_monitor_start(__channel_interference_cb, NULL);
+       if (ret != NM_DAEMON_ERROR_NONE)
+               NM_LOGI("nm_channel_interference_monitor_start failed");
+}
+
+static inline void __deinit_channel_interference_monitor()
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_channel_interference_monitor_stop();
+       if (ret != NM_DAEMON_ERROR_NONE)
+               NM_LOGI("nm_channel_interference_monitor_stop failed");
+}
+
+void __congestion_mon_cb(int congestion_level, gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       g_nm_daemon->congestion_level = congestion_level;
+       nm_gdbus_emit_congestion_level_changed(congestion_level);
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __init_congestion_mon()
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_congestion_mon_init();
+       if (ret != NM_DAEMON_ERROR_NONE) {
+               NM_LOGI("nm_congestion_mon_init failed");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       ret = nm_congestion_monitor_start(__congestion_mon_cb, NULL);
+       if (ret != NM_DAEMON_ERROR_NONE)
+               NM_LOGI("nm_congestion_monitor_start failed");
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __deinit_congestion_mon()
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_congestion_monitor_stop();
+       if (ret != NM_DAEMON_ERROR_NONE) {
+               NM_LOGI("nm_congestion_monitor_stop failed");
+       __NM_FUNC_EXIT__;
+               return;
+       }
+
+       ret = nm_congestion_mon_deinit();
+       if (ret != NM_DAEMON_ERROR_NONE)
+               NM_LOGI("nm_congestion_mon_deinit failed");
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __set_ip_detection(char *ifname, connman_tech_state_e state)
+{
+       gboolean enabled;
+       int ret = 0;
+
+       if (state == CONNMAN_TECH_STATE_CONNECTED) {
+               ret = nm_ip_conflict_enable_detection(ifname, TRUE);
+               if (ret == NM_IP_CONFLICT_ERROR_NONE)
+                       NM_LOGI("Enable ip confilct %s detection", ifname);
+       } else {
+               ret = nm_ip_conflict_is_detection_enabled(ifname, &enabled);
+               if (ret == NM_IP_CONFLICT_ERROR_NONE && enabled)
+                       ret = nm_ip_conflict_enable_detection(ifname, FALSE);
+
+               if (ret == NM_IP_CONFLICT_ERROR_NONE)
+                       NM_LOGI("Disable ip confilct %s detection", ifname);
+       }
+}
+
+static void __tech_changed_cb(connman_service_type_e type,
+               connman_tech_state_e state)
+{
+       NM_LOGI("Tech changed %d %d", type, state);
+       if (type == CONNMAN_SERVICE_TYPE_ETHERNET) {
+               nm_gdbus_emit_ethernet_state(state);
+               __set_ip_detection(IF_NAME_ETH, state);
+       } else if (type == CONNMAN_SERVICE_TYPE_WIFI) {
+               nm_gdbus_emit_wifi_state(state);
+               __set_ip_detection(IF_NAME_WLAN, state);
+       } else if (type == CONNMAN_SERVICE_TYPE_CELLULAR)
+               nm_gdbus_emit_cellular_state(state);
+}
+
+static void __conn_changed_cb(GVariant *signal_args)
+{
+       NM_LOGI("");
+       nm_gdbus_emit_connections_changed(signal_args);
+}
+
+static void __conn_error_cb(connman_service_error_e error)
+{
+       if (error != CONNMAN_SERVICE_ERROR_UNKNOWN)
+               nm_dump_log("/tmp");
+}
+
+static inline void __init_connman()
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_connman_init();
+       if (ret < 0) {
+               NM_LOGI("Init connman failed");
+       __NM_FUNC_EXIT__;
+               return;
+       }
+
+       ret = nm_connman_set_tech_changed_callback(__tech_changed_cb);
+       if (ret < 0) {
+               nm_connman_deinit();
+               NM_LOGI("Set tech changed cb failed");
+       }
+
+       ret = nm_connman_set_conn_changed_callback(__conn_changed_cb);
+       if (ret < 0) {
+               nm_connman_deinit();
+               NM_LOGI("Set connection changed cb failed");
+       }
+
+       ret = nm_connman_set_conn_error_callback(__conn_error_cb);
+       if (ret < 0) {
+               nm_connman_deinit();
+               NM_LOGI("Set connection error cb failed");
+       }
+
+       __NM_FUNC_EXIT__;
+
+}
+
+static inline void __deinit_connman()
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+
+       ret = nm_connman_unset_tech_changed_callback();
+       if (ret < 0)
+               NM_LOGI("Unset tech changed cb failed");
+
+       ret = nm_connman_unset_conn_changed_callback();
+       if (ret < 0)
+               NM_LOGI("Unset conn changed cb failed");
+
+       ret = nm_connman_unset_conn_error_callback();
+       if (ret < 0)
+               NM_LOGI("Unset connection error cb failed");
+
+       ret = nm_connman_deinit();
+       if (ret < 0) {
+               NM_LOGI("Deinit connman failed");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       __NM_FUNC_EXIT__;
+}
+
+static void __supplicant_iface_changed(
+               nm_supplicant_iface_property_e property,
+               nm_supplicant_iface_s *iface,
+               gpointer user_data)
+{
+       if (property == NM_SUPPLICANT_IFACE_PROPERTY_STATE) {
+               NM_LOGI("iface state changed");
+       } else if (property == NM_SUPPLICANT_IFACE_PROPERTY_SCANNING) {
+               NM_LOGI("iface scanning changed");
+
+               if (g_strcmp0(iface->Ifname, IF_NAME_WLAN) == 0)
+                       nm_gdbus_emit_wifi_scanning_changed(iface->scanning);
+       } else {
+               NM_LOGI("Nothing");
+       }
+}
+
+static inline void __init_supplicant()
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_supplicant_init();
+       if (ret < 0) {
+               NM_LOGI("Init supplicant failed");
+       __NM_FUNC_EXIT__;
+               return;
+       }
+
+       ret = nm_supplicant_iface_set_prop_changed_cb(__supplicant_iface_changed, NULL);
+       if (ret < 0) {
+               nm_supplicant_deinit();
+               NM_LOGI("Set supplicant iface changed cb failed");
+       }
+
+       __NM_FUNC_EXIT__;
+
+}
+
+static inline void __deinit_supplicant()
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+
+       ret = nm_supplicant_iface_unset_prop_changed_cb();
+       if (ret < 0) {
+               nm_supplicant_deinit();
+               NM_LOGI("Set supplicant iface changed cb failed");
+       }
+
+       ret = nm_supplicant_deinit();
+       if (ret < 0) {
+               NM_LOGI("Denit supplicant failed");
+       __NM_FUNC_EXIT__;
+               return;
+       }
+
+       __NM_FUNC_EXIT__;
+}
+
+static void __wpasupplicant_watching_cb(gboolean appeared)
+{
+       NM_LOGI("wpasupplicant is %s", appeared?"Enabled":"Disabled");
+       g_nm_daemon->is_wpasupplicant_enabled = appeared;
+}
+
+static void __connman_watching_cb(gboolean appeared)
+{
+       NM_LOGI("connman is %s", appeared?"Enabled":"Disabled");
+       g_nm_daemon->is_connman_enabled = appeared;
+}
+
+static void __telephony_watching_cb(gboolean appeared)
+{
+       NM_LOGI("telephony is %s", appeared?"Enabled":"Disabled");
+       g_nm_daemon->is_telephony_enabled = appeared;
+}
+
+static void __wfd_manager_watching_cb(gboolean appeared)
+{
+       NM_LOGI("wfd_manager is %s", appeared?"Enabled":"Disabled");
+       g_nm_daemon->is_wfd_manager_enabled = appeared;
+}
+
+static void __mobileap_watching_cb(gboolean appeared)
+{
+       NM_LOGI("mobileap is %s", appeared?"Enabled":"Disabled");
+       g_nm_daemon->is_mobileap_enabled = appeared;
+}
+
+static void __stc_manager_watching_cb(gboolean appeared)
+{
+       NM_LOGI("stc_manager is %s", appeared?"Enabled":"Disabled");
+       g_nm_daemon->is_stc_manager_enabled = appeared;
+}
+
+static inline void __set_watching_dbus_cbs()
+{
+       nm_gdbus_set_wpasupplicant_bus_watching_callback(__wpasupplicant_watching_cb);
+       nm_gdbus_set_connman_bus_watching_callback(__connman_watching_cb);
+       nm_gdbus_set_telephony_bus_watching_callback(__telephony_watching_cb);
+       nm_gdbus_set_wfd_manager_bus_watching_callback(__wfd_manager_watching_cb);
+       nm_gdbus_set_mobileap_bus_watching_callback(__mobileap_watching_cb);
+       nm_gdbus_set_stc_manager_bus_watching_callback(__stc_manager_watching_cb);
+}
+
+static inline void __unset_watching_dbus_cbs()
+{
+       nm_gdbus_unset_wpasupplicant_bus_watching_callback();
+       nm_gdbus_unset_connman_bus_watching_callback();
+       nm_gdbus_unset_telephony_bus_watching_callback();
+       nm_gdbus_unset_wfd_manager_bus_watching_callback();
+       nm_gdbus_unset_mobileap_bus_watching_callback();
+       nm_gdbus_unset_stc_manager_bus_watching_callback();
+}
+
+static void __gdbus_name_aquired()
+{
+       __NM_FUNC_ENTER__;
+       gboolean enabled = FALSE;
+
+       if (nm_gdbus_is_wpasupplicant_enabled(&enabled) == 0) {
+               g_nm_daemon->is_wpasupplicant_enabled  = TRUE;
+               nm_supplicant_get_properties();
+       } else
+               NM_LOGI("wpsupplicant is not enabled");
+
+       if (nm_gdbus_is_connman_enabled(&enabled) == 0) {
+               g_nm_daemon->is_connman_enabled  = TRUE;
+               nm_connman_mgr_get_properties();
+               nm_connman_mgr_get_technologies();
+               nm_connman_mgr_get_services();
+       }
+       else
+               NM_LOGI("connman is not enabled");
+
+       if (nm_gdbus_is_telephony_enabled(&enabled) == 0)
+               g_nm_daemon->is_telephony_enabled  = TRUE;
+       else
+               NM_LOGI("telephony is not enabled");
+
+       if (nm_gdbus_is_wfd_manager_enabled(&enabled) == 0)
+               g_nm_daemon->is_wfd_manager_enabled  = TRUE;
+       else
+               NM_LOGI("wfd_manager is not enabled");
+
+       if (nm_gdbus_is_mobileap_enabled(&enabled) == 0)
+               g_nm_daemon->is_mobileap_enabled  = TRUE;
+       else
+               NM_LOGI("mobileap is not enabled");
+
+       if (nm_gdbus_is_stc_manager_enabled(&enabled) == 0)
+               g_nm_daemon->is_stc_manager_enabled  = TRUE;
+       else
+               NM_LOGI("stc_manager is not enabled");
+
+       if (nm_gdbus_register_daemon_iface() < 0) {
+               g_main_loop_quit(g_nm_daemon->loop);
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       if (nm_gdbus_register_wifi_iface() < 0) {
+               g_main_loop_quit(g_nm_daemon->loop);
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       __NM_FUNC_EXIT__;
+}
+
+static void __gdbus_name_lost()
+{
+       __NM_FUNC_ENTER__;
+       g_main_loop_quit(g_nm_daemon->loop);
+       __NM_FUNC_EXIT__;
+}
+
+int nm_daemon_init()
+{
+       int ret = 0;
+       __NM_FUNC_ENTER__;
+       g_nm_daemon = g_try_malloc0(sizeof(nm_daemon_s));
+       if (!g_nm_daemon) {
+               NM_LOGI("Failed to allocate memory for daemon");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       NM_LOGI("Initialize DBus related");
+       nm_error_register();
+
+       ret = nm_gdbus_init(__gdbus_name_aquired, __gdbus_name_lost);
+       if (ret != 0) {
+               NM_LOGI("Failed to initialize gdbus");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       __set_watching_dbus_cbs();
+       __init_supplicant();
+       __init_connman();
+
+       NM_LOGI("Initialize others");
+       nm_dump_init();
+       __init_ip_conflict_detect();
+       __init_iface_monitor();
+       __init_retry_tx_rate_monitor();
+       __init_channel_interference_monitor();
+       __init_congestion_mon();
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_daemon_deinit()
+{
+       int ret = 0;
+       __NM_FUNC_ENTER__;
+
+       NM_LOGI("denitialize DBus related");
+       __unset_watching_dbus_cbs();
+       __deinit_connman();
+       __deinit_supplicant();
+       nm_error_deregister();
+       nm_gdbus_deinit();
+
+       NM_LOGI("Denitialize others");
+       nm_dump_deinit();
+       __deinit_ip_conflict_detect();
+       __deinit_iface_monitor();
+       __deinit_retry_tx_rate_monitor();
+       __deinit_channel_interference_monitor();
+       __deinit_congestion_mon();
+
+
+       g_free(g_nm_daemon);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-dump.c b/src/inm-dump.c
new file mode 100644 (file)
index 0000000..2f5e10d
--- /dev/null
@@ -0,0 +1,276 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for dump.
+ *
+ * @file        nm-dump.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <glib.h>
+
+#include "inm-daemon-log.h"
+#include "inm-dump.h"
+#include "inm-util.h"
+
+//#define NETWORK_DUMP_SCRIPT  "/opt/var/lib/net-config/network_dump.sh"
+#define NETWORK_DUMP_SCRIPT  "/usr/bin/network_dump.sh"
+#define TCP_DUMP_IN_BOOT_TIME "/opt/usr/data/tcp_dump_mode"
+#define NETWORK_LOG_PATH "/opt/usr/data/network"
+#define KILLALL_EXEC_PATH "/usr/bin/killall"
+#define TCPDUMP_EXEC_PATH "/usr/sbin/tcpdump"
+
+typedef struct {
+       gboolean is_initialized;
+       gboolean is_tcpdump_running;
+} dump_mon_s;
+
+dump_mon_s dump_mon;
+
+
+static gboolean __get_dump_state(void)
+{
+       int ret = access(TCP_DUMP_IN_BOOT_TIME, F_OK);
+       if (ret != 0) {
+               NM_LOGI("Dumpstate Get Failed (%d).", ret);
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+static int __start_dump(gchar *dump_path)
+{
+       int rv = 0;
+       gchar *path = NETWORK_DUMP_SCRIPT;
+       char *const args[] = { NETWORK_DUMP_SCRIPT, dump_path, NULL };
+       char *const envs[] = { NULL };
+
+       rv = nm_execute_file(path, args, envs);
+       if (rv < 0) {
+               NM_LOGI("Fail to execute network log dump shell");
+               return -EIO;
+       }
+       return 0;
+}
+
+static gboolean __stop_tcpdump(void)
+{
+       int ret;
+       const char *path = KILLALL_EXEC_PATH;
+       char *const args[] = { KILLALL_EXEC_PATH, "tcpdump", NULL };
+       char *const envs[] = { NULL };
+
+       if (!dump_mon.is_tcpdump_running) {
+               NM_LOGI("tcpdump is not running");
+               return FALSE;
+       }
+
+       ret = nm_execute_file(path, args, envs);
+       if (ret < 0) {
+               NM_LOGI("Failed to Kill tcpdump, ret : %d\n", ret);
+               return FALSE;
+       }
+
+       dump_mon.is_tcpdump_running = FALSE;
+
+       return TRUE;
+}
+
+static gboolean __start_tcpdump(void)
+{
+       int ret;
+       const char *start_path = TCPDUMP_EXEC_PATH;
+       char filename[128] = { 0, };
+       gchar current_time_str[TIME_STR_LEN] = {0, };
+
+
+       get_current_time(current_time_str);
+       g_snprintf(filename,
+                       TIME_STR_LEN,
+                       "%s/tcpdump-%s.pcap",
+                       NETWORK_LOG_PATH,
+                       current_time_str);
+       char *const start_args[] = { TCPDUMP_EXEC_PATH,
+                       "-W", "5", "-C", "50", "-i", "any", "-s", "0", "-w", filename, NULL};
+
+       ret = nm_execute_file_no_wait(start_path, start_args);
+       if (ret < 0) {
+               NM_LOGI("Failed to start tcpdump, ret : %d", ret);
+               return FALSE;
+       }
+
+       dump_mon.is_tcpdump_running = TRUE;
+
+       return dump_mon.is_tcpdump_running;
+}
+
+int nm_dump_start_tcpdump()
+{
+       int ret = NM_DUMP_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!dump_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_DUMP_NOT_INITIALIZED;
+       }
+
+       if (dump_mon.is_tcpdump_running) {
+               __NM_FUNC_EXIT__;
+               return NM_DUMP_IN_PROGRESS;
+       }
+
+       if (!__start_tcpdump()) {
+               return NM_DUMP_OPERATION_FAILED;
+       }
+
+       NM_LOGI("Successfully started tcpdump and running..");
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_dump_stop_tcpdump()
+{
+       int ret = NM_DUMP_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!dump_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_DUMP_NOT_INITIALIZED;
+       }
+
+       if (!dump_mon.is_tcpdump_running) {
+               NM_LOGI("tcpdump not running");
+               return ret;
+       }
+
+       if (!__stop_tcpdump())
+               return NM_DUMP_OPERATION_FAILED;
+
+       NM_LOGI("Successfully stopped tcpdump");
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_dump_get_tcpdump_state(gboolean *is_running)
+{
+       int ret = NM_DUMP_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!dump_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_DUMP_NOT_INITIALIZED;
+       }
+
+       if (!is_running) {
+               __NM_FUNC_EXIT__;
+               return NM_DUMP_INVALID_PARAMETER;
+       }
+
+       NM_LOGI("tcpdump %s running", dump_mon.is_tcpdump_running ? "is" : "is not");
+
+       *is_running = dump_mon.is_tcpdump_running;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_dump_log(gchar *dump_path)
+{
+       int ret = NM_DUMP_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!dump_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_DUMP_NOT_INITIALIZED;
+       }
+
+       NM_LOGI("Dump is started");
+
+       __start_dump(dump_path);
+       __stop_tcpdump();
+
+       NM_LOGI("Dump is finished");
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_dump_check_state_and_start()
+{
+       int ret = NM_DUMP_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!dump_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_DUMP_NOT_INITIALIZED;
+       }
+       if (!__get_dump_state())
+               return NM_DUMP_OPERATION_FAILED;
+
+       if (!__start_tcpdump()) {
+               NM_LOGI("Failed to start tcpdump");
+               return NM_DUMP_OPERATION_FAILED;
+       }
+       NM_LOGI("Successfully started tcpdump and running..");
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_dump_init()
+{
+       int ret = NM_DUMP_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       memset(&dump_mon, 0x00, sizeof(dump_mon));
+       dump_mon.is_initialized = TRUE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_dump_deinit()
+{
+       int ret = NM_DUMP_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!dump_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_DUMP_NOT_INITIALIZED;
+       }
+
+       if (dump_mon.is_tcpdump_running) {
+               NM_LOGI("tcpdump is running, shutdown");
+               __stop_tcpdump();
+       }
+
+       dump_mon.is_initialized = FALSE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-error.c b/src/inm-error.c
new file mode 100644 (file)
index 0000000..6a8fbb6
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for error.
+ *
+ * @file        nm-error.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "inm-daemon.h"
+#include "inm-daemon-log.h"
+#include "inm-error.h"
+#include "inm-util.h"
+
+
+#define NM_DAEMON_ERROR_QUARK g_quark_from_string("nm-daemon-error-quark")
+
+#define NM_ERR_STR_INVALID_PARAM "net.nmdaemon.Error.InvalidParameter"
+#define NM_ERR_STR_NOT_PERMITTED "net.nmdaemon.Error.NotPermitted"
+#define NM_ERR_STR_OUT_OF_MEMORY "net.nmdaemon.Error.OutOfMemory"
+#define NM_ERR_STR_OP_FAILED "net.nmdaemon.Error.OperationFailed"
+#define NM_ERR_STR_IN_PROGRESS "net.nmdaemon.Error.InProgress"
+
+//LCOV_EXCL_START
+static void nm_error_invalid_parameter(GError **error)
+{
+       *error = g_dbus_error_new_for_dbus_error(
+                       NM_ERR_STR_INVALID_PARAM,
+                       NM_ERR_STR_INVALID_PARAM);
+}
+
+static void nm_error_not_permitted(GError **error)
+{
+       *error = g_dbus_error_new_for_dbus_error(
+                       NM_ERR_STR_NOT_PERMITTED,
+                       NM_ERR_STR_NOT_PERMITTED);
+}
+
+static void nm_error_out_of_memory(GError **error)
+{
+       *error = g_dbus_error_new_for_dbus_error(
+                       NM_ERR_STR_OUT_OF_MEMORY,
+                       NM_ERR_STR_OUT_OF_MEMORY);
+}
+
+static void nm_error_operation_failed(GError **error)
+{
+       *error = g_dbus_error_new_for_dbus_error(
+                       NM_ERR_STR_OP_FAILED,
+                       NM_ERR_STR_OP_FAILED);
+}
+
+static void nm_error_in_progress(GError **error)
+{
+       *error = g_dbus_error_new_for_dbus_error(
+                       NM_ERR_STR_IN_PROGRESS,
+                       NM_ERR_STR_IN_PROGRESS);
+}
+
+
+void nm_error_set_gerror(nm_daemon_error_e error_code, GError **error)
+{
+       switch (error_code) {
+       case NM_DAEMON_ERROR_INVALID_PARAM:
+               nm_error_invalid_parameter(error);
+               break;
+       case NM_DAEMON_ERROR_NOT_PERMITTED:
+               nm_error_not_permitted(error);
+               break;
+       case NM_DAEMON_ERROR_OUT_OF_MEMORY:
+               nm_error_out_of_memory(error);
+               break;
+       case NM_DAEMON_ERROR_OPERATION_FAILED:
+               nm_error_operation_failed(error);
+               break;
+       case NM_DAEMON_ERROR_IN_PROGRESS:
+               nm_error_in_progress(error);
+               break;
+       default:
+               NM_LOGI("Error Not handled [%d]", error_code);
+               nm_error_operation_failed(error);
+       }
+}
+void nm_error_register(void)
+{
+       g_dbus_error_register_error(NM_DAEMON_ERROR_QUARK,
+                       NM_DAEMON_ERROR_INVALID_PARAM,
+                       NM_ERR_STR_INVALID_PARAM);
+
+       g_dbus_error_register_error(NM_DAEMON_ERROR_QUARK,
+                       NM_DAEMON_ERROR_NOT_PERMITTED,
+                       NM_ERR_STR_NOT_PERMITTED);
+
+       g_dbus_error_register_error(NM_DAEMON_ERROR_QUARK,
+                       NM_DAEMON_ERROR_OUT_OF_MEMORY,
+                       NM_ERR_STR_OUT_OF_MEMORY);
+
+       g_dbus_error_register_error(NM_DAEMON_ERROR_QUARK,
+                       NM_DAEMON_ERROR_OPERATION_FAILED,
+                       NM_ERR_STR_OP_FAILED);
+
+       g_dbus_error_register_error(NM_DAEMON_ERROR_QUARK,
+                       NM_DAEMON_ERROR_IN_PROGRESS,
+                       NM_ERR_STR_IN_PROGRESS);
+
+}
+
+void nm_error_deregister(void)
+{
+       g_dbus_error_unregister_error(NM_DAEMON_ERROR_QUARK,
+                       NM_DAEMON_ERROR_INVALID_PARAM,
+                       NM_ERR_STR_INVALID_PARAM);
+
+
+       g_dbus_error_unregister_error(NM_DAEMON_ERROR_QUARK,
+                       NM_DAEMON_ERROR_NOT_PERMITTED,
+                       NM_ERR_STR_NOT_PERMITTED);
+
+
+       g_dbus_error_unregister_error(NM_DAEMON_ERROR_QUARK,
+                       NM_DAEMON_ERROR_OUT_OF_MEMORY,
+                       NM_ERR_STR_OUT_OF_MEMORY);
+
+       g_dbus_error_unregister_error(NM_DAEMON_ERROR_QUARK,
+                       NM_DAEMON_ERROR_OPERATION_FAILED,
+                       NM_ERR_STR_OP_FAILED);
+
+       g_dbus_error_unregister_error(NM_DAEMON_ERROR_QUARK,
+                       NM_DAEMON_ERROR_IN_PROGRESS,
+                       NM_ERR_STR_IN_PROGRESS);
+
+}
+//LCOV_EXCL_STOP
diff --git a/src/inm-gdbus.c b/src/inm-gdbus.c
new file mode 100644 (file)
index 0000000..5d3ddb9
--- /dev/null
@@ -0,0 +1,2228 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implement functions for operating GDBus.
+ *
+ * @file        nm-gdbus.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "inm-connman.h"
+#include "inm-daemon.h"
+#include "inm-daemon-log.h"
+#include "inm-error.h"
+#include "inm-gdbus.h"
+
+#define NM_WIFI_SERVICE NM_DAEMON_SERVICE ".wifi"
+#define NM_WIFI_IFACE NM_DAEMON_SERVICE ".wifi"
+#define NM_WIFI_OBJ NM_DAEMON_OBJ "/wifi"
+
+#define DBUS_STD_SERVICE "org.freedesktop.DBus"
+#define DBUS_STD_INTERFACE "org.freedesktop.DBus"
+#define DBUS_STD_PATH "/org/freedesktop/DBus"
+#define DBUS_STD_PROP DBUS_STD_SERVICE ".Properties"
+#define DBUS_STD_PROP_CHANGED "PropertiesChanged"
+
+#define DBUS_STD_PEER_IFACE "org.freedesktop.DBus.Peer"
+#define DBUS_STC_PEER_IFACE_PING "Ping"
+#define DBUS_ERROR_STR_NO_OWNER "GDBus.Error:org.freedesktop.DBus.Error.NameHasNoOwner"
+
+#define WPASUPPLICANT_BUS_NAME "fi.w1.wpa_supplicant1"
+#define CONNMAN_BUS_NAME "net.connman"
+#define TELEPHONY_BUS_NAME "com.tcore.ps"
+#define WFD_MANAGER_BUS_NAME "net.wifidirect"
+#define MOBILEAP_BUS_NAME "org.tizen.MobileapAgent"
+#define STC_MANAGER_BUS_NAME "net.stc"
+
+#define WPASUPPLICANT_OBJ "/fi/w1/wpa_supplicant1"
+#define CONNMAN_OBJ "/net/connman"
+#define TELEPHONY_OBJ "/com/tcore/ps"
+#define WFD_MANAGER_OBJ "/net/wifidirect"
+#define MOBILEAP_OBJ "/org/tizen/MobileapAgent"
+#define STC_MANAGER_OBJ "/net/stc"
+
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+
+#define DEBUG_G_VARIANT(str, parameters)\
+       do {\
+               gchar *parameters_debug_str = NULL;\
+               if (parameters)\
+                       parameters_debug_str = g_variant_print(parameters, TRUE);\
+               NM_LOGI("%s[%s]", str, parameters_debug_str ? parameters_debug_str : "NULL");\
+               g_free(parameters_debug_str);\
+       } while (0)
+
+#define DEBUG_SIGNAL(sender_name, object_path, interface_name, signal_name, parameters)\
+       do {\
+               NM_LOGI("signal sender name [%s]", sender_name);\
+               NM_LOGI("signal object path [%s]", object_path);\
+               NM_LOGI("signal interface name [%s]", interface_name);\
+               NM_LOGI("signal signal name [%s]", signal_name);\
+               DEBUG_G_VARIANT("signal params ", parameters);\
+               NM_LOGI("signal params type [%s]", g_variant_get_type_string(parameters));\
+       } while (0)
+
+typedef struct {
+       GDBusConnection *conn;
+       GDBusNodeInfo *daemon_introspection;
+       GDBusNodeInfo *wifi_introspection;
+       GDBusNodeInfo *conn_introspection;
+
+       guint daemon_obj_id;
+       guint wifi_obj_id;
+       nm_gdbus_watching_bus_callback wpasupplicant_watching_cb;
+       guint wpasupplicant_watching_id;
+       nm_gdbus_watching_bus_callback connman_watching_cb;
+       guint connman_watching_id;
+       nm_gdbus_watching_bus_callback telephony_watching_cb;
+       guint telephony_watching_id;
+       nm_gdbus_watching_bus_callback wfd_manager_watching_cb;
+       guint wfd_manager_watching_id;
+       nm_gdbus_watching_bus_callback mobileap_watching_cb;
+       guint mobileap_watching_id;
+       nm_gdbus_watching_bus_callback stc_manager_watching_cb;
+       guint stc_manager_watching_id;
+
+       bus_aquired_callback bus_acquired_cb;
+       name_lost_callback name_lost_cb;
+
+       gboolean is_initialized;
+       gboolean is_bus_aquired;
+       guint owner_id;
+
+} gdbus_mon_s;
+
+typedef enum {
+       UNKNOWN,
+       POWER_OFF,
+       POWER_ON,
+       CONNECTED,
+} tech_state_e;
+
+static const gchar nm_daemon_introspection_xml[] = {
+               "<node>"
+               "<interface name='net.nm_damon'>"
+               "<method name='GetStatistics'>"
+               "<arg type='i' name='connection_type' direction='in'/>"
+               "<arg type='i' name='statistics_type' direction='in'/>"
+               "<arg type='t' name='val' direction='out'/>"
+               "</method>"
+               "<method name='ResetStatistics'>"
+               "<arg type='i' name='connection_type' direction='in'/>"
+               "<arg type='i' name='statistics_type' direction='in'/>"
+               "</method>"
+               "<method name='GetCurrentConnection'>"
+               "<arg type='o' name='object_path' direction='out'/>"
+               "<arg type='a{sv}' name='connection' direction='out'/>"
+               "</method>"
+               "<method name='GetConnections'>"
+               "<arg type='a(oa{sv})' name='connections' direction='out'/>"
+               "</method>"
+               "<property type='b' name='EthernetCableState' access='read'/>"
+               "<property type='b' name='WifiModuleState' access='read'/>"
+               "<property type='b' name='IpConflictState' access='read'/>"
+               "<property type='b' name='IpConflictDetect' access='readwrite'/>"
+               "<property type='b' name='TcpdumpState' access='readwrite'/>"
+               "<property type='i' name='CellularState' access='read'/>"
+               "<property type='i' name='WifiState' access='read'/>"
+               "<property type='i' name='EthernetState' access='read'/>"
+               "<property type='i' name='CongestionLevel' access='read'/>"
+               "<property type='i' name='RetryTxRate' access='read'/>"
+               "<property type='d' name='ChannelInterference' access='read'/>"
+/* Test purpose --> */
+               "<property type='b' name='WritingAlwaysThrowsError' access='readwrite'/>"
+               "<property type='b' name='ReadingAlwaysThrowsError' access='read'/>"
+/* <-- Test purpose */
+               "<signal name='IpConflicted'>"
+               "</signal>"
+               "<signal name='ConnectionsChanged'>"
+               "<arg type='aoao' name='connections'/>"
+               "</signal>"
+               "</interface>"
+               "</node>"
+};
+
+static const gchar nm_wifi_introspection_xml[] = {
+       "<node>"
+               "<interface name='net.nm_damon.wifi'>"
+                       "<method name='GetConnectedAp'>"
+                               "<arg type='a{sv}' name='ap' direction='out'/>"
+                       "</method>"
+                       "<method name='GetFoundAps'>"
+                               "<arg type='a(oa{sv})' name='connections' direction='out'/>"
+                       "</method>"
+                       "<property type='b' name='ScanState' access='read'/>"
+/* Test purpose --> */
+                       "<property type='b' name='WritingAlwaysThrowsError' access='readwrite'/>"
+                       "<property type='b' name='ReadingAlwaysThrowsError' access='read'/>"
+/* <-- Test purpose */
+               "</interface>"
+       "</node>"
+};
+
+
+static const gchar nm_conn_introspection_xml[] = {
+       "<node>"
+               "<interface name='net.nm_damon.conn'>"
+                       "<method name='GetAll'>"
+                       "<arg type='a{sv}' name='connection' direction='out'/>"
+                       "</method>"
+                       "<property type='s' name='Id' access='read'/>"
+                       "<property type='s' name='Name' access='read'/>"
+                       "<property type='s' name='Type' access='read'/>"
+                       "<property type='s' name='IfaceName' access='read'/>"
+                       "<property type='s' name='Ipv4State' access='read'/>"
+                       "<property type='s' name='Ipv6State' access='read'/>"
+                       "<property type='a{sv}' name='Ip' access='read'/>"
+                       "<property type='a{sv}' name='Dns' access='read'/>"
+                       "<property type='s' name='Essid' access='read'/>"
+                       "<property type='s' name='RawSsid' access='read'/>"
+                       "<property type='s' name='Bssid' access='read'/>"
+                       "<property type='i' name='Rssi' access='read'/>"
+                       "<property type='i' name='Frequency' access='read'/>"
+                       "<property type='i' name='MaxSpeed' access='read'/>"
+                       "<property type='b' name='Favorite' access='read'/>"
+                       "<property type='b' name='Passpoint' access='read'/>"
+                       "<property type='s' name='SecurityType' access='read'/>"
+                       "<property type='s' name='EncryptionType' access='read'/>"
+                       "<property type='b' name='PassphraseRequired' access='read'/>"
+                       "<property type='b' name='WpsSupported' access='read'/>"
+                       "<property type='s' name='EapPassphrase' access='read'/>"
+                       "<property type='s' name='EapCaCert' access='read'/>"
+                       "<property type='s' name='EapClientCert' access='read'/>"
+                       "<property type='s' name='EapPrivateKey' access='read'/>"
+                       "<property type='s' name='EapType' access='read'/>"
+                       "<property type='s' name='EapAuthType' access='read'/>"
+                       "<property type='s' name='DisconnectReason' access='read'/>"
+                       "<property type='s' name='AssocStatus' access='read'/>"
+                       "<property type='s' name='Vsie' access='read'/>"
+/* Test purpose --> */
+                       "<property type='b' name='WritingAlwaysThrowsError' access='readwrite'/>"
+                       "<property type='b' name='ReadingAlwaysThrowsError' access='read'/>"
+/* <-- Test purpose */
+               "</interface>"
+       "</node>"
+};
+
+gdbus_mon_s gdbus_mon;
+
+GDBusConnection *nm_gdbus_get_connection(void)
+{
+       return gdbus_mon.conn;
+}
+
+gboolean nm_gdbus_emit_signal(const gchar *destination_bus_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *params)
+{
+       gboolean rv = FALSE;
+       GError *error = NULL;
+       GDBusConnection *connection;
+
+       connection = nm_gdbus_get_connection();
+       if (connection == NULL) {
+               NM_LOGE("[NET_DBUS] GDBusconnection is NULL");
+               return 0;
+       }
+
+       rv = g_dbus_connection_emit_signal(connection, destination_bus_name,
+               object_path, interface_name, signal_name, params, &error);
+       if (rv != TRUE) {
+               NM_LOGE("[NET_DBUS] Failed to emit signal, Error: %s", error->message);
+               g_clear_error(&error);
+               return rv;
+       }
+
+       NM_LOGE("Sent signal (%s), Interface (%s)", signal_name, interface_name);
+
+       return rv;
+}
+
+static void __gdbus_signal_callback(GDBusConnection *connection,
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       signal_param_s *param = (signal_param_s *)user_data;
+       DEBUG_SIGNAL(sender_name, object_path, interface_name, signal_name, parameters);
+
+       if (param->callback)
+               param->callback(sender_name, object_path, interface_name, signal_name, parameters, user_data);
+
+       return;
+}
+
+int nm_gdbus_method_call(method_param_s *params,
+               handle_reply function, void *user_data)
+{
+       GVariant *reply = NULL;
+       GError *error = NULL;
+
+       if (!gdbus_mon.is_initialized)
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+
+       if (!params || !params->bus_name || !params->object_path)
+               return NM_GDBUS_ERROR_INVALID_PARAM;
+
+       NM_LOGI("method [%s]", params->method_name);
+
+       reply = g_dbus_connection_call_sync(
+                       gdbus_mon.conn,
+                       params->bus_name, /* bus name */
+                       params->object_path, /* object path */
+                       params->interface_name, /* interface name */
+                       params->method_name, /* method name */
+                       params->parameters, /* GVariant *params */
+                       NULL, /* reply_type */
+                       G_DBUS_CALL_FLAGS_NONE, /* flags */
+                       DBUS_REPLY_TIMEOUT , /* timeout */
+                       NULL, /* cancellable */
+                       &error); /* error */
+
+       if (error != NULL) {
+               NM_LOGI("Error! Failed to call method: [%s]", error->message);
+               g_error_free(error);
+               if (reply)
+                       g_variant_unref(reply);
+               return -1;
+       }
+
+       if (reply != NULL) {
+               DEBUG_G_VARIANT("Reply : ", reply);
+
+               if (function)
+                       function(reply, user_data);
+               g_variant_unref(reply);
+       } else {
+               NM_LOGI("reply is NULL");
+       }
+
+       return 0;
+}
+
+int nm_gdbus_subscribe_signal(signal_param_s *param)
+{
+       gint ret = NM_GDBUS_ERROR_NONE;
+
+
+       if (!gdbus_mon.is_initialized)
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+
+       if (!param || !param->sender || !param->interface_name)
+               return NM_GDBUS_ERROR_INVALID_PARAM;
+
+       param->subscriber_id =
+                       g_dbus_connection_signal_subscribe(
+                                       gdbus_mon.conn,
+                                       param->sender,
+                                       param->interface_name,
+                                       param->member,
+                                       param->object_path,
+                                       param->arg0,
+                                       G_DBUS_SIGNAL_FLAGS_NONE,
+                                       __gdbus_signal_callback,
+                                       param,
+                                       NULL);
+
+       if (param->subscriber_id == 0)
+               return NM_GDBUS_ERROR_OPERATION_FAILED;
+
+       return ret;
+}
+
+
+int nm_gdbus_subscribe_signal_with_data(signal_param_s *param, gpointer user_data)
+{
+       gint ret = NM_GDBUS_ERROR_NONE;
+
+       __NM_FUNC_ENTER__;
+
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!param || !param->sender || !param->interface_name) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_INVALID_PARAM;
+       }
+
+       param->subscriber_id =
+                       g_dbus_connection_signal_subscribe(
+                                       gdbus_mon.conn,
+                                       param->sender,
+                                       param->interface_name,
+                                       param->member,
+                                       param->object_path,
+                                       param->arg0,
+                                       G_DBUS_SIGNAL_FLAGS_NONE,
+                                       (GDBusSignalCallback)param->callback_with_data,
+                                       user_data,
+                                       NULL);
+
+       if (param->subscriber_id == 0) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_OPERATION_FAILED;
+       }
+
+       __NM_FUNC_EXIT__;
+       return ret;
+
+}
+
+int nm_gdbus_unsubscribe_signal(signal_param_s *param)
+{
+       gint ret = NM_GDBUS_ERROR_NONE;
+
+       __NM_FUNC_ENTER__;
+
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!param || !param->sender || !param->interface_name) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_INVALID_PARAM;
+       }
+
+       g_dbus_connection_signal_unsubscribe(
+                       gdbus_mon.conn,
+                       param->subscriber_id
+                       );
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+void __dbus_return_err(int ret, GDBusMethodInvocation *invocation)
+{
+       GError *err = NULL;
+       gchar* dbus_error_name = NULL;
+
+       if (!invocation)
+               return;
+
+       nm_error_set_gerror(ret, &err);
+       dbus_error_name = g_dbus_error_encode_gerror(err);
+       NM_LOGI("g_dbus_method_invocation_return_gerror with [%s]", dbus_error_name);
+       g_free(dbus_error_name);
+       g_dbus_method_invocation_return_gerror(invocation, err);
+       g_clear_error(&err);
+       return;
+}
+
+static void inline __handle_get_statistics(GVariant *parameters,
+                                          GDBusMethodInvocation *invocation)
+{
+       int connection_type = 0;
+       int statistics_type = 0;
+
+       __NM_FUNC_ENTER__;
+       g_variant_get(parameters, "(ii)", &connection_type, &statistics_type);
+
+       /* TODO get real statistics */
+
+       g_dbus_method_invocation_return_value(invocation, g_variant_new("(t)", 1000));
+       __NM_FUNC_EXIT__;
+}
+
+static void inline __handle_reset_statistics(GVariant *parameters,
+                                            GDBusMethodInvocation *invocation)
+{
+       int connection_type = 0;
+       int statistics_type = 0;
+
+       __NM_FUNC_ENTER__;
+       g_variant_get(parameters, "(ii)", &connection_type, &statistics_type);
+
+       /* TODO reset real statistics */
+
+       g_dbus_method_invocation_return_value(invocation, NULL);
+       __NM_FUNC_EXIT__;
+}
+
+static void inline __handle_get_current_connection(GVariant *parameters,
+                                                  GDBusMethodInvocation *invocation)
+{
+       GVariant *arg = NULL;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_connman_get_current_connection(&arg);
+       if (ret != NM_DAEMON_ERROR_NONE) {
+               NM_LOGI("Failed to get current connection");
+               __dbus_return_err(NM_DAEMON_ERROR_OPERATION_FAILED, invocation);
+               __NM_FUNC_EXIT__;
+               return;
+       }
+       DEBUG_G_VARIANT("ret: ", arg);
+       g_dbus_method_invocation_return_value(invocation, arg);
+       __NM_FUNC_EXIT__;
+}
+
+static void inline __handle_get_connections(GVariant *parameters,
+                                           GDBusMethodInvocation *invocation)
+{
+       GVariant *arg = NULL;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_connman_get_connections(&arg);
+       if (ret != NM_DAEMON_ERROR_NONE) {
+               NM_LOGI("Failed to get connections");
+               __dbus_return_err(NM_DAEMON_ERROR_OPERATION_FAILED, invocation);
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       g_dbus_method_invocation_return_value(invocation, arg);
+       __NM_FUNC_EXIT__;
+}
+
+static void __daemon_method_call(GDBusConnection *connection,
+                                 const gchar *sender,
+                                 const gchar *object_path,
+                                 const gchar *interface_name,
+                                 const gchar *method_name,
+                                 GVariant *parameters,
+                                 GDBusMethodInvocation *invocation,
+                                 gpointer user_data)
+{
+       if (g_strcmp0(method_name, "GetStatistics") == 0)
+               __handle_get_statistics(parameters, invocation);
+       else if (g_strcmp0(method_name, "ResetStatistics") == 0)
+               __handle_reset_statistics(parameters, invocation);
+       else if (g_strcmp0(method_name, "GetCurrentConnection") == 0)
+               __handle_get_current_connection(parameters, invocation);
+       else if (g_strcmp0(method_name, "GetConnections") == 0)
+               __handle_get_connections(parameters, invocation);
+}
+
+static inline GVariant *__get_tcpdump_state(const gchar *sender,GError **error)
+{
+       gboolean state = FALSE;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_tcpdump_state(&state);
+       if (ret != NM_DAEMON_ERROR_NONE) {
+               NM_LOGI("Failed to get");
+               nm_error_set_gerror(ret, error);
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_boolean(state);
+}
+
+static inline GVariant *__get_ip_conflict_state(const gchar *sender,GError **error)
+{
+       gboolean state = FALSE;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_ip_conflict_detect(&state);
+       if (ret < 0) {
+               NM_LOGI("Failed to get");
+               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_boolean(state);
+}
+
+static inline GVariant *__get_ip_conflict_detect(const gchar *sender,GError **error)
+{
+       gboolean detect = FALSE;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_ip_conflict_detect(&detect);
+       if (ret < 0) {
+               NM_LOGI("Failed to get");
+               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_boolean(detect);
+}
+
+static inline GVariant *__get_ethernet_cable_state(const gchar *sender,GError **error)
+{
+       gboolean state = FALSE;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_ethernet_cable_state(&state);
+       if (ret < 0) {
+               NM_LOGI("Failed to get");
+               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_boolean(state);
+}
+
+static inline GVariant *__get_wifi_module_state(const gchar *sender,GError **error)
+{
+       gboolean state = FALSE;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_wifi_module_state(&state);
+       if (ret < 0) {
+               NM_LOGI("Failed to get");
+               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_boolean(state);
+}
+
+static inline GVariant *__get_congestion_level(const gchar *sender,GError **error)
+{
+       int level = 0;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_congestion_level(&level);
+       if (ret < 0) {
+               NM_LOGI("Failed to get");
+               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_int32(level);
+}
+
+static inline GVariant *__get_retry_tx_rate(const gchar *sender,GError **error)
+{
+       int rate = 0;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_retry_tx_rate(&rate);
+       if (ret < 0) {
+               NM_LOGI("Failed to get");
+               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_int32(rate);
+}
+
+static inline GVariant *__get_channel_interference(const gchar *sender,GError **error)
+{
+       double ch_interference = 0.0;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_channel_interference(&ch_interference);
+       if (ret < 0) {
+               NM_LOGI("Failed to get channel_interference");
+               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_double(ch_interference);
+}
+
+static inline GVariant *__get_cellular_state(const gchar *sender,GError **error)
+{
+       int state = 0;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_cellular_state(&state);
+       if (ret < 0) {
+               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+               NM_LOGI("Failed to get");
+                       __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_int32(state);
+}
+
+static inline GVariant *__get_wifi_state(const gchar *sender,GError **error)
+{
+       int state = 0;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_wifi_state(&state);
+       if (ret < 0) {
+               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+               NM_LOGI("Failed to get");
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_int32(state);
+}
+
+static inline GVariant *__get_ethernet_state(const gchar *sender,GError **error)
+{
+       int state = FALSE;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_ethernet_state(&state);
+       if (ret < 0) {
+               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+               NM_LOGI("Failed to get");
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_int32(state);
+}
+
+static inline GVariant *__get_reading_error(const gchar *sender,GError **error)
+{
+       __NM_FUNC_ENTER__;
+       nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+       __NM_FUNC_EXIT__;
+       return NULL;
+}
+
+static GVariant *__daemon_get_property(GDBusConnection *connection,
+               const gchar *sender,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *property_name,
+               GError **error,
+               gpointer user_data)
+{
+       GVariant *ret = NULL;
+       ret = NULL;
+
+       if (g_strcmp0(property_name, "TcpdumpState") == 0)
+               ret = __get_tcpdump_state(sender, error);
+       else if (g_strcmp0(property_name, "IpConflictState") == 0)
+               ret = __get_ip_conflict_state(sender, error);
+       else if (g_strcmp0(property_name, "IpConflictDetect") == 0)
+               ret = __get_ip_conflict_detect(sender, error);
+       else if (g_strcmp0(property_name, "EthernetCableState") == 0)
+               ret = __get_ethernet_cable_state(sender, error);
+       else if (g_strcmp0(property_name, "WifiModuleState") == 0)
+               ret = __get_wifi_module_state(sender, error);
+       else if (g_strcmp0(property_name, "CongestionLevel") == 0)
+               ret = __get_congestion_level(sender, error);
+       else if (g_strcmp0(property_name, "RetryTxRate") == 0)
+               ret = __get_retry_tx_rate(sender, error);
+       else if (g_strcmp0(property_name, "ChannelInterference") == 0)
+               ret = __get_channel_interference(sender, error);
+       else if (g_strcmp0(property_name, "CellularState") == 0)
+               ret = __get_cellular_state(sender, error);
+       else if (g_strcmp0(property_name, "WifiState") == 0)
+               ret = __get_wifi_state(sender, error);
+       else if (g_strcmp0(property_name, "EthernetState") == 0)
+               ret = __get_ethernet_state(sender, error);
+       else if (g_strcmp0(property_name, "ReadingAlwaysThrowsError") == 0)
+               ret = __get_reading_error(sender, error);
+
+       return ret;
+}
+
+static inline void __set_tcpdump_state(const gchar *sender,
+                                      const gchar *object_path,
+                                      const gchar *interface_name,
+                                      GVariant *value,
+                                      GError **error)
+{
+       GVariantBuilder *builder = NULL;
+       GError *local_error = NULL;
+       int ret = NM_DAEMON_ERROR_NONE;
+
+       __NM_FUNC_ENTER__;
+       gboolean tcpdump_state = g_variant_get_boolean(value);
+
+       ret = nm_daemon_set_tcpdump(tcpdump_state);
+       if (ret != NM_DAEMON_ERROR_NONE) {
+               nm_error_set_gerror(ret, error);
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "TcpdumpState",
+                             g_variant_new_boolean(tcpdump_state));
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       object_path,
+                       NM_DAEMON_SERVICE,
+                       DBUS_STD_PROP_CHANGED,
+                       g_variant_new("(sa{sv}as)",
+                                       interface_name,
+                                       builder,
+                                       NULL),
+                       &local_error);
+
+       g_variant_builder_unref(builder);
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __set_writing_error(const gchar *sender,
+               const gchar *object_path,
+               const gchar *interface_name,
+               GVariant *value,
+               GError **error)
+{
+       __NM_FUNC_ENTER__;
+       nm_error_set_gerror(NM_DAEMON_ERROR_NOT_PERMITTED, error);
+       __NM_FUNC_EXIT__;
+}
+
+static gboolean __daemon_set_property(GDBusConnection *connection,
+               const gchar *sender,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *property_name,
+               GVariant *value,
+               GError **error,
+               gpointer user_data)
+{
+       if (g_strcmp0(property_name, "TcpdumpState") == 0)
+               __set_tcpdump_state(sender, object_path, interface_name, value, error);
+       else if (g_strcmp0(property_name, "WritingAlwaysThrowsError") == 0)
+               __set_writing_error(sender, object_path, interface_name, value, error);
+
+       return *error == NULL;
+}
+
+void nm_gdbus_emit_ip_conflicted(int state, gchar *if_name, gchar *ip)
+{
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariantBuilder *sub_builder = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       sub_builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(sub_builder, "{sv}", "Ifname", g_variant_new_string(if_name));
+       g_variant_builder_add(sub_builder, "{sv}", "Ip", g_variant_new_string(ip));
+       g_variant_builder_add(sub_builder, "{sv}", "State", g_variant_new_int32(state));
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                       "{sv}",
+                       "ConflictInfo",
+                       g_variant_builder_end(sub_builder));
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       NM_DAEMON_OBJ,
+                       NM_DAEMON_SERVICE,
+                       "IpConflicted",
+                       g_variant_new("(sa{sv}as)",
+                                       NM_DAEMON_SERVICE,
+                                       builder,
+                                       NULL),
+                                       &error);
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_ip_conflicted() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+       }
+
+       __NM_FUNC_EXIT__;
+}
+
+void nm_gdbus_emit_ethernet_cable_state(gboolean state)
+{
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "EthernetCableState",
+                                 g_variant_new_boolean(state));
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       NM_DAEMON_OBJ,
+                       NM_DAEMON_SERVICE,
+                       DBUS_STD_PROP_CHANGED,
+                       g_variant_new("(sa{sv}as)",
+                                       NM_DAEMON_SERVICE,
+                                       builder,
+                                       NULL),
+                                       &error);
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_ethernet_cable_state() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+       }
+
+       g_variant_builder_unref(builder);
+       __NM_FUNC_EXIT__;
+}
+
+void nm_gdbus_emit_wifi_module_state(gboolean state)
+{
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "WifiModuleState",
+                                 g_variant_new_boolean(state));
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       NM_DAEMON_OBJ,
+                       NM_DAEMON_SERVICE,
+                       DBUS_STD_PROP_CHANGED,
+                       g_variant_new("(sa{sv}as)",
+                                       NM_DAEMON_SERVICE,
+                                       builder,
+                                       NULL),
+                                       &error);
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_wifi_module_state() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+       }
+
+       g_variant_builder_unref(builder);
+       __NM_FUNC_EXIT__;
+}
+
+void nm_gdbus_emit_retry_tx_rate_changed(int retry_tx_rate)
+{
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "RetryTxRate",
+                                 g_variant_new_int32(retry_tx_rate));
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       NM_DAEMON_OBJ,
+                       NM_DAEMON_SERVICE,
+                       DBUS_STD_PROP_CHANGED,
+                       g_variant_new("(sa{sv}as)",
+                                       NM_DAEMON_SERVICE,
+                                       builder,
+                                       NULL),
+                                       &error);
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_retry_tx_rate_changed() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+       }
+
+       g_variant_builder_unref(builder);
+       __NM_FUNC_EXIT__;
+}
+
+void nm_gdbus_emit_channel_interference(int freq, double channel_intf)
+{
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariantBuilder *sub_builder = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+
+       sub_builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(sub_builder, "{sv}", "Frequency", g_variant_new_int32(freq));
+       g_variant_builder_add(sub_builder, "{sv}", "Interference", g_variant_new_double(channel_intf));
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "ChannelInterference",
+                               g_variant_builder_end(sub_builder));
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       NM_DAEMON_OBJ,
+                       NM_DAEMON_SERVICE,
+                       DBUS_STD_PROP_CHANGED,
+                       g_variant_new("(sa{sv}as)",
+                               NM_DAEMON_SERVICE,
+                               builder,
+                               NULL),
+                       &error);
+
+       g_variant_builder_unref(sub_builder);
+       g_variant_builder_unref(builder);
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_channel_interference() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+       }
+
+       __NM_FUNC_EXIT__;
+}
+
+void nm_gdbus_emit_congestion_level_changed(int congestion_level)
+{
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "CongestionLevel",
+                                 g_variant_new_int32(congestion_level));
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       NM_DAEMON_OBJ,
+                       NM_DAEMON_SERVICE,
+                       DBUS_STD_PROP_CHANGED,
+                       g_variant_new("(sa{sv}as)",
+                                       NM_DAEMON_SERVICE,
+                                       builder,
+                                       NULL),
+                                       &error);
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_congestion_level_changed() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+       }
+
+       g_variant_builder_unref(builder);
+       __NM_FUNC_EXIT__;
+}
+
+void nm_gdbus_emit_cellular_state(int state)
+{
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "CellularState",
+                                 g_variant_new_int32(state));
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       NM_DAEMON_OBJ,
+                       NM_DAEMON_SERVICE,
+                       DBUS_STD_PROP_CHANGED,
+                       g_variant_new("(sa{sv}as)",
+                                       NM_DAEMON_SERVICE,
+                                       builder,
+                                       NULL),
+                                       &error);
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_cellular_state() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+       }
+
+       g_variant_builder_unref(builder);
+       __NM_FUNC_EXIT__;
+}
+
+void nm_gdbus_emit_wifi_state(int state)
+{
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "WifiState",
+                                 g_variant_new_int32(state));
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       NM_DAEMON_OBJ,
+                       NM_DAEMON_SERVICE,
+                       DBUS_STD_PROP_CHANGED,
+                       g_variant_new("(sa{sv}as)",
+                                       NM_DAEMON_SERVICE,
+                                       builder,
+                                       NULL),
+                                       &error);
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_wifi_state() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+       }
+
+       g_variant_builder_unref(builder);
+       __NM_FUNC_EXIT__;
+}
+
+void nm_gdbus_emit_ethernet_state(int state)
+{
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "EthernetState",
+                                 g_variant_new_int32(state));
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       NM_DAEMON_OBJ,
+                       NM_DAEMON_SERVICE,
+                       DBUS_STD_PROP_CHANGED,
+                       g_variant_new("(sa{sv}as)",
+                                       NM_DAEMON_SERVICE,
+                                       builder,
+                                       NULL),
+                                       &error);
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_ethernet_state() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+       }
+
+       g_variant_builder_unref(builder);
+       __NM_FUNC_EXIT__;
+}
+
+void nm_gdbus_emit_connections_changed(GVariant *signal_args)
+{
+       GError *error = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       NM_DAEMON_OBJ,
+                       NM_DAEMON_SERVICE,
+                       "ConnectionsChanged",
+                       signal_args,
+                       &error);
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_connections_changed() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+       }
+
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __emit_conn_signal(const gchar *property,
+               gchar *path,
+               GVariant *signal_args)
+{
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                                 property,
+                                 signal_args);
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       path,
+                       NM_CONN_IFACE,
+                       DBUS_STD_PROP_CHANGED,
+                       g_variant_new("(sa{sv}as)",
+                                       NM_CONN_SERVICE,
+                                       builder,
+                                       NULL),
+                                       &error);
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_conn_%s failed. error [%d: %s]",
+                               property, error->code, error->message);
+               g_error_free(error);
+       }
+
+       g_variant_builder_unref(builder);
+       __NM_FUNC_EXIT__;
+
+}
+
+void nm_gdbus_emit_conn_ipv4_state_changed(gchar *path, GVariant *signal_args)
+{
+       __emit_conn_signal("Ipv4State", path, signal_args);
+}
+
+void nm_gdbus_emit_conn_ipv6_state_changed(gchar *path, GVariant *signal_args)
+{
+       __emit_conn_signal("Ipv6State", path, signal_args);
+}
+
+void nm_gdbus_emit_conn_ip_changed(gchar *path, GVariant *signal_args)
+{
+       __emit_conn_signal("Ip", path, signal_args);
+}
+
+void nm_gdbus_emit_conn_dns_changed(gchar *path, GVariant *signal_args)
+{
+       __emit_conn_signal("Dns", path, signal_args);
+}
+
+void nm_gdbus_emit_wifi_scanning_changed(gboolean scanning)
+{
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_bus_aquired) {
+               NM_LOGI("DBus is not acquired yet");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(builder,
+                             "{sv}",
+                             "ScanState",
+                                 g_variant_new_boolean(scanning));
+
+       g_dbus_connection_emit_signal(gdbus_mon.conn,
+                       NULL,
+                       NM_WIFI_OBJ,
+                       NM_WIFI_IFACE,
+                       DBUS_STD_PROP_CHANGED,
+                       g_variant_new("(sa{sv}as)",
+                                       NM_WIFI_IFACE,
+                                       builder,
+                                       NULL),
+                                       &error);
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_emit_wifi_scanning_changed() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+       }
+
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __handle_get_connected_ap(GVariant *parameters,
+               GDBusMethodInvocation *invocation)
+{
+       /* TODO get & return real Wi-Fi connected AP */
+}
+
+static inline void __handle_get_found_aps(GVariant *parameters,
+               GDBusMethodInvocation *invocation)
+{
+       /* TODO get real Wi-Fi Found AP */
+}
+
+static void __wifi_method_call(GDBusConnection *connection,
+               const gchar *sender,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *method_name,
+               GVariant *parameters,
+               GDBusMethodInvocation *invocation,
+               gpointer user_data)
+{
+       if (g_strcmp0(method_name, "GetConnectedAp") == 0)
+               __handle_get_connected_ap(parameters, invocation);
+       else if (g_strcmp0(method_name, "GetFoundAps") == 0)
+               __handle_get_found_aps(parameters, invocation);
+}
+
+static inline GVariant *__get_scan_state(const gchar *sender, GError **error)
+{
+       gboolean wifi_scan_state = FALSE;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_daemon_get_wifi_scan_state(&wifi_scan_state);
+       if (ret < 0) {
+               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
+               NM_LOGI("Failed to get");
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       __NM_FUNC_EXIT__;
+       return g_variant_new_boolean(wifi_scan_state);
+}
+
+static GVariant *__wifi_get_property(GDBusConnection *connection,
+               const gchar *sender,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *property_name,
+               GError **error,
+               gpointer user_data)
+{
+       GVariant *ret;
+       ret = NULL;
+
+       if (g_strcmp0(property_name, "ScanState") == 0)
+               ret = __get_scan_state(sender, error);
+       else if (g_strcmp0(property_name, "ReadingAlwaysThrowsError") == 0)
+               ret = __get_reading_error(sender, error);
+
+       return ret;
+}
+
+static gboolean __wifi_set_property(GDBusConnection *connection,
+                                      const gchar *sender,
+                                      const gchar *object_path,
+                                      const gchar *interface_name,
+                                      const gchar *property_name,
+                                      GVariant *value,
+                                      GError **error,
+                                      gpointer user_data)
+{
+       if (g_strcmp0(property_name, "WritingAlwaysThrowsError") == 0)
+               __set_writing_error(sender, object_path, interface_name, value, error);
+
+       return *error == NULL;
+}
+
+static inline void __handle_conn_get_all(gpointer user_data,
+               GVariant *parameters,
+               GDBusMethodInvocation *invocation)
+{
+       GVariant *arg = NULL;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_connman_get_connection(user_data, &arg);
+       if (ret != 0) {
+               NM_LOGI("Failed to get connection");
+               __dbus_return_err(NM_DAEMON_ERROR_OPERATION_FAILED, invocation);
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       g_dbus_method_invocation_return_value(invocation, arg);
+       __NM_FUNC_EXIT__;
+
+}
+
+static void __conn_method_call(GDBusConnection *connection,
+               const gchar *sender,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *method_name,
+               GVariant *parameters,
+               GDBusMethodInvocation *invocation,
+               gpointer user_data)
+{
+       if (g_strcmp0(method_name, "GetAll") == 0)
+               __handle_conn_get_all(user_data, parameters, invocation);
+}
+
+GDBusInterfaceVTable __daemon_iface_vtbl = {
+               __daemon_method_call,
+               __daemon_get_property,
+               __daemon_set_property};
+
+GDBusInterfaceVTable __wifi_iface_vtbl = {
+               __wifi_method_call,
+               __wifi_get_property,
+               __wifi_set_property};
+
+GDBusInterfaceVTable nm_conn_iface_vtbl = {
+               __conn_method_call,
+               NULL,
+               NULL};
+
+int nm_gdbus_register_conn_iface(gchar *conn_obj, guint *conn_obj_id, gpointer conn)
+{
+       GError *error = NULL;
+       guint obj_id = 0;
+
+       obj_id = g_dbus_connection_register_object(gdbus_mon.conn,
+                                                  conn_obj,
+                                                  gdbus_mon.conn_introspection->interfaces[0],
+                                                  &nm_conn_iface_vtbl,
+                                                  conn,
+                                                  NULL,
+                                                  &error);
+       if (obj_id == 0) {
+               NM_LOGI("register object failed!");
+               return -1;
+       }
+
+       if (error != NULL) {
+               NM_LOGI("nm_gdbus_register_conn_iface() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+               return -1;
+       }
+
+       NM_LOGI("register conn object");
+       *conn_obj_id = obj_id;
+
+       return 0;
+}
+
+void nm_gdbus_deregister_conn_iface(guint nm_conn_obj_id)
+{
+       g_dbus_connection_unregister_object(gdbus_mon.conn, nm_conn_obj_id);
+}
+
+int nm_gdbus_register_daemon_iface(void)
+{
+       GError *error = NULL;
+
+       __NM_FUNC_ENTER__;
+
+       gdbus_mon.daemon_obj_id = g_dbus_connection_register_object(
+                       gdbus_mon.conn,
+                       NM_DAEMON_OBJ,
+                       gdbus_mon.daemon_introspection->interfaces[0],
+                       &__daemon_iface_vtbl,
+                       NULL,
+                       NULL,
+                       &error);
+       if (gdbus_mon.daemon_obj_id == 0) {
+               NM_LOGI("register object failed!");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+       if (error != NULL) {
+               NM_LOGI("__register_nm_daemon_iface() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       NM_LOGI("register daemon object");
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_gdbus_register_wifi_iface()
+{
+       GError *error = NULL;
+       __NM_FUNC_ENTER__;
+
+       gdbus_mon.wifi_obj_id = g_dbus_connection_register_object(
+                       gdbus_mon.conn,
+                       NM_WIFI_OBJ,
+                       gdbus_mon.wifi_introspection->interfaces[0],
+                       &__wifi_iface_vtbl,
+                       NULL,
+                       NULL,
+                       &error);
+
+       if (gdbus_mon.wifi_obj_id == 0) {
+               NM_LOGI("register object failed!");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (error != NULL) {
+               NM_LOGI("__register_nm_wifi_iface() failed. error [%d: %s]",
+                       error->code, error->message);
+               g_error_free(error);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       NM_LOGI("register wifi object");
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_gdbus_ping(gchar *bus_name, gchar *object_name)
+{
+       GVariant *reply = NULL;
+       GError *error = NULL;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized)
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+
+       if (!bus_name || !object_name)
+               return NM_GDBUS_ERROR_INVALID_PARAM;
+
+       reply = g_dbus_connection_call_sync(
+                       gdbus_mon.conn,
+                       bus_name, /* bus name */
+                       object_name, /* object path */
+                       DBUS_STD_PEER_IFACE, /* interface name */
+                       DBUS_STC_PEER_IFACE_PING, /* method name */
+                       NULL, /* GVariant *params */
+                       NULL, /* reply_type */
+                       G_DBUS_CALL_FLAGS_NO_AUTO_START, /* flags */
+                       DBUS_REPLY_TIMEOUT , /* timeout */
+                       NULL, /* cancellable */
+                       &error); /* error */
+
+       if (error != NULL) {
+               NM_LOGI("Error! Failed to call method: [%s]", error->message);
+               if (g_strrstr(error->message, DBUS_ERROR_STR_NO_OWNER) != NULL)
+                       ret = NM_GDBUS_ERROR_HAS_NO_OWNER;
+               else
+                       ret = NM_GDBUS_ERROR_OPERATION_FAILED;
+               g_error_free(error);
+       }
+
+       if (reply != NULL)
+               g_variant_unref(reply);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_is_wpasupplicant_enabled(gboolean *enabled)
+{
+       int ret = 0;
+       __NM_FUNC_EXIT__;
+
+       ret = nm_gdbus_ping(WPASUPPLICANT_BUS_NAME, WPASUPPLICANT_OBJ);
+
+       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
+               *enabled = FALSE;
+       else
+               *enabled = TRUE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_is_connman_enabled(gboolean *enabled)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_gdbus_ping(CONNMAN_BUS_NAME, CONNMAN_OBJ);
+
+       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
+               *enabled = FALSE;
+       else
+               *enabled = TRUE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_is_telephony_enabled(gboolean *enabled)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_gdbus_ping(TELEPHONY_BUS_NAME, TELEPHONY_OBJ);
+
+       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
+               *enabled = FALSE;
+       else
+               *enabled = TRUE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_is_wfd_manager_enabled(gboolean *enabled)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_gdbus_ping(WFD_MANAGER_BUS_NAME, WFD_MANAGER_OBJ);
+
+       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
+               *enabled = FALSE;
+       else
+               *enabled = TRUE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_is_mobileap_enabled(gboolean *enabled)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_gdbus_ping(MOBILEAP_BUS_NAME, MOBILEAP_OBJ);
+
+       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
+               *enabled = FALSE;
+       else
+               *enabled = TRUE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_is_stc_manager_enabled(gboolean *enabled)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       ret = nm_gdbus_ping(STC_MANAGER_BUS_NAME, STC_MANAGER_OBJ);
+
+       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
+               *enabled = FALSE;
+       else
+               *enabled = TRUE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+static void __gdbus_name_appeared_cb(GDBusConnection *connection,
+               const gchar *name,
+               const gchar *name_owner,
+               gpointer user_data)
+{
+       NM_LOGI("%s is appeared", name);
+
+       if (g_strcmp0(name, WPASUPPLICANT_BUS_NAME) == 0) {
+               if (gdbus_mon.wpasupplicant_watching_cb)
+                       gdbus_mon.wpasupplicant_watching_cb(TRUE);
+       } else if (g_strcmp0(name, CONNMAN_BUS_NAME) == 0) {
+               if (gdbus_mon.connman_watching_cb)
+                       gdbus_mon.connman_watching_cb(TRUE);
+       } else if (g_strcmp0(name, TELEPHONY_BUS_NAME) == 0) {
+               if (gdbus_mon.telephony_watching_cb)
+                       gdbus_mon.telephony_watching_cb(TRUE);
+       } else if (g_strcmp0(name, WFD_MANAGER_BUS_NAME) == 0) {
+               if (gdbus_mon.wfd_manager_watching_cb)
+                       gdbus_mon.wfd_manager_watching_cb(TRUE);
+       } else if (g_strcmp0(name, MOBILEAP_BUS_NAME) == 0) {
+               if (gdbus_mon.mobileap_watching_cb)
+                       gdbus_mon.mobileap_watching_cb(TRUE);
+       } else if (g_strcmp0(name, STC_MANAGER_BUS_NAME) == 0) {
+               if (gdbus_mon.stc_manager_watching_cb)
+                       gdbus_mon.stc_manager_watching_cb(TRUE);
+       }
+}
+
+static void __gdbus_name_vanished_cb(GDBusConnection *connection,
+               const gchar *name,
+               gpointer user_data)
+{
+       NM_LOGI("%s is vanished", name);
+
+       if (g_strcmp0(name, WPASUPPLICANT_BUS_NAME) == 0) {
+               if (gdbus_mon.wpasupplicant_watching_cb)
+                       gdbus_mon.wpasupplicant_watching_cb(FALSE);
+       } else if (g_strcmp0(name, CONNMAN_BUS_NAME) == 0) {
+               if (gdbus_mon.connman_watching_cb)
+                       gdbus_mon.connman_watching_cb(FALSE);
+       } else if (g_strcmp0(name, TELEPHONY_BUS_NAME) == 0) {
+               if (gdbus_mon.telephony_watching_cb)
+                       gdbus_mon.telephony_watching_cb(FALSE);
+       } else if (g_strcmp0(name, WFD_MANAGER_BUS_NAME) == 0) {
+               if (gdbus_mon.wfd_manager_watching_cb)
+                       gdbus_mon.wfd_manager_watching_cb(FALSE);
+       } else if (g_strcmp0(name, MOBILEAP_BUS_NAME) == 0) {
+               if (gdbus_mon.mobileap_watching_cb)
+                       gdbus_mon.mobileap_watching_cb(FALSE);
+       } else if (g_strcmp0(name, STC_MANAGER_BUS_NAME) == 0) {
+               if (gdbus_mon.stc_manager_watching_cb)
+                       gdbus_mon.stc_manager_watching_cb(FALSE);
+       }
+}
+
+int nm_gdbus_set_wpasupplicant_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.wpasupplicant_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.wpasupplicant_watching_id);
+               gdbus_mon.wpasupplicant_watching_cb = NULL;
+               gdbus_mon.wpasupplicant_watching_id = 0;
+       }
+
+       gdbus_mon.wpasupplicant_watching_id =
+                       g_bus_watch_name_on_connection(gdbus_mon.conn,
+                                       WPASUPPLICANT_BUS_NAME,
+                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
+                                       __gdbus_name_appeared_cb,
+                                       __gdbus_name_vanished_cb,
+                                       NULL,
+                                       NULL);
+       if (gdbus_mon.wpasupplicant_watching_id == 0)
+               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
+       else
+               gdbus_mon.wpasupplicant_watching_cb = cb;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_unset_wpasupplicant_bus_watching_callback()
+{
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.wpasupplicant_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.wpasupplicant_watching_id);
+               gdbus_mon.wpasupplicant_watching_cb = NULL;
+               gdbus_mon.wpasupplicant_watching_id = 0;
+       }
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_gdbus_set_connman_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.connman_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.connman_watching_id);
+               gdbus_mon.connman_watching_cb = NULL;
+               gdbus_mon.connman_watching_id = 0;
+       }
+
+       gdbus_mon.connman_watching_id =
+                       g_bus_watch_name_on_connection(gdbus_mon.conn,
+                                       CONNMAN_BUS_NAME,
+                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
+                                       __gdbus_name_appeared_cb,
+                                       __gdbus_name_vanished_cb,
+                                       NULL,
+                                       NULL);
+       if (gdbus_mon.connman_watching_id == 0)
+               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
+       else
+               gdbus_mon.connman_watching_cb = cb;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_unset_connman_bus_watching_callback()
+{
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.connman_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.connman_watching_id);
+               gdbus_mon.connman_watching_cb = NULL;
+               gdbus_mon.connman_watching_id = 0;
+       }
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_gdbus_set_telephony_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.telephony_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.telephony_watching_id);
+               gdbus_mon.telephony_watching_cb = NULL;
+               gdbus_mon.telephony_watching_id = 0;
+       }
+
+       gdbus_mon.telephony_watching_id =
+                       g_bus_watch_name_on_connection(gdbus_mon.conn,
+                                       TELEPHONY_BUS_NAME,
+                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
+                                       __gdbus_name_appeared_cb,
+                                       __gdbus_name_vanished_cb,
+                                       NULL,
+                                       NULL);
+       if (gdbus_mon.telephony_watching_id == 0)
+               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
+       else
+               gdbus_mon.telephony_watching_cb = cb;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_unset_telephony_bus_watching_callback()
+{
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.telephony_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.telephony_watching_id);
+               gdbus_mon.telephony_watching_cb = NULL;
+               gdbus_mon.telephony_watching_id = 0;
+       }
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_gdbus_set_wfd_manager_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.wfd_manager_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.wfd_manager_watching_id);
+               gdbus_mon.wfd_manager_watching_cb = NULL;
+               gdbus_mon.wfd_manager_watching_id  = 0;
+       }
+
+       gdbus_mon.wfd_manager_watching_id =
+                       g_bus_watch_name_on_connection(gdbus_mon.conn,
+                                       WFD_MANAGER_BUS_NAME,
+                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
+                                       __gdbus_name_appeared_cb,
+                                       __gdbus_name_vanished_cb,
+                                       NULL,
+                                       NULL);
+       if (gdbus_mon.wfd_manager_watching_id == 0)
+               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
+       else
+               gdbus_mon.wfd_manager_watching_cb = cb;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_unset_wfd_manager_bus_watching_callback()
+{
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.wfd_manager_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.wfd_manager_watching_id);
+               gdbus_mon.wfd_manager_watching_cb = NULL;
+               gdbus_mon.wfd_manager_watching_id  = 0;
+       }
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_gdbus_set_mobileap_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.mobileap_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.mobileap_watching_id);
+               gdbus_mon.mobileap_watching_cb = NULL;
+               gdbus_mon.mobileap_watching_id = 0;
+       }
+
+       gdbus_mon.mobileap_watching_id =
+                       g_bus_watch_name_on_connection(gdbus_mon.conn,
+                                       MOBILEAP_BUS_NAME,
+                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
+                                       __gdbus_name_appeared_cb,
+                                       __gdbus_name_vanished_cb,
+                                       NULL,
+                                       NULL);
+       if (gdbus_mon.mobileap_watching_id == 0)
+               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
+       else
+               gdbus_mon.mobileap_watching_cb = cb;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_unset_mobileap_bus_watching_callback()
+{
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.mobileap_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.mobileap_watching_id);
+               gdbus_mon.mobileap_watching_cb = NULL;
+               gdbus_mon.mobileap_watching_id = 0;
+       }
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_gdbus_set_stc_manager_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
+{
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.stc_manager_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.stc_manager_watching_id);
+               gdbus_mon.stc_manager_watching_cb = NULL;
+               gdbus_mon.stc_manager_watching_id = 0;
+       }
+
+       gdbus_mon.stc_manager_watching_id =
+                       g_bus_watch_name_on_connection(gdbus_mon.conn,
+                                       STC_MANAGER_BUS_NAME,
+                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
+                                       __gdbus_name_appeared_cb,
+                                       __gdbus_name_vanished_cb,
+                                       NULL,
+                                       NULL);
+       if (gdbus_mon.stc_manager_watching_id == 0)
+               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
+       else
+               gdbus_mon.stc_manager_watching_cb = cb;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_unset_stc_manager_bus_watching_callback()
+{
+       __NM_FUNC_ENTER__;
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.stc_manager_watching_id != 0) {
+               g_bus_unwatch_name(gdbus_mon.stc_manager_watching_id);
+               gdbus_mon.stc_manager_watching_cb = NULL;
+               gdbus_mon.stc_manager_watching_id = 0;
+       }
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+static void __on_bus_acquired(GDBusConnection *connection,
+                              const gchar *name,
+                              gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       gdbus_mon.is_bus_aquired = TRUE;
+
+       if (gdbus_mon.bus_acquired_cb)
+               gdbus_mon.bus_acquired_cb();
+       __NM_FUNC_EXIT__;
+}
+
+static void __on_name_acquired(GDBusConnection *connection,
+                              const gchar *name,
+                              gpointer user_data)
+{
+       NM_LOGI("Bus name [%s] acquired\n", name);
+}
+
+static void __on_name_lost(GDBusConnection *connection,
+                          const gchar *name,
+                          gpointer user_data)
+{
+       gdbus_mon.is_bus_aquired = FALSE;
+
+       NM_LOGI("Bus name lost");
+       if (gdbus_mon.name_lost_cb)
+               gdbus_mon.name_lost_cb();
+}
+
+int __init_introspection()
+{
+       gdbus_mon.daemon_introspection =
+                       g_dbus_node_info_new_for_xml(nm_daemon_introspection_xml, NULL);
+
+       if (!gdbus_mon.daemon_introspection) {
+               NM_LOGI("No daemon introspection\n");
+               return -1;
+       }
+
+       gdbus_mon.wifi_introspection =
+                       g_dbus_node_info_new_for_xml(nm_wifi_introspection_xml, NULL);
+
+       if (!gdbus_mon.wifi_introspection) {
+               NM_LOGI("No wifi introspection\n");
+               if (gdbus_mon.daemon_introspection) {
+                       g_dbus_node_info_unref(gdbus_mon.daemon_introspection);
+                       gdbus_mon.daemon_introspection = NULL;
+               }
+               return -1;
+       }
+
+       gdbus_mon.conn_introspection =
+                       g_dbus_node_info_new_for_xml(nm_conn_introspection_xml, NULL);
+
+       if (!gdbus_mon.wifi_introspection) {
+               NM_LOGI("No conn introspection\n");
+               if (gdbus_mon.daemon_introspection) {
+                       g_dbus_node_info_unref(gdbus_mon.daemon_introspection);
+                       gdbus_mon.daemon_introspection = NULL;
+               }
+
+               if (gdbus_mon.wifi_introspection) {
+                       g_dbus_node_info_unref(gdbus_mon.wifi_introspection);
+                       gdbus_mon.wifi_introspection = NULL;
+               }
+               return -1;
+       }
+
+       return 0;
+}
+
+void __deinit_introspection()
+{
+       if (gdbus_mon.daemon_introspection)
+               g_dbus_node_info_unref(gdbus_mon.daemon_introspection);
+
+       if (gdbus_mon.wifi_introspection)
+               g_dbus_node_info_unref(gdbus_mon.wifi_introspection);
+
+       if (gdbus_mon.conn_introspection)
+               g_dbus_node_info_unref(gdbus_mon.conn_introspection);
+
+       gdbus_mon.daemon_introspection = NULL;
+       gdbus_mon.wifi_introspection = NULL;
+       gdbus_mon.conn_introspection = NULL;
+}
+
+int nm_gdbus_init(bus_aquired_callback bus_acquired_cb,
+                                 name_lost_callback name_lost_cb)
+{
+       gint ret = NM_GDBUS_ERROR_NONE;
+       GError *error = NULL;
+
+       __NM_FUNC_ENTER__;
+
+       memset(&gdbus_mon, 0x00, sizeof(gdbus_mon));
+       gdbus_mon.conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (gdbus_mon.conn == NULL) {
+               if (error != NULL) {
+                       NM_LOGI("Error! Failed to connect to the D-BUS daemon: [%s]",
+                                       error->message);
+                       g_error_free(error);
+               }
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_OPERATION_FAILED;
+       }
+       NM_LOGI("Get System DBus");
+
+       if (__init_introspection() != 0) {
+               NM_LOGI("Introspection initialize failed");
+               g_object_unref(gdbus_mon.conn);
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_OPERATION_FAILED;
+       }
+
+       gdbus_mon.is_initialized = TRUE;
+       gdbus_mon.bus_acquired_cb = bus_acquired_cb;
+       gdbus_mon.name_lost_cb = name_lost_cb;
+
+       gdbus_mon.owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+                       NM_DAEMON_SERVICE,
+                       G_BUS_NAME_OWNER_FLAGS_NONE,
+                       __on_bus_acquired,
+                       __on_name_acquired,
+                       __on_name_lost,
+                       NULL,
+                       NULL);
+       NM_LOGI("Request to Own [%u]", gdbus_mon.owner_id);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_gdbus_deinit()
+{
+       gint ret = NM_GDBUS_ERROR_NONE;
+
+       __NM_FUNC_ENTER__;
+
+       if (!gdbus_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_GDBUS_ERROR_NOT_INITIALIZED;
+       }
+
+       if (gdbus_mon.wifi_obj_id)
+               g_dbus_connection_unregister_object(gdbus_mon.conn,
+                               gdbus_mon.wifi_obj_id);
+
+       if (gdbus_mon.daemon_obj_id)
+               g_dbus_connection_unregister_object(gdbus_mon.conn,
+                               gdbus_mon.daemon_obj_id);
+
+       g_bus_unown_name(gdbus_mon.owner_id);
+
+       g_object_unref(gdbus_mon.conn);
+
+       __deinit_introspection();
+
+       memset(&gdbus_mon, 0x00, sizeof(gdbus_mon));
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-iface-mon.c b/src/inm-iface-mon.c
new file mode 100644 (file)
index 0000000..95a2322
--- /dev/null
@@ -0,0 +1,306 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for monitoring interface.
+ *
+ * @file        nm-iface-mon.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <net/if.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "inm-daemon-log.h"
+#include "inm-iface-mon.h"
+#include "inm-util.h"
+
+#define IFACE_CABLE_STATUS     "/sys/class/net/%s/carrier"
+
+/*Poll the interface Plug-in /Plug-out status at every 1000 ms*/
+#define IFACE_POLLING_TIME       1000
+
+typedef struct {
+       gboolean is_initialized;
+       GHashTable *monitoring_cbs;
+} iface_mon_s;
+
+iface_mon_s iface_mon;
+
+static void __destroy_mon_data(gpointer data)
+{
+       iface_mon_data_s *mon_data = (iface_mon_data_s *)data;
+       __NM_FUNC_ENTER__;
+
+       g_free(data);
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+/*
+static gboolean __status_polling_callback(gpointer user_data)
+{
+       iface_mon_data_s *data = NULL;
+       gchar file_path[128] = {0,};
+       int status;
+
+
+       data = (iface_mon_data_s *)user_data;
+       if (!data) {
+               NM_LOGI("user data not available");
+               return TRUE;
+       }
+
+       g_snprintf(file_path, 128, IFACE_CABLE_STATUS, data->iface_name);
+       if (nm_check_cable_status(file_path, &status) < 0) {
+               __NM_FUNC_EXIT__;
+               return TRUE;
+       }
+       NM_LOGI("%s : [%d]", file_path, status);
+
+       if (data->cb)
+               data->cb(data->iface_name, status, data->cb_user_data);
+
+       return TRUE;
+}
+
+static int __attatch_monitor_file(iface_mon_data_s *data)
+{
+       __NM_FUNC_ENTER__;
+
+       data->timer_source_id = g_timeout_add(IFACE_POLLING_TIME,
+                       __status_polling_callback,
+                       data);
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+*/
+
+void __nm_wifi_module_state_changed_cb(keynode_t *node, gpointer user_data)
+{
+       iface_mon_data_s *data = NULL;
+       int device_status = 0;
+       if (!user_data) {
+               NM_LOGE("user data not available");
+               return;
+       }
+       data = (iface_mon_data_s *)user_data;
+
+       if (vconf_get_int(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT, &device_status) < 0) {
+               NM_LOGE("Unable to read status from vconf key");
+               return;
+       }
+
+       NM_LOGI("Wi-Fi Module State [%d]", device_status);
+
+       if (data->cb)
+               data->cb(data->iface_name, device_status, NULL);
+
+}
+
+static int __nm_wifi_set_module_state_changed_cb(gboolean flag, iface_mon_data_s *data)
+{
+       static __thread gint refcount = 0;
+       int ret = 0;
+
+       if (flag) {
+               if (refcount == 0) {
+                       ret = vconf_notify_key_changed(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT,
+                                       __nm_wifi_module_state_changed_cb, data);
+               }
+
+               refcount++;
+               NM_LOGI("Successfully registered(%d)", refcount);
+       } else {
+               if (refcount > 0) {
+                       if (--refcount == 0) {
+                               if (vconf_ignore_key_changed(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT,
+                                                       __nm_wifi_module_state_changed_cb) < 0) {
+                                       NM_LOGI("Error to de-register vconf callback(%d)", refcount);
+                                       return -1;
+                               } else
+                                       NM_LOGI("Successfully de-registered(%d)", refcount);
+                       }
+               }
+       }
+
+       return ret;
+}
+
+int nm_iface_mon_start_monitor(char *iface_name, nm_iface_mon_callback cb, void *user_data)
+{
+       iface_mon_data_s *data = NULL;
+       int ret = NM_IFACE_MON_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!iface_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IFACE_MON_NOT_INITIALIZED;
+       }
+
+       if (!cb || !iface_name || strlen(iface_name) == 0) {
+               __NM_FUNC_EXIT__;
+               return NM_IFACE_MON_INVALID_PARAMETER;
+}
+
+       data = (iface_mon_data_s *)g_try_malloc0(sizeof(iface_mon_data_s));
+       if (!data) {
+               __NM_FUNC_EXIT__;
+               return NM_IFACE_MON_OPERATION_FAILED;
+       }
+       data->cb = cb;
+       data->cb_user_data = user_data;
+
+       if (strncmp(iface_name, "eth", 3) == 0) {
+               /** netlink event based ethernet monitoring */
+               if (nm_rtnl_init(data) < 0) {
+                       g_free(data);
+                       __NM_FUNC_EXIT__;
+                       return NM_IFACE_MON_OPERATION_FAILED;
+               }
+       } else if (strncmp(iface_name, "wlan", 4) == 0) {
+               g_strlcpy(data->iface_name, iface_name, IFNAMSIZ);
+               if (__nm_wifi_set_module_state_changed_cb(TRUE, data) < 0) {
+                       g_free(data);
+                       __NM_FUNC_EXIT__;
+                       return NM_IFACE_MON_OPERATION_FAILED;
+               }
+       } else {
+               NM_LOGE("Invalid Interface: %s", iface_name);
+               g_free(data);
+               __NM_FUNC_EXIT__;
+               return NM_IFACE_MON_INVALID_PARAMETER;
+       }
+
+       g_hash_table_insert(iface_mon.monitoring_cbs, g_strdup(iface_name), data);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_iface_mon_stop_monitor(char *iface_name)
+{
+       int ret = NM_IFACE_MON_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!iface_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IFACE_MON_NOT_INITIALIZED;
+       }
+
+       if (!iface_name || strlen(iface_name) == 0) {
+               __NM_FUNC_EXIT__;
+               return NM_IFACE_MON_INVALID_PARAMETER;
+       }
+
+       /** Cleanup netlink socket for ethernet interface */
+       if (strncmp(iface_name, "eth", 3) == 0) {
+               nm_rtnl_cleanup();
+       } else if (strncmp(iface_name, "wlan", 4) == 0) {
+               if (__nm_wifi_set_module_state_changed_cb(FALSE, NULL) < 0) {
+                       __NM_FUNC_EXIT__;
+                       return NM_IFACE_MON_OPERATION_FAILED;
+               }
+       }
+
+       g_hash_table_remove(iface_mon.monitoring_cbs, iface_name);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_iface_mon_get_iface_state(char *iface_name, int *state)
+{
+       int ret = NM_IFACE_MON_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+       gchar file_path[128] = {0,};
+
+       if (!iface_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IFACE_MON_NOT_INITIALIZED;
+       }
+
+       if (!state || !iface_name || strlen(iface_name) == 0) {
+               __NM_FUNC_EXIT__;
+               return NM_IFACE_MON_INVALID_PARAMETER;
+       }
+       g_snprintf(file_path, 128, IFACE_CABLE_STATUS, iface_name);
+       if (nm_check_cable_status(file_path, state) < 0) {
+               __NM_FUNC_EXIT__;
+               return NM_IFACE_MON_OPERATION_FAILED;
+       }
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_iface_mon_init()
+{
+       int ret = NM_IFACE_MON_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       memset(&iface_mon, 0x00, sizeof(iface_mon));
+       iface_mon.is_initialized = TRUE;
+
+       iface_mon.monitoring_cbs = g_hash_table_new_full(g_str_hash,
+                       g_str_equal,
+                       g_free,
+                       __destroy_mon_data
+                       );
+
+       if (!iface_mon.monitoring_cbs) {
+               iface_mon.is_initialized = FALSE;
+               __NM_FUNC_EXIT__;
+               return NM_IFACE_MON_OPERATION_FAILED;
+       }
+
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_iface_mon_deinit()
+{
+       int ret = NM_IFACE_MON_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!iface_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IFACE_MON_NOT_INITIALIZED;
+       }
+
+       iface_mon.is_initialized = FALSE;
+       g_hash_table_remove_all(iface_mon.monitoring_cbs);
+       g_hash_table_unref(iface_mon.monitoring_cbs);
+       iface_mon.monitoring_cbs = NULL;
+
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-ip-conflict.c b/src/inm-ip-conflict.c
new file mode 100644 (file)
index 0000000..c2e4896
--- /dev/null
@@ -0,0 +1,819 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements Detecting IP conflict functions.
+ *
+ * @file        nm-ip-conflict.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <errno.h>
+
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include <linux/if.h>
+#include <linux/if_packet.h>
+#include <linux/if_ether.h>
+#include <linux/if_arp.h>
+#include <net/ethernet.h>
+
+#include <arpa/inet.h>
+
+#include <glib.h>
+
+#include "inm-daemon-log.h"
+#include "inm-ip-conflict.h"
+#include "inm-util.h"
+
+#define ARP_PACKET_SIZE 60
+#define CONFLICT_REMOVE_ITERATION_LIMIT 4
+#define MIN_ARP_SEND_TIME 20000
+#define BURST_ARP_SEND_TIME 3000
+#define MAX_ARP_SEND_TIME 32000
+#define INITIAL_BURST_ARP_COUNT 5
+#define MSEC 1000
+#define IP_ALEN 4
+
+#ifndef MAC_FMT
+#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
+#endif
+
+#ifndef IP_FMT
+#define IP_FMT "%d.%d.%d.%d"
+#endif
+
+#define REMOVE_G_SOURCE(g_source) \
+       do { \
+               if ((g_source)) { \
+                       g_source_remove((g_source)); \
+                       (g_source) = 0; \
+               } \
+       } while (0)
+
+typedef struct __attribute__((packed))
+{
+       unsigned short arp_hrd;
+       unsigned short arp_pro;
+       unsigned char arp_hln;
+       unsigned char arp_pln;
+       unsigned short arp_op;
+       unsigned char arp_sha[ETH_ALEN];
+       unsigned char arp_sip[IP_ALEN];
+       unsigned char arp_tha[ETH_ALEN];
+       unsigned char arp_tip[IP_ALEN];
+} arp_message_s;
+
+typedef struct {
+       gboolean detection_enabled;
+
+       gchar if_name[IFNAMSIZ];
+
+       int ifindex;
+       unsigned char hwaddr[ETH_ALEN];
+       unsigned char ipaddr[IP_ALEN];
+
+       gboolean initial_bursts;
+       gint iteration;
+       guint timeout;
+
+       /* arp sock related */
+       gint sock;
+       GIOChannel * sock_io_channel;
+       guint sock_source_id;
+       guint timer_source_id;
+       guint arp_reply_timer_source_id;
+
+       struct sockaddr_ll ll_addr;
+
+       nm_ip_conflict_state_e state;
+
+       ip_conflict_callback cb;
+       gpointer cb_user_data;
+} ip_conflict_data_s;
+
+typedef struct {
+       gboolean is_initialized;
+
+       guint initial_time;
+
+       GHashTable *ip_conflict_cb_tbl;
+} ip_conflict_mon_s;
+
+ip_conflict_mon_s ip_conflict_mon;
+
+static gboolean __send_arp(gpointer user_data);
+
+static void __print_mac(guchar *mac)
+{
+       NM_LOGI(MAC_FMT "\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+}
+
+static void __print_ip(guchar *ip)
+{
+       NM_LOGI(IP_FMT "\n", ip[0], ip[1], ip[2], ip[3]);
+}
+
+static void __init_ll_addr(struct sockaddr_ll *ll_addr)
+{
+       ll_addr->sll_family = AF_PACKET;
+       ll_addr->sll_protocol = htons(ETH_P_ARP);
+       ll_addr->sll_hatype = htons(ARPHRD_ETHER);
+       ll_addr->sll_pkttype = (PACKET_BROADCAST);
+       ll_addr->sll_halen = ETH_ALEN;
+       ll_addr->sll_addr[6] = 0x00;
+       ll_addr->sll_addr[7] = 0x00;
+       return;
+}
+
+static void __init_ip_conflict_sock_data(ip_conflict_data_s *ip_conflict_data)
+{
+       ip_conflict_data->initial_bursts = TRUE;
+       ip_conflict_data->sock = -1;
+       ip_conflict_data->sock_io_channel = NULL;
+       ip_conflict_data->sock_source_id = 0;
+       ip_conflict_data->timer_source_id = 0;
+       ip_conflict_data->iteration = 0;
+       ip_conflict_data->state = IP_CONFLICT_STATE_UNKNOWN;
+       ip_conflict_data->detection_enabled = FALSE;
+
+       return;
+}
+
+static gboolean __arp_reply_timeout_cb(gpointer data)
+{
+       __NM_FUNC_ENTER__;
+       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)data;
+
+       ip_conflict_data->iteration++;
+       REMOVE_G_SOURCE(ip_conflict_data->arp_reply_timer_source_id);
+       REMOVE_G_SOURCE(ip_conflict_data->timer_source_id);
+
+       if (ip_conflict_data->state != IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED &&
+                       ip_conflict_data->iteration == CONFLICT_REMOVE_ITERATION_LIMIT) {
+               ip_conflict_data->iteration = 0;
+               ip_conflict_data->state = IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED;
+               ip_conflict_data->initial_bursts = TRUE;
+               if (ip_conflict_data->cb)
+                       ip_conflict_data->cb(ip_conflict_data->state,
+                                       ip_conflict_data->if_name,
+                                       ip_conflict_data->ipaddr,
+                                       ip_conflict_data->cb_user_data);
+       }
+
+       ip_conflict_data->timer_source_id = g_timeout_add(ip_conflict_data->timeout, __send_arp, ip_conflict_data);
+       __NM_FUNC_EXIT__;
+       return G_SOURCE_REMOVE;
+}
+
+static gboolean __check_arp_receive(GIOChannel *source,
+                                                 GIOCondition condition, gpointer data)
+{
+       arp_message_s *ah = NULL;
+       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)data;
+       gchar buf[ARP_PACKET_SIZE] = {0, };
+       gchar *ptr = NULL;
+       gsize bytes_read = 0;
+       GError *error = NULL;
+
+       if (g_io_channel_read_chars(source, buf, ARP_PACKET_SIZE,
+                               &bytes_read, &error) != G_IO_STATUS_NORMAL) {
+               NM_LOGI("Failure received arp packet[%d]:[%s]",
+                               error->code, error->message);
+               g_error_free(error);
+               return TRUE;
+       }
+
+       ptr = buf + ETH_HLEN;
+       ah = (arp_message_s *)ptr;
+
+       /* Only handle ARP replies */
+       if (ah->arp_op != htons(ARPOP_REPLY)) {
+               return TRUE;
+       }
+
+       if (memcmp(ah->arp_sha, ip_conflict_data->hwaddr, ETH_ALEN) == 0 ||
+               memcmp(ah->arp_sip, ip_conflict_data->ipaddr, 4) != 0) {
+               NM_LOGI("Packet not intended to us.\n");
+               return TRUE;
+       }
+
+       ip_conflict_data->iteration = 0;
+       NM_LOGI("ip conflict is detected !\n");
+       ip_conflict_data->state = IP_CONFLICT_STATE_CONFLICT_DETECTED;
+       ip_conflict_data->timeout = BURST_ARP_SEND_TIME;
+       if (ip_conflict_data->cb)
+               ip_conflict_data->cb(ip_conflict_data->state,
+                               ip_conflict_data->if_name,
+                               ip_conflict_data->ipaddr,
+                               ip_conflict_data->cb_user_data);
+
+       REMOVE_G_SOURCE(ip_conflict_data->arp_reply_timer_source_id);
+       REMOVE_G_SOURCE(ip_conflict_data->timer_source_id);
+       ip_conflict_data->timer_source_id =
+                       g_timeout_add(ip_conflict_data->timeout, __send_arp, NULL);
+
+       return TRUE;
+}
+
+int __get_iface_info(ip_conflict_data_s *ip_conflict_data)
+{
+       struct ifreq ifr;
+       char err_str[128] = {0,};
+       int sock = -1;
+
+       __NM_FUNC_ENTER__;
+
+       /* TODO laod local Iface info */
+
+       memset(&ifr, 0x00, sizeof(ifr));
+       if (strlen(ip_conflict_data->if_name) == 0)
+               return -1;
+
+       g_strlcpy(ifr.ifr_name, ip_conflict_data->if_name, strlen(ip_conflict_data->if_name) + 1);
+       NM_LOGI("get %s info\n", ifr.ifr_name);
+       sock = socket(AF_INET, SOCK_DGRAM, 0);
+       if (sock < 0) {
+               strerror_r(errno, err_str, 128);
+               NM_LOGE("errno[%d]: %s\n", errno, err_str);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (ioctl(sock, SIOCGIFHWADDR, &ifr) <0) {
+               strerror_r(errno, err_str, 128);
+               NM_LOGE("errno[%d]: %s\n", errno, err_str);
+               __NM_FUNC_EXIT__;
+               close(sock);
+               return -1;
+       }
+
+       memcpy(ip_conflict_data->hwaddr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
+       NM_LOGI("Successfully got our MAC address: ");
+       __print_mac(ip_conflict_data->hwaddr);
+
+       if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0) {
+               strerror_r(errno, err_str, 128);
+               NM_LOGE("errno[%d]: %s\n", errno, err_str);
+               __NM_FUNC_EXIT__;
+               close(sock);
+               return -1;
+       }
+       ip_conflict_data->ifindex = ifr.ifr_ifindex;
+       NM_LOGI("Successfully got interface index: %i\n", ip_conflict_data->ifindex);
+
+       if (ioctl(sock, SIOCGIFADDR, &ifr) < 0) {
+               strerror_r(errno, err_str, 128);
+               NM_LOGE("errno[%d]: %s\n", errno, err_str);
+               close(sock);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (ifr.ifr_addr.sa_family != AF_INET) {
+               NM_LOGE("addr is not AF_INET\n");
+               close(sock);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       memcpy(ip_conflict_data->ipaddr, &(ifr.ifr_addr.sa_data[2]), 4);
+       NM_LOGI("IP addr: ");
+       __print_ip(ip_conflict_data->ipaddr);
+       close(sock);
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+void __set_defend_arp_ethhdr(ip_conflict_data_s *ip_conflict_data, struct ethhdr *eh)
+{
+       memset(eh->h_dest, 0xff, ETH_ALEN);
+       memcpy(eh->h_source, ip_conflict_data->hwaddr, ETH_ALEN);
+       eh->h_proto = htons(ETH_P_ARP);
+       return;
+}
+
+void __set_defend_arp(ip_conflict_data_s *ip_conflict_data, arp_message_s *ah)
+{
+       ah->arp_hrd = htons(ARPHRD_ETHER);
+       ah->arp_pro = htons(ETH_P_IP);
+       ah->arp_hln = ETH_ALEN;
+       ah->arp_pln = 4;
+       ah->arp_op = htons(ARPOP_REQUEST);
+
+       memcpy(ah->arp_sha, ip_conflict_data->hwaddr, ETH_ALEN);
+       /* by RFC 5227 2.1.1.  Probe Details,
+        'sender IP address' field MUST be set to all zeroes;
+        this is to avoid polluting ARP caches in other hosts
+        on the same link in the case where the address turns
+        out to be already in use by another host. */
+
+       memset(ah->arp_sip, 0x00, 4);
+       //memcpy(ah->arp_sip, ip_conflict_mons.ipaddr, 4);
+
+       memset(ah->arp_tha, 0x00, ETH_ALEN);
+
+       memcpy(ah->arp_tip, ip_conflict_data->ipaddr, 4);
+       return;
+}
+
+static int __recover_socket(ip_conflict_data_s *ip_conflict_data)
+{
+       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+       if (ip_conflict_data->sock >= 0) {
+               close(ip_conflict_data->sock);
+               ip_conflict_data->sock = -1;
+       }
+
+       /* reopen socket */
+       if ((ip_conflict_data->sock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ARP))) == -1) {
+               NM_LOGI("socket %d", ip_conflict_data->sock);
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               NM_LOGI("socket Failed. Error = %s\n", error_buf);
+       }
+
+       return ip_conflict_data->sock;
+}
+
+static gboolean __send_arp(gpointer user_data)
+{
+       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)user_data;
+       static gint initial_send_arp_count = 0;
+       guchar buf[60] = {0,};
+       guchar *pos = NULL;
+       gint ret = 0;
+
+       if (ip_conflict_data->initial_bursts &&
+                       initial_send_arp_count >= INITIAL_BURST_ARP_COUNT) {
+               ip_conflict_data->initial_bursts = FALSE;
+               initial_send_arp_count = 0;
+       }
+
+       if (ip_conflict_data->initial_bursts)
+               initial_send_arp_count++;
+
+       __get_iface_info(ip_conflict_data);
+
+       pos = buf;
+       __set_defend_arp_ethhdr(ip_conflict_data, (struct ethhdr *)pos);
+
+       pos = buf + ETH_HLEN;
+       __set_defend_arp(ip_conflict_data, (arp_message_s *)pos);
+
+       /* Construct the destination address */
+       memcpy(ip_conflict_data->ll_addr.sll_addr, ip_conflict_data->hwaddr, ETH_ALEN);
+       ip_conflict_data->ll_addr.sll_ifindex = ip_conflict_data->ifindex;
+
+       ret = sendto(ip_conflict_data->sock, buf, 42, 0,
+               (struct sockaddr *) &(ip_conflict_data->ll_addr),
+               sizeof(struct sockaddr_ll));
+
+       if (ret == -1 && __recover_socket(ip_conflict_data) < 0) {
+               REMOVE_G_SOURCE(ip_conflict_data->timer_source_id);
+               ip_conflict_data->timer_source_id =
+                               g_timeout_add(ip_conflict_data->timeout, __send_arp, ip_conflict_data);
+       } else {
+               NM_LOGD("Sent ARP Packet \n");
+               REMOVE_G_SOURCE(ip_conflict_data->timer_source_id);
+
+               if (ip_conflict_data->state == IP_CONFLICT_STATE_CONFLICT_DETECTED ||
+                               ip_conflict_data->initial_bursts)
+                       ip_conflict_data->timeout = BURST_ARP_SEND_TIME;
+               else
+                       ip_conflict_data->timeout = ip_conflict_mon.initial_time;
+
+               /* Adding timeout callback for arp request */
+               ip_conflict_data->arp_reply_timer_source_id =
+                               g_timeout_add(1000, __arp_reply_timeout_cb, ip_conflict_data);
+       }
+
+       return FALSE;
+}
+
+static void __start_ip_conflict_mon(gpointer key,
+        gpointer value,
+        gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       gchar error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)value;
+       ip_conflict_mon_s *mon = (ip_conflict_mon_s *)user_data;
+
+       gint sock = -1;
+
+       if (!ip_conflict_data->detection_enabled) {
+               NM_LOGI("IP conflict detection disabled");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       __init_ip_conflict_sock_data(ip_conflict_data);
+
+       sock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ARP));
+       if (sock < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               NM_LOGI("socket Failed. Error = %s\n", error_buf);
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       ip_conflict_data->sock = sock;
+       ip_conflict_data->sock_io_channel = g_io_channel_unix_new(sock);
+       if (!ip_conflict_data->sock_io_channel) {
+               NM_LOGI("Failed to create channel");
+               ip_conflict_data->sock = -1;
+               close(sock);
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       g_io_channel_set_close_on_unref(ip_conflict_data->sock_io_channel, TRUE);
+
+       if (G_IO_STATUS_NORMAL !=
+                       g_io_channel_set_encoding(ip_conflict_data->sock_io_channel,
+                                       NULL, NULL))
+               NM_LOGI("Failed to set encoding NULL on io channel");
+
+       if (G_IO_STATUS_NORMAL !=
+                       g_io_channel_set_flags(ip_conflict_data->sock_io_channel,
+                                       G_IO_FLAG_NONBLOCK, NULL))
+               NM_LOGI("Failed to set flags on io channel");
+
+       ip_conflict_data->sock_source_id =
+                       g_io_add_watch(ip_conflict_data->sock_io_channel, G_IO_IN,
+                                       __check_arp_receive, ip_conflict_data);
+       NM_LOGD("socket %d", sock);
+
+       ip_conflict_data->timeout = mon->initial_time;
+       __send_arp(ip_conflict_data);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __stop_ip_conflict_mon(gpointer key,
+        gpointer value,
+        gpointer user_data)
+{
+       GError* error = NULL;
+       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)value;
+
+       __NM_FUNC_ENTER__;
+
+       REMOVE_G_SOURCE(ip_conflict_data->timer_source_id);
+
+       if (ip_conflict_data->sock < 0) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       if (G_IO_STATUS_NORMAL !=
+               g_io_channel_shutdown(ip_conflict_data->sock_io_channel,
+                               FALSE,
+                               &error)) {
+               NM_LOGI("Failure received while shutdown io channel[%d]:[%s]",
+                               error->code, error->message);
+               g_error_free(error);
+       }
+
+       g_io_channel_unref(ip_conflict_data->sock_io_channel);
+       REMOVE_G_SOURCE(ip_conflict_data->sock_source_id);
+       close(ip_conflict_data->sock);
+       ip_conflict_data->sock = -1;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+int nm_ip_conflict_enable_detection(gchar *if_name, gboolean enable)
+{
+       gint ret = NM_IP_CONFLICT_ERROR_NONE;
+       ip_conflict_data_s *ip_conflict_data = NULL;
+
+       __NM_FUNC_ENTER__;
+
+       if (!ip_conflict_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
+       }
+
+       ip_conflict_data =
+                       g_hash_table_lookup(ip_conflict_mon.ip_conflict_cb_tbl, if_name);
+       if (!ip_conflict_data) {
+               NM_LOGI("ip_conflict_data not found");
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
+       }
+
+       if (enable) {
+               if (ip_conflict_data->sock != -1) {
+                       __NM_FUNC_EXIT__;
+                       return NM_IP_CONFLICT_ERROR_IN_PROGRESS;
+               }
+
+               ip_conflict_data->detection_enabled = TRUE;
+               ip_conflict_data->state = IP_CONFLICT_STATE_UNKNOWN;
+
+               __start_ip_conflict_mon(if_name, ip_conflict_data, &ip_conflict_mon);
+               if (!ip_conflict_data->sock_source_id == 0) {
+                       NM_LOGI("Failed to start IP conflict monitoring");
+                       ip_conflict_data->detection_enabled = FALSE;
+                       return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
+               }
+       } else {
+               if (ip_conflict_data->sock != -1) {
+                       __stop_ip_conflict_mon(if_name, ip_conflict_data, &ip_conflict_mon);
+                       ip_conflict_data->detection_enabled = FALSE;
+                       ip_conflict_data->state = IP_CONFLICT_STATE_UNKNOWN;
+               }
+       }
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_ip_conflict_get_detection_period(guint *period)
+{
+       gint ret = NM_IP_CONFLICT_ERROR_NONE;
+
+       __NM_FUNC_ENTER__;
+
+       if (!ip_conflict_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!period) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
+       }
+
+       *period = ip_conflict_mon.initial_time / MSEC;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_ip_conflict_set_detection_period(guint period)
+{
+       gint ret = NM_IP_CONFLICT_ERROR_NONE;
+
+       __NM_FUNC_ENTER__;
+
+       if (!ip_conflict_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (period < MAX_ARP_SEND_TIME && period > MIN_ARP_SEND_TIME) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
+       }
+
+       ip_conflict_mon.initial_time = period * MSEC;
+
+       g_hash_table_foreach(ip_conflict_mon.ip_conflict_cb_tbl,
+                       __stop_ip_conflict_mon,
+                       &ip_conflict_mon);
+       g_hash_table_foreach(ip_conflict_mon.ip_conflict_cb_tbl,
+                       __start_ip_conflict_mon,
+                       &ip_conflict_mon);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_ip_conflict_get_state(gchar *if_name, guint *state)
+{
+       gint ret = NM_IP_CONFLICT_ERROR_NONE;
+       ip_conflict_data_s *ip_conflict_data = NULL;
+
+       __NM_FUNC_ENTER__;
+
+       if (!ip_conflict_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!state) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
+       }
+
+       ip_conflict_data =
+                       g_hash_table_lookup(ip_conflict_mon.ip_conflict_cb_tbl, if_name);
+       if (!ip_conflict_data) {
+               NM_LOGI("ip_conflict_data not found");
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
+       }
+
+       *state = ip_conflict_data->state;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_ip_conflict_is_detection_enabled(gchar *if_name, gboolean *enabled)
+{
+       gint ret = NM_IP_CONFLICT_ERROR_NONE;
+       ip_conflict_data_s *ip_conflict_data = NULL;
+
+       __NM_FUNC_ENTER__;
+
+       if (!ip_conflict_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!enabled) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
+       }
+
+       ip_conflict_data =
+                       g_hash_table_lookup(ip_conflict_mon.ip_conflict_cb_tbl, if_name);
+       if (!ip_conflict_data) {
+               NM_LOGI("ip_conflict_data not found");
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
+       }
+
+       *enabled = ip_conflict_data->detection_enabled;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+ip_conflict_data_s *__create_ip_confilct_data(gchar *if_name)
+{
+       ip_conflict_data_s *ip_conflict_data = NULL;
+
+       ip_conflict_data =
+                       g_hash_table_lookup(ip_conflict_mon.ip_conflict_cb_tbl, if_name);
+       if (ip_conflict_data)
+               return ip_conflict_data;
+
+       ip_conflict_data =
+                       (ip_conflict_data_s *)g_try_malloc0(sizeof(ip_conflict_data_s));
+       if (!ip_conflict_data) {
+               NM_LOGI("Error! Failed to allocate memory");
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       if (!g_hash_table_insert(
+                       ip_conflict_mon.ip_conflict_cb_tbl,
+                       g_strdup(if_name),
+                       ip_conflict_data)) {
+               g_free(ip_conflict_data);
+               NM_LOGI("Error! Failed to insert ip_conflict_data");
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       __init_ip_conflict_sock_data(ip_conflict_data);
+       __init_ll_addr((struct sockaddr_ll *)&(ip_conflict_data->ll_addr));
+
+       return ip_conflict_data;
+}
+
+void __destroy_ip_conflict_data(gpointer user_data)
+{
+       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)user_data;
+
+       if (!ip_conflict_data)
+               return;
+
+       __stop_ip_conflict_mon(ip_conflict_data->if_name, ip_conflict_data, &ip_conflict_mon);
+       g_free(ip_conflict_data);
+
+       return;
+}
+
+int ip_conflict_set_callback(gchar *if_name, ip_conflict_callback cb, gpointer user_data)
+{
+       gint ret = NM_IP_CONFLICT_ERROR_NONE;
+       ip_conflict_data_s *ip_conflict_data = NULL;
+
+       __NM_FUNC_ENTER__;
+
+       if (!ip_conflict_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!if_name) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
+       }
+
+       ip_conflict_data = __create_ip_confilct_data(if_name);
+       if (!ip_conflict_data) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
+       }
+
+       g_strlcpy(ip_conflict_data->if_name, if_name, IFNAMSIZ);
+       ip_conflict_data->cb = cb;
+       ip_conflict_data->cb_user_data = user_data;
+
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int ip_conflict_unset_callback(gchar *if_name)
+{
+       gint ret = NM_IP_CONFLICT_ERROR_NONE;
+       ip_conflict_data_s *ip_conflict_data = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (!ip_conflict_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!if_name) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
+       }
+
+       ip_conflict_data =
+                       g_hash_table_lookup(ip_conflict_mon.ip_conflict_cb_tbl, if_name);
+       if (!ip_conflict_data) {
+               NM_LOGI("ip_conflict_data not found");
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
+       }
+
+       g_hash_table_remove(ip_conflict_mon.ip_conflict_cb_tbl, ip_conflict_data);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int ip_conflict_detection_init()
+{
+       gint ret = NM_IP_CONFLICT_ERROR_NONE;
+
+       __NM_FUNC_ENTER__;
+
+       memset(&ip_conflict_mon, 0x00, sizeof(ip_conflict_mon));
+
+       ip_conflict_mon.is_initialized = TRUE;
+       ip_conflict_mon.initial_time = MIN_ARP_SEND_TIME;
+
+       ip_conflict_mon.ip_conflict_cb_tbl = g_hash_table_new_full(g_str_hash,
+                       g_str_equal,
+                       g_free,
+                       __destroy_ip_conflict_data
+                       );
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int ip_conflict_detection_deinit()
+{
+       gint ret = NM_IP_CONFLICT_ERROR_NONE;
+
+       __NM_FUNC_ENTER__;
+
+       if (!ip_conflict_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
+       }
+
+       g_hash_table_remove_all(ip_conflict_mon.ip_conflict_cb_tbl);
+       g_hash_table_unref(ip_conflict_mon.ip_conflict_cb_tbl);
+
+       memset(&ip_conflict_mon, 0x00, sizeof(ip_conflict_mon));
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-mobileap.c b/src/inm-mobileap.c
new file mode 100644 (file)
index 0000000..413a517
--- /dev/null
@@ -0,0 +1,966 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling signal from Wi-Fi Direct manager.
+ *
+ * @file        nm-wfd-manager.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-mobileap.h"
+
+#define IP_ADDR_LEN 4
+#define MAC_ADDR_LEN 6
+#define MOBILEAP_STR_INFO_LEN 41
+
+#define TETHER_SIGNAL_NET_CLOSED                               "net_closed"
+#define TETHER_SIGNAL_STA_CONNECT                              "sta_connected"
+#define TETHER_SIGNAL_STA_DISCONNECT                   "sta_disconnected"
+#define TETHER_SIGNAL_WIFI_ON                                  "wifi_on"
+#define TETHER_SIGNAL_WIFI_OFF                                 "wifi_off"
+#define TETHER_SIGNAL_USB_ON                                   "usb_on"
+#define TETHER_SIGNAL_USB_OFF                                  "usb_off"
+#define TETHER_SIGNAL_BT_ON                                            "bluetooth_on"
+#define TETHER_SIGNAL_BT_OFF                                   "bluetooth_off"
+#define TETHER_SIGNAL_WIFI_AP_ON                               "wifi_ap_on"
+#define TETHER_SIGNAL_WIFI_AP_OFF                              "wifi_ap_off"
+#define TETHER_SIGNAL_NO_DATA_TIMEOUT                  "no_data_timeout"
+#define TETHER_SIGNAL_LOW_BATTERY                              "low_batt_mode"
+#define TETHER_SIGNAL_FLIGHT_MODE                              "flight_mode"
+#define TETHER_SIGNAL_SECURITY_TYPE_CHANGED            "security_type_changed"
+#define TETHER_SIGNAL_SSID_VISIBILITY_CHANGED  "ssid_visibility_changed"
+#define TETHER_SIGNAL_PASSPHRASE_CHANGED               "passphrase_changed"
+#define TETHER_SIGNAL_DHCP_STATUS                              "dhcp_status"
+
+#define SOFTAP_SIGNAL_STA_CONNECT                              "sta_connected"
+#define SOFTAP_SIGNAL_STA_DISCONNECT                   "sta_disconnected"
+#define SOFTAP_SIGNAL_ON                                               "soft_ap_on"
+#define SOFTAP_SIGNAL_OFF                                              "soft_ap_off"
+#define SOFTAP_SIGNAL_NO_DATA_TIMEOUT                  "no_data_timeout"
+#define SOFTAP_SIGNAL_LOW_BATTERY                              "low_batt_mode"
+#define SOFTAP_SIGNAL_FLIGHT_MODE                              "flight_mode"
+#define SOFTAP_SIGNAL_SECURITY_TYPE_CHANGED            "security_type_changed"
+#define SOFTAP_SIGNAL_SSID_VISIBLITY_CHANGED   "ssid_visibility_changed"
+#define SOFTAP_SIGNAL_PASSPHRASECHANGED                        "passphrase_changed"
+#define SOFTAP_SIGNAL_DHCP_STATUS                              "dhcp_status"
+
+typedef enum {
+       MOBILEAP_SIGNAL_NAME_OWENER_CHANGED,
+       MOBILEAP_SIGNAL_TETHER_NET_CLOSED,
+       MOBILEAP_SIGNAL_TETHER_STA_CONNECT,
+       MOBILEAP_SIGNAL_TETHER_STA_DISCONNECT,
+       MOBILEAP_SIGNAL_TETHER_WIFI_ON,
+       MOBILEAP_SIGNAL_TETHER_WIFI_OFF,
+       MOBILEAP_SIGNAL_TETHER_USB_ON,
+       MOBILEAP_SIGNAL_TETHER_USB_OFF,
+       MOBILEAP_SIGNAL_TETHER_BT_ON,
+       MOBILEAP_SIGNAL_TETHER_BT_OFF,
+       MOBILEAP_SIGNAL_TETHER_WIFI_AP_ON,
+       MOBILEAP_SIGNAL_TETHER_WIFI_AP_OFF,
+       MOBILEAP_SIGNAL_TETHER_NO_DATA_TIMeOUT,
+       MOBILEAP_SIGNAL_TETHER_LOW_BATTERY,
+       MOBILEAP_SIGNAL_TETHER_FLIGHT_MODE,
+       MOBILEAP_SIGNAL_TETHER_SECURITY_TYPE_CHANGED,
+       MOBILEAP_SIGNAL_TETHER_SSID_VISIBILITY_CHANGED,
+       MOBILEAP_SIGNAL_TETHER_PASSPHRASE_CHANGED,
+       MOBILEAP_SIGNAL_TETHER_DHCP_STATUS,
+       MOBILEAP_SIGNAL_SOFTAP_STA_CONNECT,
+       MOBILEAP_SIGNAL_SOFTAP_STA_DISCONNECT,
+       MOBILEAP_SIGNAL_SOFTAP_ON,
+       MOBILEAP_SIGNAL_SOFTAP_OFF,
+       MOBILEAP_SIGNAL_SOFTAP_NO_DATA_TIMEOUT,
+       MOBILEAP_SIGNAL_SOFTAP_LOW_BATTERY,
+       MOBILEAP_SIGNAL_SOFTAP_FLIGHT_MODE,
+       MOBILEAP_SIGNAL_SOFTAP_SECURITY_TYPE_CHANGED,
+       MOBILEAP_SIGNAL_SOFTAP_SSID_VISIBLITY_CHANGED,
+       MOBILEAP_SIGNAL_SOFTAP_PASSPHRASECHANGED,
+       MOBILEAP_SIGNAL_SOFTAP_DHCP_STATUS,
+       MOBILEAP_SIGNAL_MAX,
+} mobileap_signal_e;
+
+typedef enum {
+       MOBILEAP_TYPE_NONE,
+       MOBILEAP_TYPE_WIFI,
+       MOBILEAP_TYPE_USB,
+       MOBILEAP_TYPE_BT,
+       MOBILEAP_TYPE_P2P,
+       MOBILEAP_TYPE_WIFI_AP,
+       MOBILEAP_TYPE_MAX,
+} mobileap_type_e;
+
+typedef struct {
+       mobileap_type_e interface;                                      /* interface type */
+       guchar ip[IP_ADDR_LEN];                                         /**< assigned IP address */
+       guchar mac[MAC_ADDR_LEN];                                               /**< MAC Address */
+       gchar hostname[MOBILEAP_STR_INFO_LEN +1];       /**< Device name */
+       guint32 tm;                                                                     /**< connection time*/
+} mobileap_sta_s;
+
+typedef struct {
+       mobileap_type_e interface;                                              /* interface type */
+       gchar interface_name[MOBILEAP_STR_INFO_LEN +1]; /**< interface alphanumeric name */
+       guchar ip_address[IP_ADDR_LEN];                                 /**< assigned ip addresss to interface */
+       guchar gateway_address[IP_ADDR_LEN];                            /**< gateway address of interface */
+       guchar subnet_mask[IP_ADDR_LEN];                                        /**< subnet mask of interface */
+} mobileap_iface_s;
+
+typedef struct {
+       mobileap_iface_s iface_info;
+       GHashTable *sta_info;
+
+} tethering_mon_s;
+
+typedef struct {
+       mobileap_iface_s iface_info;
+       GHashTable *sta_info;
+} softap_mon_s;
+
+typedef struct {
+       gboolean is_initialized;
+       softap_mon_s softap;
+       tethering_mon_s tether;
+} mobileap_mon_s;
+
+mobileap_mon_s mobileap_mon;
+
+static DECLARE_DBUS_SIGNAL_HANDLER(name_owner_changed_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_net_closed_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_sta_connected_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_sta_disconnected_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_on_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_off_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_usb_on_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_usb_off_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_bt_on_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_bt_off_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_ap_on_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_ap_off_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_no_data_timeout_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_low_battery_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_flight_mode_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_security_type_changed_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_ssid_visibility_changed_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_passphrase_changed_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_dhcp_status_cb);
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_sta_connect_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_sta_disconnect_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_on_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_off_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_no_data_timeout_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_low_battery_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_flight_mode_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_security_type_changed_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_ssid_visibility_changed_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_passphrase_changed_cb);
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_dhcp_status_cb);
+
+static signal_param_s mobileap_signal_param[] = {
+               {
+                               .sender = DBUS_SERVICE_DBUS,
+                               .interface_name = DBUS_INTERFACE_DBUS,
+                               .member = DBUS_SIGNAL_NAME_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = MOBILEAP_SERVICE,
+                               .callback = __name_owner_changed_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_NET_CLOSED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_net_closed_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_STA_CONNECT,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_sta_connected_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_STA_DISCONNECT,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_sta_disconnected_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_WIFI_ON,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_wifi_on_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_WIFI_OFF,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_wifi_off_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_USB_ON,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_usb_on_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_USB_OFF,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_usb_off_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_BT_ON,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_bt_on_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_BT_OFF,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_bt_off_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_WIFI_AP_ON,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_wifi_ap_on_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_WIFI_AP_OFF,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_wifi_ap_off_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_NO_DATA_TIMEOUT,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_no_data_timeout_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_LOW_BATTERY,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_low_battery_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_FLIGHT_MODE,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_flight_mode_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_SECURITY_TYPE_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_security_type_changed_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_SSID_VISIBILITY_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_ssid_visibility_changed_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_PASSPHRASE_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_passphrase_changed_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = TETHERING_INTERFACE,
+                               .member = TETHER_SIGNAL_DHCP_STATUS,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __tether_dhcp_status_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = SOFTAP_INTERFACE,
+                               .member = SOFTAP_SIGNAL_STA_CONNECT,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __softap_sta_connect_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = SOFTAP_INTERFACE,
+                               .member = SOFTAP_SIGNAL_STA_DISCONNECT,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __softap_sta_disconnect_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = SOFTAP_INTERFACE,
+                               .member = SOFTAP_SIGNAL_ON,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __softap_on_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = SOFTAP_INTERFACE,
+                               .member = SOFTAP_SIGNAL_OFF,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __softap_off_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = SOFTAP_INTERFACE,
+                               .member = SOFTAP_SIGNAL_NO_DATA_TIMEOUT,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __softap_no_data_timeout_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = SOFTAP_INTERFACE,
+                               .member = SOFTAP_SIGNAL_LOW_BATTERY,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __softap_low_battery_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = SOFTAP_INTERFACE,
+                               .member = SOFTAP_SIGNAL_FLIGHT_MODE,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __softap_flight_mode_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = SOFTAP_INTERFACE,
+                               .member = SOFTAP_SIGNAL_SECURITY_TYPE_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __softap_security_type_changed_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = SOFTAP_INTERFACE,
+                               .member = SOFTAP_SIGNAL_SSID_VISIBLITY_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __softap_ssid_visibility_changed_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = SOFTAP_INTERFACE,
+                               .member = SOFTAP_SIGNAL_PASSPHRASECHANGED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __softap_passphrase_changed_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = MOBILEAP_SERVICE,
+                               .interface_name = SOFTAP_INTERFACE,
+                               .member = SOFTAP_SIGNAL_DHCP_STATUS,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __softap_dhcp_status_cb,
+                               .subscriber_id  = 0,
+               },
+};
+
+static gint __txt_to_mac(const gchar *txt, guchar *mac)
+{
+       int i = 0;
+
+       if (!txt || !mac) {
+               NM_LOGI("Invalid parameter");
+               return -1;
+       }
+
+       for (;;) {
+               mac[i++] = (char) strtoul((char *)txt, (char **)&txt, 16);
+               if (!*txt++ || i == 6)
+                       break;
+       }
+
+       if (i != MAC_ADDR_LEN)
+               return -1;
+
+       return 0;
+}
+
+static gint __txt_to_ip(const gchar *txt, guchar *ip)
+{
+       int i = 0;
+
+       for (;;) {
+               ip[i++] = (char) strtoul((char *)txt, (char **)&txt, 10);
+               if (i == IP_ADDR_LEN || !*txt++)
+                       break;
+       }
+
+       if (i != IP_ADDR_LEN)
+               return -1;
+
+       return 0;
+}
+
+static inline void __tether_init(mobileap_type_e type)
+{
+
+       mobileap_mon.tether.iface_info.interface = type;
+       mobileap_mon.tether.sta_info = g_hash_table_new_full(
+                       g_str_hash,
+                       g_str_equal,
+                       g_free,
+                       g_free);
+}
+
+
+static inline void __tether_deinit()
+{
+       mobileap_mon.tether.iface_info.interface = MOBILEAP_TYPE_NONE;
+       if (mobileap_mon.tether.sta_info) {
+               g_hash_table_remove_all(mobileap_mon.tether.sta_info);
+               g_hash_table_unref(mobileap_mon.tether.sta_info);
+               mobileap_mon.tether.sta_info = NULL;
+       }
+}
+
+static inline void __softap_init()
+{
+       mobileap_mon.softap.sta_info = g_hash_table_new_full(
+                       g_str_hash,
+                       g_str_equal,
+                       g_free,
+                       g_free);
+}
+
+static inline void __softap_deinit()
+{
+       mobileap_mon.softap.iface_info.interface = MOBILEAP_TYPE_NONE;
+       if (mobileap_mon.softap.sta_info) {
+               g_hash_table_remove_all(mobileap_mon.softap.sta_info);
+               g_hash_table_unref(mobileap_mon.softap.sta_info);
+               mobileap_mon.softap.sta_info = NULL;
+       }
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(name_owner_changed_cb)
+{
+       gchar *name = NULL;
+       gchar *old = NULL;
+       gchar *new = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (parameters == NULL)
+               return;
+
+       g_variant_get(parameters, "(&s&s&s)", &name, &old, &new);
+
+       if (g_strcmp0(name, MOBILEAP_SERVICE) == 0 && *new == '\0')
+               NM_LOGI("wfd-manager destroyed: name %s, old %s, new %s", name, old, new);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_net_closed_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_sta_connected_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_sta_disconnected_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_on_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __tether_init(MOBILEAP_TYPE_WIFI);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_off_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __tether_deinit();
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_usb_on_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __tether_init(MOBILEAP_TYPE_USB);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_usb_off_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __tether_deinit();
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_bt_on_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __tether_init(MOBILEAP_TYPE_BT);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_bt_off_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __tether_deinit();
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_ap_on_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __tether_init(MOBILEAP_TYPE_WIFI_AP);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_ap_off_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __tether_deinit();
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_no_data_timeout_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_low_battery_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_flight_mode_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_security_type_changed_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_ssid_visibility_changed_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_passphrase_changed_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(tether_dhcp_status_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       mobileap_sta_s *sta = NULL;
+       const gchar *event = NULL;
+       const guint32 type = 0;
+       const gchar *ip_addr = NULL;
+       const gchar *mac_addr = NULL;
+       const gchar *name = NULL;
+       const guint32 time = 0;
+
+       if (!parameters) {
+               NM_LOGI("Invalid parameters");
+               return;
+       }
+
+       g_variant_get(parameters, "(&su&s&s&su)",
+                       &event, &type, &ip_addr, &mac_addr, &name, &time);
+
+       if (!event || !ip_addr || !mac_addr || !name) {
+               NM_LOGI("failed to get parameters");
+               return;
+       }
+
+       if (!mobileap_mon.tether.sta_info) {
+               NM_LOGI("hash table empty");
+               return;
+       }
+
+       if (g_strcmp0("DhcpConnected", event) == 0) {
+
+               sta = g_try_malloc0(sizeof(mobileap_sta_s));
+               if (!sta) {
+                       NM_LOGI("malloc failed");
+                       return;
+               }
+
+               sta->interface = type;
+               __txt_to_mac(mac_addr, sta->mac);
+               __txt_to_ip(ip_addr, sta->ip);
+               g_strlcpy(sta->hostname, name, MOBILEAP_STR_INFO_LEN);
+               sta->tm = time;
+               g_hash_table_replace(mobileap_mon.tether.sta_info,
+                               strdup(mac_addr), sta);
+
+       } else if (g_strcmp0("DhcpLeaseDeleted", event) == 0) {
+               if(g_hash_table_remove(mobileap_mon.tether.sta_info, mac_addr))
+                       NM_LOGI("%s is removed", mac_addr);
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_sta_connect_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_sta_disconnect_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_on_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __softap_init();
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_off_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __softap_deinit();
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_no_data_timeout_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_low_battery_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_flight_mode_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_security_type_changed_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_ssid_visibility_changed_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_passphrase_changed_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER(softap_dhcp_status_cb)
+{
+       __NM_FUNC_ENTER__;
+
+       mobileap_sta_s *sta = NULL;
+       const gchar *event = NULL;
+       const gchar *ip_addr = NULL;
+       const gchar *mac_addr = NULL;
+       const gchar *name = NULL;
+       const guint32 time = 0;
+
+       if (!parameters) {
+               NM_LOGI("Invalid parameters");
+               return;
+       }
+
+       g_variant_get(parameters, "(&s&s&s&su)",
+                       &event, &ip_addr, &mac_addr, &name, &time);
+
+       if (!event || !ip_addr || !mac_addr || !name) {
+               NM_LOGI("failed to get parameters");
+               return;
+       }
+
+       if (!mobileap_mon.softap.sta_info) {
+               NM_LOGI("hash table empty");
+               return;
+       }
+
+       if (g_strcmp0("DhcpConnected", event) == 0) {
+
+               sta = g_try_malloc0(sizeof(mobileap_sta_s));
+               if (!sta) {
+                       NM_LOGI("malloc failed");
+                       return;
+               }
+
+               __txt_to_mac(mac_addr, sta->mac);
+               __txt_to_ip(ip_addr, sta->ip);
+               g_strlcpy(sta->hostname, name, MOBILEAP_STR_INFO_LEN);
+               sta->tm = time;
+               g_hash_table_replace(mobileap_mon.softap.sta_info,
+                               strdup(mac_addr), sta);
+
+       } else if (g_strcmp0("DhcpLeaseDeleted", event) == 0) {
+               if(g_hash_table_remove(mobileap_mon.softap.sta_info, mac_addr))
+                       NM_LOGI("%s is removed", mac_addr);
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+
+static inline void __subscribe_mobileap_signal()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+       int signal_idx = 0;
+       __NM_FUNC_ENTER__;
+
+       for (signal_idx = MOBILEAP_SIGNAL_NAME_OWENER_CHANGED;
+                       signal_idx < MOBILEAP_SIGNAL_MAX; signal_idx++) {
+               ret = nm_gdbus_subscribe_signal(&(mobileap_signal_param[signal_idx]));
+               if (ret != NM_GDBUS_ERROR_NONE)
+                       NM_LOGI("Error! Failed to subscribe signal");
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline void __unsubscribe_mobileap_signal()
+{
+       int signal_idx = 0;
+       int ret = NM_GDBUS_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       for (signal_idx = MOBILEAP_SIGNAL_NAME_OWENER_CHANGED;
+                       signal_idx < MOBILEAP_SIGNAL_MAX; signal_idx++) {
+
+               if (mobileap_signal_param[signal_idx].subscriber_id == 0)
+                       continue;
+
+               ret = nm_gdbus_unsubscribe_signal(&(mobileap_signal_param[signal_idx]));
+               if (ret != NM_GDBUS_ERROR_NONE)
+                       NM_LOGI("Error! Failed to unsubscribe signal");
+               else
+                       mobileap_signal_param[signal_idx].subscriber_id = 0;
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+int nm_mobileap_init()
+{
+       __NM_FUNC_ENTER__;
+
+       memset(&mobileap_mon, 0x00, sizeof(mobileap_mon));
+       mobileap_mon.is_initialized = TRUE;
+       __subscribe_mobileap_signal();
+
+       __NM_FUNC_EXIT__;
+       return NM_MOBILEAP_ERROR_NONE;
+}
+
+int nm_mobileap_deinit()
+{
+       __NM_FUNC_ENTER__;
+
+       if (!mobileap_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_MOBILEAP_ERROR_NOT_INITIALIZED;
+       }
+       __unsubscribe_mobileap_signal();
+       memset(&mobileap_mon, 0x00, sizeof(mobileap_mon));
+
+       __NM_FUNC_EXIT__;
+       return NM_MOBILEAP_ERROR_NONE;
+}
+
diff --git a/src/inm-net-access.c b/src/inm-net-access.c
new file mode 100644 (file)
index 0000000..1948d1b
--- /dev/null
@@ -0,0 +1,708 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for monitoring internet accessibility.
+ *
+ * @file        nm-net-access.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+
+#include <net/if.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/inotify.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netinet/if_ether.h>
+#include <net/if_arp.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+#include <net/route.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include "inm-daemon-log.h"
+#include "inm-util.h"
+#include "inm-net-access.h"
+
+#define BUF_SIZE 2048
+#define NM_INTERNET_CHECK_TIMEOUT      3
+#define HTTP_STATUS_CODE_OK    "HTTP/1.1 200"
+#define HTTP_STATUS_CODE_FOUND "HTTP/1.1 302"
+
+#define HTTP_STR_AUTH_ACTION   "auth action"
+#define HTTP_STR_LOCATION              "Location: "
+#define HTTP_STR_REQ_DATA              "GET /index.html HTTP/1.1\r\nHost: connman.net\r\n\r\n"
+
+#define URL_LIST_NUM           6
+
+typedef enum {
+       INTERNET_CHECK_STATE_NONE                       = 0,
+       INTERNET_CHECK_STATE_DNS_CHECK          = 1,
+       INTERNET_CHECK_STATE_PACKET_CHECK       = 2
+} nm_internet_check_state_e;
+
+typedef struct {
+       int fd;
+       char *addr;
+       int port;
+       guint transport_watch;
+       guint send_watch;
+       gboolean header_done;
+       gboolean request_started;
+} nm_internet_param_s;
+
+static const char* url_list[] = {
+        "www.google.com",
+        "www.msn.com",
+        "www.yahoo.com",
+        "m.google.com",
+        "www.amazon.com",
+        "www.youtube.com"
+};
+
+typedef struct {
+       GCancellable *cancellable;
+       nm_internet_param_s *net_params;
+       char *proxy_addr;
+       int url_index;
+       char *redirect_url1;
+       char *redirect_url2;
+       gboolean perform_recheck;
+       gboolean is_internet_available;
+       nm_internet_check_state_e check_state;
+       guint timer_source_id;
+} nm_net_access_mon_s;
+
+static nm_net_access_mon_s net_access_mon = {0, };
+
+static void __connect_sockets(void);
+static void __internet_check_state(nm_internet_check_state_e state);
+
+gboolean nm_net_access_get_status()
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return net_access_mon.is_internet_available;
+}
+
+static inline gboolean __is_http_status_ok_and_auth(unsigned char *reply)
+{
+       return (NULL != g_strrstr((char*)reply, HTTP_STATUS_CODE_OK)) &&
+                       (NULL != g_strrstr((char*)reply, HTTP_STR_AUTH_ACTION));
+}
+
+static inline gboolean __is_http_status_found(unsigned char *reply)
+{
+       return (NULL != g_strrstr((char*)reply, HTTP_STATUS_CODE_FOUND));
+}
+
+static inline gboolean __does_http_have_location(unsigned char *reply, char *temp)
+{
+       return ((temp = g_strrstr((char*)reply, HTTP_STR_LOCATION)) != NULL);
+}
+
+static inline gboolean __is_url1_null()
+{
+       return (net_access_mon.redirect_url1 == NULL);
+}
+
+static inline gboolean __is_url2_null()
+{
+       return (net_access_mon.redirect_url2 == NULL);
+}
+
+static inline gboolean __both_urls_not_null()
+{
+       return !(net_access_mon.redirect_url1 == NULL &&
+                       net_access_mon.redirect_url2 == NULL);
+}
+
+static inline gboolean __are_urls_same()
+{
+       return (g_strcmp0(net_access_mon.redirect_url1,
+                       net_access_mon.redirect_url2) == 0);
+}
+
+static inline void __process_urls()
+{
+       NM_LOGI("[%s] [%s]", net_access_mon.redirect_url1,
+                       net_access_mon.redirect_url2);
+
+       if (__are_urls_same()) {
+               NM_LOGI("Internet is un-available(Redirection to Error page)");
+               net_access_mon.is_internet_available = FALSE;
+       } else
+               net_access_mon.is_internet_available = TRUE;
+
+       g_free(net_access_mon.redirect_url1);
+       g_free(net_access_mon.redirect_url2);
+       net_access_mon.redirect_url1 = NULL;
+       net_access_mon.redirect_url2 = NULL;
+
+}
+
+static inline void __get_redirect_urls(char *temp)
+{
+       char *saveptr = NULL;
+       char * location = NULL;
+       int location_str_len = strlen(HTTP_STR_LOCATION);
+
+       location = strtok_r(temp, "\r", &saveptr);
+       if (!location)
+               return;
+
+       NM_LOGI("%s", location);
+
+       if (__is_url1_null())
+               net_access_mon.redirect_url1 = g_strdup(location + location_str_len);
+       else if (__is_url2_null())
+               net_access_mon.redirect_url2 = g_strdup(location + location_str_len);
+
+       if (__both_urls_not_null())
+               __process_urls();
+}
+
+static void __update_internet_status(unsigned char *reply)
+{
+       /* If the HTTP response is either 302 or 200 with redirection,
+        * then no Internet is available */
+       char *temp = NULL;
+       net_access_mon.is_internet_available = FALSE;
+
+       if (NULL != reply) {
+               if (__is_http_status_ok_and_auth(reply)) {
+                       NM_LOGI("200 OK but redirection found so:: Internet is un-available");
+               } else if (__is_http_status_found(reply)) {
+                       NM_LOGI("302:: Internet is un-available");
+               } else if (__does_http_have_location(reply, temp)) {
+                       __get_redirect_urls(temp);
+               } else {
+                       net_access_mon.is_internet_available = TRUE;
+                       NM_LOGI("Internet is available");
+               }
+       }
+
+       /* TODO: decide what will we do here */
+       /*
+       if (net_access_mon.is_internet_available == TRUE)
+       */
+}
+
+static gboolean __data_activity_timeout(gpointer data)
+{
+       nm_internet_param_s *net_params = NULL;
+       nm_internet_check_state_e prev_state =
+                       (nm_internet_check_state_e)GPOINTER_TO_INT(data);
+       __NM_FUNC_ENTER__;
+
+
+       NM_LOGI("Prev_state: state=%d (1:dns check / 2:packet check)", prev_state);
+
+       net_params = net_access_mon.net_params;
+       if (net_access_mon.net_params == NULL)
+               return FALSE;
+
+       if (TRUE == net_access_mon.perform_recheck &&
+                       prev_state != INTERNET_CHECK_STATE_NONE) {
+               net_access_mon.perform_recheck = FALSE;
+               if (prev_state == INTERNET_CHECK_STATE_DNS_CHECK) {
+                       net_params->request_started = FALSE;
+                       nm_net_access_start_checking();
+               } else
+                       __connect_sockets();
+       } else {
+               net_access_mon.perform_recheck = TRUE;
+               __internet_check_state(INTERNET_CHECK_STATE_NONE);
+       }
+
+       return FALSE;
+}
+
+static void __internet_check_timer_stop(void)
+{
+       if (net_access_mon.timer_source_id != 0) {
+               g_source_remove(net_access_mon.timer_source_id);
+               net_access_mon.timer_source_id = 0;
+       }
+       return;
+}
+
+static void __internet_check_timer_start(nm_internet_check_state_e state)
+{
+       static guint timeout = 0;
+       if (net_access_mon.timer_source_id != 0) {
+               NM_LOGI("netconfig_data_activity_timer is already running, so stop it");
+               __internet_check_timer_stop();
+       }
+
+       if (state == INTERNET_CHECK_STATE_NONE)
+               return;
+       else if (state == INTERNET_CHECK_STATE_DNS_CHECK)
+               timeout = NM_INTERNET_CHECK_TIMEOUT;
+       else if (state == INTERNET_CHECK_STATE_PACKET_CHECK)
+               timeout = NM_INTERNET_CHECK_TIMEOUT;
+
+       net_access_mon.timer_source_id = g_timeout_add_seconds(timeout,
+                       __data_activity_timeout,
+                       GINT_TO_POINTER(state));
+}
+
+static void __internet_check_state(nm_internet_check_state_e state)
+{
+       nm_internet_check_state_e prev_state = net_access_mon.check_state;
+
+       if (prev_state == state)
+               return;
+
+       NM_LOGI("state change (%d) -> (%d)", prev_state, state);
+       net_access_mon.check_state = state;
+
+       switch (state) {
+       case INTERNET_CHECK_STATE_DNS_CHECK:
+               __internet_check_timer_start(state);
+               break;
+       case INTERNET_CHECK_STATE_PACKET_CHECK:
+               if (prev_state == INTERNET_CHECK_STATE_DNS_CHECK)
+                       __internet_check_timer_stop();
+
+               __internet_check_timer_start(state);
+               break;
+       case INTERNET_CHECK_STATE_NONE:
+               switch (prev_state) {
+               case INTERNET_CHECK_STATE_DNS_CHECK:
+               case INTERNET_CHECK_STATE_PACKET_CHECK:
+                       __internet_check_timer_stop();
+                       nm_net_access_stop_checking();
+                       break;
+               default:
+                       break;
+               }
+               break;
+       }
+}
+
+static gboolean __received_data_event(GIOChannel *channel,
+               GIOCondition condition, gpointer data)
+{
+       nm_internet_param_s *net_params = NULL;
+       int n, fd;
+       unsigned char buf[BUF_SIZE] = {0, };
+       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+
+       net_params = net_access_mon.net_params;
+       if (net_params == NULL)
+               return FALSE;
+
+       if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
+               goto cleanup;
+
+       fd = g_io_channel_unix_get_fd(channel);
+       if (fd < 0)
+               goto cleanup;
+
+       n = read(fd, buf, BUF_SIZE - 1);
+       NM_LOGI("Received %d bytes[%s]", n, buf);
+       buf[BUF_SIZE - 1] = '\0';
+
+       if (n < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               NM_LOGI("read failed. %s", error_buf);
+
+               goto cleanup;
+       } else if (n == 0) {
+               NM_LOGI("connection closed");
+
+               goto cleanup;
+       }
+
+       /* We got data from server successfully */
+       __update_internet_status(buf);
+       __internet_check_state(INTERNET_CHECK_STATE_NONE);
+
+       return TRUE;
+
+cleanup:
+       /* Fail to get data from server */
+       __internet_check_state(INTERNET_CHECK_STATE_NONE);
+
+       return FALSE;
+}
+
+static gboolean __send_data_event(GIOChannel *channel,
+               GIOCondition condition, gpointer data)
+{
+       nm_internet_param_s *net_params = NULL;
+       gchar error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+       int n, fd;
+       const char *request_data = HTTP_STR_REQ_DATA;
+
+       net_params = net_access_mon.net_params;
+       if (net_params == NULL)
+               return FALSE;
+
+       if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
+               goto cleanup;
+
+       fd = g_io_channel_unix_get_fd(channel);
+       if (fd < 0)
+               goto cleanup;
+
+       /* We don't need to send anymore. Just return here.*/
+       /* Socket will be closed received part*/
+       if (net_params->header_done == TRUE)
+               return FALSE;
+
+       n = send(fd, request_data, strlen(request_data), MSG_NOSIGNAL);
+       NM_LOGI("Sent %d bytes", n);
+
+       if (n < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               NM_LOGI("send failed. %s", error_buf);
+
+               goto cleanup;
+       } else if (n == 0) {
+               NM_LOGI("connection closed");
+
+               goto cleanup;
+       }
+
+       net_params->header_done = TRUE;
+       return TRUE;
+
+cleanup:
+       __internet_check_state(INTERNET_CHECK_STATE_NONE);
+
+       return FALSE;
+}
+
+static void __connect_sockets(void)
+{
+       nm_internet_param_s *net_params = NULL;
+       GIOFlags flags;
+       struct sockaddr_in addr;
+       GIOChannel *channel = NULL;
+       int sock;
+
+       net_params = net_access_mon.net_params;
+       if (net_params == NULL || net_params->addr == NULL)
+               return;
+
+       sock = socket(PF_INET, SOCK_STREAM, 0);
+       if (sock < 0)
+               goto cleanup;
+
+       /* TODO: check below. What will be the ifname? */
+       /*
+       if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE,
+                       WIFI_IFNAME, strlen(WIFI_IFNAME) + 1) < 0) {
+               ERR("Bind to device error");
+               close(sock);
+               goto cleanup;
+       }
+       */
+
+       memset(&addr, 0, sizeof(struct sockaddr_in));
+       addr.sin_family = AF_INET;
+       addr.sin_addr.s_addr = inet_addr(net_params->addr);
+       addr.sin_port = htons(net_params->port);
+
+       /* Register Watch */
+       channel = g_io_channel_unix_new(sock);
+
+       flags = g_io_channel_get_flags(channel);
+       g_io_channel_set_flags(channel, flags | G_IO_FLAG_NONBLOCK, NULL);
+       g_io_channel_set_encoding(channel, NULL, NULL);
+       g_io_channel_set_buffered(channel, FALSE);
+
+       if (connect(sock, (struct sockaddr *)&addr,
+                       sizeof(struct sockaddr_in)) < 0) {
+               if (errno != EINPROGRESS) {
+                       NM_LOGI("connect fail");
+                       close(sock);
+                       goto cleanup;
+               }
+       }
+
+       NM_LOGI("Connect successful");
+
+       net_params->fd = sock;
+       net_params->transport_watch = g_io_add_watch(channel,
+                       (GIOCondition) (G_IO_IN | G_IO_HUP | G_IO_NVAL | G_IO_ERR),
+                       (GIOFunc) __received_data_event, NULL);
+       net_params->send_watch = g_io_add_watch(channel,
+                       (GIOCondition) (G_IO_OUT | G_IO_HUP | G_IO_NVAL | G_IO_ERR),
+                       (GIOFunc) __send_data_event, NULL);
+
+       __internet_check_state(INTERNET_CHECK_STATE_PACKET_CHECK);
+       return;
+
+cleanup:
+       __internet_check_state(INTERNET_CHECK_STATE_NONE);
+}
+
+static void __obtain_host_ip_addr_cb(GObject *src,
+               GAsyncResult *res,
+               gpointer user_data)
+{
+       nm_internet_param_s *net_params = NULL;
+       GList *list, *cur;
+       GInetAddress *addr;
+       gchar *str_addr;
+       GError *error = NULL;
+
+       net_params = net_access_mon.net_params;
+       if (net_params == NULL)
+               return;
+
+       if (net_access_mon.check_state == INTERNET_CHECK_STATE_NONE)
+               return;
+
+       list = g_resolver_lookup_by_name_finish((GResolver *)src, res, &error);
+       if (error != NULL) {
+               if (error->code == G_IO_ERROR_CANCELLED)
+                       NM_LOGI("G_IO_ERROR_CANCELLED is called[%s]", error->message);
+               g_error_free(error);
+       }
+
+       if (!list) {
+               NM_LOGI("no data");
+               goto cleanup;
+       }
+
+       for (cur = list; cur; cur = cur->next) {
+               addr = cur->data;
+               str_addr = g_inet_address_to_string(addr);
+               if (!str_addr)
+                       continue;
+
+               if (net_params != NULL) {
+                       g_free(net_params->addr);
+                       net_params->addr = str_addr;
+               }
+
+               g_object_unref(cur->data);
+               break;
+       }
+
+       g_list_free(list);
+
+       if (net_params->addr == NULL)
+               goto cleanup;
+
+       net_params->port = 80;
+       __connect_sockets();
+
+       return;
+
+cleanup:
+       __internet_check_state(INTERNET_CHECK_STATE_NONE);
+}
+
+gboolean __obtain_host_ip_addr(void)
+{
+       nm_internet_param_s *net_params = NULL;
+       char *host, *addr, *port;
+       char *saveptr = NULL;
+
+       net_params = net_access_mon.net_params;
+       if (net_params == NULL)
+               return FALSE;
+
+       if (net_params->request_started == TRUE)
+               return FALSE;
+       else
+               net_params->request_started = TRUE;
+
+       if (net_params->addr != NULL)
+               return TRUE;
+
+       net_access_mon.proxy_addr = nm_util_get_default_proxy();
+       NM_LOGI("Proxy(%s)", net_access_mon.proxy_addr);
+
+       if (++net_access_mon.url_index >= URL_LIST_NUM)
+               net_access_mon.url_index = 0;
+
+       NM_LOGI("addr (%s)", url_list[net_access_mon.url_index]);
+
+       /* FIXME: domain proxy should be resolved */
+       if (net_access_mon.proxy_addr == NULL) {
+               GResolver *r = NULL;
+               r = g_resolver_get_default();
+
+               g_resolver_lookup_by_name_async(r,
+                               url_list[net_access_mon.url_index],
+                               net_access_mon.cancellable,
+                               __obtain_host_ip_addr_cb,
+                               NULL);
+               __internet_check_state(INTERNET_CHECK_STATE_DNS_CHECK);
+
+               g_object_unref(r);
+               return FALSE;
+       } else {
+               host = g_strdup(net_access_mon.proxy_addr);
+               if (host == NULL)
+                       goto cleanup;
+
+               addr = strtok_r(host, ":", &saveptr);
+               if (addr == NULL)
+                       goto cleanup;
+
+               port = strrchr(net_access_mon.proxy_addr, ':');
+               if (port == NULL)
+                       goto cleanup;
+               else {
+                       char *end;
+                       int tmp = strtol(port + 1, &end, 10);
+
+                       if (*end == '\0') {
+                               *port = '\0';
+                               net_params->port = tmp;
+                       }
+               }
+               g_free(net_params->addr);
+               net_params->addr = g_strdup(addr);
+
+               g_free(host);
+       }
+       return TRUE;
+
+cleanup:
+       g_free(host);
+       nm_net_access_stop_checking();
+
+       return FALSE;
+}
+
+void nm_net_access_start_checking(void)
+{
+       nm_internet_param_s *net_params = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (net_access_mon.net_params == NULL) {
+               net_params = g_try_malloc0(sizeof(nm_internet_param_s));
+               if (net_params == NULL) {
+                       __NM_FUNC_EXIT__;
+                       return;
+               }
+               net_params->fd = -1;
+       } else {
+               net_params = net_access_mon.net_params;
+       }
+
+       if ((net_access_mon.check_state != INTERNET_CHECK_STATE_NONE) ||
+                       (net_params->request_started == TRUE)) {
+               NM_LOGI("Older query in progress");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       net_access_mon.is_internet_available = FALSE;
+
+       /* If the host IP is resolved, directly go for connecting to sockets*/
+       if (__obtain_host_ip_addr() == TRUE)
+               __connect_sockets();
+       __NM_FUNC_EXIT__;
+}
+
+void nm_net_access_stop_checking(void)
+{
+       nm_internet_param_s *net_params = NULL;
+
+       __NM_FUNC_ENTER__;
+       net_params = net_access_mon.net_params;
+       if (net_params == NULL) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       net_params->header_done = FALSE;
+       net_params->request_started = FALSE;
+
+       if (g_cancellable_is_cancelled(net_access_mon.cancellable) == FALSE) {
+               g_cancellable_cancel(net_access_mon.cancellable);
+               NM_LOGI("g_cancellable_cancel is called and return stop_internet_check");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       if (net_params->transport_watch > 0) {
+               g_source_remove(net_params->transport_watch);
+               net_params->transport_watch = 0;
+       }
+
+       if (net_params->send_watch > 0) {
+               g_source_remove(net_params->send_watch);
+               net_params->send_watch = 0;
+       }
+
+       if (net_params->fd > 0) {
+               close(net_params->fd);
+               net_params->fd = -1;
+       }
+
+       if (net_params->addr != NULL) {
+               g_free(net_params->addr);
+               net_params->addr = NULL;
+       }
+
+       if (net_access_mon.proxy_addr) {
+               g_free(net_access_mon.proxy_addr);
+               net_access_mon.proxy_addr = NULL;
+       }
+
+       g_free(net_params);
+       net_access_mon.net_params = NULL;
+
+       if (net_access_mon.redirect_url1) {
+               g_free(net_access_mon.redirect_url1);
+               net_access_mon.redirect_url1 = NULL;
+       }
+
+       if (net_access_mon.redirect_url2) {
+               g_free(net_access_mon.redirect_url2);
+               net_access_mon.redirect_url2 = NULL;
+       }
+       __NM_FUNC_EXIT__;
+}
+
+void nm_net_access_init(void)
+{
+       __NM_FUNC_ENTER__;
+       net_access_mon.cancellable = g_cancellable_new();
+       __NM_FUNC_EXIT__;
+}
+
+void nm_net_access_deinit(void)
+{
+       __NM_FUNC_ENTER__;
+       g_object_unref(net_access_mon.cancellable);
+       __NM_FUNC_EXIT__;
+}
+
diff --git a/src/inm-netaccess.c b/src/inm-netaccess.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/inm-netlink.c b/src/inm-netlink.c
new file mode 100644 (file)
index 0000000..3605cb2
--- /dev/null
@@ -0,0 +1,1013 @@
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <arpa/inet.h>
+#include <netinet/ether.h>
+#include <netinet/icmp6.h>
+#include <net/if_arp.h>
+#include <linux/if.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+
+#include <netlink/genl/genl.h>
+#include <netlink/genl/ctrl.h>
+
+#include <glib.h>
+#include "inm-iface-mon.h"
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-util.h"
+#include "inm-daemon.h"
+
+#define NMDAEMON_NETWORK_PATH                  "/net/nmdaemon/network"
+#define NMDAEMON_NETWORK_INTERFACE             "net.nmdaemon.network"
+
+#define NETWORK_RETRY_RATE_MON_INTERVAL                5*1000
+#define NETWORK_CHANNEL_MON_INTERVAL           5*1000
+#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
+
+static GIOChannel *channel = NULL;
+static guint channel_watch = 0;
+
+static nmdaemon_request_table_s request_table[NMDAEMON_MONITOR_TYPE_MAX];
+static nmdaemon_htmode_e g_htmode;
+
+static void __destroy_mon_data(gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       nmdaemon_mon_data_s *mon_data = (nmdaemon_mon_data_s *)user_data;
+
+       g_source_remove(mon_data->timer_source_id);
+       mon_data->timer_source_id = 0;
+
+       nl_socket_free(mon_data->nl_global->socket);
+       g_free(mon_data->nl_global);
+       g_free(mon_data);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+static const char *operstate2str(unsigned char operstate)
+{
+       switch (operstate) {
+       case IF_OPER_UNKNOWN:
+               return "UNKNOWN";
+       case IF_OPER_NOTPRESENT:
+               return "NOT-PRESENT";
+       case IF_OPER_DOWN:
+               return "DOWN";
+       case IF_OPER_LOWERLAYERDOWN:
+               return "LOWER-LAYER-DOWN";
+       case IF_OPER_TESTING:
+               return "TESTING";
+       case IF_OPER_DORMANT:
+               return "DORMANT";
+       case IF_OPER_UP:
+               return "UP";
+       }
+
+       return "";
+}
+
+/*
+static void __nm_notify_ethernet_cable_state(const char *sig_name, const char *key)
+{
+       GVariantBuilder *builder;
+       GVariant *params;
+
+       NM_LOGE("[Signal] %s %s", sig_name, key);
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "key", g_variant_new_string(key));
+
+       params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       nm_gdbus_emit_signal(NULL,
+                               NMDAEMON_NETWORK_PATH,
+                               NMDAEMON_NETWORK_INTERFACE,
+                               sig_name,
+                               params);
+
+       return;
+}
+*/
+
+static gboolean __nm_extract_link(struct ifinfomsg *msg, int bytes,
+               const char **ifname, unsigned char *operstate)
+{
+       struct rtattr *attr;
+
+       if (!ifname || !operstate)
+               return FALSE;
+
+       for (attr = IFLA_RTA(msg); RTA_OK(attr, bytes);
+                                       attr = RTA_NEXT(attr, bytes)) {
+               switch (attr->rta_type) {
+               case IFLA_IFNAME:
+                       *ifname = RTA_DATA(attr);
+                       break;
+               case IFLA_OPERSTATE:
+                       *operstate = *((unsigned char *) RTA_DATA(attr));
+                       break;
+               }
+       }
+
+       if (*ifname == NULL && *operstate == 0xff)
+               return FALSE;
+
+       return TRUE;
+}
+
+static void __nl_message(void *buf, size_t length, gpointer user_data)
+{
+       NM_LOGE("");
+       while (length > 0) {
+               struct nlmsghdr *hdr = buf;
+               iface_mon_data_s *data = (iface_mon_data_s *)user_data;
+               if (!data)
+                       NM_LOGI("user data not available");
+
+               if (!NLMSG_OK(hdr, length))
+                       break;
+
+               if (hdr->nlmsg_type == RTM_NEWLINK) {
+                       unsigned char operstate = 0xff;
+                       const char *ifname = NULL;
+                       struct ifinfomsg *msg = (struct ifinfomsg *) NLMSG_DATA(hdr);
+
+                       if (!__nm_extract_link(msg, IFA_PAYLOAD(hdr), &ifname, &operstate))
+                               return;
+
+                       if (strncmp(ifname, "eth", 3) == 0 && operstate != 0xff) {
+                               NM_LOGI("%s {newlink} index %d operstate %u <%s>", ifname, msg->ifi_index,
+                                               operstate, operstate2str(operstate));
+
+                               int status = 0;
+                               if (operstate == IF_OPER_UP) {
+                                       NM_LOGI("ATTACHED");
+                                       status = 1;
+                               } else if (operstate == IF_OPER_DOWN) {
+                                       NM_LOGI("DETACHED");
+                                       status = 0;
+                               }
+
+                               if (data->cb)
+                                       data->cb((char *)ifname, status, data->cb_user_data);
+                       }
+               }
+
+               length -= hdr->nlmsg_len;
+               buf += hdr->nlmsg_len;
+       }
+}
+
+static gboolean __nm_netlink_event(GIOChannel *channel, GIOCondition cond, gpointer user_data)
+{
+       NM_LOGE("");
+       struct sockaddr_nl nladdr;
+       socklen_t addr_len = sizeof(nladdr);
+       unsigned char buf[4096];
+       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+       int fd, length = 0;
+
+       if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR))
+               return FALSE;
+
+       memset(buf, 0, sizeof(buf));
+       memset(&nladdr, 0, sizeof(nladdr));
+
+       fd = g_io_channel_unix_get_fd(channel);
+
+       length = recvfrom(fd, buf, sizeof(buf), 0,
+                       (struct sockaddr *) &nladdr, &addr_len);
+       if (length < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               NM_LOGE("Failed to get netlink message [error: %s]", error_buf);
+               if (errno == EINTR || errno == EAGAIN)
+                       return TRUE;
+
+               return FALSE;
+       }
+
+       if (length == 0)
+               return FALSE;
+
+       if (nladdr.nl_pid != 0) { /* not sent by kernel, ignore */
+               NM_LOGE("Received msg from %u, ignoring it", nladdr.nl_pid);
+               return TRUE;
+       }
+
+       __nl_message(buf, length, user_data);
+
+       return TRUE;
+}
+
+int nm_rtnl_init(gpointer user_data)
+{
+       NM_LOGE("");
+       struct sockaddr_nl addr;
+       int fd;
+
+       memset(&addr, 0, sizeof(addr));
+       addr.nl_family = AF_NETLINK;
+       addr.nl_groups = RTMGRP_LINK;
+
+       fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+       if (fd < 0) {
+               NM_LOGI("Failed to create socket");
+               return -1;
+       }
+
+       if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+               NM_LOGI("Failed to bin socket");
+               close(fd);
+               return -1;
+       }
+
+       channel = g_io_channel_unix_new(fd);
+       g_io_channel_set_close_on_unref(channel, TRUE);
+
+       g_io_channel_set_encoding(channel, NULL, NULL);
+       g_io_channel_set_buffered(channel, FALSE);
+
+       channel_watch = g_io_add_watch(channel,
+                               G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
+                               __nm_netlink_event, user_data);
+
+       return 0;
+}
+
+void nm_rtnl_cleanup(void)
+{
+       NM_LOGE("");
+       if (channel_watch) {
+               NM_LOGI("Remove channel watch");
+               g_source_remove(channel_watch);
+               channel_watch = 0;
+       }
+
+       g_io_channel_shutdown(channel, TRUE, NULL);
+       g_io_channel_unref(channel);
+
+       channel = NULL;
+}
+
+/** Retry Tx Rate monitor */
+static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
+                        void *user_data)
+{
+       int *ret = user_data;
+       *ret = err->error;
+       NM_LOGI("Error: %d", err->error);
+
+       return NL_STOP;
+}
+
+static int finish_handler(struct nl_msg *msg, void *arg)
+{
+       int *ret = arg;
+       *ret = 0;
+       return NL_SKIP;
+}
+
+static int ack_handler(struct nl_msg *msg, void *arg)
+{
+       int *ret = arg;
+       *ret = 0;
+       return NL_STOP;
+}
+
+static const char *ht_secondary_offset[4] = {
+        "no secondary",
+        "above",
+        "[reserved!]",
+        "below",
+};
+
+struct nmdaemon_ie_print {
+        const char *name;
+        void (*print)(nmdaemon_mon_data_s *data, const uint8_t type, uint8_t len, const uint8_t *ie);
+        uint8_t minlen, maxlen;
+        uint8_t flags;
+};
+
+static void __nmdaemon_print_ht_op(nmdaemon_mon_data_s *data, const uint8_t type, uint8_t len, const uint8_t *ie)
+{
+       strncpy(data->sec_chan_offset, ht_secondary_offset[ie[1] & 0x3], SEC_OFFSET_LEN);
+}
+
+static const struct nmdaemon_ie_print ie_printers[] = {
+       [61] = { "HT operation", __nmdaemon_print_ht_op, 22, 22, 1, },
+};
+
+static void nmdaemon_print_ie(nmdaemon_mon_data_s *data, const struct nmdaemon_ie_print *p, const uint8_t type,
+                     uint8_t len, const uint8_t *ie)
+{
+        if (!p->print)
+                return;
+
+       if (len < p->minlen || len > p->maxlen) {
+
+               int i;
+               if (len > 1) {
+                       NM_LOGE(" <invalid: %d bytes:", len);
+                       for (i = 0; i < len; i++)
+                               NM_LOGE(" %.02x", ie[i]);
+               } else if (len)
+                       NM_LOGE("invalid: 1 byte: %.02x", ie[0]);
+               else
+                       NM_LOGE("invalid: no data");
+
+               return;
+       }
+
+        p->print(data, type, len, ie);
+}
+
+static void __nmdaemon_print_ies(nmdaemon_mon_data_s *data, unsigned char *ie, int ielen)
+{
+       while (ielen >= 2 && ielen >= ie[1]) {
+               if (ie[0] < ARRAY_SIZE(ie_printers) &&
+                               ie_printers[ie[0]].name) {
+                       nmdaemon_print_ie(data, &ie_printers[ie[0]], ie[0], ie[1], ie + 2);
+               }
+               ielen -= ie[1] + 2;
+               ie += ie[1] + 2;
+       }
+}
+
+static nmdaemon_chan_info_s *__nmdaemon_find_chan(nmdaemon_chan_intf_info_s *intf_info, int freq)
+{
+       nmdaemon_chan_info_s *chan = NULL;
+       int i;
+       for (i = 0; i < intf_info->cur_pos; i++) {
+               chan = &intf_info->chan[i];
+
+               if (chan->freq == freq)
+                       return chan;
+       }
+
+       return NULL;
+}
+
+static gboolean __nmdaemon_is_2_4Ghz_band(int freq)
+{
+       if ((freq >= 2412) && (freq <= 2472))
+               return TRUE;
+
+       return FALSE;
+}
+
+static double __nmdaemon_get_channel_interference(nmdaemon_mon_data_s *data)
+{
+       nmdaemon_chan_info_s *chan, *adj_chan = NULL;
+       nmdaemon_chan_intf_info_s *intf_info = (nmdaemon_chan_intf_info_s *)data->intf_info;
+       int n_chans = 1;
+       int j;
+       double total_weight = 0;
+       double total_intf = 0;
+
+       if (intf_info->htmode == NMDAEMON_HTMODE_HT40) {
+               n_chans = 2;
+       }
+
+       if (intf_info->htmode == NMDAEMON_HTMODE_HT80) {
+               n_chans = 4;
+       }
+
+       chan = &intf_info->chan[intf_info->home_channel_pos];
+       total_intf = chan->intf_factor;
+       total_weight = 1;
+
+       for (j = 1; j < n_chans; j++) {
+               if (!strcmp(data->sec_chan_offset, "above")) {
+                       adj_chan = __nmdaemon_find_chan(intf_info, chan->freq + (j * 20));
+                       if (!adj_chan) {
+                               break;
+                       }
+               }
+
+               if (!strcmp(data->sec_chan_offset, "below")) {
+                       adj_chan = __nmdaemon_find_chan(intf_info, chan->freq - (j * 20));
+                       if (!adj_chan) {
+                               break;
+                       }
+               }
+
+               if (adj_chan) {
+                       total_intf += adj_chan->intf_factor;
+                       total_weight += 1;
+               }
+
+       }
+
+       if (intf_info->is_2_4Ghz_band) {
+               for (j = 0; j < n_chans; j++) {
+                       if (!strcmp(data->sec_chan_offset, "above")) {
+                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq + (j * 20) - 5);
+                               if (adj_chan) {
+                                       total_intf += (0.85 * adj_chan->intf_factor);
+                                       total_weight += 0.85;
+                               }
+
+                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq + (j * 20) - 10);
+                               if (adj_chan) {
+                                       total_intf += (0.55 * adj_chan->intf_factor);
+                                       total_weight += 0.55;
+                               }
+
+                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq + (j * 20) + 5);
+                               if (adj_chan) {
+                                       total_intf += (0.85 * adj_chan->intf_factor);
+                                       total_weight += 0.85;
+                               }
+
+                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq + (j * 20) + 10);
+                               if (adj_chan) {
+                                       total_intf += (0.55 * adj_chan->intf_factor);
+                                       total_weight += 0.55;
+                               }
+                       }
+
+                       if (!strcmp(data->sec_chan_offset, "below")) {
+                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq - (j * 20) + 5);
+                               if (adj_chan) {
+                                       total_intf += (0.85 * adj_chan->intf_factor);
+                                       total_weight += 0.85;
+                               }
+
+                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq - (j * 20) + 10);
+                               if (adj_chan) {
+                                       total_intf += (0.55 * adj_chan->intf_factor);
+                                       total_weight += 0.55;
+                               }
+
+                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq - (j * 20) - 5);
+                               if (adj_chan) {
+                                       total_intf += (0.85 * adj_chan->intf_factor);
+                                       total_weight += 0.85;
+                               }
+
+                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq - (j * 20) - 10);
+                               if (adj_chan) {
+                                       total_intf += (0.55 * adj_chan->intf_factor);
+                                       total_weight += 0.55;
+                               }
+                       }
+               }
+       }
+
+       total_intf = total_intf/total_weight;
+       NM_LOGI("total_intf: %lf", total_intf);
+
+       return total_intf;
+}
+
+static int nl_scan_info(struct nl_msg *msg, void *user_data)
+{
+       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s *)user_data;
+       struct nlattr *tb[NL80211_ATTR_MAX + 1];
+       struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+       struct nlattr *bss[NL80211_BSS_MAX + 1];
+
+       static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
+               [NL80211_BSS_TSF] = { .type = NLA_U64 },
+               [NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
+               [NL80211_BSS_BSSID] = { },
+               [NL80211_BSS_BEACON_INTERVAL] = { .type = NLA_U16 },
+               [NL80211_BSS_CAPABILITY] = { .type = NLA_U16 },
+               [NL80211_BSS_INFORMATION_ELEMENTS] = { },
+               [NL80211_BSS_SIGNAL_MBM] = { .type = NLA_U32 },
+               [NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 },
+               [NL80211_BSS_STATUS] = { .type = NLA_U32 },
+               [NL80211_BSS_SEEN_MS_AGO] = { .type = NLA_U32 },
+               [NL80211_BSS_BEACON_IES] = { },
+       };
+
+       nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+                       genlmsg_attrlen(gnlh, 0), NULL);
+
+       if (!tb[NL80211_ATTR_BSS]) {
+               NM_LOGE("bss info missing!\n");
+               return NL_SKIP;
+       }
+
+       if (nla_parse_nested(bss, NL80211_BSS_MAX,
+                               tb[NL80211_ATTR_BSS],
+                               bss_policy)) {
+               NM_LOGE("failed to parse nested attributes!");
+               return NL_SKIP;
+       }
+
+       if (!bss[NL80211_BSS_BSSID])
+               return NL_SKIP;
+
+       if (bss[NL80211_BSS_STATUS]) {
+               if (nla_get_u32(bss[NL80211_BSS_STATUS]) != NL80211_BSS_STATUS_ASSOCIATED) {
+                       NM_LOGE("sta is not associated to this AP");
+                       return NL_SKIP;
+               }
+       } else {
+               return NL_SKIP;
+       }
+
+       if (bss[NL80211_BSS_FREQUENCY]) {
+               data->freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
+               NM_LOGI("data->freq: %d", data->freq);
+       }
+
+       if (bss[NL80211_BSS_INFORMATION_ELEMENTS]) {
+               if (bss[NL80211_BSS_BEACON_IES])
+                       NM_LOGI("Information elements from Probe Response frame:");
+               __nmdaemon_print_ies(data, nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]),
+                               nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]));
+       }
+
+       return NL_SKIP;
+}
+
+static int nl_survey_info(struct nl_msg *msg, void *user_data)
+{
+       __NM_FUNC_ENTER__;
+       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s *)user_data;
+       nmdaemon_chan_intf_info_s *intf_info = (nmdaemon_chan_intf_info_s *)data->intf_info;
+       struct nlattr *tb[NL80211_ATTR_MAX + 1];
+       struct genlmsghdr *genlh = nlmsg_data(nlmsg_hdr(msg));
+       struct nlattr *survey_info[NL80211_SURVEY_INFO_MAX + 1];
+
+       static struct nla_policy survey_policy[NL80211_SURVEY_INFO_MAX + 1] = {
+               [NL80211_SURVEY_INFO_FREQUENCY] = { .type = NLA_U32 },
+               [NL80211_SURVEY_INFO_NOISE] = { .type = NLA_U8 },
+       };
+       unsigned int freq = 0;
+       unsigned long long ch_active_time = 0;
+       unsigned long long ch_busy_time = 0;
+       unsigned long long ch_tx_time = 0;
+       gboolean is_2_4Ghz_band = TRUE;
+
+       nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(genlh, 0),
+                       genlmsg_attrlen(genlh, 0), NULL);
+
+       if (!tb[NL80211_ATTR_SURVEY_INFO]) {
+               NM_LOGE("survey data missing!");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (nla_parse_nested(survey_info, NL80211_SURVEY_INFO_MAX,
+                               tb[NL80211_ATTR_SURVEY_INFO],
+                               survey_policy)) {
+               NM_LOGE("failed to parse nested attributes!");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (survey_info[NL80211_SURVEY_INFO_FREQUENCY]) {
+               freq = nla_get_u32(survey_info[NL80211_SURVEY_INFO_FREQUENCY]);
+               NM_LOGI("frequency: %u MHz%s", freq,
+                               survey_info[NL80211_SURVEY_INFO_IN_USE] ? " [in use]" : "");
+               is_2_4Ghz_band = __nmdaemon_is_2_4Ghz_band(freq);
+       }
+
+       if (is_2_4Ghz_band == intf_info->is_2_4Ghz_band) {
+               intf_info->chan[intf_info->cur_pos].freq = freq;
+
+               if (survey_info[NL80211_SURVEY_INFO_TIME]) {
+                       ch_active_time = (unsigned long long)nla_get_u64(survey_info[NL80211_SURVEY_INFO_TIME]);
+                       NM_LOGI("channel active time: %llu ms", ch_active_time);
+               }
+               if (survey_info[NL80211_SURVEY_INFO_TIME_BUSY]) {
+                       ch_busy_time = (unsigned long long)nla_get_u64(survey_info[NL80211_SURVEY_INFO_TIME_BUSY]);
+                       NM_LOGI("channel busy time: %llu ms", ch_busy_time);
+               }
+               if (survey_info[NL80211_SURVEY_INFO_TIME_TX]) {
+                       ch_tx_time = (unsigned long long)nla_get_u64(survey_info[NL80211_SURVEY_INFO_TIME_TX]);
+                       NM_LOGI("channel transmit time: %llu ms", ch_tx_time);
+               }
+
+               if (survey_info[NL80211_SURVEY_INFO_IN_USE]) {
+                       intf_info->home_channel_pos = intf_info->cur_pos;
+               }
+
+               intf_info->chan[intf_info->cur_pos].intf_factor = (((double)(ch_busy_time - ch_tx_time)) / ((double)(ch_active_time - ch_tx_time)));
+               intf_info->cur_pos++;
+       }
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+static int nl_station_info(struct nl_msg* msg, void *user_data)
+{
+       __NM_FUNC_ENTER__;
+       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s *)user_data;
+       int retry_rate = 0;
+       float tx_retries = 0.0, tx_packets = 0.0, tx_failed = 0.0;
+       struct nlattr *tb[NL80211_ATTR_MAX + 1];
+       struct genlmsghdr *genlh = nlmsg_data(nlmsg_hdr(msg));
+       struct nlattr *sta_info[NL80211_STA_INFO_MAX + 1];
+       char mac_addr[20];
+       static struct nla_policy station_stats[NL80211_STA_INFO_MAX + 1] = {
+               [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
+               [NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
+               [NL80211_STA_INFO_TX_RETRIES] = { .type = NLA_U32 },
+               [NL80211_STA_INFO_TX_FAILED] = { .type = NLA_U32 },
+               [NL80211_STA_INFO_TX_BITRATE] = { .type = NLA_NESTED },
+       };
+
+       struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
+        static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
+                [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
+                [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
+        };
+
+       nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(genlh, 0),
+                       genlmsg_attrlen(genlh, 0), NULL);
+
+       if (!tb[NL80211_ATTR_STA_INFO]) {
+               NM_LOGE("sta info missing");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+       if (nla_parse_nested(sta_info, NL80211_STA_INFO_MAX,
+                               tb[NL80211_ATTR_STA_INFO],
+                               station_stats)) {
+               NM_LOGE("Failed to parse nested station info");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       nmdaemon_convert_byte_to_string(mac_addr, nla_data(tb[NL80211_ATTR_MAC]));
+       NM_LOGI("Station %s)", mac_addr);
+
+       if (sta_info[NL80211_STA_INFO_INACTIVE_TIME])
+               NM_LOGI("Inactive time: %u ms",
+                               nla_get_u32(sta_info[NL80211_STA_INFO_INACTIVE_TIME]));
+       if (sta_info[NL80211_STA_INFO_TX_PACKETS]) {
+               tx_packets = (float)nla_get_u32(sta_info[NL80211_STA_INFO_TX_PACKETS]);
+               NM_LOGI("Tx packets: %f", tx_packets);
+       }
+       if (sta_info[NL80211_STA_INFO_TX_RETRIES]) {
+               tx_retries = (float)nla_get_u32(sta_info[NL80211_STA_INFO_TX_RETRIES]);
+               NM_LOGI("Tx retries: %f", tx_retries);
+       }
+       if (sta_info[NL80211_STA_INFO_TX_FAILED]) {
+               tx_failed = (float)nla_get_u32(sta_info[NL80211_STA_INFO_TX_FAILED]);
+               NM_LOGI("Tx failed: %f", tx_failed);
+       }
+       if (sta_info[NL80211_STA_INFO_TX_BITRATE]) {
+               if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+                                       sta_info[NL80211_STA_INFO_TX_BITRATE], rate_policy)) {
+                       NM_LOGE("failed to parse nested rate attributes!");
+                       g_htmode = NMDAEMON_HTMODE_UNKNOWN;
+                       __NM_FUNC_EXIT__;
+                       return -1;
+               }
+
+               g_htmode = NMDAEMON_HTMODE_HT20;
+               if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
+                       g_htmode = NMDAEMON_HTMODE_HT40;
+               else if (rinfo[NL80211_RATE_INFO_80_MHZ_WIDTH])
+                       g_htmode = NMDAEMON_HTMODE_HT80;
+       }
+
+       retry_rate = (tx_retries/tx_packets) * 100;
+
+       if (data->tx_cb)
+               data->tx_cb(retry_rate, data->cb_user_data);
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+static int __nmdaemon_initialize_nl80211(gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s*)user_data;
+       nmdaemon_nl_global_s *global = (nmdaemon_nl_global_s *)data->nl_global;
+       int err = 0;
+
+       global->if_index = nmdaemon_get_interface_index(WIFI_IFNAME);
+       if (global->if_index < 0) {
+               NM_LOGE("Failed to get interface index");
+               return -1;
+       }
+
+       global->socket = nl_socket_alloc();
+       if (!global->socket) {
+               NM_LOGE("Failed to allocate netlink socket.");
+               return -ENOMEM;
+       }
+
+       global->cb = nl_cb_alloc(NL_CB_DEFAULT);
+       if (!global->cb) {
+               NM_LOGE("Failed to allocate netlink callbacks.");
+               err = -ENOMEM;
+               goto fail;
+       }
+       if (genl_connect(global->socket)) {
+               NM_LOGE("Failed to connect to generic netlink.");
+               err = -ENOLINK;
+               goto fail;
+       }
+
+       global->id = genl_ctrl_resolve(global->socket, "nl80211");
+       if (global->id < 0) {
+               NM_LOGE("Failed to find the nl80211 driver");
+               err = -ENOENT;
+               goto fail;
+       }
+       NM_LOGI("ID [%d]", global->id);
+
+       __NM_FUNC_EXIT__;
+       return 0;
+
+fail:
+       nl_cb_put(global->cb);
+       nl_socket_free(global->socket);
+
+       __NM_FUNC_EXIT__;
+       return err;
+}
+
+static gboolean __nmdaemon_send_netlink_cmd(gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       int err;
+       struct nl_msg *msg;
+       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s*)user_data;
+       nmdaemon_nl_global_s *global = (nmdaemon_nl_global_s *)data->nl_global;
+
+       if (data->timer_source_id == 0) {
+               NM_LOGI("monitoring stopped, timer_source_id: %d.", data->timer_source_id);
+               __NM_FUNC_EXIT__;
+               return FALSE;
+       }
+
+       /** allocate a message */
+       msg = nlmsg_alloc();
+       if (msg == NULL) {
+               NM_LOGE("Failed to allocate netlink message");
+               __NM_FUNC_EXIT__;
+               return FALSE;
+       }
+
+       /** setup the command into message */
+       genlmsg_put(msg, 0, 0, global->id, 0, NLM_F_DUMP, global->cmd, 0);
+
+       /** add message attributes */
+       err = nla_put_u32(msg, NL80211_ATTR_IFINDEX, global->if_index);
+       if (err < 0) {
+               NM_LOGE("Failed to add integer attribute, error (%d:%s)", err, nl_geterror(-err));
+               goto out;
+       }
+
+       /** send the messge */
+       err = nl_send_auto_complete(global->socket, msg);
+       if (err < 0) {
+               NM_LOGE("Failed to send nl message, error (%d:%s)", err, nl_geterror(-err));
+               goto out;
+       }
+       NM_LOGI("nl80211 cmd[%d] sent %d bytes to the kernel", global->cmd, err);
+
+       err = 1;
+       nl_cb_err(global->cb, NL_CB_CUSTOM, error_handler, &err);
+       nl_cb_set(global->cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
+       nl_cb_set(global->cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
+
+       switch(global->cmd) {
+       case NL80211_CMD_GET_SCAN:
+               nl_cb_set(global->cb, NL_CB_VALID, NL_CB_CUSTOM, nl_scan_info, user_data);
+               break;
+       case NL80211_CMD_GET_STATION:
+               nl_cb_set(global->cb, NL_CB_VALID, NL_CB_CUSTOM, nl_station_info, user_data);
+               break;
+       case NL80211_CMD_GET_SURVEY:
+               nl_cb_set(global->cb, NL_CB_VALID, NL_CB_CUSTOM, nl_survey_info, user_data);
+               break;
+       default:
+               goto out;
+       }
+
+       /** Receive the kernel message. */
+       while (err > 0)
+               nl_recvmsgs(global->socket, global->cb);
+
+out:
+       nlmsg_free(msg);
+       __NM_FUNC_EXIT__;
+       return TRUE;
+}
+
+int nm_retry_tx_rate_monitor_start(nm_retry_tx_rate_callback cb, void *user_data)
+{
+       __NM_FUNC_ENTER__;
+       nmdaemon_mon_data_s *data = NULL;
+
+       if (!cb) {
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_INVALID_PARAM;
+       }
+
+       request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].is_initialized = TRUE;
+       request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table = g_hash_table_new_full(g_direct_hash,
+                       g_direct_equal,
+                       NULL,
+                       __destroy_mon_data
+                       );
+
+       if (!request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table) {
+               request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].is_initialized = FALSE;
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_OPERATION_FAILED;
+       }
+
+       data = (nmdaemon_mon_data_s *)g_try_malloc0(sizeof(nmdaemon_mon_data_s));
+       if (!data) {
+               NM_LOGE("Failed to allocate memory to data variable.");
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
+       }
+
+       data->tx_cb = cb;
+       data->cb_user_data = user_data;
+
+       data->nl_global = (nmdaemon_nl_global_s *)g_try_malloc0(sizeof(nmdaemon_nl_global_s));
+       if (!data->nl_global) {
+               NM_LOGE("Failed to allocate memory to nl_global.");
+               g_free(data);
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
+       }
+
+       /** Initialize netlink socket */
+       data->nl_global->cmd = NL80211_CMD_GET_STATION;
+       int err = __nmdaemon_initialize_nl80211(data);
+       if (err < 0) {
+               NM_LOGE("__nmdaemon_initialize_nl80211() failed, error %d", err);
+               g_free(data->nl_global);
+               g_free(data);
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
+       }
+
+       data->timer_source_id = g_timeout_add(NETWORK_RETRY_RATE_MON_INTERVAL,
+                       __nmdaemon_send_netlink_cmd, data);
+
+       g_hash_table_insert(request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table,
+                       GINT_TO_POINTER(NL80211_CMD_GET_STATION), data);
+
+       __NM_FUNC_EXIT__;
+       return NM_DAEMON_ERROR_NONE;
+}
+
+int nm_retry_tx_rate_monitor_stop()
+{
+       __NM_FUNC_ENTER__;
+       gint ret = NM_DAEMON_ERROR_NONE;
+
+       if (!request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_NOT_INITIALIZED;
+       }
+
+       request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].is_initialized = FALSE;
+       g_hash_table_remove_all(request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table);
+       g_hash_table_unref(request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table);
+       request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table = NULL;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+static gboolean __nmdaemon_monitor_channel_interference(void *user_data)
+{
+       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s*)user_data;
+       gboolean ret;
+
+       data->nl_global->cmd = NL80211_CMD_GET_SCAN;
+       ret = __nmdaemon_send_netlink_cmd(data);
+       if (ret == FALSE)
+               return FALSE;
+
+       /** Fill Channel Information */
+       nmdaemon_chan_intf_info_s *intf_info = (nmdaemon_chan_intf_info_s *)data->intf_info;
+       intf_info->home_channel_freq = data->freq;
+       intf_info->is_2_4Ghz_band = __nmdaemon_is_2_4Ghz_band(intf_info->home_channel_freq);
+       intf_info->cur_pos = 0;
+       intf_info->home_channel_pos = -1;
+
+       /** get htmode */
+       data->nl_global->cmd = NL80211_CMD_GET_STATION;
+       ret = __nmdaemon_send_netlink_cmd(data);
+       if (ret == FALSE)
+               return FALSE;
+       intf_info->htmode = g_htmode;
+
+       data->nl_global->cmd = NL80211_CMD_GET_SURVEY;
+       ret = __nmdaemon_send_netlink_cmd(data);
+       if (ret == FALSE)
+               return FALSE;
+
+       double channel_intf = __nmdaemon_get_channel_interference(data);
+
+       if (data->ch_cb)
+               data->ch_cb(data->freq, channel_intf, data->cb_user_data);
+
+       return TRUE;
+}
+
+int nm_channel_interference_monitor_start(nm_channel_interference_callback cb, void *user_data)
+{
+       __NM_FUNC_ENTER__;
+       nmdaemon_mon_data_s *data = NULL;
+
+       if (!cb) {
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_INVALID_PARAM;
+       }
+
+       request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].is_initialized = TRUE;
+       request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table = g_hash_table_new_full(g_direct_hash,
+                       g_direct_equal,
+                       NULL,
+                       __destroy_mon_data
+                       );
+
+       if (!request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table) {
+               request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].is_initialized = FALSE;
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_OPERATION_FAILED;
+       }
+
+       data = (nmdaemon_mon_data_s*)g_try_malloc0(sizeof(nmdaemon_mon_data_s));
+       if (!data) {
+               NM_LOGE("Failed to allocate memory to data variable");
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
+       }
+
+       data->ch_cb = cb;
+       data->cb_user_data = user_data;
+
+       data->nl_global = (nmdaemon_nl_global_s*)g_try_malloc0(sizeof(nmdaemon_nl_global_s));
+       if (!data->nl_global) {
+               NM_LOGE("Failed to allocate memory to nl_global.");
+               g_free(data);
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
+       }
+
+       data->intf_info = (nmdaemon_chan_intf_info_s *)g_try_malloc0(sizeof(nmdaemon_chan_intf_info_s));
+       if (!data->intf_info) {
+               NM_LOGE("Failed to allocate memory to intf_info.");
+               g_free(data->nl_global);
+               g_free(data);
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
+       }
+
+       /** Initialize netlink socket */
+       int err = __nmdaemon_initialize_nl80211(data);
+       if (err < 0) {
+               NM_LOGE("__nmdaemon_initialize_nl80211() failed, error %d", err);
+               g_free(data->intf_info);
+               g_free(data->nl_global);
+               g_free(data);
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
+       }
+
+       data->timer_source_id = g_timeout_add(NETWORK_CHANNEL_MON_INTERVAL,
+                       __nmdaemon_monitor_channel_interference, data);
+
+       g_hash_table_insert(request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table,
+                       GINT_TO_POINTER(NL80211_CMD_GET_SURVEY), data);
+
+       __NM_FUNC_EXIT__;
+       return NM_DAEMON_ERROR_NONE;
+}
+
+int nm_channel_interference_monitor_stop()
+{
+       __NM_FUNC_ENTER__;
+       gint ret = NM_DAEMON_ERROR_NONE;
+
+       if (!request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_DAEMON_ERROR_NOT_INITIALIZED;
+       }
+
+       request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].is_initialized = FALSE;
+       g_hash_table_remove_all(request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table);
+       g_hash_table_unref(request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table);
+       request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table = NULL;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-statistics.c b/src/inm-statistics.c
new file mode 100644 (file)
index 0000000..142bf25
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for Monitoring /proc/.
+ *
+ * @file        nm-statistics.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include "inm-daemon-log.h"
+#include "inm-statistics.h"
+
+/*Poll the interface statistics at every 1000 ms*/
+#define STAT_POLLING_TIME       1000
+
+#define NM_PROC_DEV "/proc/net/dev"
+
+typedef struct {
+       gboolean is_initialized;
+       gboolean is_enabled;
+       guint timer_source_id;
+       nm_statistics_callback cb;
+       gpointer cb_user_data;
+} statistics_mon_s;
+
+statistics_mon_s stat_mon = {0,};
+
+
+static gboolean __get_statistics(gpointer user_data)
+{
+       nm_statistic_s stats;
+       FILE *fp;
+       gchar buf[1024];
+       gchar *p_ifname = NULL, *p_entry = NULL;
+       gchar *ret = NULL;
+
+       __NM_FUNC_ENTER__;
+
+       if (!stat_mon.cb) {
+               __NM_FUNC_EXIT__;
+               return TRUE;
+       }
+
+       fp = fopen(NM_PROC_DEV, "r");
+       if (fp == NULL) {
+               NM_LOGI("Failed to open %s", NM_PROC_DEV);
+               __NM_FUNC_EXIT__;
+               return TRUE;
+       }
+
+       ret = fgets(buf, sizeof(buf), fp);
+       if (ret == NULL) {
+               NM_LOGI("Nothing to read from %s", NM_PROC_DEV);
+               fclose(fp);
+               return TRUE;
+       }
+
+       p_ifname = buf;
+       while (*p_ifname == ' ') p_ifname++;
+       p_entry = strchr(p_ifname, ':');
+       if (p_entry != NULL) {
+               *p_entry++ = '\0';
+               g_strlcpy(stats.ifname, p_ifname, IFNAMSIZ);
+
+               /* read interface statistics */
+               sscanf(p_entry,
+                               "%llu %llu %lu %lu %lu %lu %lu %lu "
+                               "%llu %llu %lu %lu %lu %lu %lu %lu",
+                               (long long unsigned int *)&stats.rx_bytes, /* rx bytes */
+                               &stats.rx_packets,              /* rx packet */
+                               &stats.rx_errs,                 /* rx errors */
+                               &stats.rx_drop,                 /* rx dropped */
+                               &stats.rx_fifo,                 /* rx fifo errors */
+                               &stats.rx_frame,                /* rx frame errors */
+                               &stats.rx_compressed,   /* rx compressed */
+                               &stats.rx_multicast,    /* rx multicast */
+
+                               (long long unsigned int *)&stats.tx_bytes, /* tx bytes */
+                               &stats.tx_packets,              /* tx packet */
+                               &stats.tx_errs,                 /* tx errors */
+                               &stats.tx_drop,                 /* tx dropped */
+                               &stats.tx_fifo,                 /* tx fifo errors */
+                               &stats.tx_cols,                 /* collisions */
+                               &stats.tx_carrier,              /* tx carrier errors */
+                               &stats.tx_compressed    /* tx compressed */
+                               );
+               stat_mon.cb(&stats, user_data);
+       } else {
+               NM_LOGI("No matched Iface name in proc file");
+       }
+
+       fclose(fp);
+
+       __NM_FUNC_EXIT__;
+       return TRUE;
+}
+
+int nm_statistics_start_monitor(nm_statistics_callback cb, void *user_data)
+{
+       gint ret = NM_STATISTICS_ERROR_NONE;
+       guint source_id = 0;
+       __NM_FUNC_ENTER__;
+
+       if (!cb) {
+               __NM_FUNC_ENTER__;
+               return NM_STATISTICS_ERROR_INVALID_PARAM;
+       }
+
+       source_id = g_timeout_add(STAT_POLLING_TIME,
+                       __get_statistics, NULL);
+
+       if (stat_mon.timer_source_id >  0)
+               g_source_remove(stat_mon.timer_source_id);
+
+       stat_mon.timer_source_id = source_id;
+       stat_mon.cb = cb;
+       stat_mon.cb_user_data = user_data;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_statistics_stop_monitor()
+{
+       int ret = NM_STATISTICS_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!stat_mon.is_enabled) {
+               __NM_FUNC_ENTER__;
+               return NM_STATISTICS_ERROR_NONE;
+       }
+
+       if (stat_mon.timer_source_id >  0) {
+               g_source_remove(stat_mon.timer_source_id);
+               stat_mon.timer_source_id = 0;
+       }
+
+       stat_mon.cb = NULL;
+       stat_mon.cb_user_data = NULL;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_statistics_is_enabled(gboolean *enabled)
+{
+       int ret = NM_STATISTICS_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!enabled) {
+               __NM_FUNC_ENTER__;
+               return NM_STATISTICS_ERROR_INVALID_PARAM;
+       }
+
+       *enabled = stat_mon.is_enabled;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_statistics_init()
+{
+       int ret = NM_STATISTICS_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_statistics_deinit()
+{
+       int ret = NM_STATISTICS_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-stc-manager.c b/src/inm-stc-manager.c
new file mode 100644 (file)
index 0000000..87efcc8
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling signal from STC manager.
+ *
+ * @file        nm-stc-manager.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-stc-manager.h"
+
+typedef enum {
+       STC_SIGNAL_NAME_OWENER_CHANGED,
+       STC_SIGNAL_MAX,
+} stc_manager_signal_e;
+
+typedef struct {
+       gboolean is_initialized;
+
+} stc_manager_mon_s;
+
+stc_manager_mon_s stc_manager_mon;
+
+static void __name_owner_changed_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+static signal_param_s signal_param[] = {
+               {
+                               .sender = DBUS_SERVICE_DBUS,
+                               .interface_name = DBUS_INTERFACE_DBUS,
+                               .member = DBUS_SIGNAL_NAME_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = STC_MANAGER_SERVICE,
+                               .callback = __name_owner_changed_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = STC_MANAGER_SERVICE,
+                               .interface_name = STC_MANAGER_STATS_INTERFACE,
+                               .member = NULL/* TODO */,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = NULL /* TODO */,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = STC_MANAGER_SERVICE,
+                               .interface_name = STC_MANAGER_RESTRICTION_INTERFACE,
+                               .member = NULL/* TODO */,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = NULL /* TODO */,
+                               .subscriber_id  = 0,
+               },
+};
+
+static void __name_owner_changed_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       gchar *name = NULL;
+       gchar *old = NULL;
+       gchar *new = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (parameters == NULL)
+               return;
+
+       g_variant_get(parameters, "(&s&s&s)", &name, &old, &new);
+
+       if (g_strcmp0(name, STC_MANAGER_SERVICE) == 0 && *new == '\0')
+               NM_LOGI("stc-manager destroyed: name %s, old %s, new %s", name, old, new);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+int nm_stc_manager_init()
+{
+       int ret = NM_STC_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       memset(&stc_manager_mon, 0x00, sizeof(stc_manager_mon));
+       stc_manager_mon.is_initialized = TRUE;
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[STC_SIGNAL_NAME_OWENER_CHANGED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_STC_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_STC_ERROR_NONE;
+}
+
+int nm_stc_manager_deinit()
+{
+       int ret = NM_STC_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!stc_manager_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_STC_ERROR_NOT_INITIALIZED;
+       }
+
+       nm_gdbus_unsubscribe_signal(&(signal_param[STC_SIGNAL_NAME_OWENER_CHANGED]));
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
diff --git a/src/inm-supplicant-bss.c b/src/inm-supplicant-bss.c
new file mode 100644 (file)
index 0000000..6cc2251
--- /dev/null
@@ -0,0 +1,564 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling signal from WPA Supplicant BSS interface.
+ *
+ * @file        nm-supplicant-bss.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-supplicant.h"
+#include "inm-supplicant-internal.h"
+
+#define DEBUG_G_VARIANT(str, parameters)\
+       do {\
+               gchar *parameters_debug_str = NULL;\
+               if (parameters)\
+                       parameters_debug_str = g_variant_print(parameters, TRUE);\
+               NM_LOGI("%s[%s]", str, parameters_debug_str ? parameters_debug_str : "NULL");\
+               g_free(parameters_debug_str);\
+       } while (0)
+#define DEBUG_SIGNAL(sender_name, object_path, interface_name, signal_name, parameters)\
+       do {\
+               NM_LOGI("signal sender name [%s]", sender_name);\
+               NM_LOGI("signal object path [%s]", object_path);\
+               NM_LOGI("signal interface name [%s]", interface_name);\
+               NM_LOGI("signal signal name [%s]", signal_name);\
+               DEBUG_G_VARIANT("signal params ", parameters);\
+               NM_LOGI("signal params type [%s]", g_variant_get_type_string(parameters));\
+       } while (0)
+
+typedef enum {
+       BSS_SIGNAL_PROPERTIESCHANGED,
+       BSS_SIGNAL_MAX,
+} supplicant_bss_signal_e;
+
+typedef struct {
+       guint key_mgmt;
+       guint pairwaise;
+       guint group;
+} wpa_s;
+
+typedef struct {
+       guint key_mgmt;
+       guint pairwaise;
+       guint group;
+       guint mgmt_group;
+} rsn_s;
+
+typedef struct {
+       /*
+        * BSSID of the BSS.
+        */
+       guchar bssid[BSSID_LEN];
+       /*
+        * SSID of the BSS.
+        */
+       gchar ssid[SSID_LEN + 1];
+       /*
+        * WPA information of the BSS.
+        */
+       wpa_s wpa;
+       /*
+        * RSN information of the BSS.
+        */
+       rsn_s rsn;
+       /*
+        * WPS information of the BSS.
+        */
+       guint wps_type;
+       /*
+        * indicates if BSS supports privacy.
+        */
+       gboolean private;
+       /*
+        * Describes mode of the BSS.
+        * Possible values are: "ad-hoc" and "infrastructure".
+        */
+       guint mode;
+       /*
+        * Frequency of the BSS in MHz.
+        */
+       guint16 frequency;
+
+       /*
+        * Signal strength of the BSS.
+        */
+       gint16 signal;
+       /*
+        * Number of seconds since the BSS was last seen.
+        */
+       guint age;
+
+       guint subscriber_id[BSS_SIGNAL_MAX];
+} supplicant_bss_s;
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(bss_properties_changed);
+
+static signal_param_s bss_signal_params[] = {
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_BSS,
+                       .member = DBUS_SIGNAL_PROPERTIES_CHANGED,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __bss_properties_changed,
+                       .subscriber_id  = 0,
+               }
+};
+
+static method_param_s get_bss_property_method_param = {
+               .bus_name = SUPPLICANT_SERVICE,
+               .object_path = NULL,
+               .interface_name = DBUS_PROPERTIES_INTERFACE,
+               .method_name = DBUS_PROPERTIES_METHOD_GETALL,
+               .parameters = NULL,
+};
+
+static inline int __subscribe_bss_signal(const gchar *path, supplicant_bss_s *bss_data)
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+       int signal_idx = 0;
+       __NM_FUNC_ENTER__;
+
+       if (!path || !bss_data) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       NM_LOGI("path [%s]", path);
+       for (signal_idx = BSS_SIGNAL_PROPERTIESCHANGED; signal_idx < BSS_SIGNAL_MAX; signal_idx++) {
+               bss_signal_params[signal_idx].object_path = path;
+               ret = nm_gdbus_subscribe_signal_with_data(&(bss_signal_params[signal_idx]), bss_data);
+               if (ret != NM_GDBUS_ERROR_NONE)
+                       NM_LOGI("Error! Failed to subscribe signal");
+               else
+                       bss_data->subscriber_id[signal_idx] =
+                                       bss_signal_params[signal_idx].subscriber_id;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_SUPPLICANT_ERROR_NONE;
+}
+
+static inline int __unsubscribe_bss_signal(supplicant_bss_s *bss_data)
+{
+       int signal_idx = 0;
+       int ret = NM_GDBUS_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!bss_data) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       for (signal_idx = BSS_SIGNAL_PROPERTIESCHANGED; signal_idx < BSS_SIGNAL_MAX; signal_idx++) {
+
+               if (bss_data->subscriber_id[signal_idx] == 0)
+                       continue;
+
+               bss_signal_params[signal_idx].subscriber_id = bss_data->subscriber_id[signal_idx];
+               ret = nm_gdbus_unsubscribe_signal(&(bss_signal_params[signal_idx]));
+               if (ret != NM_GDBUS_ERROR_NONE)
+                       NM_LOGI("Error! Failed to unsubscribe signal");
+               else
+                       bss_data->subscriber_id[signal_idx] = 0;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_SUPPLICANT_ERROR_NONE;
+}
+
+void nm_supplicant_bss_destroy(gpointer data)
+{
+       supplicant_bss_s *bss_data = (supplicant_bss_s *)data;
+       __NM_FUNC_ENTER__;
+
+       NM_LOGI("BSS destroyed [%s]", bss_data->ssid);
+
+       __unsubscribe_bss_signal(bss_data);
+
+       g_free(bss_data);
+       __NM_FUNC_EXIT__;
+       return;
+}
+/*
+static void inline __get_pairwise(GVariant *value, guint *pairwaise)
+{
+       GVariantIter *iter = NULL;
+       const gchar *str = NULL;
+
+       g_variant_get(value, "as", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       *pairwaise = 0;
+       while (g_variant_iter_loop(iter, "&s", &str)) {
+               if (g_strcmp0(str, "none") == 0)
+                       *pairwaise = *pairwaise | PAIRWISE_CAP_NONE;
+               else if (g_strcmp0(str, "ccmp") == 0)
+                       *pairwaise = *pairwaise | PAIRWISE_CAP_CCMP;
+               else if (g_strcmp0(str, "tkip") == 0)
+                       *pairwaise = *pairwaise | PAIRWISE_CAP_TKIP;
+       }
+       g_variant_iter_free(iter);
+}
+
+static void inline __get_group(GVariant *value, guint *group)
+{
+       GVariantIter *iter = NULL;
+       const gchar *str = NULL;
+
+       g_variant_get(value, "as", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       *group = 0;
+       while (g_variant_iter_loop(iter, "&s", &str)) {
+               if (g_strcmp0(str, "none") == 0)
+                       *group = *group | GROUP_CAP_CCMP;
+               else if (g_strcmp0(str, "ccmp") == 0)
+                       *group = *group | GROUP_CAP_TKIP;
+               else if (g_strcmp0(str, "wep104") == 0)
+                       *group = *group | GROUP_CAP_WEP104;
+               else if (g_strcmp0(str, "wep40") == 0)
+                       *group = *group | GROUP_CAP_WEP40;
+       }
+
+       g_variant_iter_free(iter);
+}
+
+static void inline __get_key_mgmt(GVariant *value, guint *key_mgmt)
+{
+       GVariantIter *iter = NULL;
+       const gchar *str = NULL;
+
+       g_variant_get(value, "as", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       *key_mgmt = 0;
+       while (g_variant_iter_loop(iter, "&s", &str)) {
+               if (g_strcmp0(str, "none") == 0)
+                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_NONE;
+               else if (g_strcmp0(str, "wpa-psk") == 0)
+                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_PSK;
+               else if (g_strcmp0(str, "wpa-ft-psk") == 0)
+                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_FT_PSK;
+               else if (g_strcmp0(str, "wpa-psk-sha256") == 0)
+                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_PSK_SHA256;
+               else if (g_strcmp0(str, "wpa-eap") == 0)
+                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_EAP;
+               else if (g_strcmp0(str, "wpa-ft-eap") == 0)
+                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_FT_EAP;
+               else if (g_strcmp0(str, "wpa-eap-sha256") == 0)
+                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_EAP_SHA256;
+               else if (g_strcmp0(str, "ieee8021x") == 0)
+                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_IEEE8021X;
+               else if (g_strcmp0(str, "wpa-none") == 0)
+                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_NONE;
+               else if (g_strcmp0(str, "wps") == 0)
+                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPS;
+       }
+       g_variant_iter_free(iter);
+}
+*/
+
+static gboolean __unpack_ays(unsigned char *dst, GVariant *src, int size)
+{
+       GVariantIter *iter = NULL;
+       int length = 0;
+       int res = FALSE;
+
+       if (!dst || !src || size == 0) {
+               NM_LOGI("Invalid parameter");
+               return FALSE;
+       }
+
+       g_variant_get(src, "ay", &iter);
+       if (iter == NULL) {
+               NM_LOGI("failed to get iterator");
+               return FALSE;
+       }
+
+       while (g_variant_iter_loop(iter, "y", &dst[length])) {
+               length++;
+               if (length >= size)
+                       break;
+       }
+       g_variant_iter_free(iter);
+
+       return res;
+}
+
+static void inline __get_bss_bssid(GVariant *value, supplicant_bss_s *bss)
+{
+       __unpack_ays(bss->bssid, value, BSSID_LEN);
+}
+
+static void inline __get_bss_ssid(GVariant *value, supplicant_bss_s *bss)
+{
+       __unpack_ays((unsigned char *)bss->ssid, value, SSID_LEN);
+}
+
+static void inline __get_bss_privacy(GVariant *value, supplicant_bss_s *bss)
+{
+       g_variant_get(value, "b", &(bss->private));
+}
+
+static void inline __get_bss_mode(GVariant *value, supplicant_bss_s *bss)
+{
+       const gchar *str = NULL;
+       g_variant_get(value, "&s", &str);
+
+       bss->mode = 0;
+       if (g_strcmp0(str, "infrastructure") == 0)
+               bss->mode |= MODE_INFRA;
+       else if (g_strcmp0(str, "ad-hoc") == 0)
+               bss->mode |= MODE_ADHOC;
+       else if (g_strcmp0(str, "ap") == 0)
+               bss->mode |= MODE_AP;
+       else if (g_strcmp0(str, "p2p") == 0)
+               bss->mode |= MODE_P2P;
+}
+
+static void inline __get_bss_freq(GVariant *value, supplicant_bss_s *bss)
+{
+       g_variant_get(value, "q", &(bss->frequency));
+}
+
+static void inline __get_bss_signal(GVariant *value, supplicant_bss_s *bss)
+{
+       g_variant_get(value, "n", &(bss->signal));
+}
+
+static void inline __get_bss_property(const gchar *key, GVariant *value, supplicant_bss_s *bss)
+{
+       if (g_strcmp0(key, "BSSID") == 0)
+               __get_bss_bssid(value, bss);
+       else if (g_strcmp0(key, "SSID") == 0)
+               __get_bss_ssid(value, bss);
+       else if (g_strcmp0(key, "Privacy") == 0)
+               __get_bss_privacy(value, bss);
+       else if (g_strcmp0(key, "Mode") == 0)
+               __get_bss_mode(value, bss);
+       else if (g_strcmp0(key, "Frequency") == 0)
+               __get_bss_freq(value, bss);
+       else if (g_strcmp0(key, "Signal") == 0)
+               __get_bss_signal(value, bss);
+}
+
+static inline int __init_bss(const gchar *path, supplicant_bss_s *bss, GHashTable *bss_tbl)
+{
+       gchar *key = NULL;
+       gint ret = 0;
+       __NM_FUNC_ENTER__;
+
+       key = g_strdup(path);
+       if (g_hash_table_replace(bss_tbl, key, bss))
+               NM_LOGI("BSS replaced");
+
+       ret = __subscribe_bss_signal(path, bss);
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               g_hash_table_steal(bss_tbl, key);
+               g_free(key);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       NM_LOGI("BSS replaced [%s]", path);
+       return 0;
+}
+
+int nm_supplicant_bss_add(const gchar *path, GVariantIter *iter, GHashTable *bss_tbl)
+{
+       supplicant_bss_s *bss = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!path || !iter) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       bss = (supplicant_bss_s *)g_try_malloc0(sizeof(supplicant_bss_s));
+       if (!bss) {
+               NM_LOGI("Error! Failed to allocate bss");
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       if (__init_bss(path, bss, bss_tbl) < 0) {
+               NM_LOGI("Error! Failed to init bss");
+               g_free(bss);
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
+               __get_bss_property(key, var, bss);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_supplicant_bss_remove(const gchar *path, GHashTable *bss_tbl)
+{
+       supplicant_bss_s *bss = NULL;
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+
+       if (!path || !bss_tbl) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       bss = g_hash_table_lookup(bss_tbl, path);
+       if (!bss) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       g_hash_table_remove(bss_tbl, path);
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+void __get_bss_properties(GVariant *value, gpointer user_data)
+{
+       GVariantIter *iter = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+       supplicant_bss_s *bss = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (!value || !user_data) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       g_variant_get(value, "(a{sv})", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       bss = (supplicant_bss_s *)user_data;
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
+               __get_bss_property(key, var, bss);
+
+       g_variant_iter_free(iter);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(bss_properties_changed)
+{
+       supplicant_bss_s *bss = NULL;
+
+       __NM_FUNC_ENTER__;
+
+       DEBUG_SIGNAL(sender_name, object_path, interface_name, signal, parameters);
+       bss = (supplicant_bss_s *)user_data;
+       if (!bss) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("bss not found");
+               return;
+       }
+
+       if (parameters)
+               __get_bss_properties(parameters, bss);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline gboolean __dbus_get_bss_properties(const gchar *path, supplicant_bss_s *bss)
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       get_bss_property_method_param.object_path = path;
+       get_bss_property_method_param.parameters = g_variant_new("(s)",
+                       SUPPLICANT_IFACE_BSS);
+
+       ret = nm_gdbus_method_call(&get_bss_property_method_param,
+                       __get_bss_properties,
+                       (gpointer)bss);
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               NM_LOGI("get property all failure");
+               return FALSE;
+       }
+
+       __NM_FUNC_EXIT__;
+       return TRUE;
+}
+
+int nm_supplicant_bss_add_by_path(const gchar *path, GHashTable *bsss)
+{
+       supplicant_bss_s *bss = NULL;
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+
+       if (!path) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       bss = (supplicant_bss_s *)g_try_malloc0(sizeof(supplicant_bss_s));
+       if (!bss) {
+               NM_LOGI("Error! Failed to allocate bss");
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       if (__init_bss(path, bss, bsss) < 0) {
+               NM_LOGI("Error! Failed to init bss");
+               g_free(bss);
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+
+       __dbus_get_bss_properties(path, bss);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-supplicant-iface.c b/src/inm-supplicant-iface.c
new file mode 100644 (file)
index 0000000..587ceb9
--- /dev/null
@@ -0,0 +1,1486 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling signal from WPA Supplicant network interface.
+ *
+ * @file        nm-supplicant-iface.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-supplicant.h"
+#include "inm-supplicant-internal.h"
+
+static void __handle_scan_done(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_bss_added(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_bss_removed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_blob_added(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_blob_removed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_network_added(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_network_removed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_network_selected(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_sta_authorized(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_sta_deauthorized(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __iface_properties_changed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_certification(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_eap(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_network_request(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_probe_request(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_wps_event(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static void __handle_wps_credentials(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data);
+
+static signal_param_s iface_signal_params[] = {
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "ScanDone",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_scan_done,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "BSSAdded",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_bss_added,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "BSSRemoved",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_bss_removed,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "BlobAdded",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_blob_added,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "BlobRemoved",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_blob_removed,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "NetworkAdded",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_network_added,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "NetworkRemoved",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_network_removed,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "NetworkSelected",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_network_selected,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "StaAuthorized",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_sta_authorized,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "StaDeauthorized",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_sta_deauthorized,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = DBUS_SIGNAL_PROPERTIES_CHANGED,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __iface_properties_changed,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "Certification",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_certification,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "EAP",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_eap,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "NetworkRequest",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_network_request,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
+                       .member = "ProbeRequest",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_probe_request,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_WPS,
+                       .member = "Event",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_wps_event,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_WPS,
+                       .member = "Credentials",
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback = __handle_wps_credentials,
+                       .subscriber_id  = 0,
+               },
+};
+
+static method_param_s get_iface_property_method_param = {
+               .bus_name = SUPPLICANT_SERVICE,
+               .object_path = NULL,
+               .interface_name = DBUS_PROPERTIES_INTERFACE,
+               .method_name = DBUS_PROPERTIES_METHOD_GETALL,
+               .parameters = NULL,
+};
+
+static method_param_s signal_poll_method_param = {
+               .bus_name = SUPPLICANT_SERVICE,
+               .object_path = NULL,
+               .interface_name = SUPPLICANT_IFACE_INTERFACE,
+               .method_name = "SignalPoll",
+               .parameters = NULL,
+};
+
+nm_supplicant_iface_changed_callback g_iface_prop_changed_cb;
+gpointer g_iface_prop_changed_cb_user_data;
+GHashTable *g_supplicant_iface_tbl = NULL;
+
+static inline int __subscribe_iface_signal(const gchar *path, nm_supplicant_iface_s *iface_data)
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+       int signal_idx = 0;
+       __NM_FUNC_ENTER__;
+
+       if (!path || !iface_data) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       NM_LOGI("path [%s]", path);
+       for (signal_idx = IFACE_SIGNAL_SCANDONE; signal_idx < IFACE_SIGNAL_MAX; signal_idx++) {
+               iface_signal_params[signal_idx].object_path = path;
+               ret = nm_gdbus_subscribe_signal(&(iface_signal_params[signal_idx]));
+               if (ret != NM_GDBUS_ERROR_NONE)
+                       NM_LOGI("Error! Failed to subscribe signal");
+               else
+                       iface_data->subscriber_id[signal_idx] =
+                                       iface_signal_params[signal_idx].subscriber_id;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_SUPPLICANT_ERROR_NONE;
+}
+
+static inline int __unsubscribe_iface_signal(nm_supplicant_iface_s *iface_data)
+{
+       int signal_idx = 0;
+       int ret = NM_GDBUS_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!iface_data) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       for (signal_idx = IFACE_SIGNAL_SCANDONE; signal_idx < IFACE_SIGNAL_PROBEREQUEST; signal_idx++) {
+
+               if (iface_data->subscriber_id[signal_idx] == 0)
+                       continue;
+
+               iface_signal_params[signal_idx].subscriber_id = iface_data->subscriber_id[signal_idx];
+               ret = nm_gdbus_unsubscribe_signal(&(iface_signal_params[signal_idx]));
+               if (ret != NM_GDBUS_ERROR_NONE)
+                       NM_LOGI("Error! Failed to unsubscribe signal");
+               else
+                       iface_data->subscriber_id[signal_idx] = 0;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_SUPPLICANT_ERROR_NONE;
+}
+
+static void __destroy_iface_data(gpointer data)
+{
+       nm_supplicant_iface_s *iface_data = (nm_supplicant_iface_s *)data;
+       __NM_FUNC_ENTER__;
+
+       g_hash_table_remove_all(iface_data->bss_tbl);
+       g_hash_table_unref(iface_data->bss_tbl);
+       iface_data->bss_tbl = NULL;
+
+       __unsubscribe_iface_signal(iface_data);
+
+       g_free(iface_data);
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void inline __get_cap_pairwise(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       GVariantIter *iter = NULL;
+       const gchar *str = NULL;
+
+       g_variant_get(value, "as", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface->cap.pairwise = 0;
+       while (g_variant_iter_loop(iter, "&s", &str)) {
+               if (g_strcmp0(str, "none") == 0)
+                       iface->cap.pairwise |= PAIRWISE_CAP_NONE;
+               else if (g_strcmp0(str, "ccmp") == 0)
+                       iface->cap.pairwise |= PAIRWISE_CAP_CCMP;
+               else if (g_strcmp0(str, "tkip") == 0)
+                       iface->cap.pairwise |= PAIRWISE_CAP_TKIP;
+       }
+       g_variant_iter_free(iter);
+}
+
+static void inline __get_cap_group(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       GVariantIter *iter = NULL;
+       const gchar *str = NULL;
+
+       g_variant_get(value, "as", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface->cap.group = 0;
+       while (g_variant_iter_loop(iter, "&s", &str)) {
+               if (g_strcmp0(str, "none") == 0)
+                       iface->cap.group |= GROUP_CAP_CCMP;
+               else if (g_strcmp0(str, "ccmp") == 0)
+                       iface->cap.pairwise |= GROUP_CAP_TKIP;
+               else if (g_strcmp0(str, "wep104") == 0)
+                       iface->cap.pairwise |= GROUP_CAP_WEP104;
+               else if (g_strcmp0(str, "wep40") == 0)
+                       iface->cap.pairwise |= GROUP_CAP_WEP40;
+       }
+
+       g_variant_iter_free(iter);
+}
+
+static void inline __get_cap_key_mgmt(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       GVariantIter *iter = NULL;
+       const gchar *str = NULL;
+
+       g_variant_get(value, "as", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface->cap.key_mgmt = 0;
+       while (g_variant_iter_loop(iter, "&s", &str)) {
+               if (g_strcmp0(str, "none") == 0)
+                       iface->cap.key_mgmt |= KEY_MGMT_CAP_NONE;
+               else if (g_strcmp0(str, "wpa-psk") == 0)
+                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_PSK;
+               else if (g_strcmp0(str, "wpa-ft-psk") == 0)
+                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_FT_PSK;
+               else if (g_strcmp0(str, "wpa-psk-sha256") == 0)
+                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_PSK_SHA256;
+               else if (g_strcmp0(str, "wpa-eap") == 0)
+                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_EAP;
+               else if (g_strcmp0(str, "wpa-ft-eap") == 0)
+                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_FT_EAP;
+               else if (g_strcmp0(str, "wpa-eap-sha256") == 0)
+                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_EAP_SHA256;
+               else if (g_strcmp0(str, "ieee8021x") == 0)
+                       iface->cap.key_mgmt |= KEY_MGMT_CAP_IEEE8021X;
+               else if (g_strcmp0(str, "wpa-none") == 0)
+                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_NONE;
+               else if (g_strcmp0(str, "wps") == 0)
+                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPS;
+       }
+       g_variant_iter_free(iter);
+}
+
+static void inline __get_cap_proto(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       GVariantIter *iter = NULL;
+       const gchar *str = NULL;
+
+       g_variant_get(value, "as", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface->cap.proto = 0;
+       while (g_variant_iter_loop(iter, "&s", &str)) {
+               if (g_strcmp0(str, "rsn") == 0)
+                       iface->cap.proto |= PROTOCOL_RSN;
+               else if (g_strcmp0(str, "wpa") == 0)
+                       iface->cap.proto |= PROTOCOL_WPA;
+       }
+
+       g_variant_iter_free(iter);
+}
+
+static void inline __get_cap_auth_alg(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       GVariantIter *iter = NULL;
+       const gchar *str = NULL;
+
+       g_variant_get(value, "as", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface->cap.auth_alg = 0;
+       while (g_variant_iter_loop(iter, "&s", &str)) {
+               if (g_strcmp0(str, "open") == 0)
+                       iface->cap.auth_alg |= AUTH_ALG_OPEN;
+               else if (g_strcmp0(str, "shared") == 0)
+                       iface->cap.auth_alg |= AUTH_ALG_SHARED;
+               else if (g_strcmp0(str, "leap") == 0)
+                       iface->cap.auth_alg |= AUTH_ALG_LEAP;
+       }
+
+       g_variant_iter_free(iter);
+}
+
+static void inline __get_cap_scan(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       GVariantIter *iter = NULL;
+       const gchar *str = NULL;
+
+       g_variant_get(value, "as", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface->cap.scan = 0;
+       while (g_variant_iter_loop(iter, "&s", &str)) {
+               if (g_strcmp0(str, "active") == 0)
+                       iface->cap.scan |= SCAN_ACTIVE;
+               else if (g_strcmp0(str, "passive") == 0)
+                       iface->cap.scan |= SCAN_PASSIVE;
+               else if (g_strcmp0(str, "ssid") == 0)
+                       iface->cap.scan |= SCAN_SSID;
+       }
+
+       g_variant_iter_free(iter);
+}
+
+static void inline __get_cap_mode(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       GVariantIter *iter = NULL;
+       const gchar *str = NULL;
+       g_variant_get(value, "as", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface->cap.modes = 0;
+       while (g_variant_iter_loop(iter, "&s", &str)) {
+               if (g_strcmp0(str, "infrastructure") == 0)
+                       iface->cap.modes |= MODE_INFRA;
+               else if (g_strcmp0(str, "ad-hoc") == 0)
+                       iface->cap.modes |= MODE_ADHOC;
+               else if (g_strcmp0(str, "ap") == 0)
+                       iface->cap.modes |= MODE_AP;
+               else if (g_strcmp0(str, "p2p") == 0)
+                       iface->cap.modes |= MODE_P2P;
+       }
+
+       g_variant_iter_free(iter);
+}
+static void inline __get_iface_capabilities(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       GVariantIter *iter = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+
+       g_variant_get(value, "a{sv}", &iter);
+       if (!iter)
+               return;
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (g_strcmp0(key, "Pairwise") == 0)
+                       __get_cap_pairwise(var, iface);
+               else if (g_strcmp0(key, "Group") == 0)
+                       __get_cap_group(var, iface);
+               else if (g_strcmp0(key, "KeyMgmt") == 0)
+                       __get_cap_key_mgmt(var, iface);
+               else if (g_strcmp0(key, "Protocol") == 0)
+                       __get_cap_proto(var, iface);
+               else if (g_strcmp0(key, "AuthAlg") == 0)
+                       __get_cap_auth_alg(var, iface);
+               else if (g_strcmp0(key, "Scan") == 0)
+                       __get_cap_scan(var, iface);
+               else if (g_strcmp0(key, "Modes") == 0)
+                       __get_cap_mode(var, iface);
+       }
+
+       g_variant_iter_free(iter);
+}
+
+static void inline __get_iface_state(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       const gchar *str = NULL;
+
+       g_variant_get(value, "&s", &str);
+
+       if (g_strcmp0(str, "unknown") == 0)
+               iface->state = IFACE_STATE_UNKNOWN;
+       else if (g_strcmp0(str, "disconnected") == 0)
+               iface->state = IFACE_STATE_DISCONNECTED;
+       else if (g_strcmp0(str, "inactive") == 0)
+               iface->state = IFACE_STATE_INACTIVE;
+       else if (g_strcmp0(str, "scanning") == 0)
+               iface->state = IFACE_STATE_SCANNING;
+       else if (g_strcmp0(str, "authenticating") == 0)
+               iface->state = IFACE_STATE_AUTHENTICATING;
+       else if (g_strcmp0(str, "associating") == 0)
+               iface->state = IFACE_STATE_ASSOCIATING;
+       else if (g_strcmp0(str, "associated") == 0)
+               iface->state = IFACE_STATE_ASSOCIATED;
+       else if (g_strcmp0(str, "4way_handshake") == 0)
+               iface->state = IFACE_STATE_4WAY_HANDSHAKE;
+       else if (g_strcmp0(str, "group_handshake") == 0)
+               iface->state = IFACE_STATE_GROUP_HANDSHAKE;
+       else if (g_strcmp0(str, "completed") == 0)
+               iface->state = IFACE_STATE_COMPLETED;
+
+       NM_LOGI("state [%s]", str);
+}
+
+static void inline __get_iface_scanning(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       g_variant_get(value, "b", &(iface->scanning));
+
+       NM_LOGI("%s", (iface->scanning)?"Scanning":"Not scanning");
+}
+
+static void inline __get_iface_ifname(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       const gchar *str = NULL;
+
+       g_variant_get(value, "&s", &str);
+       g_strlcpy(iface->Ifname, str, IFNAME_MAX + 1);
+
+       NM_LOGI("state [%s]", str);
+}
+
+static void inline __get_iface_current_bss(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       const gchar *path = NULL;
+       gpointer bss = NULL;
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(value, "&o", &path);
+       if (!path)
+               return;
+
+       if (g_strcmp0(path, "/") == 0) {
+               NM_LOGI("Null path");
+               iface->current_bss = NULL;
+               return;
+       }
+
+       bss = g_hash_table_lookup(iface->bss_tbl, path);
+       if (bss)
+               iface->current_bss = bss;
+       else
+               iface->current_bss = NULL;
+
+       __NM_FUNC_EXIT__;
+}
+
+static void inline __get_iface_bsss(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       GVariantIter *iter = NULL;
+       const gchar *obj = NULL;
+
+       g_variant_get(value, "ao", &iter);
+       if (!iter || !iface) {
+               NM_LOGI("Invalid params");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       while (g_variant_iter_loop(iter, "o", &obj))
+               nm_supplicant_bss_add_by_path(obj, iface->bss_tbl);
+
+       g_variant_iter_free(iter);
+}
+
+static void inline __get_iface_current_network(GVariant *value, nm_supplicant_iface_s *iface)
+{
+       const gchar *obj = NULL;
+
+       g_variant_get(value, "&o", &obj);
+
+       g_free(iface->current_network);
+       iface->current_network = NULL;
+
+       if (g_strcmp0(obj, "/") == 0) {
+               NM_LOGI("Null path");
+               return;
+       }
+
+       nm_supplicant_network_add_by_path(obj, &(iface->current_network));
+       return;
+}
+
+static void inline __get_iface_property(const gchar *key, GVariant *value, nm_supplicant_iface_s *iface)
+{
+       if (g_strcmp0(key, "Capabilities") == 0)
+               __get_iface_capabilities(value, iface);
+       else if (g_strcmp0(key, "State") == 0)
+               __get_iface_state(value, iface);
+       else if (g_strcmp0(key, "Scanning") == 0)
+               __get_iface_scanning(value, iface);
+       else if (g_strcmp0(key, "Ifname") == 0)
+               __get_iface_ifname(value, iface);
+       else if (g_strcmp0(key, "CurrentBSS") == 0)
+               __get_iface_current_bss(value, iface);
+       else if (g_strcmp0(key, "BSSs") == 0)
+               __get_iface_bsss(value, iface);
+       else if (g_strcmp0(key, "CurrentNetwork") == 0)
+               __get_iface_current_network(value, iface);
+/*
+       else if (g_strcmp0(key, "CurrentAuthMode") == 0)
+               __get_iface_current_auth_mode(value, iface);
+       else if (g_strcmp0(key, "Blobs") == 0)
+               __get_iface_blobs(value, iface);
+       else if (g_strcmp0(key, "Networks") == 0)
+               __get_iface_networks(value, iface);
+*/
+}
+
+static void inline __get_iface_property_without_bss(const gchar *key, GVariant *value, nm_supplicant_iface_s *iface)
+{
+       NM_LOGI("Prop %s", key);
+       if (g_strcmp0(key, "Capabilities") == 0)
+               __get_iface_capabilities(value, iface);
+       else if (g_strcmp0(key, "State") == 0)
+               __get_iface_state(value, iface);
+       else if (g_strcmp0(key, "Scanning") == 0)
+               __get_iface_scanning(value, iface);
+       else if (g_strcmp0(key, "Ifname") == 0)
+               __get_iface_ifname(value, iface);
+       else if (g_strcmp0(key, "CurrentBSS") == 0)
+               __get_iface_current_bss(value, iface);
+       else if (g_strcmp0(key, "CurrentNetwork") == 0)
+               __get_iface_current_network(value, iface);
+/*
+       else if (g_strcmp0(key, "CurrentAuthMode") == 0)
+               __get_iface_current_auth_mode(value, iface);
+       else if (g_strcmp0(key, "Blobs") == 0)
+               __get_iface_blobs(value, iface);
+       else if (g_strcmp0(key, "Networks") == 0)
+               __get_iface_networks(value, iface);
+*/
+}
+
+void __get_iface_properties(GVariant *value, gpointer user_data)
+{
+       GVariantIter *iter = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+       nm_supplicant_iface_s *iface = NULL;
+
+       if (!value || !user_data)
+               return;
+
+       g_variant_get(value, "(a{sv})", &iter);
+       if (!iter)
+               return;
+
+       iface = (nm_supplicant_iface_s *)user_data;
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
+               __get_iface_property(key, var, iface);
+
+       g_variant_iter_free(iter);
+
+       return;
+}
+
+void __get_iface_properties_without_bss(GVariant *value, gpointer user_data)
+{
+       GVariantIter *iter = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+       nm_supplicant_iface_s *iface = NULL;
+
+       if (!value || !user_data)
+               return;
+
+       g_variant_get(value, "(a{sv})", &iter);
+       if (!iter) {
+               NM_LOGI("null iter!");
+               return;
+       }
+
+       iface = (nm_supplicant_iface_s *)user_data;
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
+               __get_iface_property_without_bss(key, var, iface);
+
+       g_variant_iter_free(iter);
+
+       return;
+}
+static void __handle_scan_done(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_bss_added(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       nm_supplicant_iface_s *iface = NULL;
+       GVariantIter *iter = NULL;
+       const gchar *path = NULL;
+       gint ret = 0;
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(parameters, "(oa{sv})", &path, &iter);
+       if (!path || !iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
+       if (!iface) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("iface not found");
+               return;
+       }
+
+       ret = nm_supplicant_bss_add(path, iter, iface->bss_tbl);
+       if (ret < 0) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("nm_supplicant_bss_add failed");
+               return;
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_bss_removed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       nm_supplicant_iface_s *iface = NULL;
+       const gchar *path = NULL;
+       gint ret = 0;
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(parameters, "(o)", &path);
+       if (!path) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
+       if (!iface) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("iface not found");
+               return;
+       }
+
+       ret = nm_supplicant_bss_remove(path, iface->bss_tbl);
+       if (ret < 0) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("nm_supplicant_bss_remove failed");
+               return;
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_blob_added(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_blob_removed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_network_added(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_ENTER__;
+       nm_supplicant_iface_s *iface = NULL;
+       GVariantIter *iter = NULL;
+       const gchar *path = NULL;
+       gint ret = 0;
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(parameters, "(oa{sv})", &path, &iter);
+       if (!path || !iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
+       if (!iface) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("iface not found");
+               return;
+       }
+
+       ret = nm_supplicant_network_add(path, iter, &(iface->current_network));
+       if (ret < 0) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("nm_supplicant_network_add failed");
+               return;
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_network_removed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       nm_supplicant_iface_s *iface = NULL;
+       const gchar *path = NULL;
+       gint ret = 0;
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(parameters, "(o)", &path);
+       if (!path) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
+       if (!iface) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("iface not found");
+               return;
+       }
+
+       ret = nm_supplicant_network_remove(path, iface->current_network);
+       if (ret < 0) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("nm_supplicant_network_remove failed");
+               return;
+       }
+       iface->current_network = NULL;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_network_selected(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       nm_supplicant_iface_s *iface = NULL;
+       const gchar *path = NULL;
+       gint ret = 0;
+
+       g_variant_get(parameters, "(o)", &path);
+       if (!path) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
+       if (!iface) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("iface not found");
+               return;
+       }
+
+       ret = nm_supplicant_network_select(path, iface->current_network);
+       if (ret < 0) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("nm_supplicant_network_select failed");
+               return;
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_sta_authorized(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_sta_deauthorized(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_certification(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_eap(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_network_request(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_probe_request(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_wps_event(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       GVariantIter *iter = NULL;
+       const gchar *event = NULL;
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(parameters, "(s(a{sv}))", &event, &iter);
+       if (!event || !iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       nm_supplicant_wps_handle_event_signal(event, iter);
+
+       g_variant_iter_free(iter);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __handle_wps_credentials(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       nm_supplicant_wps_handle_event_credentials(parameters);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __iface_properties_changed(const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       nm_supplicant_iface_s *iface = NULL;
+       nm_supplicant_iface_property_e changed = NM_SUPPLICANT_IFACE_PROPERTY_NONE;
+       guint state;
+       gboolean scanning;
+
+       __NM_FUNC_ENTER__;
+
+       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
+       if (!iface) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("iface not found");
+               return;
+       }
+
+       state = iface->state;
+       scanning = iface->scanning;
+
+       if (parameters)
+               __get_iface_properties_without_bss(parameters, iface);
+
+       if (iface->state == IFACE_STATE_COMPLETED)
+               nm_supplicant_iface_signal_poll(object_path);
+
+       if (iface->state != state)
+               changed |= NM_SUPPLICANT_IFACE_PROPERTY_STATE;
+
+       if (iface->scanning != scanning)
+               changed |= NM_SUPPLICANT_IFACE_PROPERTY_SCANNING;
+
+
+       if (g_iface_prop_changed_cb)
+               g_iface_prop_changed_cb(changed, iface, g_iface_prop_changed_cb_user_data);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline int __init_iface(const gchar *path, nm_supplicant_iface_s *iface)
+{
+       gchar *key = NULL;
+       gint ret = 0;
+       __NM_FUNC_ENTER__;
+       iface->bss_tbl = g_hash_table_new_full(g_str_hash,
+                       g_str_equal,
+                       g_free,
+                       nm_supplicant_bss_destroy
+                       );
+
+       if (!iface->bss_tbl) {
+               NM_LOGI("Error! Failed to allocate bss tbl");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       key = g_strdup(path);
+       if (g_hash_table_replace(g_supplicant_iface_tbl, key, iface))
+               NM_LOGI("Iface replaced");
+
+       ret = __subscribe_iface_signal(path, iface);
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               g_hash_table_steal(g_supplicant_iface_tbl, key);
+               g_free(key);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       ret = nm_supplicant_p2p_init(path, &(iface->p2p));
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("nm_supplicant_p2p_init failed");
+
+       return 0;
+}
+
+int nm_supplicant_iface_add(const gchar *path, GVariantIter *iter)
+{
+       nm_supplicant_iface_s *iface = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!path || !iter) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       iface = (nm_supplicant_iface_s *)g_try_malloc0(sizeof(nm_supplicant_iface_s));
+       if (!iface) {
+               NM_LOGI("Error! Failed to allocate iface");
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       if (__init_iface(path, iface) < 0) {
+               __NM_FUNC_EXIT__;
+               g_free(iface);
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
+               __get_iface_property(key, var, iface);
+
+       if (g_iface_prop_changed_cb)
+               g_iface_prop_changed_cb(NM_SUPPLICANT_IFACE_PROPERTY_SCANNING |
+                               NM_SUPPLICANT_IFACE_PROPERTY_STATE,
+                               iface,
+                               g_iface_prop_changed_cb_user_data);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_supplicant_iface_remove(const gchar *path)
+{
+       nm_supplicant_iface_s *iface = NULL;
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+
+       if (!path) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       iface = g_hash_table_lookup(g_supplicant_iface_tbl, path);
+       if (!iface) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       ret = nm_supplicant_p2p_deinit(iface->p2p);
+       if (ret != NM_SUPPLICANT_ERROR_NONE)
+               NM_LOGI("nm_supplicant_p2p_deinit failed");
+       iface->p2p = NULL;
+
+       g_hash_table_remove(g_supplicant_iface_tbl, path);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+static inline void __dbus_get_iface_properties(const gchar *path, nm_supplicant_iface_s *iface)
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       get_iface_property_method_param.object_path = path;
+       get_iface_property_method_param.parameters = g_variant_new("(s)",
+                       SUPPLICANT_IFACE_INTERFACE);
+
+       ret = nm_gdbus_method_call(&get_iface_property_method_param,
+                       __get_iface_properties,
+                       (gpointer)iface);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get property all failure");
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline void __iface_signal_poll(GVariant *value, gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       /* TODO: get iface info from signal poll
+       nm_supplicant_iface_s *iface = (nm_supplicant_iface_s *)user_data;
+
+       if (!value || !user_data)
+               return;
+
+*/
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+int nm_supplicant_iface_signal_poll(const gchar *path)
+{
+       nm_supplicant_iface_s *iface = NULL;
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       iface = g_hash_table_lookup(g_supplicant_iface_tbl, path);
+       if (!iface) {
+               __NM_FUNC_EXIT__;
+               NM_LOGI("iface not found");
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       signal_poll_method_param.object_path = path;
+
+       ret = nm_gdbus_method_call(&signal_poll_method_param,
+                       __iface_signal_poll,
+                       (gpointer)iface);
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               NM_LOGI("signal poll failure");
+               ret = NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       __NM_FUNC_EXIT__;
+       return ret;
+
+}
+
+int nm_supplicant_iface_add_by_path(const gchar *path)
+{
+       nm_supplicant_iface_s *iface = NULL;
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+
+       if (!path) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       iface = (nm_supplicant_iface_s *)g_try_malloc0(sizeof(nm_supplicant_iface_s));
+       if (!iface) {
+               NM_LOGI("Error! Failed to allocate iface");
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       if (__init_iface(path, iface) < 0) {
+               __NM_FUNC_EXIT__;
+               g_free(iface);
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       __dbus_get_iface_properties(path, iface);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+
+int nm_supplicant_iface_set_prop_changed_cb(nm_supplicant_iface_changed_callback cb, gpointer user_data)
+{
+
+       if (!g_supplicant_iface_tbl)
+               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
+
+       g_iface_prop_changed_cb = cb;
+       g_iface_prop_changed_cb_user_data = user_data;
+
+       return NM_SUPPLICANT_ERROR_NONE;
+}
+
+int nm_supplicant_iface_unset_prop_changed_cb()
+{
+       if (!g_supplicant_iface_tbl)
+               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
+
+       g_iface_prop_changed_cb = NULL;
+       g_iface_prop_changed_cb_user_data = NULL;
+
+       return NM_SUPPLICANT_ERROR_NONE;
+
+}
+
+int nm_supplicant_iface_get_iface(gchar *iface_name, nm_supplicant_iface_s **iface)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+       nm_supplicant_iface_s *iface_data = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (!g_supplicant_iface_tbl)
+               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
+
+
+       g_hash_table_iter_init (&iter, g_supplicant_iface_tbl);
+       while (g_hash_table_iter_next (&iter, &key, &value)) {
+               iface_data = (nm_supplicant_iface_s *)value;
+               if (iface_data == NULL)
+                       continue;
+
+               NM_LOGI("%s is iface name", iface_data->Ifname);
+               if (g_strcmp0(iface_name, iface_data->Ifname) == 0) {
+                       *iface = iface_data;
+                       return NM_SUPPLICANT_ERROR_NONE;
+               }
+
+               iface_data = NULL;
+       }
+
+       return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       __NM_FUNC_EXIT__;
+}
+
+int nm_supplicant_iface_init()
+{
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+       g_supplicant_iface_tbl = g_hash_table_new_full(g_str_hash,
+                       g_str_equal,
+                       g_free,
+                       __destroy_iface_data
+                       );
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_supplicant_iface_deinit()
+{
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       g_hash_table_remove_all(g_supplicant_iface_tbl);
+       g_hash_table_unref(g_supplicant_iface_tbl);
+       g_supplicant_iface_tbl = NULL;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-supplicant-internal.h b/src/inm-supplicant-internal.h
new file mode 100644 (file)
index 0000000..70afce5
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file defines macro and declares functions for handling signal from WPA Supplicant.
+ *
+ * @file        nm-supplicant-internal.h
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+#ifndef __NM_SUPPLICANT_INTERNAL_H__
+#define __NM_SUPPLICANT_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SUPPLICANT_SERVICE                             "fi.w1.wpa_supplicant1"
+#define SUPPLICANT_PATH                                        "/fi/w1/wpa_supplicant1"
+
+#define SUPPLICANT_INTERFACE                   "fi.w1.wpa_supplicant1"
+#define SUPPLICANT_IFACE_INTERFACE             SUPPLICANT_INTERFACE ".Interface"
+#define SUPPLICANT_IFACE_WPS                   SUPPLICANT_IFACE_INTERFACE ".WPS"
+#define SUPPLICANT_IFACE_P2P                   SUPPLICANT_IFACE_INTERFACE ".P2PDevice"
+#define SUPPLICANT_IFACE_BSS                   SUPPLICANT_INTERFACE ".BSS"
+#define SUPPLICANT_IFACE_NETWORK               SUPPLICANT_INTERFACE ".NETWORK"
+
+typedef enum {
+       EAP_METHOD_UNKNOWN = 0x00,
+       EAP_METHOD_MD5 = 0x01,
+       EAP_METHOD_TLS = 0x02,
+       EAP_METHOD_MSCHPV2 = 0x04,
+       EAP_METHOD_PEAP = 0x08,
+       EAP_METHOD_TTLS = 0x10,
+       EAP_METHOD_GTC = 0x20,
+       EAP_METHOD_OTP = 0x40,
+       EAP_METHOD_LEAP = 0x80,
+       EAP_METHOD_WSC = 0x100,
+} supplicant_eap_method_e;
+
+typedef enum {
+
+       CAPABILITY_UNKNOWN = 0x00,
+       CAPABILITY_AP = 0x01,
+       CAPABILITY_IBSS_RSN = 0x02,
+       CAPABILITY_P2P = 0x04,
+       CAPABILITY_INTERWORKING = 0x08,
+} supplicant_capability_e;
+
+typedef enum {
+       PAIRWISE_CAP_NONE = 0x01,
+       PAIRWISE_CAP_CCMP = 0x02,
+       PAIRWISE_CAP_TKIP = 0x04,
+} pairwise_cap_e;
+
+typedef enum {
+       GROUP_CAP_CCMP = 0x01,
+       GROUP_CAP_TKIP = 0x02,
+       GROUP_CAP_WEP104 = 0x04,
+       GROUP_CAP_WEP40 = 0x08,
+} gruop_cap_e;
+
+typedef enum {
+       KEY_MGMT_CAP_NONE = 0x01,
+       KEY_MGMT_CAP_WPA_PSK = 0x02,
+       KEY_MGMT_CAP_WPA_FT_PSK = 0x04,
+       KEY_MGMT_CAP_WPA_PSK_SHA256 = 0x08,
+       KEY_MGMT_CAP_WPA_EAP = 0x10,
+       KEY_MGMT_CAP_WPA_FT_EAP = 0x20,
+       KEY_MGMT_CAP_WPA_EAP_SHA256 = 0x40,
+       KEY_MGMT_CAP_IEEE8021X = 0x80,
+       KEY_MGMT_CAP_WPA_NONE = 0x100,
+       KEY_MGMT_CAP_WPS = 0x200,
+} key_mgmt_cap_e;
+
+typedef enum {
+       PROTOCOL_RSN = 0x01,
+       PROTOCOL_WPA = 0x02,
+} protocol_e;
+
+typedef enum {
+       AUTH_ALG_OPEN = 0x01,
+       AUTH_ALG_SHARED = 0x02,
+       AUTH_ALG_LEAP = 0x03,
+} auth_alg_e;
+
+typedef enum {
+       SCAN_ACTIVE = 0x01,
+       SCAN_PASSIVE = 0x02,
+       SCAN_SSID = 0x04,
+} scan_e;
+
+typedef enum {
+       MODE_INFRA = 0x01,
+       MODE_ADHOC = 0x02,
+       MODE_AP = 0x04,
+       MODE_P2P = 0x08,
+} modes_e;
+
+typedef enum {
+       IFACE_STATE_UNKNOWN,
+       IFACE_STATE_DISCONNECTED,
+       IFACE_STATE_INACTIVE,
+       IFACE_STATE_SCANNING,
+       IFACE_STATE_AUTHENTICATING,
+       IFACE_STATE_ASSOCIATING,
+       IFACE_STATE_ASSOCIATED,
+       IFACE_STATE_4WAY_HANDSHAKE,
+       IFACE_STATE_GROUP_HANDSHAKE,
+       IFACE_STATE_COMPLETED,
+} iface_state_e;
+
+typedef enum {
+       P2P_PEER_STATE_FOUND,
+       P2P_PEER_STATE_PD,
+       P2P_PEER_STATE_GO_NEG,
+       P2P_PEER_STATE_WPS,
+       P2P_PEER_STATE_CONNECTED,
+       P2P_PEER_STATE_PD_FAIL,
+       P2P_PEER_STATE_GO_NEG_FAIL,
+       P2P_PEER_STATE_WPS_FAIL,
+       P2P_PEER_STATE_GROUP_FAIL,
+} p2p_peer_state_e;
+
+typedef enum {
+       P2P_ROLE_NONE,
+       P2P_ROLE_GC,
+       P2P_ROLE_GO,
+}p2p_role_e;
+
+int nm_supplicant_get_eap_methods(unsigned int *eap_methods);
+int nm_supplicant_get_capabilities(unsigned int *capabilities);
+int nm_supplicant_get_wfd_ies(unsigned char *ies, unsigned int *length);
+int nm_supplicant_iface_state_changed(nm_supplicant_iface_s *iface);
+
+int nm_supplicant_iface_init();
+int nm_supplicant_iface_deinit();
+int nm_supplicant_iface_add(const gchar *path, GVariantIter *iter);
+int nm_supplicant_iface_remove(const gchar *path);
+int nm_supplicant_iface_add_by_path(const gchar *path);
+int nm_supplicant_iface_signal_poll(const gchar *path);
+
+void nm_supplicant_wps_handle_event_signal(const gchar *event, GVariantIter *iter);
+void nm_supplicant_wps_handle_event_credentials(GVariant *credentials);
+
+int nm_supplicant_bss_add(const gchar *path, GVariantIter *iter, GHashTable *bss_tbl);
+int nm_supplicant_bss_add_by_path(const gchar *path, GHashTable *bss_tbl);
+int nm_supplicant_bss_remove(const gchar *path, GHashTable *bss_tbls);
+void nm_supplicant_bss_destroy(gpointer data);
+
+int nm_supplicant_network_add(const gchar *path, GVariantIter *iter, gpointer *network);
+int nm_supplicant_network_add_by_path(const gchar *path, gpointer *network);
+int nm_supplicant_network_remove(const gchar *path, gpointer network);
+int nm_supplicant_network_select(const gchar *path, gpointer network);
+void nm_supplicant_network_destroy(gpointer data);
+
+int nm_supplicant_p2p_init(const gchar *path, gpointer *p2p);
+int nm_supplicant_p2p_deinit(gpointer p2p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NM_SUPPLICANT_INTERNAL_H__ */
+
diff --git a/src/inm-supplicant-network.c b/src/inm-supplicant-network.c
new file mode 100644 (file)
index 0000000..1abeb71
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling signal from WPA Supplicant network interface.
+ *
+ * @file        nm-supplicant-network.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-supplicant.h"
+#include "inm-supplicant-internal.h"
+
+#define DEBUG_G_VARIANT(str, parameters)\
+       do {\
+               gchar *parameters_debug_str = NULL;\
+               if (parameters)\
+                       parameters_debug_str = g_variant_print(parameters, TRUE);\
+               NM_LOGI("%s[%s]", str, parameters_debug_str ? parameters_debug_str : "NULL");\
+               g_free(parameters_debug_str);\
+       } while (0)
+
+#define DEBUG_SIGNAL(sender_name, object_path, interface_name, signal_name, parameters)\
+       do {\
+               NM_LOGI("signal sender name [%s]", sender_name);\
+               NM_LOGI("signal object path [%s]", object_path);\
+               NM_LOGI("signal interface name [%s]", interface_name);\
+               NM_LOGI("signal signal name [%s]", signal_name);\
+               DEBUG_G_VARIANT("signal params ", parameters);\
+               NM_LOGI("signal params type [%s]", g_variant_get_type_string(parameters));\
+       } while (0)
+typedef enum {
+       NETWORK_SIGNAL_PROPERTIESCHANGED,
+       NETWORK_SIGNAL_MAX,
+} supplicant_network_signal_e;
+
+typedef struct {
+       gchar *path;
+       gboolean enable;
+       gboolean selected;
+       uint subscriber_id[NETWORK_SIGNAL_MAX];
+} supplicant_network_s;
+
+static method_param_s get_net_property_method_param = {
+               .bus_name = SUPPLICANT_SERVICE,
+               .object_path = NULL,
+               .interface_name = DBUS_PROPERTIES_INTERFACE,
+               .method_name = DBUS_PROPERTIES_METHOD_GETALL,
+               .parameters = NULL,
+};
+
+static void inline __get_network_enabled(GVariant *value, supplicant_network_s *net)
+{
+       g_variant_get(value, "b", &(net->enable));
+
+       NM_LOGI("Network %s", (net->enable)?"Enabled":"Disabled");
+}
+
+static void inline __get_network_property(const gchar *key, GVariant *value, supplicant_network_s *net)
+{
+       __NM_FUNC_ENTER__;
+
+       if (g_strcmp0(key, "Enabled") == 0)
+               __get_network_enabled(value, net);
+
+       __NM_FUNC_EXIT__;
+}
+
+void __get_network_properties(GVariant *value, gpointer user_data)
+{
+       GVariantIter *iter = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+       supplicant_network_s *net = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (!value || !user_data) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       g_variant_get(value, "(a{sv})", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       net = (supplicant_network_s *)user_data;
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
+               __get_network_property(key, var, net);
+
+       g_variant_iter_free(iter);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline int __init_net(const gchar *path, supplicant_network_s *net)
+{
+       gchar *key = NULL;
+
+       __NM_FUNC_ENTER__;
+
+       key = g_strdup(path);
+       if (!key) {
+               NM_LOGI("Error! Failed to get key");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (net->path)
+               g_free(net->path);
+       net->path = key;
+
+       return 0;
+}
+
+int nm_supplicant_network_add(const gchar *path, GVariantIter *iter, gpointer *network)
+{
+       supplicant_network_s *net = NULL;
+       const gchar *key = NULL;
+       GVariant *var = NULL;
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!path || !iter || !network) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       net = (supplicant_network_s *)g_try_malloc0(sizeof(supplicant_network_s));
+       if (!net) {
+               NM_LOGI("Error! Failed to allocate net");
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       if (__init_net(path, net) < 0) {
+               NM_LOGI("Error! Failed to init net");
+               g_free(net);
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
+               __get_network_property(key, var, net);
+
+       *network = net;
+       __NM_FUNC_EXIT__;
+       return ret;
+
+}
+
+static inline void __dbus_get_net_properties(const gchar *path, supplicant_network_s *net)
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       get_net_property_method_param.object_path = path;
+       get_net_property_method_param.parameters = g_variant_new("(s)",
+                       SUPPLICANT_IFACE_NETWORK);
+
+       ret = nm_gdbus_method_call(&get_net_property_method_param,
+                       __get_network_properties,
+                       (gpointer)net);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get property all failure");
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+int nm_supplicant_network_add_by_path(const gchar *path, gpointer *network)
+{
+       supplicant_network_s *net = NULL;
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+
+       if (!path) {
+               NM_LOGI("NULL obj");
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       net = (supplicant_network_s *)g_try_malloc0(sizeof(supplicant_network_s));
+       if (!net) {
+               NM_LOGI("Error! Failed to allocate net");
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       if (__init_net(path, net) < 0) {
+               __NM_FUNC_EXIT__;
+               g_free(net);
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       __dbus_get_net_properties(path, net);
+
+       *network = net;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_supplicant_network_remove(const gchar *path, gpointer network)
+{
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+
+       if (!path || !network) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       nm_supplicant_network_destroy(network);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_supplicant_network_select(const gchar *path, gpointer network)
+{
+       supplicant_network_s *net = NULL;
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+
+       if (!path || !network) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       net = (supplicant_network_s *)network;
+       net->selected = TRUE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+
+}
+
+void nm_supplicant_network_destroy(gpointer data)
+{
+       supplicant_network_s *network = NULL;
+       __NM_FUNC_ENTER__;
+
+
+       if (!data) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+       network = (supplicant_network_s *)data;
+
+       g_free(network->path);
+       g_free(network);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
diff --git a/src/inm-supplicant-p2p.c b/src/inm-supplicant-p2p.c
new file mode 100644 (file)
index 0000000..320ed13
--- /dev/null
@@ -0,0 +1,786 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling signal from WPA Supplicant P2P interface.
+ *
+ * @file        nm-supplicant-p2p.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-supplicant.h"
+#include "inm-supplicant-internal.h"
+
+#define DEVICE_NAME_LEN 32
+#define MAC_ADDR_LEN 6
+
+#define SUPPLICANT_P2P_SIGNAL_DEVICE_FOUND             "DeviceFound"
+#define SUPPLICANT_P2P_SIGNAL_DEVICE_LOST              "DeviceLost"
+#define SUPPLICANT_P2P_SIGNAL_PD_REQ_DISPLAY   "ProvisionDiscoveryRequestDisplayPin"
+#define SUPPLICANT_P2P_SIGNAL_PD_RESP_DISPLAY  "ProvisionDiscoveryResponseDisplayPin"
+#define SUPPLICANT_P2P_SIGNAL_PD_REQ_KEYPAD            "ProvisionDiscoveryRequestEnterPin"
+#define SUPPLICANT_P2P_SIGNAL_PD_RESP_KEYPAD   "ProvisionDiscoveryResponseEnterPin"
+#define SUPPLICANT_P2P_SIGNAL_PD_REQ_PBC               "ProvisionDiscoveryPBCRequest"
+#define SUPPLICANT_P2P_SIGNAL_PD_RESP_PBC              "ProvisionDiscoveryPBCResponse"
+#define SUPPLICANT_P2P_SIGNAL_PD_FAILURE               "ProvisionDiscoveryFailure"
+#define SUPPLICANT_P2P_SIGNAL_GROUP_STARTED            "GroupStarted"
+#define SUPPLICANT_P2P_SIGNAL_GO_NEG_SUCCESS   "GONegotiationSuccess"
+#define SUPPLICANT_P2P_SIGNAL_GO_NEG_FAILURE   "GONegotiationFailure"
+#define SUPPLICANT_P2P_SIGNAL_GO_NEG_REQ               "GONegotiationRequest"
+#define SUPPLICANT_P2P_SIGNAL_INVITE_REUSLT            "InvitationResult"
+#define SUPPLICANT_P2P_SIGNAL_GROUP_FINISHED   "GroupFinished"
+#define SUPPLICANT_P2P_SIGNAL_WPS_FAILED               "WpsFailed"
+#define SUPPLICANT_P2P_SIGNAL_INVITATION_RECEIVED              "InvitationReceived"
+#define SUPPLICANT_P2P_SIGNAL_GROUP_FORMATION_FAILURE          "GroupFormationFailure"
+
+typedef enum {
+       P2P_SIGNAL_DEVICE_FOUND,
+       P2P_SIGNAL_DEVICE_LOST,
+       P2P_SIGNAL_PD_REQ_DISPLAY,
+       P2P_SIGNAL_PD_RESP_DISPLAY,
+       P2P_SIGNAL_PD_REQ_KEYPAD,
+       P2P_SIGNAL_PD_RESP_KEYPAD,
+       P2P_SIGNAL_PD_REQ_PBC,
+       P2P_SIGNAL_PD_RESP_PBC,
+       P2P_SIGNAL_PD_FAILURE,
+       P2P_SIGNAL_GROUP_STRARTED,
+       P2P_SIGNAL_GO_NEG_SUCCESS,
+       P2P_SIGNAL_GO_NEG_FAILURE,
+       P2P_SIGNAL_GO_NEG_REQ,
+       P2P_SIGNAL_INVITE_RESULT,
+       P2P_SIGNAL_GROUP_FINISHED,
+       P2P_SIGNAL_WPS_FAILED,
+       P2P_SIGNAL_INVITE_RECEIVED,
+       P2P_SIGNAL_GROUP_FORMATION_FAILURE,
+       P2P_SIGNAL_MAX,
+} p2p_signal_e;
+
+typedef struct {
+       gchar device_name[DEVICE_NAME_LEN];
+       gint level;
+       guchar device_cap;
+       guchar group_cap;
+       gchar dev_addr[MAC_ADDR_LEN];
+       gint state;
+} supplicant_p2p_peer_s;
+
+typedef struct {
+
+} supplicant_p2p_group_s;
+
+typedef struct {
+       gchar device_name[DEVICE_NAME_LEN];
+       guint go_intent;
+       gboolean persistent_reconnect;
+       guint listen_reg_class;
+       guint listen_channel;
+       guint op_reg_class;
+       guint op_channel;
+
+       /*
+        * List of BSSs known to the interface
+        */
+       GHashTable *peers;
+       supplicant_p2p_group_s *group;
+       guint role;
+       guint subscriber_id[P2P_SIGNAL_MAX];
+} supplicant_p2p_s;
+
+typedef void (*handle_p2p_device_signal_properties) (
+               gchar *key,
+               GVariant *value,
+               supplicant_p2p_s *p2p);
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_device_found);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_device_lost);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_display);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_display);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_keypad);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_keypad);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_pbc);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_pbc);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_started);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_neg_success);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_go_neg_failure);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_go_neg_req);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_invite_result);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_finished);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_wps_failed);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_invitation_receivced);
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_formation_failure);
+
+static signal_param_s p2p_signal_params[] = {
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_DEVICE_FOUND,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_device_found,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_DEVICE_LOST,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_device_lost,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_PD_REQ_DISPLAY,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_pd_req_display,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_PD_RESP_DISPLAY,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_pd_resp_display,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_PD_REQ_KEYPAD,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_pd_req_keypad,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_PD_RESP_KEYPAD,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_device_found,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_PD_REQ_PBC,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_pd_resp_keypad,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_PD_RESP_PBC,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_pd_req_pbc,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_PD_FAILURE,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_pd_resp_pbc,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_GROUP_STARTED,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_group_started,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_GO_NEG_SUCCESS,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_neg_success,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_GO_NEG_FAILURE,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_go_neg_failure,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_GO_NEG_REQ,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_go_neg_req,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_INVITE_REUSLT,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_invite_result,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_GROUP_FINISHED,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_group_finished,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_WPS_FAILED,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_wps_failed,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_INVITATION_RECEIVED,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_invitation_receivced,
+                       .subscriber_id  = 0,
+               },
+               {
+                       .sender = SUPPLICANT_SERVICE,
+                       .interface_name = SUPPLICANT_IFACE_P2P,
+                       .member = SUPPLICANT_P2P_SIGNAL_GROUP_FORMATION_FAILURE,
+                       .object_path = NULL,
+                       .arg0 = NULL,
+                       .callback_with_data = __p2p_group_formation_failure,
+                       .subscriber_id  = 0,
+               },
+};
+
+/*
+static method_param_s get_p2p_property_method_param = {
+               .bus_name = SUPPLICANT_SERVICE,
+               .object_path = NULL,
+               .interface_name = DBUS_PROPERTIES_INTERFACE,
+               .method_name = DBUS_PROPERTIES_METHOD_GETALL,
+               .parameters = NULL,
+};
+
+static inline void __get_peer_property(gchar *key, GVariant *value, supplicant_p2p_peer_s *peer)
+{
+
+}
+
+static inline void __get_peer_properties(GVariant *param, supplicant_p2p_peer_s *peer)
+{
+       GVariantIter *iter = NULL;
+       gchar *key = NULL;
+       GVariant *value = NULL;
+
+       g_variant_get(param, "(a{sv})", &iter);
+       if (!iter)
+               return;
+       while (g_variant_iter_loop (iter, "{sv}", &key, &value))
+               __get_peer_property(key, value, peer);
+
+       g_variant_iter_free(iter);
+
+       return;
+}
+*/
+
+static void __supplicant_peer_destroy(gpointer data)
+{
+       supplicant_p2p_peer_s *peer = NULL;
+
+       if (!data)
+               return;
+
+       peer = (supplicant_p2p_peer_s *)data;
+
+       g_free(peer);
+}
+
+static inline supplicant_p2p_peer_s * __get_peer(const char *path, gpointer user_data)
+{
+       supplicant_p2p_s *p2p_data = NULL;
+       if (!path || !user_data)
+               return NULL;
+
+       p2p_data = (supplicant_p2p_s *)user_data;
+
+       return g_hash_table_lookup(p2p_data->peers, path);
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_device_found)
+{
+       __NM_FUNC_ENTER__;
+       supplicant_p2p_s *p2p_data = NULL;
+       supplicant_p2p_peer_s *peer = NULL;
+       const char *path = NULL;
+
+       g_variant_get(parameters, "(&o)", &path);
+       if (!path)
+               return;
+
+       p2p_data = (supplicant_p2p_s *)user_data;
+       if (!user_data)
+               return;
+
+       peer = g_try_malloc0(sizeof(supplicant_p2p_peer_s));
+       if (!peer)
+               return;
+
+       g_hash_table_replace(p2p_data->peers, g_strdup(path), peer);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_device_lost)
+{
+       __NM_FUNC_ENTER__;
+       supplicant_p2p_s *p2p_data = NULL;
+       const char *path = NULL;
+
+       g_variant_get(parameters, "(&o)", &path);
+       if (!path)
+               return;
+
+       p2p_data = (supplicant_p2p_s *)user_data;
+       if (!user_data)
+               return;
+
+       g_hash_table_remove(p2p_data->peers, path);
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_display)
+{
+       __NM_FUNC_ENTER__;
+       supplicant_p2p_peer_s *peer = NULL;
+       const char *path = NULL;
+       const char *pin;
+
+       g_variant_get(parameters, "(&o&s)", &path, &pin);
+       peer = __get_peer(path, user_data);
+       if (!peer)
+               return;
+
+       peer->state = P2P_PEER_STATE_PD;
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_display)
+{
+       __NM_FUNC_ENTER__;
+       supplicant_p2p_peer_s *peer = NULL;
+       const char *path = NULL;
+       const char *pin;
+
+       g_variant_get(parameters, "(&o&s)", &path, &pin);
+       peer = __get_peer(path, user_data);
+       if (!peer)
+               return;
+
+       peer->state = P2P_PEER_STATE_PD;
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_keypad)
+{
+       __NM_FUNC_ENTER__;
+       supplicant_p2p_peer_s *peer = NULL;
+       const char *path = NULL;
+
+       g_variant_get(parameters, "(&o)", &path);
+       peer = __get_peer(path, user_data);
+       if (!peer)
+               return;
+
+       peer->state = P2P_PEER_STATE_PD;
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_keypad)
+{
+       __NM_FUNC_ENTER__;
+       supplicant_p2p_peer_s *peer = NULL;
+       const char *path = NULL;
+
+       g_variant_get(parameters, "(&o)", &path);
+       peer = __get_peer(path, user_data);
+       if (!peer)
+               return;
+
+       peer->state = P2P_PEER_STATE_PD;
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_pbc)
+{
+       __NM_FUNC_ENTER__;
+       supplicant_p2p_peer_s *peer = NULL;
+       const char *path = NULL;
+
+       g_variant_get(parameters, "(&o)", &path);
+       peer = __get_peer(path, user_data);
+       if (!peer)
+               return;
+
+       peer->state = P2P_PEER_STATE_PD;
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_pbc)
+{
+       __NM_FUNC_ENTER__;
+       supplicant_p2p_peer_s *peer = NULL;
+       const char *path = NULL;
+
+       g_variant_get(parameters, "(&o)", &path);
+       peer = __get_peer(path, user_data);
+       if (!peer)
+               return;
+
+       peer->state = P2P_PEER_STATE_PD;
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+
+static inline void __handle_p2p_device_event_variant(
+               handle_p2p_device_signal_properties handler,
+               GVariant *param,
+               gpointer user_data
+               )
+{
+       GVariantIter *iter = NULL;
+       gchar *key = NULL;
+       GVariant *value = NULL;
+
+       g_variant_get(param, "(a{sv})", &iter);
+       if (!iter)
+               return;
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &value))
+               handler(key, value, (supplicant_p2p_s *)user_data);
+
+       g_variant_iter_free(iter);
+
+       return;
+}
+
+static inline void __get_group_started_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
+{
+
+}
+
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_started)
+{
+       __NM_FUNC_ENTER__;
+
+       __handle_p2p_device_event_variant(
+                       __get_group_started_property,
+                       user_data,
+                       parameters);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline void __get_go_neg_success_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
+{
+
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_neg_success)
+{
+       __NM_FUNC_ENTER__;
+
+       __handle_p2p_device_event_variant(
+                       __get_go_neg_success_property,
+                       user_data,
+                       parameters);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline void __get_go_neg_fail_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
+{
+
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_go_neg_failure)
+{
+       __NM_FUNC_ENTER__;
+
+       __handle_p2p_device_event_variant(
+                       __get_go_neg_fail_property,
+                       user_data,
+                       parameters);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_go_neg_req)
+{
+       __NM_FUNC_ENTER__;
+       supplicant_p2p_peer_s *peer = NULL;
+       const char *path = NULL;
+       guint16 dev_passwd_id = 0;
+       guchar go_intent = 0;
+
+       g_variant_get(parameters, "(&oqy)", &path, &dev_passwd_id, &go_intent);
+       peer = __get_peer(path, user_data);
+       if (!peer)
+               return;
+
+       peer->state = P2P_PEER_STATE_GO_NEG;
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_invite_result)
+{
+       __NM_FUNC_ENTER__;
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline void __get_group_finished_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
+{
+
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_finished)
+{
+       __NM_FUNC_ENTER__;
+
+       __handle_p2p_device_event_variant(
+                       __get_group_finished_property,
+                       user_data,
+                       parameters);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline void __get_wps_failed_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
+{
+
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_wps_failed)
+{
+       __NM_FUNC_ENTER__;
+
+       __handle_p2p_device_event_variant(
+                       __get_wps_failed_property,
+                       user_data,
+                       parameters);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+
+static inline void __get_invitation_received_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
+{
+
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_invitation_receivced)
+{
+       __NM_FUNC_ENTER__;
+
+       __handle_p2p_device_event_variant(
+                       __get_invitation_received_property,
+                       user_data,
+                       parameters);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_formation_failure)
+{
+       __NM_FUNC_ENTER__;
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline int __subscribe_p2p_signal(const gchar *path, supplicant_p2p_s *data)
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+       int signal_idx = 0;
+       __NM_FUNC_ENTER__;
+
+       if (!path || !data) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       NM_LOGI("path [%s]", path);
+       for (signal_idx = P2P_SIGNAL_DEVICE_FOUND; signal_idx < P2P_SIGNAL_MAX; signal_idx++) {
+               p2p_signal_params[signal_idx].object_path = path;
+               ret = nm_gdbus_subscribe_signal_with_data(&(p2p_signal_params[signal_idx]), data);
+               if (ret != NM_GDBUS_ERROR_NONE)
+                       NM_LOGI("Error! Failed to subscribe signal");
+               else
+                       data->subscriber_id[signal_idx] =
+                                       p2p_signal_params[signal_idx].subscriber_id;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_SUPPLICANT_ERROR_NONE;
+}
+
+static inline int __unsubscribe_p2p_signal(supplicant_p2p_s *data)
+{
+       int signal_idx = 0;
+       int ret = NM_GDBUS_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!data) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       for (signal_idx = P2P_SIGNAL_DEVICE_FOUND; signal_idx < P2P_SIGNAL_MAX; signal_idx++) {
+
+               if (data->subscriber_id[signal_idx] == 0)
+                       continue;
+
+               p2p_signal_params[signal_idx].subscriber_id = data->subscriber_id[signal_idx];
+               ret = nm_gdbus_unsubscribe_signal(&(p2p_signal_params[signal_idx]));
+               if (ret != NM_GDBUS_ERROR_NONE)
+                       NM_LOGI("Error! Failed to unsubscribe signal");
+               else
+                       data->subscriber_id[signal_idx] = 0;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_SUPPLICANT_ERROR_NONE;
+}
+
+int nm_supplicant_p2p_init(const gchar *path, gpointer *p2p)
+{
+       supplicant_p2p_s *p2p_data = NULL;
+       gint ret = 0;
+       __NM_FUNC_ENTER__;
+
+       if (!path || !p2p) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       p2p_data = (supplicant_p2p_s *)g_try_malloc0(sizeof(supplicant_p2p_s));
+       if (!p2p_data) {
+               NM_LOGI("Error! Failed to allocate net");
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
+       }
+
+       p2p_data->peers = g_hash_table_new_full(g_str_hash,
+                       g_str_equal,
+                       g_free,
+                       __supplicant_peer_destroy
+                       );
+
+       if (!p2p_data->peers) {
+               NM_LOGI("Error! Failed to allocate bss tbl");
+               g_free(p2p_data);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+
+       ret = __subscribe_p2p_signal(path, p2p_data);
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               g_hash_table_destroy(p2p_data->peers);
+               g_free(p2p_data);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       *p2p = p2p_data;
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_supplicant_p2p_deinit(gpointer p2p)
+{
+       supplicant_p2p_s *p2p_data = NULL;
+       gint ret = 0;
+       __NM_FUNC_ENTER__;
+
+       if (!p2p) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       p2p_data = (supplicant_p2p_s *)p2p;
+       ret = __unsubscribe_p2p_signal(p2p_data);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("__unsubscribe_p2p_signal failed");
+
+       g_hash_table_destroy(p2p_data->peers);
+
+       g_free(p2p);
+       __NM_FUNC_EXIT__;
+       return 0;
+}
diff --git a/src/inm-supplicant-wps.c b/src/inm-supplicant-wps.c
new file mode 100644 (file)
index 0000000..be60b18
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling signal from WPA Supplicant WPS interface.
+ *
+ * @file        nm-supplicant-wps.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+
+#include "inm-daemon-log.h"
+#include "inm-supplicant.h"
+#include "inm-supplicant-internal.h"
+
+void nm_supplicant_wps_handle_event_signal(const gchar *event, GVariantIter *iter)
+{
+       __NM_FUNC_ENTER__;
+
+       if (!event || ! iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+
+}
+
+void nm_supplicant_wps_handle_event_credentials(GVariant *credentials)
+{
+       __NM_FUNC_ENTER__;
+
+       if (!credentials) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       __NM_FUNC_EXIT__;
+       return;
+
+
+}
diff --git a/src/inm-supplicant.c b/src/inm-supplicant.c
new file mode 100644 (file)
index 0000000..40ccdf4
--- /dev/null
@@ -0,0 +1,534 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling signal from WPA Supplicant.
+ *
+ * @file        nm-supplicant.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-supplicant.h"
+#include "inm-supplicant-internal.h"
+
+#define SUPPPLICANT_SIGNAL_IFACE_ADDED         "InterfaceAdded"
+#define SUPPPLICANT_SIGNAL_IFACE_REMOVED               "InterfaceRemoved"
+
+#define WFDIE_SUBELEM_LEN_DEV_INFO 6
+
+typedef enum {
+       SIGNAL_IFACE_ADDED,
+       SIGNAL_IFACE_REMOVED,
+       SIGNAL_PROP_CHANGED,
+       SIGNAL_NAME_OWNER_CHANGED,
+       SIGNAL_MAX,
+
+} supplicant_signal_e;
+
+typedef struct {
+       gboolean is_initialized;
+       guint eap_methods;
+       guint capabilities;
+       guchar ies[WFDIE_SUBELEM_LEN_DEV_INFO + 3];
+
+} supplicant_mon_s;
+
+supplicant_mon_s supplicant_mon;
+
+void __iface_added(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+void __iface_removed(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+void __supplicant_properties_changed(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+static void __name_owner_changed_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+static signal_param_s signal_param[] = {
+               {
+                               .sender = SUPPLICANT_SERVICE,
+                               .interface_name = SUPPLICANT_INTERFACE,
+                               .member = SUPPPLICANT_SIGNAL_IFACE_ADDED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __iface_added,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = SUPPLICANT_SERVICE,
+                               .interface_name = SUPPLICANT_INTERFACE,
+                               .member = SUPPPLICANT_SIGNAL_IFACE_REMOVED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __iface_removed,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = SUPPLICANT_SERVICE,
+                               .interface_name = SUPPLICANT_INTERFACE,
+                               .member = DBUS_SIGNAL_PROPERTIES_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = NULL,
+                               .callback = __supplicant_properties_changed,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = DBUS_SERVICE_DBUS,
+                               .interface_name = DBUS_INTERFACE_DBUS,
+                               .member = DBUS_SIGNAL_NAME_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = SUPPLICANT_SERVICE,
+                               .callback = __name_owner_changed_cb,
+                               .subscriber_id  = 0,
+               },
+};
+
+static method_param_s get_supplicant_property_method_param = {
+               .bus_name = SUPPLICANT_SERVICE,
+               .object_path = SUPPLICANT_PATH,
+               .interface_name = DBUS_PROPERTIES_INTERFACE,
+               .method_name = DBUS_PROPERTIES_METHOD_GETALL,
+               .parameters = NULL,
+};
+
+static gboolean __unpack_ays(unsigned char *dst, GVariant *src, int size)
+{
+       GVariantIter *iter = NULL;
+       int length = 0;
+       int res = FALSE;
+
+       if (!dst || !src || size == 0) {
+               NM_LOGI("Invalid parameter");
+               return FALSE;
+       }
+
+       g_variant_get(src, "ay", &iter);
+       if (iter == NULL) {
+               NM_LOGI("failed to get iterator");
+               return FALSE;
+       }
+
+       while (g_variant_iter_loop(iter, "y", &dst[length])) {
+               length++;
+               if (length >= size)
+                       break;
+       }
+       g_variant_iter_free(iter);
+
+       if (length < size) {
+               NM_LOGI("array is shorter than size");
+               res = FALSE;
+       }
+
+       return res;
+}
+
+static void __name_owner_changed_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       gchar *name = NULL;
+       gchar *old = NULL;
+       gchar *new = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (parameters == NULL)
+               return;
+
+       g_variant_get(parameters, "(&s&s&s)", &name, &old, &new);
+
+       if (g_strcmp0(name, SUPPLICANT_SERVICE) == 0 && *new == '\0')
+               NM_LOGI("Supplicant destroyed: name %s, old %s, new %s", name, old, new);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline void __get_supplicant_interface(GVariant *value)
+{
+       GVariantIter *iter = NULL;
+       const gchar *obj = NULL;
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(value, "ao", &iter);
+
+       while (g_variant_iter_loop(iter, "o", &obj))
+               nm_supplicant_iface_add_by_path(obj);
+
+       g_variant_iter_free(iter);
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __get_supplicant_eap_method(GVariant *value, supplicant_mon_s *supp)
+{
+       GVariantIter *iter = NULL;
+       const gchar *method = NULL;
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(value, "as", &iter);
+
+       supp->eap_methods = EAP_METHOD_UNKNOWN;
+       while (g_variant_iter_loop(iter, "s", &method)) {
+               /* Check Type of DNS Address */
+               if (g_strcmp0(method, "MD5") == 0)
+                       supp->eap_methods |= CAPABILITY_AP;
+               else if (g_strcmp0(method, "TLS") == 0)
+                       supp->eap_methods |= EAP_METHOD_TLS;
+               else if (g_strcmp0(method, "MSCHAPV2") == 0)
+                       supp->eap_methods |= EAP_METHOD_MSCHPV2;
+               else if (g_strcmp0(method, "PEAP") == 0)
+                       supp->eap_methods |= EAP_METHOD_PEAP;
+               else if (g_strcmp0(method, "TTLS") == 0)
+                       supp->eap_methods |= EAP_METHOD_TTLS;
+               else if (g_strcmp0(method, "GTC") == 0)
+                       supp->eap_methods |= EAP_METHOD_GTC;
+               else if (g_strcmp0(method, "OTP") == 0)
+                       supp->eap_methods |= EAP_METHOD_OTP;
+               else if (g_strcmp0(method, "LEAP") == 0)
+                       supp->eap_methods |= EAP_METHOD_LEAP;
+               else if (g_strcmp0(method, "WSC") == 0)
+                       supp->eap_methods |= EAP_METHOD_WSC;
+       }
+       g_variant_iter_free(iter);
+       __NM_FUNC_EXIT__;
+}
+
+static inline void __get_supplicant_capability(GVariant *value, supplicant_mon_s *supp)
+{
+       GVariantIter *iter = NULL;
+       const gchar *cap = NULL;
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(value, "as", &iter);
+
+       supp->capabilities = CAPABILITY_UNKNOWN;
+       while (g_variant_iter_loop(iter, "s", &cap)) {
+               /* Check Type of DNS Address */
+               if (g_strcmp0(cap, "ap") == 0)
+                       supp->capabilities |= CAPABILITY_AP;
+               else if (g_strcmp0(cap, "ibss-rsn") == 0)
+                       supp->capabilities |= CAPABILITY_IBSS_RSN ;
+               else if (g_strcmp0(cap, "p2p") == 0)
+                       supp->capabilities |= CAPABILITY_P2P ;
+               else if (g_strcmp0(cap, "interworking") == 0)
+                       supp->capabilities |= CAPABILITY_INTERWORKING  ;
+       }
+       g_variant_iter_free(iter);
+       __NM_FUNC_EXIT__;
+}
+
+void __get_supplicant_property(gchar *key, GVariant *value, supplicant_mon_s *supp)
+{
+       __NM_FUNC_ENTER__;
+
+       if (g_strcmp0(key, "Interfaces") == 0)
+               __get_supplicant_interface(value);
+       else if (g_strcmp0(key, "EapMethods") == 0)
+               __get_supplicant_eap_method(value, supp);
+       else if (g_strcmp0(key, "Capabilities") == 0)
+               __get_supplicant_capability(value, supp);
+       else if (g_strcmp0(key, "WFDIEs") == 0)
+               if (__unpack_ays(supp->ies, value, WFDIE_SUBELEM_LEN_DEV_INFO + 3)) {
+                       NM_LOGI("WFDIEs valid");
+       }
+
+       __NM_FUNC_EXIT__;
+}
+
+void __get_supplicant_properties(GVariant *value, void *user_data)
+{
+       GVariantIter *iter = NULL;
+       gchar *key = NULL;
+       GVariant *var = NULL;
+       supplicant_mon_s *supp = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (!value || !user_data) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       g_variant_get(value, "(a{sv})", &iter);
+       if (!iter) {
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       supp = (supplicant_mon_s *)user_data;
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
+               __get_supplicant_property(key, var, supp);
+
+       g_variant_iter_free(iter);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+void __iface_added(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       const gchar *path = NULL;
+       GVariantIter *iter = NULL;
+
+       g_variant_get(parameters, "(oa{sv})", &path, &iter);
+
+       if (path && iter)
+               nm_supplicant_iface_add(path, iter);
+       else
+               NM_LOGI("NULL path or variants");
+
+       g_variant_iter_free(iter);
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+void __iface_removed(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+       const gchar *path = NULL;
+
+       g_variant_get(parameters, "(o)", &path);
+       if (path)
+               nm_supplicant_iface_remove(path);
+       else
+               NM_LOGI("NULL path");
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+void __supplicant_properties_changed(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       if (parameters)
+               __get_supplicant_properties(parameters, &supplicant_mon);
+
+       __NM_FUNC_EXIT__;
+}
+
+
+int nm_supplicant_get_properties()
+{
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       get_supplicant_property_method_param.parameters = g_variant_new("(s)",
+                       SUPPLICANT_INTERFACE);
+
+       ret = nm_gdbus_method_call(&get_supplicant_property_method_param,
+                       __get_supplicant_properties,
+                       (gpointer)&supplicant_mon);
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_METHOD_CALL_FAILED;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_SUPPLICANT_ERROR_NONE;
+}
+
+int nm_supplicant_get_eap_methods(unsigned int *eap_methods)
+{
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!supplicant_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!eap_methods) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       *eap_methods = supplicant_mon.eap_methods;
+
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_supplicant_get_capabilities(unsigned int *capabilities)
+{
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!supplicant_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!capabilities) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       *capabilities = supplicant_mon.capabilities;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_supplicant_get_wfd_ies(unsigned char *ies, unsigned int *length)
+{
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!supplicant_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!ies || !length) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
+       }
+
+       memcpy(ies, supplicant_mon.ies, WFDIE_SUBELEM_LEN_DEV_INFO + 3);
+       *length = WFDIE_SUBELEM_LEN_DEV_INFO + 3;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+int nm_supplicant_init()
+{
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       memset(&supplicant_mon, 0x00, sizeof(supplicant_mon));
+       supplicant_mon.is_initialized = TRUE;
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[SIGNAL_IFACE_ADDED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[SIGNAL_IFACE_REMOVED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[SIGNAL_PROP_CHANGED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[SIGNAL_NAME_OWNER_CHANGED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_supplicant_iface_init();
+       if (ret != NM_SUPPLICANT_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_SUPPLICANT_ERROR_NONE;
+}
+
+int nm_supplicant_deinit()
+{
+       int ret = NM_SUPPLICANT_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       if (!supplicant_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
+       }
+
+       ret = nm_supplicant_iface_deinit();
+       if (ret != NM_SUPPLICANT_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       nm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_IFACE_ADDED]));
+       nm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_IFACE_REMOVED]));
+       nm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_PROP_CHANGED]));
+       nm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_NAME_OWNER_CHANGED]));
+
+       memset(&supplicant_mon, 0x00, sizeof(supplicant_mon));
+       supplicant_mon.is_initialized = FALSE;
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
diff --git a/src/inm-telephony.c b/src/inm-telephony.c
new file mode 100644 (file)
index 0000000..a9bcbda
--- /dev/null
@@ -0,0 +1,507 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions to get information from telephony module.
+ *
+ * @file        nm-telephony.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-telephony.h"
+
+#define TELEPHONY_SERVICE                              "com.tcore.ps"
+#define TELEPHONY_MASTER_PATH                  "/"
+#define TELEPHONY_MASTER_INTERFACE             TELEPHONY_SERVICE ".master"
+#define TELEPHONY_MODEM_INTERFACE              TELEPHONY_SERVICE ".modem"
+#define TELEPHONY_NETWORK_INTERFACE            TELEPHONY_SERVICE ".network"
+#define TELEPHONY_PROFILE_INTERFACE            TELEPHONY_SERVICE ".context"
+
+enum {
+       TELEPHONY_CMD_GET_MODEMS,
+       TELEPHONY_CMD_GET_PROFILE_LIST,
+       TELEPHONY_CMD_GET_PROFILE,
+};
+
+/**
+ * Below structure is used to export profile name
+ */
+typedef struct
+{
+       /** Profile name */
+       gchar profile_name[NM_PROFILE_NAME_LEN_MAX + 1];
+} nm_profile_name_s;
+
+static method_param_s tel_method_params[] = {
+               {
+                               .bus_name = TELEPHONY_SERVICE,
+                               .object_path = TELEPHONY_MASTER_PATH,
+                               .interface_name = TELEPHONY_MASTER_INTERFACE,
+                               .method_name = "GetModems",
+                               .parameters = NULL,
+               },
+               {
+                               .bus_name = TELEPHONY_SERVICE,
+                               .object_path = NULL,
+                               .interface_name = TELEPHONY_MODEM_INTERFACE,
+                               .method_name = "GetProfileList",
+                               .parameters = NULL,
+               },
+               {
+                               .bus_name = TELEPHONY_SERVICE,
+                               .object_path = NULL,
+                               .interface_name = TELEPHONY_PROFILE_INTERFACE,
+                               .method_name = "GetProfile",
+                               .parameters = NULL,
+               },
+};
+
+static void __get_modem_properties(GVariant *reply, gpointer user_data)
+{
+       GVariantIter *iter = NULL;
+       GVariantIter *modem_properties = NULL;
+       GSList **modem_path_list;
+       const char *modem_path;
+       __NM_FUNC_ENTER__;
+
+       if (!reply || !user_data)
+               return;
+
+       modem_path_list = (GSList **)user_data;
+
+       g_variant_get(reply, "(a{sa{ss}})", &iter);
+       while (g_variant_iter_loop(iter, "{sa{ss}}", &modem_path, &modem_properties)) {
+               *modem_path_list = g_slist_append(*modem_path_list, g_strdup(modem_path));
+               NM_LOGI("modem object path: %s", modem_path);
+       }
+
+       g_variant_iter_free(iter);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static int __get_modem_object_path(GSList **modem_path_list)
+{
+
+       int ret = 0;
+       __NM_FUNC_ENTER__;
+
+       ret = nm_gdbus_method_call(
+                       &(tel_method_params[TELEPHONY_CMD_GET_MODEMS]),
+                       __get_modem_properties,
+                       (gpointer)modem_path_list);
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               NM_LOGI("Failed to get modem paths");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+static void __get_profiles(GVariant *reply, gpointer user_data)
+{
+       GVariantIter *iter = NULL;
+       const char *str = NULL;
+       GSList **profiles = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (!reply || !user_data)
+               return;
+
+       profiles = (GSList **)user_data;
+
+       g_variant_get(reply, "(as)", &iter);
+       while (g_variant_iter_loop(iter, "s", &str))
+               *profiles = g_slist_append(*profiles, g_strdup(str));
+
+       g_variant_iter_free(iter);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static GSList *__get_profile_list()
+{
+       GSList *profile_list = NULL, *list = NULL;
+       GSList *modem_path_list = NULL;
+       const char *path = NULL;
+       int ret = 0;
+
+       __NM_FUNC_ENTER__;
+
+       ret = __get_modem_object_path(&modem_path_list);
+       if (ret < 0) {
+               NM_LOGI("Failed to get modems path list");
+
+               g_slist_free_full(modem_path_list, g_free);
+               __NM_FUNC_EXIT__;
+               return NULL;
+       }
+
+       for (list = modem_path_list; list != NULL; list = list->next) {
+               path = (const char *)list->data;
+
+               NM_LOGI("path: %s", path);
+               tel_method_params[TELEPHONY_CMD_GET_PROFILE_LIST].object_path = path;
+               ret = nm_gdbus_method_call(
+                               &(tel_method_params[TELEPHONY_CMD_GET_PROFILE_LIST]),
+                               __get_profiles,
+                               (gpointer)&profile_list);
+               if (ret != NM_GDBUS_ERROR_NONE) {
+                       NM_LOGI("Failed to get profiles: %s", path);
+                       continue;
+               }
+       }
+
+       g_slist_free_full(modem_path_list, g_free);
+       __NM_FUNC_EXIT__;
+       return profile_list;
+}
+
+static int __get_profile_names(nm_profile_name_s **profile_names,
+               int *profile_cnt)
+{
+
+       int ret = 0;
+       int count = 0, i = 0;
+       GSList *profile_list = NULL, *list = NULL;
+       nm_profile_name_s *p_profile_name = NULL;
+
+       profile_list = __get_profile_list();
+       count = g_slist_length(profile_list);
+       NM_LOGI("[%d] profile found", count);
+       if (count > 0) {
+               p_profile_name = (nm_profile_name_s*)malloc(sizeof(nm_profile_name_s) * count);
+               ret = 0;
+       } else {
+               *profile_cnt = 0;
+               goto out;
+       }
+
+       if (p_profile_name == NULL) {
+               NM_LOGI("Failed to allocate memory");
+               *profile_cnt = 0;
+               ret = -1;
+               goto out;
+       }
+
+       for (list = profile_list, i = 0; list != NULL; list = list->next, i++)
+               g_strlcpy(p_profile_name[i].profile_name,
+                               (const char *)list->data, NM_PROFILE_NAME_LEN_MAX);
+
+       *profile_names = p_profile_name;
+       *profile_cnt = count;
+
+out:
+       g_slist_free_full(profile_list, g_free);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+static int __find_matching_profile(char *profile_name, nm_profile_name_s *profile_list, int profile_cnt)
+{
+       gchar *connman_profile_name = NULL;
+       gchar *telephony_profile_name = NULL;
+       gchar *str_ptr = NULL;
+       int i = 0;
+
+       NM_LOGI("search connman profile name[%s] from %d list",
+                       profile_name, profile_cnt);
+       connman_profile_name = strrchr(profile_name, '/') + 1;
+       for (i = 0; i < profile_cnt; i++) {
+               telephony_profile_name = strrchr(profile_list[i].profile_name, '/') + 1;
+               str_ptr = strstr(connman_profile_name, telephony_profile_name);
+
+               if (str_ptr != NULL && g_strcmp0(str_ptr, telephony_profile_name) == 0) {
+
+                       NM_LOGI("PDP profile name found in cellular profile: %s, %d",
+                                       telephony_profile_name, i);
+                       break;
+               } else {
+                       NM_LOGI("[%s] not matched", telephony_profile_name);
+               }
+       }
+
+       return i;
+}
+
+static int __search_pdp_profile(char* profile_name, nm_telephony_profile_s *profile_info)
+{
+
+       int ret = 0;
+       nm_profile_name_s *profile_list = NULL;
+       int profile_cnt = 0;
+       int idx = 0;
+
+       __NM_FUNC_ENTER__;
+
+       /* Get pdp profile list from telephony service */
+       ret = __get_profile_names(&profile_list, &profile_cnt);
+       if (ret < 0) {
+               NM_LOGI("Failed to get profile list from telephony service");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (profile_list == NULL || profile_cnt <= 0) {
+               NM_LOGI("There is no PDP profiles");
+               g_free(profile_list);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       /* Find matching profile */
+       idx = __find_matching_profile(profile_name, profile_list, profile_cnt);
+       if (idx >= profile_cnt) {
+               NM_LOGI("There is no matching PDP profiles");
+               ret = -1;;
+       } else {
+               g_strlcpy(profile_info->profile_name,
+                               profile_list[idx].profile_name, NM_PROFILE_NAME_LEN_MAX);
+       }
+
+       g_free(profile_list);
+
+       __NM_FUNC_EXIT__;
+       return ret;
+}
+
+static inline void __get_path(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       if (value != NULL)
+               g_strlcpy(profile_info->profile_name, value, NM_PROFILE_NAME_LEN_MAX);
+}
+
+static inline void __get_svc_ctg_id(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       net_service_type_e service_type = NET_SERVICE_UNKNOWN;
+
+       if (value != NULL)
+               service_type = atoi(value);
+
+       if (service_type > NET_SERVICE_UNKNOWN)
+               profile_info->service_type = service_type;
+}
+
+static inline void __get_apn(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       if (value != NULL)
+               g_strlcpy(profile_info->apn, value, NM_PDP_APN_LEN_MAX);
+}
+
+static inline void __get_pdp_protocol(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       net_pdn_type_e pdn_type = NET_PDN_TYPE_UNKNOWN;
+
+       if (value != NULL)
+               pdn_type = atoi(value);
+
+       if (pdn_type == NET_PDN_TYPE_IPV4)
+               profile_info->pdn_type = NET_PDN_TYPE_IPV4;
+       else if (pdn_type == NET_PDN_TYPE_IPV6)
+               profile_info->pdn_type = NET_PDN_TYPE_IPV6;
+       else if (pdn_type == NET_PDN_TYPE_IPV4_IPV6)
+               profile_info->pdn_type = NET_PDN_TYPE_IPV4_IPV6;
+}
+
+static inline void __get_auth_type(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       net_auth_type_e auth_type = NET_PDP_AUTH_NONE;
+
+       if (value != NULL)
+               auth_type = atoi(value);
+
+       if (auth_type == NET_PDP_AUTH_PAP)
+               profile_info->auth_info.auth_type = NET_PDP_AUTH_PAP;
+       else if (auth_type == NET_PDP_AUTH_CHAP)
+               profile_info->auth_info.auth_type = NET_PDP_AUTH_CHAP;
+}
+
+static inline void __get_user_name(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       if (value != NULL)
+               g_strlcpy(profile_info->auth_info.user_name, value, NM_PDP_AUTH_USERNAME_LEN_MAX);
+
+}
+
+static inline void __get_password(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       if (value != NULL)
+               g_strlcpy(profile_info->auth_info.password, value, NM_PDP_AUTH_PASSWORD_LEN_MAX);
+}
+
+static inline void __get_proxy_addr(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       if (value != NULL)
+               g_strlcpy(profile_info->proxy_addr, value, NET_PROXY_LEN_MAX);
+}
+
+static inline void __get_home_url(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       if (value != NULL)
+               g_strlcpy(profile_info->home_url, value, NM_HOME_URL_LEN_MAX);
+}
+
+static inline void __get_default_conn(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       if (value == NULL)
+               return;
+
+       if (g_strcmp0(value, "TRUE") == 0)
+               profile_info->default_conn = TRUE;
+       else
+               profile_info->default_conn = FALSE;
+}
+
+static inline void __get_keyword(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       if (value != NULL)
+               g_strlcpy(profile_info->keyword, value, NM_PDP_APN_LEN_MAX);
+}
+
+static inline void __get_editable(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       if (value == NULL)
+               return;
+
+       if (g_strcmp0(value, "TRUE") == 0)
+               profile_info->editable = TRUE;
+       else
+               profile_info->editable = FALSE;
+
+       return;
+}
+
+static inline void __get_hidden(const gchar *value, nm_telephony_profile_s *profile_info)
+{
+       if (value == NULL)
+               return;
+
+       if (g_strcmp0(value, "TRUE") == 0)
+               profile_info->hidden = TRUE;
+       else
+               profile_info->hidden = FALSE;
+
+       return;
+}
+
+static void __get_profile_properties(GVariant *reply, gpointer user_data)
+{
+       GVariantIter *iter;
+       nm_telephony_profile_s *profile_info = NULL;
+       const gchar *key = NULL;
+       const gchar *value = NULL;
+
+       if (!reply || ! user_data)
+               return;
+
+       profile_info = (nm_telephony_profile_s *)user_data;
+
+       g_variant_get(reply, "(a{ss})", &iter);
+       while (g_variant_iter_loop(iter, "{ss}", &key, &value)) {
+               if (g_strcmp0(key, "path") == 0)
+                       __get_path(value, profile_info);
+               else if (g_strcmp0(key, "svc_ctg_id") == 0)
+                       __get_svc_ctg_id(value, profile_info);
+               else if (g_strcmp0(key, "apn") == 0)
+                       __get_apn(value, profile_info);
+               else if (g_strcmp0(key, "pdp_protocol") == 0)
+                       __get_pdp_protocol(value, profile_info);
+               else if (g_strcmp0(key, "roam_pdp_protocol") == 0)
+                       __get_auth_type(value, profile_info);
+               else if (g_strcmp0(key, "auth_type") == 0)
+                       __get_auth_type(value, profile_info);
+               else if (g_strcmp0(key, "auth_id") == 0)
+                       __get_user_name(value, profile_info);
+               else if (g_strcmp0(key, "auth_pwd") == 0)
+                       __get_password(value, profile_info);
+               else if (g_strcmp0(key, "proxy_addr") == 0)
+                       __get_proxy_addr(value, profile_info);
+               else if (g_strcmp0(key, "home_url") == 0)
+                       __get_home_url(value, profile_info);
+               else if (g_strcmp0(key, "default_internet_conn") == 0)
+                       __get_default_conn(value, profile_info);
+               else if (g_strcmp0(key, "profile_name") == 0)
+                       __get_keyword(value, profile_info);
+               else if (g_strcmp0(key, "editable") == 0)
+                       __get_editable(value, profile_info);
+               else if (g_strcmp0(key, "hidden") == 0)
+                       __get_hidden(value, profile_info);
+       }
+
+       g_variant_iter_free(iter);
+       return;
+}
+
+static int __get_profile_info(nm_telephony_profile_s *profile_info)
+{
+       int ret = 0;
+       __NM_FUNC_ENTER__;
+
+       if (profile_info == NULL) {
+               NM_LOGI("Invalid parameter!");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       tel_method_params[TELEPHONY_CMD_GET_PROFILE].object_path = profile_info->profile_name;
+       ret = nm_gdbus_method_call(
+                       &(tel_method_params[TELEPHONY_CMD_GET_PROFILE]),
+                       __get_profile_properties,
+                       (gpointer)profile_info);
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               NM_LOGI("Failed to get profile");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
+
+int nm_telephony_get_pdp_profile(gchar *path, nm_telephony_profile_s *profile_info)
+{
+       int ret = 0;
+       __NM_FUNC_ENTER__;
+
+       ret = __search_pdp_profile(path, profile_info);
+       if (ret < 0 || strlen(profile_info->profile_name) <= 0)
+               return -1;
+
+       /* Get profile info from telephony service */
+       ret = __get_profile_info(profile_info);
+       if (ret < 0)
+               return -1;
+
+       __NM_FUNC_EXIT__;
+       return 0;
+}
diff --git a/src/inm-util.c b/src/inm-util.c
new file mode 100644 (file)
index 0000000..bf8750d
--- /dev/null
@@ -0,0 +1,294 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements utility functions used by network monitoring daemon.
+ *
+ * @file        nm-util.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <signal.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <net/if.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "inm-util.h"
+#include "inm-daemon-log.h"
+
+int nm_execute_file(const char *file_path,
+               char *const args[], char *const envs[])
+{
+       pid_t pid = 0;
+       int status = 0;
+       int rv = 0;
+       errno = 0;
+       register unsigned int index = 0;
+       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+
+       __NM_FUNC_ENTER__;
+
+       while (args[index] != NULL) {
+               NM_LOGI("%s", args[index]);
+               index++;
+       }
+
+       if (!(pid = fork())) {
+               NM_LOGI("pid(%d), ppid (%d)", getpid(), getppid());
+               NM_LOGI("Inside child, exec (%s) command", file_path);
+
+               errno = 0;
+               if (execve(file_path, args, envs) == -1) {
+                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+                       NM_LOGI("Fail to execute command (%s)", error_buf);
+                       exit(1);
+               }
+       } else if (pid > 0) {
+               if (waitpid(pid, &status, 0) == -1)
+                       NM_LOGI("wait pid (%u) status (%d)", pid, status);
+
+               if (WIFEXITED(status)) {
+                       rv = WEXITSTATUS(status);
+                       NM_LOGI("exited, status=%d", rv);
+               } else if (WIFSIGNALED(status)) {
+                       NM_LOGI("killed by signal %d", WTERMSIG(status));
+               } else if (WIFSTOPPED(status)) {
+                       NM_LOGI("stopped by signal %d", WSTOPSIG(status));
+               } else if (WIFCONTINUED(status)) {
+                       NM_LOGI("continued");
+               }
+
+               __NM_FUNC_EXIT__;
+               return rv;
+       }
+
+       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+       NM_LOGI("failed to fork(%s)", error_buf);
+       __NM_FUNC_EXIT__;
+       return -EIO;
+}
+
+static void __no_wait_signal_handler()
+{
+       pid_t child_pid = 0;
+       int state = 0;
+
+       child_pid = waitpid(-1, &state, WNOHANG);
+
+       NM_LOGI("child_id(%d) state(%d)", child_pid, WEXITSTATUS(state));
+}
+
+int nm_execute_file_no_wait(const char *file_path, char *const args[])
+{
+       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+       pid_t pid = 0;
+       int rv = 0;
+       errno = 0;
+       register unsigned int index = 0;
+
+       struct sigaction act;
+       int state = 0;
+
+       __NM_FUNC_ENTER__;
+
+       act.sa_handler = __no_wait_signal_handler;
+       sigemptyset(&act.sa_mask);
+       act.sa_flags = 0;
+
+       state = sigaction(SIGCHLD, &act, 0);
+       if (state != 0) {
+               NM_LOGI("sigaction() : %d");
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       while (args[index] != NULL) {
+               NM_LOGI("%s", args[index]);
+               index++;
+       }
+
+       if (!(pid = fork())) {
+               NM_LOGI("pid(%d), ppid (%d)", getpid(), getppid());
+               NM_LOGI("Inside child, exec (%s) command", file_path);
+
+               errno = 0;
+               if (execvp(file_path, args) == -1) {
+                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+                       NM_LOGI("Fail to execute command (%s)", error_buf);
+                       __NM_FUNC_EXIT__;
+                       return -1;
+               }
+       } else if (pid > 0) {
+               NM_LOGI("Successfully launched child process");
+               __NM_FUNC_EXIT__;
+               return rv;
+       }
+
+       __NM_FUNC_EXIT__;
+       return -EIO;
+}
+
+void get_current_time(gchar *time_str)
+{
+       struct timeval mytime;
+       struct tm stTempTime;
+
+       if (!time_str)
+               return;
+
+
+       struct tm {
+               int tm_sec; // Seconds
+               int tm_min; // Minutes
+               int tm_hour; // Hour (0--23)
+               int tm_mday; // Day of month (1--31)
+               int tm_mon; // Month (0--11)
+               int tm_year; // Year (calendar year minus 1900)
+               int tm_wday; // Weekday (0--6; Sunday = 0)
+               int tm_yday; // Day of year (0--365)
+               int tm_isdst; // 0 if daylight savings time is not in effect)
+       };
+
+       gettimeofday(&mytime, NULL);
+       localtime_r(&mytime.tv_sec, &stTempTime);
+       g_snprintf(time_str, TIME_STR_LEN, "%04d.%02d.%02d-%02d_%02d_%02d",
+                       stTempTime.tm_year + 1900, stTempTime.tm_mon + 1, stTempTime.tm_mday,
+                       stTempTime.tm_hour, stTempTime.tm_min, stTempTime.tm_sec);
+       time_str[TIME_STR_LEN - 1] = '\0';
+
+       return;
+}
+
+int nm_check_cable_status(const char *file_path, int *status)
+{
+       int ret = 0;
+       int carrier = 0;
+       FILE *fd = NULL;
+       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0,};
+
+       __NM_FUNC_ENTER__;
+       ret = access(file_path, F_OK);
+       if (ret < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               NM_LOGI("Could not access %s [%s]", file_path, error_buf);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       fd = fopen(file_path, "r");
+       if (fd == NULL) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               NM_LOGI("Could not open %s [%s]", file_path, error_buf);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       ret = fscanf(fd, "%d", &carrier);
+       if (ret < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               NM_LOGI("Could not scan [%s]", error_buf);
+               fclose(fd);
+               __NM_FUNC_EXIT__;
+               return -1;
+       }
+
+       NM_LOGI("carrier state is [%d]", carrier);
+       *status = carrier;
+       fclose(fd);
+       __NM_FUNC_EXIT__;
+       return 0;
+
+}
+
+int nmdaemon_get_interface_index(const char *interface_name)
+{
+       struct ifreq ifr;
+       int sock = 0;
+       int result = 0;
+       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+
+       if (interface_name == NULL) {
+               NM_LOGE("Inteface name is NULL");
+               return -1;
+       }
+
+       errno = 0;
+       sock = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+       if (sock < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               NM_LOGE("Failed to create socket : %s", error_buf);
+               return -1;
+       }
+
+       memset(&ifr, 0, sizeof(ifr));
+       strncpy(ifr.ifr_name, interface_name, sizeof(ifr.ifr_name) - 1);
+       result = ioctl(sock, SIOCGIFINDEX, &ifr);
+       close(sock);
+
+       if (result < 0) {
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
+               NM_LOGE("Failed to get ifr index: %s", error_buf);
+               return -1;
+       }
+
+       return ifr.ifr_ifindex;
+}
+
+void nmdaemon_convert_byte_to_string(char *bssid, unsigned char *user_data)
+{
+       int i;
+
+       for (i = 0; i < MAC_ADDR_LEN; i++) {
+               if (i == 0) {
+                       snprintf(bssid, 3, "%02x", user_data[i]);
+                       bssid += 2;
+               } else {
+                       snprintf(bssid, 4, ":%02x", user_data[i]);
+                       bssid += 3;
+               }
+       }
+}
+
+gchar* nm_util_get_default_proxy()
+{
+       char *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
+       gchar *ret = NULL;
+
+       if (proxy) {
+               ret = g_strdup(proxy);
+               free(proxy);
+       }
+       return ret;
+}
diff --git a/src/inm-wfd-manager.c b/src/inm-wfd-manager.c
new file mode 100644 (file)
index 0000000..ae21168
--- /dev/null
@@ -0,0 +1,1068 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements functions for handling signal from Wi-Fi Direct manager.
+ *
+ * @file        nm-wfd-manager.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+
+#include "inm-daemon-log.h"
+#include "inm-gdbus.h"
+#include "inm-wfd-manager.h"
+
+#define WFD_EVENT_CONNECTION_RSP 3
+
+#define DEVICE_NAME_LEN 32
+#define MAC_ADDR_LEN 6
+#define MAC_STR_LEN 18
+#define IP_ADDR_LEN 4
+
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+
+#define WFD_SIGNAL_ACTIVATION          "Activation"
+#define WFD_SIGNAL_DEACTIVATION                "Deactivation"
+#define WFD_SIGNAL_CREATED                     "Created"
+#define WFD_SIGNAL_DESTROYED           "Destroyed"
+#define WFD_SIGNAL_CONNECTION          "Connection"
+#define WFD_SIGNAL_PEERIPASSIGNED      "PeerIPAssigned"
+#define WFD_SIGNAL_DISCONNECTION       "Disconnection"
+
+#define WFD_METHOD_GET_GO_INTENT       "GetGoIntent"
+#define WFD_METHOD_GET_MAX_CLIENT      "GetMaxClient"
+#define WFD_METHOD_GET_REQ_WPS_MODE    "GetReqWpsMode"
+#define WFD_METHOD_GET_MAC_ADDR                "GetMacAddress"
+#define WFD_METHOD_GET_DEVICE_NAME     "GetDeviceName"
+
+#define WFD_METHOD_GET_IP_ADDR         "GetIPAddress"
+#define WFD_METHOD_GET_SUBNET_MASK     "GetSubnetMask"
+#define WFD_METHOD_GET_GATEWAY         "GetGateway"
+#define WFD_METHOD_GET_OP_CHANNEL      "GetOperatingChannel"
+#define WFD_METHOD_IS_GROUP_OWNER      "IsGroupOwner"
+#define WFD_METHOD_GET_CONNECTED       "GetConnectedPeers"
+
+typedef enum {
+       WFD_SIGNAL_NAME_OWENER_CHANGED,
+       WFD_MANAGE_SIGNAL_ACTIVATION,
+       WFD_MANAGE_SIGNAL_DEACTIVATION,
+       WFD_MANAGE_SIGNAL_GROUP_CREATED,
+       WFD_MANAGE_SIGNAL_GROUP_DESTROYED,
+       WFD_MANAGE_SIGNAL_CONNECTION,
+       WFD_MANAGE_SIGNAL_PEERIPASSIGNED,
+       WFD_MANAGE_SIGNAL_DISCONNECTION,
+       WFD_MANAGE_SIGNAL_MAX,
+} wfd_manager_signal_e;
+
+typedef struct {
+       gchar device_name[DEVICE_NAME_LEN + 1];
+       guchar mac_addr[MAC_ADDR_LEN];
+       guchar intf_addr[MAC_ADDR_LEN];
+       guchar ip_addr[IP_ADDR_LEN];
+} wfd_peer_s;
+
+typedef struct {
+       gboolean is_initialized;
+       gboolean activated;
+       guint device_role;
+       gint go_intent;
+       gint max_client;
+       gint op_channel;
+       gint req_wps_mode;
+       gchar device_name[DEVICE_NAME_LEN + 1];
+       guchar mac_addr[MAC_ADDR_LEN];
+
+       gchar group_iface_name[DEVICE_NAME_LEN + 1];
+       guchar ip_addr[IP_ADDR_LEN];
+       guchar subnet_mask[IP_ADDR_LEN];
+       guchar gateway_addr[IP_ADDR_LEN];
+
+       GHashTable *connected_peer;
+
+} wfd_manager_mon_s;
+
+wfd_manager_mon_s wfd_manager_mon;
+
+static void __name_owner_changed_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+static void __activation_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+static void __deactivation_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+static void __group_created_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+static void __group_destroyed_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+static void __connection_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+static void __peer_ip_assigned_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+static void __disconnection_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data);
+
+static signal_param_s signal_param[] = {
+               {
+                               .sender = DBUS_SERVICE_DBUS,
+                               .interface_name = DBUS_INTERFACE_DBUS,
+                               .member = DBUS_SIGNAL_NAME_CHANGED,
+                               .object_path = NULL,
+                               .arg0 = WFD_MANAGER_SERVICE,
+                               .callback = __name_owner_changed_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = WFD_MANAGER_SERVICE,
+                               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
+                               .member = WFD_SIGNAL_ACTIVATION,
+                               .object_path = WFD_MANAGER_PATH,
+                               .arg0 = NULL,
+                               .callback = __activation_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = WFD_MANAGER_SERVICE,
+                               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
+                               .member = WFD_SIGNAL_DEACTIVATION,
+                               .object_path = WFD_MANAGER_PATH,
+                               .arg0 = NULL,
+                               .callback = __deactivation_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = WFD_MANAGER_SERVICE,
+                               .interface_name = WFD_MANAGER_GROUP_INTERFACE,
+                               .member = WFD_SIGNAL_CREATED,
+                               .object_path = WFD_MANAGER_PATH,
+                               .arg0 = NULL,
+                               .callback = __group_created_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = WFD_MANAGER_SERVICE,
+                               .interface_name = WFD_MANAGER_GROUP_INTERFACE,
+                               .member = WFD_SIGNAL_DESTROYED,
+                               .object_path = WFD_MANAGER_PATH,
+                               .arg0 = NULL,
+                               .callback = __group_destroyed_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = WFD_MANAGER_SERVICE,
+                               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
+                               .member = WFD_SIGNAL_CONNECTION,
+                               .object_path = WFD_MANAGER_PATH,
+                               .arg0 = NULL,
+                               .callback = __connection_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = WFD_MANAGER_SERVICE,
+                               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
+                               .member = WFD_SIGNAL_PEERIPASSIGNED,
+                               .object_path = WFD_MANAGER_PATH,
+                               .arg0 = NULL,
+                               .callback = __peer_ip_assigned_cb,
+                               .subscriber_id  = 0,
+               },
+               {
+                               .sender = WFD_MANAGER_SERVICE,
+                               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
+                               .member = WFD_SIGNAL_DISCONNECTION,
+                               .object_path = WFD_MANAGER_PATH,
+                               .arg0 = NULL,
+                               .callback = __disconnection_cb,
+                               .subscriber_id  = 0,
+               },
+};
+
+static method_param_s get_manager_conf_param = {
+               .bus_name = WFD_MANAGER_SERVICE,
+               .object_path = WFD_MANAGER_PATH,
+               .interface_name = WFD_MANAGER_CONFIG_INTERFACE,
+               .method_name = NULL,
+               .parameters = NULL,
+};
+
+static method_param_s get_manager_group_param = {
+               .bus_name = WFD_MANAGER_SERVICE,
+               .object_path = WFD_MANAGER_PATH,
+               .interface_name = WFD_MANAGER_GROUP_INTERFACE,
+               .method_name = NULL,
+               .parameters = NULL,
+};
+
+static method_param_s get_manager_manage_param = {
+               .bus_name = WFD_MANAGER_SERVICE,
+               .object_path = WFD_MANAGER_PATH,
+               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
+               .method_name = NULL,
+               .parameters = NULL,
+};
+
+static gint __txt_to_mac(const gchar *txt, guchar *mac)
+{
+       int i = 0;
+
+       if (!txt || !mac) {
+               NM_LOGI("Invalid parameter");
+               return -1;
+       }
+
+       for (;;) {
+               mac[i++] = (char) strtoul((char *)txt, (char **)&txt, 16);
+               if (!*txt++ || i == 6)
+                       break;
+       }
+
+       if (i != MAC_ADDR_LEN)
+               return -1;
+
+       return 0;
+}
+
+static gint __txt_to_ip(const gchar *txt, guchar *ip)
+{
+       int i = 0;
+
+       for (;;) {
+               ip[i++] = (char) strtoul((char *)txt, (char **)&txt, 10);
+               if (i == IP_ADDR_LEN || !*txt++)
+                       break;
+       }
+
+       if (i != IP_ADDR_LEN)
+               return -1;
+
+       return 0;
+}
+
+static gboolean __unpack_ays(unsigned char *dst, GVariant *src, int size)
+{
+       GVariantIter *iter = NULL;
+       int length = 0;
+       int res = FALSE;
+
+       if (!dst || !src || size == 0) {
+               NM_LOGI("Invalid parameter");
+               return FALSE;
+       }
+
+       g_variant_get(src, "ay", &iter);
+       if (iter == NULL) {
+               NM_LOGI("failed to get iterator");
+               return FALSE;
+       }
+
+       while (g_variant_iter_loop(iter, "y", &dst[length])) {
+               length++;
+               if (length >= size)
+                       break;
+       }
+       g_variant_iter_free(iter);
+
+       return res;
+}
+
+static void __name_owner_changed_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       gchar *name = NULL;
+       gchar *old = NULL;
+       gchar *new = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (parameters == NULL)
+               return;
+
+       g_variant_get(parameters, "(&s&s&s)", &name, &old, &new);
+
+       if (g_strcmp0(name, WFD_MANAGER_SERVICE) == 0 && *new == '\0')
+               NM_LOGI("wfd-manager destroyed: name %s, old %s, new %s", name, old, new);
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __get_go_intent(GVariant *value, gpointer user_data)
+{
+       gint ret = 0;
+
+       if (!value || !user_data)
+               return;
+
+       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
+
+       g_variant_get(value, "(ii)", &ret, &(manager->go_intent));
+
+       return;
+}
+
+static inline void __get_wfd_manager_go_intent()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+
+       get_manager_conf_param.method_name = WFD_METHOD_GET_GO_INTENT;
+
+       ret = nm_gdbus_method_call(&get_manager_conf_param,
+                       __get_go_intent,
+                       (gpointer)&wfd_manager_mon);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get go intent failure");
+
+       return;
+}
+
+static void __get_max_client(GVariant *value, gpointer user_data)
+{
+       gint ret = 0;
+
+       if (!value || !user_data)
+               return;
+
+       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
+
+       g_variant_get(value, "(ii)", &ret, &(manager->max_client));
+
+       return;
+}
+
+static inline void __get_wfd_manager_max_client()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+
+       get_manager_conf_param.method_name = WFD_METHOD_GET_MAX_CLIENT;
+
+       ret = nm_gdbus_method_call(&get_manager_conf_param,
+                       __get_max_client,
+                       (gpointer)&wfd_manager_mon);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get max_client failure");
+
+       return;
+}
+
+static void __get_req_wps_mode(GVariant *value, gpointer user_data)
+{
+       gint ret = 0;
+
+       if (!value || !user_data)
+               return;
+
+       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
+
+       g_variant_get(value, "(ii)", &ret, &(manager->req_wps_mode));
+
+       return;
+}
+
+static inline void __get_wfd_manager_req_wps_mode()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+
+       get_manager_conf_param.method_name = WFD_METHOD_GET_REQ_WPS_MODE;
+
+       ret = nm_gdbus_method_call(&get_manager_conf_param,
+                       __get_req_wps_mode,
+                       (gpointer)&wfd_manager_mon);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get requested wps mode failure");
+
+       return;
+}
+
+static void __get_device_name(GVariant *value, gpointer user_data)
+{
+       gint ret = 0;
+       const gchar *str;
+
+       if (!value || !user_data)
+               return;
+
+       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
+
+       g_variant_get(value, "(i&s)", &ret, &str);
+
+       g_strlcpy(manager->device_name, str, DEVICE_NAME_LEN + 1);
+
+       return;
+}
+
+static inline void __get_wfd_manager_device_name()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+
+       get_manager_conf_param.method_name = WFD_METHOD_GET_DEVICE_NAME;
+
+       ret = nm_gdbus_method_call(&get_manager_conf_param,
+                       __get_device_name,
+                       (gpointer)&wfd_manager_mon);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get mac address failure");
+
+       return;
+}
+
+static void __get_mac_addr(GVariant *value, gpointer user_data)
+{
+       gint ret = 0;
+       const gchar *str;
+
+       if (!value || !user_data)
+               return;
+
+       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
+
+       g_variant_get(value, "(i&s)", &ret, &str);
+
+       __txt_to_mac(str, manager->mac_addr);
+
+       return;
+}
+
+static inline void __get_wfd_manager_mac_addr()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+
+       get_manager_conf_param.method_name = WFD_METHOD_GET_MAC_ADDR;
+
+       ret = nm_gdbus_method_call(&get_manager_conf_param,
+                       __get_mac_addr,
+                       (gpointer)&wfd_manager_mon);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get mac address failure");
+
+       return;
+}
+
+
+static void __get_op_channel(GVariant *value, gpointer user_data)
+{
+       gint ret = 0;
+
+       if (!value || !user_data)
+               return;
+
+       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
+
+       g_variant_get(value, "(ii)", &ret, &(manager->op_channel));
+
+       return;
+}
+
+static inline void __get_wfd_manager_op_channel()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+
+       get_manager_conf_param.method_name = WFD_METHOD_GET_OP_CHANNEL;
+
+       ret = nm_gdbus_method_call(&get_manager_conf_param,
+                       __get_op_channel,
+                       (gpointer)&wfd_manager_mon);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get op channel failure");
+
+       return;
+}
+
+static void __get_ip_addr(GVariant *value, gpointer user_data)
+{
+       gint ret = 0;
+       const gchar *str;
+
+       if (!value || !user_data)
+               return;
+
+       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
+
+       g_variant_get(value, "(i&s)", &ret, &str);
+
+       __txt_to_ip(str, manager->ip_addr);
+
+       return;
+}
+
+static inline void __get_wfd_manager_ip_addr()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+
+       get_manager_conf_param.method_name = WFD_METHOD_GET_IP_ADDR;
+
+       ret = nm_gdbus_method_call(&get_manager_conf_param,
+                       __get_ip_addr,
+                       (gpointer)&wfd_manager_mon);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get mac address failure");
+
+       return;
+}
+
+static void __get_subnet_mask(GVariant *value, gpointer user_data)
+{
+       gint ret = 0;
+       const gchar *str;
+
+       if (!value || !user_data)
+               return;
+
+       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
+
+       g_variant_get(value, "(i&s)", &ret, &str);
+
+       __txt_to_ip(str, manager->subnet_mask);
+
+       return;
+}
+
+static inline void __get_wfd_manager_subnet_mask()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+
+       get_manager_conf_param.method_name = WFD_METHOD_GET_SUBNET_MASK;
+
+       ret = nm_gdbus_method_call(&get_manager_conf_param,
+                       __get_subnet_mask,
+                       (gpointer)&wfd_manager_mon);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get mac address failure");
+
+       return;
+}
+
+static void __get_gateway(GVariant *value, gpointer user_data)
+{
+       gint ret = 0;
+       const gchar *str;
+
+       if (!value || !user_data)
+               return;
+
+       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
+
+       g_variant_get(value, "(i&s)", &ret, &str);
+
+       __txt_to_ip(str, manager->gateway_addr);
+
+       return;
+}
+
+static inline void __get_wfd_manager_gateway()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+
+       get_manager_conf_param.method_name = WFD_METHOD_GET_GATEWAY;
+
+       ret = nm_gdbus_method_call(&get_manager_conf_param,
+                       __get_gateway,
+                       (gpointer)&wfd_manager_mon);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get gateway address failure");
+
+       return;
+}
+
+static inline void __get_wfd_manager_group_info()
+{
+       __get_wfd_manager_ip_addr();
+       __get_wfd_manager_subnet_mask();
+       __get_wfd_manager_gateway();
+       __get_wfd_manager_op_channel();
+}
+
+static inline void __reset_wfd_manager_group_info()
+{
+       wfd_manager_mon.device_role = NM_WFD_DEVICE_NONE;
+       memset(wfd_manager_mon.ip_addr, 0x00, IP_ADDR_LEN);
+       memset(wfd_manager_mon.gateway_addr, 0x00, IP_ADDR_LEN);
+       memset(wfd_manager_mon.subnet_mask, 0x00, IP_ADDR_LEN);
+       wfd_manager_mon.op_channel = 0;
+}
+
+static inline void __clear_wfd_manager_info()
+{
+       if(wfd_manager_mon.connected_peer) {
+               g_hash_table_remove_all(wfd_manager_mon.connected_peer);
+               g_hash_table_unref(wfd_manager_mon.connected_peer);
+               wfd_manager_mon.connected_peer = NULL;
+       }
+
+       __reset_wfd_manager_group_info();
+
+       wfd_manager_mon.activated = FALSE;
+       memset(wfd_manager_mon.ip_addr, 0x00, IP_ADDR_LEN);
+       memset(wfd_manager_mon.gateway_addr, 0x00, IP_ADDR_LEN);
+       memset(wfd_manager_mon.subnet_mask, 0x00, IP_ADDR_LEN);
+       wfd_manager_mon.op_channel = 0;
+}
+
+static void __activation_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       wfd_manager_mon.activated = TRUE;
+       __get_wfd_manager_go_intent();
+       __get_wfd_manager_max_client();
+       __get_wfd_manager_req_wps_mode();
+       __get_wfd_manager_mac_addr();
+       __get_wfd_manager_device_name();
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __deactivation_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       __clear_wfd_manager_info();
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __group_created_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       wfd_manager_mon.device_role = NM_WFD_DEVICE_GO;
+       __get_wfd_manager_group_info();
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __group_destroyed_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       if(wfd_manager_mon.connected_peer) {
+               g_hash_table_remove_all(wfd_manager_mon.connected_peer);
+               g_hash_table_unref(wfd_manager_mon.connected_peer);
+               wfd_manager_mon.connected_peer = NULL;
+       }
+
+       __reset_wfd_manager_group_info();
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static void __is_group_owner(GVariant *value, gpointer user_data)
+{
+       gboolean is_group_owner;
+
+       if (!value || !user_data)
+               return;
+
+       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
+
+       g_variant_get(value, "(b)", &is_group_owner);
+       if (is_group_owner)
+               manager->device_role = NM_WFD_DEVICE_GO;
+       else
+               manager->device_role = NM_WFD_DEVICE_GC;
+
+       return;
+}
+
+static inline void __is_wfd_manager_group_owner()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+
+       get_manager_group_param.method_name = WFD_METHOD_IS_GROUP_OWNER;
+
+       ret = nm_gdbus_method_call(&get_manager_group_param,
+                       __is_group_owner,
+                       (gpointer)&wfd_manager_mon);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get device role failure");
+
+       return;
+}
+
+static inline void __get_peer_info(GVariantIter *iter, wfd_manager_mon_s *manager)
+{
+       GVariant *var = NULL;
+       gchar *key = NULL;
+       wfd_peer_s *peer;
+       __NM_FUNC_ENTER__;
+
+       gchar hash_key[MAC_STR_LEN] = {0, };
+
+       if (!iter) {
+               __NM_FUNC_ENTER__;
+               return;
+       }
+
+       peer = g_try_malloc0(sizeof(wfd_peer_s));
+       if (!peer) {
+               __NM_FUNC_ENTER__;
+               return;
+       }
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+               if (!g_strcmp0(key, "DeviceName")) {
+                       const char *str = NULL;
+                       g_variant_get(var, "&s", &str);
+                       g_strlcpy(peer->device_name, str, DEVICE_NAME_LEN);
+               } else if (!g_strcmp0(key, "DeviceAddress")) {
+                       __unpack_ays(peer->mac_addr, var, MAC_ADDR_LEN);
+               } else if (!g_strcmp0(key, "InterfaceAddress")) {
+                       __unpack_ays(peer->intf_addr, var, MAC_ADDR_LEN);
+               } else if (!g_strcmp0(key, "IPAddress")) {
+                       __unpack_ays(peer->ip_addr, var, IP_ADDR_LEN);
+               } else {
+                       ;/* Do Nothing */
+               }
+       }
+       g_snprintf(hash_key, MAC_STR_LEN, MACSTR, MAC2STR(peer->mac_addr));
+       g_hash_table_replace(manager->connected_peer, g_strdup(hash_key), peer);
+       NM_LOGI("Peer %s is added", hash_key);
+
+       return;
+}
+
+static void __get_connected_peers(GVariant *value, gpointer user_data)
+{
+       GVariantIter *iter_peers = NULL;
+       GVariantIter *iter_peer = NULL;
+       gint ret = 0;
+       __NM_FUNC_ENTER__;
+
+       if (!value) {
+               __NM_FUNC_ENTER__;
+               return;
+       }
+
+       g_variant_get(value, "(iaa{sv})", &ret, &iter_peers);
+       if (ret != 0) {
+               __NM_FUNC_ENTER__;
+               return;
+       }
+
+       while (g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
+               if (!wfd_manager_mon.connected_peer) {
+                       NM_LOGI("Create hash table for peers");
+                       wfd_manager_mon.connected_peer = g_hash_table_new_full(g_str_hash,
+                                       g_str_equal,
+                                       g_free,
+                                       g_free);
+               }
+
+               __get_peer_info(iter_peer, &wfd_manager_mon);
+       }
+
+
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+static inline void __get_wfd_manager_connected_peers()
+{
+       int ret = NM_GDBUS_ERROR_NONE;
+
+       get_manager_manage_param.method_name = WFD_METHOD_GET_CONNECTED;
+
+       ret = nm_gdbus_method_call(&get_manager_manage_param,
+                       __get_connected_peers,
+                       (gpointer)&wfd_manager_mon);
+       if (ret != NM_GDBUS_ERROR_NONE)
+               NM_LOGI("get connected failure");
+
+       return;
+}
+
+static inline gboolean __is_connected(GVariant *parameters)
+{
+       gint error_code;
+       gint connection_state;
+       gchar *peer_mac_address;
+
+       g_variant_get(parameters, "(ii&s)",
+                       &error_code, &connection_state, &peer_mac_address);
+
+       return error_code == 0 &&
+                       connection_state == WFD_EVENT_CONNECTION_RSP &&
+                       peer_mac_address;
+
+}
+
+static void __connection_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       __NM_FUNC_ENTER__;
+
+       if (!__is_connected(parameters)) {
+               __NM_FUNC_ENTER__;
+               return;
+       }
+
+       __get_wfd_manager_group_info();
+       __is_wfd_manager_group_owner();
+       __get_wfd_manager_connected_peers();
+
+       __NM_FUNC_EXIT__;
+       return;
+
+}
+
+static void __peer_ip_assigned_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       wfd_peer_s *peer;
+       gchar *peer_mac = NULL;
+       gchar *peer_ip = NULL;
+       __NM_FUNC_ENTER__;
+
+       if (!wfd_manager_mon.connected_peer) {
+               NM_LOGI("Wired, there's no connected");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       g_variant_get(parameters, "(&s&s)", &peer_mac, &peer_ip);
+       if (!peer_mac || !peer_ip) {
+               NM_LOGI("Invalied parameters");
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       peer = g_hash_table_lookup(wfd_manager_mon.connected_peer, peer_mac);
+       if (!peer) {
+               NM_LOGI("Peer %s not matched", peer_mac);
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       __txt_to_ip(peer_ip, peer->ip_addr);
+       __NM_FUNC_EXIT__;
+
+}
+
+static void __disconnection_cb(
+               const gchar *sender_name,
+        const gchar *object_path,
+        const gchar *interface_name,
+        const gchar *signal_name,
+        GVariant *parameters,
+        gpointer user_data)
+{
+       gint ret = 0;
+       gint state = 0;
+       gchar *peer_mac = NULL;
+       __NM_FUNC_ENTER__;
+
+       g_variant_get(parameters, "(ii&s)", &ret, &state, &peer_mac);
+       if(!g_hash_table_remove(wfd_manager_mon.connected_peer, peer_mac)) {
+               NM_LOGI("there's no peer [%s]", peer_mac);
+               __NM_FUNC_EXIT__;
+               return;
+       }
+
+       __is_wfd_manager_group_owner();
+       if (wfd_manager_mon.device_role != NM_WFD_DEVICE_GO) {
+
+               if (wfd_manager_mon.connected_peer) {
+                       g_hash_table_remove_all(wfd_manager_mon.connected_peer);
+                       g_hash_table_unref(wfd_manager_mon.connected_peer);
+                       wfd_manager_mon.connected_peer = NULL;
+               }
+               __reset_wfd_manager_group_info();
+       }
+       __NM_FUNC_EXIT__;
+       return;
+}
+
+int nm_wfd_manager_init()
+{
+       int ret = NM_WFD_ERROR_NONE;
+       __NM_FUNC_ENTER__;
+
+       memset(&wfd_manager_mon, 0x00, sizeof(wfd_manager_mon));
+       wfd_manager_mon.is_initialized = TRUE;
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_SIGNAL_NAME_OWENER_CHANGED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_ACTIVATION]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_DEACTIVATION]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_GROUP_CREATED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_GROUP_DESTROYED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_CONNECTION]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_PEERIPASSIGNED]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_DISCONNECTION]));
+       if (ret != NM_GDBUS_ERROR_NONE) {
+               __NM_FUNC_EXIT__;
+               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
+       }
+
+       __NM_FUNC_EXIT__;
+       return NM_WFD_ERROR_NONE;
+}
+
+int nm_wfd_manager_deinit()
+{
+       __NM_FUNC_ENTER__;
+
+       if (!wfd_manager_mon.is_initialized) {
+               __NM_FUNC_EXIT__;
+               return NM_WFD_ERROR_NOT_INITIALIZED;
+       }
+       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_SIGNAL_NAME_OWENER_CHANGED]));
+       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_ACTIVATION]));
+       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_DEACTIVATION]));
+       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_GROUP_CREATED]));
+       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_GROUP_DESTROYED]));
+       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_CONNECTION]));
+       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_PEERIPASSIGNED]));
+       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_DISCONNECTION]));
+
+       __clear_wfd_manager_info();
+
+       __NM_FUNC_EXIT__;
+       return NM_WFD_ERROR_NONE;
+}
+
diff --git a/src/inm-wfdmanager.c b/src/inm-wfdmanager.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/nm-apagent.c b/src/nm-apagent.c
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/src/nm-congestion-mon.c b/src/nm-congestion-mon.c
deleted file mode 100644 (file)
index 1d509bf..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for monitoring congestion in network.
- *
- * @file        nm-congestion-mon.c
- * @author      Niraj Kumar Goit (niraj.g@samsung.com)
- * @version     0.1
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include "nm-daemon-log.h"
-#include "nm-iface-mon.h"
-#include "nm-util.h"
-
-#define NETWORK_CONGESTION_MON         "/proc/net/snmp"
-#define NETWORK_CONG_MON_INTERVAL      10*1000
-
-typedef struct {
-       gboolean is_initialized;
-       GHashTable *monitoring_cbs;
-} congestion_mon_s;
-
-typedef struct {
-       guint timer_source_id;
-       nm_congestion_mon_callback cb;
-       gpointer cb_user_data;
-}congestion_mon_data_s;
-
-congestion_mon_s cong_mon;
-static __thread congestion_mon_data_s *data = NULL;
-static __thread gboolean g_cong_mon_started;
-
-static void __destroy_cong_mon_data(gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       congestion_mon_data_s *mon_data = (congestion_mon_data_s *)user_data;
-
-       g_source_remove(mon_data->timer_source_id);
-       g_free(mon_data);
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static int __nm_check_congestion_status(int *status)
-{
-       double prev_transmit = -1;
-       double curr_transmit = -1;
-       double prev_retrans = -1;
-       double curr_retrans = -1;
-       double retrans_rate = 0 ;
-       int ret = 0;
-       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0,};
-       FILE * fd = NULL;
-
-       errno = 0;
-       ret = access(NETWORK_CONGESTION_MON, F_OK);
-       if (ret < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               NM_LOGE("Could not access %s, error:[%s]", NETWORK_CONGESTION_MON, error_buf);
-               return -1;
-       }
-       fd = fopen(NETWORK_CONGESTION_MON, "r" );
-       if (!fd) {
-               NM_LOGE("Failed to open file: [%s]", NETWORK_CONGESTION_MON);
-               return -1;
-       }
-
-       char *buffer;
-       size_t buf_size = 0;
-       int  i = 0;
-       while (getline(&buffer, &buf_size, fd) != -1) {
-               if (strstr(buffer, "Tcp"))
-                       i++;
-               if (i == 2) {
-                       int j = 0, u = 0;
-                       while (j < 10 && u < (int)buf_size) {
-                               if(buffer[u] == ' ') {
-                                       j++;
-                               }
-                               u++;
-                       }
-
-                       char *token1, *token2;
-                       token1 = strtok_r(buffer+u, " ", &token2);
-                       /** Transmitted data */
-                       strtok_r(token2, " ", &token1);
-                       double transmit = atof(token2);
-
-                       /** Retransmitted data */
-                       strtok_r(token1 , " ", &token2);
-                       double retransmit = atof(token1);
-
-                       if(prev_transmit == -1 || transmit < prev_transmit) {
-                               prev_transmit = transmit;
-                               curr_transmit = transmit;
-                       } else {
-                               prev_transmit = curr_transmit;
-                               curr_transmit = transmit;
-
-                       }
-
-                       if (prev_retrans == -1 || prev_retrans > retransmit) {
-                               curr_retrans = retransmit;
-                               prev_retrans = retransmit;
-                       } else {
-                               prev_retrans = curr_retrans;
-                               curr_retrans = retransmit ;
-                       }
-
-                       break;
-               }
-
-       }
-
-       fclose(fd);
-
-       double tcp_retrans_data =   curr_retrans - prev_retrans ;
-       double tcp_trans_data = curr_transmit - prev_transmit;
-
-       NM_LOGI("transmitted %lf retarnsmitted %lf after 10 seconds", tcp_trans_data, tcp_retrans_data);
-
-       if(tcp_retrans_data == 0 && tcp_trans_data == 0) {
-               NM_LOGI("Tcp data is not transmitted yet.");
-       } else if(tcp_trans_data == 0) {
-               retrans_rate = (curr_retrans/curr_transmit) * 100;
-       } else {
-               retrans_rate = (tcp_retrans_data/tcp_trans_data) * 100;
-       }
-
-       *status = retrans_rate;
-       return 0;
-}
-
-static gboolean __nm_cong_mon_status_callback(gpointer user_data)
-{
-       int status;
-
-       if (!g_cong_mon_started) {
-               NM_LOGE("congestion monitor is stopped");
-               return FALSE;
-       }
-
-       if (__nm_check_congestion_status(&status) < 0) {
-               __NM_FUNC_EXIT__;
-               return TRUE;
-       }
-       NM_LOGI("Network Congestion Status:[%d]", status);
-
-       if (data->cb)
-               data->cb(status, data->cb_user_data);
-
-       return TRUE;
-}
-
-static int __nm_attatch_cong_mon_file(congestion_mon_data_s *data)
-{
-       __NM_FUNC_ENTER__;
-
-       data->timer_source_id = g_timeout_add(NETWORK_CONG_MON_INTERVAL,
-                       __nm_cong_mon_status_callback, data);
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_congestion_monitor_start(nm_congestion_mon_callback cb, void *user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       if (!cong_mon.is_initialized) {
-               NM_LOGE("congestion monitor is not initialized");
-               __NM_FUNC_EXIT__;
-               return NM_CONG_MON_NOT_INITIALIZED;
-       }
-
-       if (g_cong_mon_started) {
-               NM_LOGE("congestion monitor is already started");
-               __NM_FUNC_EXIT__;
-               return NM_CONG_MON_ALREADY_STARTED;
-       }
-
-       if (!cb) {
-               NM_LOGE("Invalid parameter");
-               __NM_FUNC_EXIT__;
-               return NM_CONG_MON_INVALID_PARAMETER;
-       }
-
-       data = (congestion_mon_data_s*)g_try_malloc0(sizeof(congestion_mon_data_s));
-       if (!data) {
-               NM_LOGE("Failed to allocate memory");
-               __NM_FUNC_EXIT__;
-               return NM_CONG_MON_OPERATION_FAILED;
-       }
-
-       data->cb = cb;
-       data->cb_user_data = user_data;
-
-       if (__nm_attatch_cong_mon_file(data) < 0) {
-               NM_LOGE("Failed to attach congestion monitor file");
-               __NM_FUNC_EXIT__;
-               return NM_CONG_MON_OPERATION_FAILED;
-       }
-       g_cong_mon_started = TRUE;
-
-       __NM_FUNC_EXIT__;
-       return NM_CONG_MON_ERROR_NONE;
-}
-
-int nm_congestion_monitor_stop()
-{
-       int ret = NM_CONG_MON_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!cong_mon.is_initialized) {
-               NM_LOGE("congestion monitor is not initialized");
-               __NM_FUNC_EXIT__;
-               return NM_CONG_MON_NOT_INITIALIZED;
-       }
-       g_cong_mon_started = FALSE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_congestion_mon_init()
-{
-       int ret = NM_CONG_MON_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       memset(&cong_mon, 0x00, sizeof(cong_mon));
-       cong_mon.is_initialized = TRUE;
-
-       cong_mon.monitoring_cbs = g_hash_table_new_full(g_str_hash,
-                       g_str_equal,
-                       g_free,
-                       __destroy_cong_mon_data
-                       );
-
-       if (!cong_mon.monitoring_cbs) {
-               cong_mon.is_initialized = FALSE;
-               __NM_FUNC_EXIT__;
-               return NM_CONG_MON_OPERATION_FAILED;
-       }
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_congestion_mon_deinit()
-{
-       int ret = NM_CONG_MON_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!cong_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_CONG_MON_NOT_INITIALIZED;
-       }
-
-       cong_mon.is_initialized = FALSE;
-       g_hash_table_remove_all(cong_mon.monitoring_cbs);
-       g_hash_table_unref(cong_mon.monitoring_cbs);
-       cong_mon.monitoring_cbs = NULL;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-connman-internal.h b/src/nm-connman-internal.h
deleted file mode 100644 (file)
index 405ea80..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macro and declares functions for handling signal from connman.
- *
- * @file        nm-connman-internal.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#ifndef __NM_CONNMAN_INTERNAL_H__
-#define __NM_CONNMAN_INTERNAL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define CONNMAN_CLOCK_INTERFACE                        CONNMAN_SERVICE ".Clock"
-#define CONNMAN_ERROR_INTERFACE                        CONNMAN_SERVICE ".Error"
-#define CONNMAN_MANAGER_PATH                   "/"
-
-typedef enum {
-       /*
-        * If the device is in offline mode
-        */
-       MANAGER_STATE_OFFLINE,
-       /*
-        * If no service is in either "ready" or "online" state
-        */
-       MANAGER_STATE_IDLE,
-       /*
-        * If at least one service is in "ready" state and
-        *  no service is in "online" state
-        */
-       MANAGER_STATE_READY,
-       /*
-        *  When at least one service is in "online" state
-        */
-       MANAGER_STATE_ONLINE,
-} connman_manager_state_e;
-
-typedef enum {
-       /*
-        * IPV4 Address type
-        */
-       CONNMAN_ADDR_IPV4,
-       /*
-        * IPV6 Address type
-        */
-       CONNMAN_ADDR_IPV6,
-} connman_addr_type_e;
-
-typedef enum {
-       CONNMAN_SERVICE_STATE_UNKNOWN,
-       CONNMAN_SERVICE_STATE_IDLE,
-       CONNMAN_SERVICE_STATE_ASSOCIATION,
-       CONNMAN_SERVICE_STATE_CONFIGURATION,
-       CONNMAN_SERVICE_STATE_READY,
-       CONNMAN_SERVICE_STATE_ONLINE,
-       CONNMAN_SERVICE_STATE_DISCONNECT,
-       CONNMAN_SERVICE_STATE_FAILURE,
-
-} connman_service_state_e;
-
-typedef enum {
-       CONNMAN_SERVICE_SECURITY_UNKNOWN,
-       CONNMAN_SERVICE_SECURITY_NONE,
-       CONNMAN_SERVICE_SECURITY_WEP,
-       CONNMAN_SERVICE_SECURITY_PSK,
-       CONNMAN_SERVICE_SECURITY_8021X,
-       CONNMAN_SERVICE_SECURITY_WPA,
-       CONNMAN_SERVICE_SECURITY_RSN,
-} connman_service_security_e;
-
-typedef enum {
-       CONNMAN_IPCONFIG_METHOD_UNKNOWN,
-       CONNMAN_IPCONFIG_METHOD_OFF,
-       CONNMAN_IPCONFIG_METHOD_FIXED,
-       CONNMAN_IPCONFIG_METHOD_MANUAL,
-       CONNMAN_IPCONFIG_METHOD_DHCP,
-       CONNMAN_IPCONFIG_METHOD_AUTO,
-} connman_ipconfig_method_e;
-
-typedef enum {
-       /*
-        * Not defined
-        */
-       CONNMAN_DNS_CONFIG_TYPE_UNKNOWN,
-       /*
-        * Manual DNS configuration
-        */
-       CONNMAN_DNS_CONFIG_TYPE_STATIC,
-       /*
-        * Config DNS using DHCP client
-        */
-       CONNMAN_DNS_CONFIG_TYPE_DYNAMIC,
-} connman_dns_config_type_e;
-
-typedef enum {
-       /*
-        * Not defined
-        */
-       CONNMAN_PROXY_TYPE_UNKNOWN,
-       /*
-        * Direct connection
-        */
-       CONNMAN_PROXY_TYPE_DIRECT,
-       /*
-        * Auto configuration(Use PAC file) If URL property is not set,
-        * DHCP/WPAD auto-discover will be tried
-        */
-       CONNMAN_PROXY_TYPE_AUTO,
-       /*
-        * Manual configuration
-        */
-       CONNMAN_PROXY_TYPE_MANUAL,
-} connman_proxy_type_e;
-
-typedef enum {
-
-       /** Not defined */
-       CONNMAN_PDP_TYPE_NONE   = 0x00,
-       /** PDP-GPRS type */
-       CONNMAN_PDP_TYPE_GPRS,
-       /** PDP-EDGE type */
-       CONNMAN_PDP_TYPE_EDGE,
-       /** PDP-UMTS type */
-       CONNMAN_PDP_TYPE_UMTS,
-} connman_pdp_type_e;
-
-typedef enum {
-
-       /** auto connection mode */
-       CONNMAN_WLAN_MODE_AUTO = 0x01,
-       /** Connection mode Adhoc  */
-       CONNMAN_WLAN_MODE_ADHOC,
-       /** Infra connection mode */
-       CONNMAN_WLAN_MODE_INFRA,
-} connman_wlan_mode_e;
-
-void nm_connman_mgr_tech_added(
-               const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *parameters,
-               gpointer user_data);
-
-void nm_connman_mgr_tech_removed(
-               const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *parameters,
-               gpointer user_data);
-
-void nm_connman_mgr_service_changed(
-               const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *parameters,
-               gpointer user_data);
-
-void nm_connman_mgr_property_changed(
-               const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *parameters,
-               gpointer user_data);
-
-int nm_connman_tech_init();
-int nm_connman_tech_deinit();
-void nm_connman_tech_add(gchar *path, GVariantIter *iter);
-void nm_connman_tech_remove(GVariant *parameters);
-
-int nm_connman_service_init();
-int nm_connman_service_deinit();
-void nm_connman_service_get_from_reply(GVariant *reply, gpointer user_data);
-void nm_connman_service_add(gchar *path, GVariantIter *iter, GVariantBuilder *added);
-void nm_connman_service_remove(gchar *path, GVariantBuilder *removed);
-void nm_connman_service_change(GVariant *parameters);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_CONNMAN_INTERNAL_H__ */
-
diff --git a/src/nm-connman-mgr.c b/src/nm-connman-mgr.c
deleted file mode 100644 (file)
index 7629ae0..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling connman manager DBus interface.
- *
- * @file        nm-connman-mgr.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <glib.h>
-#include <gio/gio.h>
-
-
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-connman.h"
-#include "nm-connman-internal.h"
-
-typedef enum {
-       MANAGER_CMD_GET_PROP,
-       MANAGER_CMD_GET_TECH,
-       MANAGER_CMD_GET_SERVICE,
-
-} manager_cmd_e;
-
-typedef struct {
-       /*
-        * The global connection state of a system
-        */
-       int state;
-       /* The offline mode indicates the global setting for
-        * switching all radios on or off. Changing offline mode
-        * to true results in powering down all devices.
-        */
-       gboolean offline_mode;
-       /*
-        * deprecated
-        */
-       gboolean session_mode;
-       gboolean auto_connect_mode;
-} connman_manager_s;
-
-static method_param_s connman_method_params[] = {
-               {
-                               .bus_name = CONNMAN_SERVICE,
-                               .object_path = CONNMAN_MANAGER_PATH,
-                               .interface_name = CONNMAN_MANAGER_INTERFACE,
-                               .method_name = "GetProperties",
-                               .parameters = NULL,
-               },
-               {
-                               .bus_name = CONNMAN_SERVICE,
-                               .object_path = CONNMAN_MANAGER_PATH,
-                               .interface_name = CONNMAN_MANAGER_INTERFACE,
-                               .method_name = "GetTechnologies",
-                               .parameters = NULL,
-               },
-               {
-                               .bus_name = CONNMAN_SERVICE,
-                               .object_path = CONNMAN_MANAGER_PATH,
-                               .interface_name = CONNMAN_MANAGER_INTERFACE,
-                               .method_name = "GetServices",
-                               .parameters = NULL,
-               },
-};
-
-connman_manager_s connman_manager = {
-               .state  = 0,
-               .offline_mode = FALSE,
-               .session_mode = FALSE,
-               .auto_connect_mode  = FALSE,
-};
-
-void nm_connman_mgr_tech_added(
-               const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       GVariantIter *iter = NULL;
-       gchar *path = NULL;
-
-       g_variant_get(parameters, "(&oa{sv})", &path, &iter);
-       nm_connman_tech_add(path, iter);
-
-       g_variant_iter_free(iter);
-       return;
-       __NM_FUNC_EXIT__;
-}
-
-void nm_connman_mgr_tech_removed(
-               const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       nm_connman_tech_remove(parameters);
-
-       return;
-       __NM_FUNC_EXIT__;
-
-}
-
-void nm_connman_mgr_service_changed(
-               const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       nm_connman_service_change(parameters);
-
-       return;
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __set_manager_state(const gchar *state)
-{
-       if (g_strcmp0(state, "offline") == 0)
-               connman_manager.state = MANAGER_STATE_OFFLINE;
-       else if (g_strcmp0(state, "idle") == 0)
-               connman_manager.state = MANAGER_STATE_IDLE;
-       else if (g_strcmp0(state, "ready") == 0)
-               connman_manager.state = MANAGER_STATE_READY;
-       else if (g_strcmp0(state, "online") == 0)
-               connman_manager.state = MANAGER_STATE_ONLINE;
-
-       return;
-}
-
-static inline void __mgr_get_property(gchar *key, GVariant *value)
-{
-       if (g_strcmp0(key, "State") == 0) {
-               const char *state = NULL;
-
-               g_variant_get(value, "&s", &state);
-               __set_manager_state(state);
-
-       } else if (g_strcmp0(key, "OfflineMode") == 0){
-               g_variant_get(value, "b", &connman_manager.offline_mode);
-       } else if (g_strcmp0(key, "SessionMode") == 0){
-               g_variant_get(value, "b", &connman_manager.session_mode);
-       }  else if (g_strcmp0(key, "AutoConnectMode") == 0){
-               g_variant_get(value, "b", &connman_manager.auto_connect_mode);
-       }
-}
-
-static void __mgr_property_changed(GVariant *property)
-{
-       gchar *key = NULL;
-       GVariant *value = NULL;
-       g_variant_get(property, "(&sv)", &key, &value);
-
-       if (key)
-               __mgr_get_property(key, value);
-}
-
-static void __get_manager_properties(GVariant *reply, gpointer user_data)
-{
-       GVariantIter *iter = NULL;
-       gchar *key = NULL;
-       GVariant *value = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (!reply) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       g_variant_get(reply, "(a{sv})", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       while (g_variant_iter_loop(iter, "{sv}", &key, &value))
-               __mgr_get_property(key, value);
-
-       g_variant_iter_free(iter);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __get_technologies(GVariant *reply, gpointer user_data)
-{
-       GVariantIter *iter_outer = NULL;
-       GVariantIter *iter_inner = NULL;
-       gchar *path = NULL;
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(reply, "(a(oa{sv}))", &iter_outer);
-
-       while (g_variant_iter_loop(iter_outer, "(&oa{sv})", &path, &iter_inner)) {
-
-               if (path == NULL || iter_inner == NULL)
-                       continue;
-               nm_connman_tech_add(path, iter_inner);
-       }
-
-       g_variant_iter_free(iter_outer);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-void nm_connman_mgr_property_changed(
-               const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __mgr_property_changed(parameters);
-
-       return;
-       __NM_FUNC_EXIT__;
-}
-
-int nm_connman_mgr_get_properties()
-{
-       int ret = NM_CONNMAN_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       ret = nm_gdbus_method_call(
-                       &(connman_method_params[MANAGER_CMD_GET_PROP]),
-                       __get_manager_properties,
-                       NULL);
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_METHOD_CALL_FAILED;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_CONNMAN_ERROR_NONE;
-}
-
-int nm_connman_mgr_get_state(int *state)
-{
-       int ret = NM_CONNMAN_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       *state = connman_manager.state;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_connman_mgr_get_offline_mode(gboolean *offline_mode)
-{
-       int ret = NM_CONNMAN_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       *offline_mode = connman_manager.offline_mode;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-
-}
-int nm_connman_mgr_get_technologies()
-{
-       int ret = NM_CONNMAN_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       ret = nm_gdbus_method_call(
-                       &(connman_method_params[MANAGER_CMD_GET_TECH]),
-                       __get_technologies,
-                       NULL);
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_METHOD_CALL_FAILED;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_CONNMAN_ERROR_NONE;
-}
-
-int nm_connman_mgr_get_services()
-{
-       int ret = NM_CONNMAN_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       ret = nm_gdbus_method_call(
-                       &(connman_method_params[MANAGER_CMD_GET_SERVICE]),
-                       nm_connman_service_get_from_reply,
-                       NULL);
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_METHOD_CALL_FAILED;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_CONNMAN_ERROR_NONE;
-}
diff --git a/src/nm-connman-service.c b/src/nm-connman-service.c
deleted file mode 100755 (executable)
index 4b0346d..0000000
+++ /dev/null
@@ -1,2940 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling connman service DBus interface.
- *
- * @file        nm-connman-service.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <stdlib.h>
-
-#include <arpa/inet.h>
-
-#include <glib.h>
-
-#include "nm-connman.h"
-#include "nm-connman-internal.h"
-#include "nm-telephony.h"
-#include "nm-gdbus.h"
-#include "nm-daemon-log.h"
-
-#define IP_LEN 4
-#define IPV6_LEN 16
-#define MAC_LEN 6
-
-/* Maximum length of device name  */
-#define        MAX_DEVICE_NAME_LEN 32
-
-/* Maximum length of IPv6 Privacy  ["enabled", "disabled", "preferred"] */
-#define        IPV6_MAX_PRIVACY_LEN 9
-
-/* Maximum length of proxy string */
-#define MAX_PROXY_LEN 64
-
-/** MAX number of DNS Address */
-#define        MAX_DNS_ADDR 3
-
-#define IPV6_LEN 16
-
-/** Length of essid */
-#define WLAN_ESSID_LEN      128
-
-/** Length of bssid */
-#define WLAN_BSSID_LEN      17
-
-/**
- * Length of WPS PIN code
- * WPS PIN code should be 4 or 8 digits
- */
-#define WLAN_MAX_PIN_LEN               8
-
-/**
- * Passphrase length should be between 8..63,
- * If we plan to use encrypted key(hex value generated by wpa_passphrase),
- * then we have to set this value to some higher number
- *
- */
-#define WLAN_MAX_PSK_PASSPHRASE_LEN 65
-
-/**
- * Length of WEP Key
- * Max of 10 Hex digits allowed in case of 64 bit encryption
- * Max of 26 Hex digits allowed in case of 128 bit encryption
- */
-#define WLAN_MAX_WEP_KEY_LEN        26
-
-/**
- * These lengths depends on authentication server being used,
- * In case of freeradius server Max allowed length for username/password is 255
- * Let us restrict this value to some optimal value say 50.
- * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
- */
-#define WLAN_USERNAME_LEN               50
-
-/**
- * These lengths depends on authentication server being used,
- * In case of freeradius server Max allowed length for username/password is 255
- * Let us restrict this value to some optimal value say 50.
- * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
- */
-#define WLAN_PASSWORD_LEN               50
-
-/**
- * length of CA Cert file name
- * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
- */
-#define WLAN_CA_CERT_FILENAME_LEN       128
-
-/**
- * length of Client Cert file name
- * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
- */
-#define WLAN_CLIENT_CERT_FILENAME_LEN   128
-
-/**
- * length of private key file name
- * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
- */
-#define WLAN_PRIVATE_KEY_FILENAME_LEN   128
-
-/**
- * length of Private key password
- * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
- */
-#define WLAN_PRIVATE_KEY_PASSWD_LEN     50
-
-/**
- * @enum wlan_security_mode_type_e
- * Below security modes are used in infrastructure and ad-hoc mode
- * For now all EAP security mechanisms are provided only in infrastructure mode
- */
-typedef enum
-{
-       /** Security disabled */
-       WLAN_SEC_MODE_NONE = 0x01,
-       /** WEP */
-       WLAN_SEC_MODE_WEP,
-       /** EAP */
-       WLAN_SEC_MODE_IEEE8021X,
-       /** WPA-PSK */
-       WLAN_SEC_MODE_WPA_PSK,
-       /** WPA2-PSK */
-       WLAN_SEC_MODE_WPA2_PSK,
-       WLAN_SEC_MODE_WPA_FT_PSK,
-} wlan_security_mode_type_e;
-
-/**
- * @enum wlan_encryption_mode_type_e
- * Below encryption modes are used in infrastructure and ad-hoc mode
- */
-typedef enum
-{
-       /** Encryption disabled */
-       WLAN_ENC_MODE_NONE = 0x01,
-       /** WEP */
-       WLAN_ENC_MODE_WEP,
-       /** TKIP */
-       WLAN_ENC_MODE_TKIP,
-       /** AES */
-       WLAN_ENC_MODE_AES,
-       /** TKIP and AES are both supported */
-       WLAN_ENC_MODE_TKIP_AES_MIXED,
-} wlan_encryption_mode_type_e;
-
-/**
- * @enum wlan_eap_type_e
- * EAP type
- * @see wlan_eap_info_e
- */
-typedef enum {
-       /** EAP PEAP type */
-       WLAN_SEC_EAP_TYPE_PEAP = 0x01,
-       /** EAP TLS type */
-       WLAN_SEC_EAP_TYPE_TLS,
-       /** EAP TTLS type */
-       WLAN_SEC_EAP_TYPE_TTLS,
-       /** EAP SIM type */
-       WLAN_SEC_EAP_TYPE_SIM,
-       /** EAP AKA type */
-       WLAN_SEC_EAP_TYPE_AKA,
-} wlan_eap_type_e;
-
-/**
- * @enum wlan_eap_auth_type_e
- * EAP phase2 authentication type
- * @see wlan_eap_info_e
- */
-typedef enum {
-       /** EAP phase2 authentication none */
-       WLAN_SEC_EAP_AUTH_NONE = 0x01,
-       /** EAP phase2 authentication PAP */
-       WLAN_SEC_EAP_AUTH_PAP,
-       /** EAP phase2 authentication MSCHAP */
-       WLAN_SEC_EAP_AUTH_MSCHAP,
-       /** EAP phase2 authentication MSCHAPv2 */
-       WLAN_SEC_EAP_AUTH_MSCHAPV2,
-       /** EAP phase2 authentication GTC */
-       WLAN_SEC_EAP_AUTH_GTC,
-       /** EAP phase2 authentication MD5 */
-       WLAN_SEC_EAP_AUTH_MD5,
-} wlan_eap_auth_type_e;
-
-/**
- * @enum wlan_eap_keymgmt_type_e
- * EAP keymgmt type
- * @see wlan_eap_info_e
- */
-typedef enum {
-       WLAN_SEC_EAP_KEYMGMT_UNKNOWN = 0x00,
-       WLAN_SEC_EAP_KEYMGMT_NONE,
-       WLAN_SEC_EAP_KEYMGMT_FT,
-       WLAN_SEC_EAP_KEYMGMT_CCKM,
-       WLAN_SEC_EAP_KEYMGMT_OKC,
-} wlan_eap_keymgmt_type_e;
-
-typedef struct {
-       /*
-        * Possible values are "dhcp", "manual", "auto"
-        * and "off".
-        */
-       gint method;
-       /*
-        * The current configured IPv4 address.
-        */
-       struct in_addr address;
-       /*
-        * The current configured IPv4 netmask.
-        */
-       struct in_addr netmask;
-       /*
-        * The current configured IPv4 gateway.
-        */
-       struct in_addr gateway;
-       /*
-        * The current configured IPv4 DHCP server IP.
-        */
-       struct in_addr dhcp_server_ip;
-       /*
-        * The current configured IPv4 DHCP lease duration.
-        */
-       gint dhcp_lease_duration;
-} connman_ipv4_s;
-
-typedef struct {
-       /*
-        * Possible values are "auto", "manual", "6to4" and "off".
-        */
-       gint method;
-
-       /*
-        * The current configured IPv6 address.
-        */
-       struct in6_addr address;
-       /*
-        * The prefix length of the IPv6 address.
-        */
-       gint prefix_length;
-       /*
-        * The current configured IPv6 gateway.
-        */
-       struct in6_addr gateway;
-       /*
-        * Enable or disable IPv6 privacy extension
-        * that is described in RFC 4941. The value
-        * has only meaning if Method is set to "auto".
-        * Value "disabled" means that privacy extension
-        * is disabled and normal autoconf addresses are
-        * used.
-        *
-        * Value "enabled" means that privacy extension is
-        * enabled and system prefers to use public
-        * addresses over temporary addresses.
-        * Value "prefered" means that privacy extension is
-        * enabled and system prefers temporary addresses
-        * over public addresses.
-        * Default value is "disabled".
-        */
-       gchar privacy[IPV6_MAX_PRIVACY_LEN + 1];
-
-} connman_ipv6_s;
-
-typedef union {
-       /*
-        * IP Version 4 address
-        */
-       struct in_addr ip;
-       /*
-        * IP Version 6 address
-        */
-       struct in6_addr ipv6;
-} connman_ip_addr_u;
-
-typedef struct {
-       gint addr_type;
-       connman_ip_addr_u addr;
-} connman_dns_addr;
-
-typedef struct {
-       /*
-        * Possible values are "direct", "auto" and "manual".
-        */
-       gint method;
-       /*
-        * Automatic proxy configuration URL. Used by "auto" method.
-        */
-       gchar addr[MAX_PROXY_LEN + 1];
-
-} connman_proxy_s;
-
-typedef struct {
-       /*
-        * Possible values are "auto" and "manual".
-        */
-       gint method;
-       /*
-        * Interface name (for example eth0).
-        */
-       gchar interface[MAX_DEVICE_NAME_LEN];
-       /*
-        * Ethernet device address (MAC address).
-        */
-       guint8 address[MAC_LEN];
-       /*
-        * The Ethernet MTU (default is 1500).
-        */
-       gint mtu;
-} connman_eth_s;
-
-typedef struct {
-       /* TODO: fill eth specific info */
-} connman_eth_priv_s;
-
-typedef struct {
-       /* TODO: fill bt specific info */
-
-} connman_bt_priv_s;
-
-/**
- * Below structure is used to export essid
- */
-typedef struct
-{
-       /** ESSID */
-       char essid[WLAN_ESSID_LEN+1];
-} net_essid_s;
-
-/**
- * Below structure is used by WPA-PSK or WPA2-PSK
- * @remark To see the maximum length of PSK passphrase key.
- * @see wlan_auth_info_t
- */
-typedef struct
-{
-       /** key value for WPA-PSK or WPA2-PSK */
-       gchar pskKey[WLAN_MAX_PSK_PASSPHRASE_LEN + 1];
-} wlan_psk_info_s;
-
-/**
- * Below structure is used by WEP
- * @remark To see the maximum length of WEP key.
- * @see wlan_auth_info_s
- */
-typedef struct
-{
-       /** key value for WEP */
-       gchar wepKey[WLAN_MAX_WEP_KEY_LEN + 1];
-} wlan_wep_info_s;
-
-/**
- * Below structure is used by EAP
- * @see wlan_auth_info_s
- */
-typedef struct
-{
-       /** User name */
-       gchar username[WLAN_USERNAME_LEN+1];
-       /** Password */
-       gchar password[WLAN_PASSWORD_LEN+1];
-
-       /**
-        * Following fields are mandatory for EAP-TLS,
-        * Optional for EAP-TTLS and EAP-PEAP
-        */
-       /**
-        * For EAP-TTLS and EAP-PEAP only ca_cert_filename[] can also be provided
-        */
-       /* Used to authenticate server */
-       gchar ca_cert_filename[WLAN_CA_CERT_FILENAME_LEN+1];
-       /** client certificate file name */
-       gchar client_cert_filename[WLAN_CLIENT_CERT_FILENAME_LEN+1];
-       /** private key file name */
-       gchar private_key_filename[WLAN_PRIVATE_KEY_FILENAME_LEN+1];
-       /** private key password */
-       gchar private_key_passwd[WLAN_PRIVATE_KEY_PASSWD_LEN+1];
-
-       /** eap type */
-       wlan_eap_type_e eap_type;
-       /** eap phase2 authentication type */
-       wlan_eap_auth_type_e eap_auth;
-       /** eap keymgmt type */
-       wlan_eap_keymgmt_type_e eap_keymgmt_type;
-} wlan_eap_info_s;
-
-/**
- * At any point of time only one security mechanism is supported
- * @see wlan_sec_info_s
- */
-typedef union
-{
-       /** Wep Authentication */
-       wlan_wep_info_s wep;
-       /** psk Authentication */
-       wlan_psk_info_s psk;
-       /** eap Authentication */
-       wlan_eap_info_s eap;
-} wlan_auth_info_u;
-
-/**
- * This is main security information structure
- * @see connman_wlan_priv_s
- */
-typedef struct
-{
-       /** security mode type */
-       wlan_security_mode_type_e sec_mode;
-       /** encryption mode type */
-       wlan_encryption_mode_type_e enc_mode;
-       /** authentication information */
-       wlan_auth_info_u auth_info;
-       /** If WPS is supported, then this property will be set to TRUE */
-       gboolean wps_support;
-       /** keymgmt */
-       unsigned int keymgmt;
-} wlan_sec_info_s;
-
-typedef struct {
-
-       /** Infrastucture / ad-hoc / auto mode */
-       connman_wlan_mode_e mode;
-
-       /** ESSID */
-       gchar essid[WLAN_ESSID_LEN + 1];
-
-       /** Basic service set identification */
-       gchar bssid[WLAN_BSSID_LEN + 1];
-
-       /**  Strength : between 0 and 100 */
-       guchar strength;
-       /** Frequency band(MHz) */
-       guint frequency;
-       /** Maximum speed of the line(bps) */
-       guint max_rate;
-       /** If a passphrase has been set already or if no
-               passphrase is needed, then this property will
-               be set to FALSE. */
-       gchar passphrase_required;
-
-       /** Security mode and authentication info */
-       wlan_sec_info_s sec_info;
-
-       /** Passpoint AP or not */
-       gboolean passpoint;
-
-       /** Hidden network */
-       gboolean is_hidden;
-       gint reason;
-       gint assoc_status;
-
-} connman_wlan_priv_s;
-
-typedef union {
-       connman_eth_priv_s eth;
-       connman_bt_priv_s bt;
-       nm_telephony_profile_s cell;
-       connman_wlan_priv_s wlan;
-
-} connman_srv_priv_u;
-
-typedef struct {
-       /*
-        * The service state information.
-        * The "ready" state signals a successfully
-        * connected device. "online" signals that an
-        * Internet connection is available and has been
-        * verified.
-        */
-       gint state;
-       gint state_ipv6;
-       /*
-        * The service error status details.
-        * This property is only valid when the service is in
-        * the "failure" state. Otherwise it might be empty or
-        * not present at all.
-        */
-       gint error;
-       /*
-        * The service name (for example "Wireless" etc.)
-        * For Ethernet devices and hidden WiFi networks this
-        * property is not present.
-        */
-       gchar *name;
-       /*
-        * The service type (for example "ethernet", "wifi" etc.)
-        * Together with a missing Name property, this can
-        * be used to identify hidden WiFi networks.
-        */
-       gint type;
-       /*
-        * If the service type is WiFi, then this property is
-        * present security methods or key management settings.
-        */
-       gint security;
-       /*
-        * Indicates the signal strength of the service. This
-        * is a normalized value between 0 and 100.
-        * This property will not be present for Ethernet devices.
-        */
-       guint8 strength;
-       /*
-        * Will be true if a cable is plugged in or the user
-        * selected and successfully connected to this service.
-        */
-       gboolean favorite;
-       /*
-        * This value will be set to true if the service is
-        * configured externally via a configuration file.
-        */
-       gboolean immutable;
-       /*
-        * If set to true, this service will auto-connect
-        * when no other connection is available.
-        * The service won't auto-connect while roaming.
-        */
-       gboolean auto_connect;
-       /*
-        * This property indicates if this service is roaming.
-        */
-       gboolean roaming;
-       /*
-        * The list of currently active nameservers for this
-        * service. If the server is not in READY or ONLINE
-        * state than this list will be empty.
-        *
-        */
-       GSList *name_servers;
-       /*
-        * The list of manually configured domain name
-        * servers. Some cellular networks don't provide
-        * correct name servers and this allows for an
-        * override.
-        */
-       GSList *configured_name_servers;
-       /*
-        * The list of currently active timeservers for this
-        * service. If the server is not in READY or ONLINE
-        * state than this list will be empty.
-        */
-       GSList *time_servers;
-       /*
-        * The list of manually configured time servers.
-        */
-       GSList *configured_time_servers;
-
-       /*
-        * IPv4 Dns configuration type
-        */
-       gint dns_conf_type;
-       /*
-        * IPv6 Dns configuration type
-        */
-       gint dns_conf_type_v6;
-       /*
-        * No of IPv4 DNS Address for the connection link
-        */
-       gint dns_cnt;
-       /*
-        * No of IPv6 DNS Address for the connection link
-        */
-       gint dns_cnt_v6;
-       /*
-        * IPv4 Dns Server Address of the connection link
-        */
-       connman_dns_addr dns_addr[MAX_DNS_ADDR];
-
-       /*
-        * IPv6 Dns Server Address of the connection link
-        */
-       connman_dns_addr dns_addr_v6[MAX_DNS_ADDR];
-
-       connman_ipv4_s ip;
-       /*
-        * Same values as IPv4 property. The IPv4 represents
-        * the actual system configuration while this allows
-        * user configuration.
-        */
-       connman_ipv4_s configured_ip;
-
-       connman_ipv6_s ipv6;
-       /*
-        * Same values as IPv6 property. The IPv6 represents
-        * the actual system configuration while this allows
-        * user configuration.
-        */
-       connman_ipv6_s configured_ipv6;
-
-       connman_proxy_s proxy;
-
-       connman_eth_s eth;
-       /*
-        * Whether or not mDNS support is enabled.
-        */
-       gboolean mdns;
-       /*
-        * Same values as mDNS property. The mDNS
-        * represents the actual system configuration
-        * while this allows user configuration.
-        */
-       gboolean configured_mdns;
-       guint subscriber_id;
-
-       guint conn_obj_id;
-       gchar obj_path[DBUS_OBJECT_PATH_MAX + 1];
-
-       connman_srv_priv_u priv_info;
-} connman_service_s;
-
-static void __service_property_changed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-typedef struct {
-       int num;
-       char *str;
-} str_map_s;
-
-str_map_s conn_type[] = {
-       {CONNMAN_SERVICE_TYPE_UNKNOWN, "Unknown"},
-       {CONNMAN_SERVICE_TYPE_SYSTEM, "system"},
-       {CONNMAN_SERVICE_TYPE_ETHERNET, "ethernet"},
-       {CONNMAN_SERVICE_TYPE_WIFI, "wifi"},
-       {CONNMAN_SERVICE_TYPE_BLUETOOTH, "bluetooth"},
-       {CONNMAN_SERVICE_TYPE_CELLULAR, "cellular"},
-       {CONNMAN_SERVICE_TYPE_GPS, "gps"},
-       {CONNMAN_SERVICE_TYPE_VPN, "vpn"},
-       {CONNMAN_SERVICE_TYPE_GADGET, "gadget"},
-       {CONNMAN_SERVICE_TYPE_P2P, "p2p"},
-       {0, NULL},
-};
-
-str_map_s conn_state[] = {
-       {CONNMAN_SERVICE_STATE_UNKNOWN, "Unknown"},
-       {CONNMAN_SERVICE_STATE_IDLE, "idle"},
-       {CONNMAN_SERVICE_STATE_ASSOCIATION, "association"},
-       {CONNMAN_SERVICE_STATE_CONFIGURATION, "configuration"},
-       {CONNMAN_SERVICE_STATE_READY, "ready"},
-       {CONNMAN_SERVICE_STATE_ONLINE, "online"},
-       {CONNMAN_SERVICE_STATE_DISCONNECT, "disconnect"},
-       {CONNMAN_SERVICE_STATE_FAILURE, "failure"},
-       {0, NULL},
-};
-
-str_map_s conn_ip_config[] = {
-       {CONNMAN_IPCONFIG_METHOD_UNKNOWN, "unknown"},
-       {CONNMAN_IPCONFIG_METHOD_OFF, "off"},
-       {CONNMAN_IPCONFIG_METHOD_FIXED, "fixed"},
-       {CONNMAN_IPCONFIG_METHOD_MANUAL, "manual"},
-       {CONNMAN_IPCONFIG_METHOD_DHCP, "dhcp"},
-       {CONNMAN_IPCONFIG_METHOD_AUTO, "auto"},
-       {0, NULL},
-};
-
-str_map_s conn_dns_config[] = {
-       {CONNMAN_DNS_CONFIG_TYPE_UNKNOWN, "unknown"},
-       {CONNMAN_DNS_CONFIG_TYPE_STATIC, "static"},
-       {CONNMAN_DNS_CONFIG_TYPE_DYNAMIC, "dynamic"},
-       {0, NULL},
-};
-
-str_map_s conn_proxy_type[] = {
-       {CONNMAN_PROXY_TYPE_UNKNOWN, "unknown"},
-       {CONNMAN_PROXY_TYPE_DIRECT, "direct"},
-       {CONNMAN_PROXY_TYPE_AUTO, "auto"},
-       {CONNMAN_PROXY_TYPE_MANUAL, "manul"},
-       {0, NULL},
-};
-
-str_map_s conn_sec_type[] = {
-               {0, NULL},
-               {WLAN_SEC_MODE_NONE, "none"},
-               {WLAN_SEC_MODE_WEP, "wep"},
-               {WLAN_SEC_MODE_IEEE8021X, "ieee8021x"},
-               {WLAN_SEC_MODE_WPA_PSK, "psk"},
-               {WLAN_SEC_MODE_WPA2_PSK, "rsn"},
-               {WLAN_SEC_MODE_WPA_FT_PSK, "ft_psk"},
-               {0, NULL},
-};
-
-str_map_s conn_enc_type[] = {
-               {0, NULL},
-               {WLAN_ENC_MODE_NONE, "none"},
-               {WLAN_ENC_MODE_WEP, "wep"},
-               {WLAN_ENC_MODE_TKIP, "tkip"},
-               {WLAN_ENC_MODE_AES, "aes"},
-               {WLAN_ENC_MODE_TKIP_AES_MIXED, "mixed"},
-               {0, NULL},
-};
-
-str_map_s conn_eap_type[] = {
-               {0, NULL},
-               {WLAN_SEC_EAP_TYPE_PEAP, "peap"},
-               {WLAN_SEC_EAP_TYPE_TLS, "tls"},
-               {WLAN_SEC_EAP_TYPE_TTLS, "ttls"},
-               {WLAN_SEC_EAP_TYPE_SIM, "sim"},
-               {WLAN_SEC_EAP_TYPE_AKA, "aka"},
-               {0, NULL},
-};
-
-str_map_s conn_eap_auth_type[] = {
-               {0, NULL},
-               {WLAN_SEC_EAP_AUTH_NONE, "none"},
-               {WLAN_SEC_EAP_AUTH_PAP, "pap"},
-               {WLAN_SEC_EAP_AUTH_MSCHAP, "mschap"},
-               {WLAN_SEC_EAP_AUTH_MSCHAPV2, "mschapv2"},
-               {WLAN_SEC_EAP_AUTH_GTC, "gtc"},
-               {WLAN_SEC_EAP_AUTH_MD5, "md5"},
-               {0, NULL},
-};
-
-GHashTable *service_tbl = NULL;
-nm_connman_conn_changed_cb g_conn_changed_cb = NULL;
-nm_connman_error_cb g_conn_error_cb = NULL;
-
-static signal_param_s service_signal_param = {
-               .sender = CONNMAN_SERVICE,
-               .interface_name = CONNMAN_SERVICE_INTERFACE,
-               .member = DBUS_SIGNAL_PROPERTY_CHANGED,
-               .object_path = NULL,
-               .arg0 = NULL,
-               .callback = __service_property_changed,
-               .subscriber_id  = 0,
-};
-
-static GVariant *__nm_connman_service_get_ip(connman_service_s *service);
-static GVariant *__nm_connman_service_get_dns(connman_service_s *service);
-static GVariant *__nm_connman_service_get_ipv4_state(connman_service_s *service);
-static GVariant *__nm_connman_service_get_ipv6_state(connman_service_s *service);
-
-static int __ws_txt_to_mac(const gchar *txt, guchar *mac)
-{
-       int i = 0;
-
-       if (!txt || !mac) {
-               NM_LOGI("Invalid parameter");
-               return -1;
-       }
-
-       for (;;) {
-               mac[i++] = (char) strtoul((char *)txt, (char **)&txt, 16);
-               if (!*txt++ || i == 6)
-                       break;
-       }
-
-       if (i != MAC_LEN)
-               return -1;
-
-       return 0;
-}
-
-static inline void __get_state(connman_service_s *service, GVariant *value)
-{
-       const gchar *state_str = NULL;
-       state_str =  g_variant_get_string(value, NULL);
-
-       if (g_strcmp0(state_str, "idle") == 0)
-               service->state = CONNMAN_SERVICE_STATE_IDLE;
-       else if (g_strcmp0(state_str, "failure") == 0)
-               service->state = CONNMAN_SERVICE_STATE_FAILURE;
-       else if (g_strcmp0(state_str, "association") == 0)
-               service->state = CONNMAN_SERVICE_STATE_ASSOCIATION;
-       else if (g_strcmp0(state_str, "configuration") == 0)
-               service->state = CONNMAN_SERVICE_STATE_CONFIGURATION;
-       else if (g_strcmp0(state_str, "ready") == 0)
-               service->state = CONNMAN_SERVICE_STATE_READY;
-       else if (g_strcmp0(state_str, "disconnect") == 0)
-               service->state = CONNMAN_SERVICE_STATE_DISCONNECT;
-       else if (g_strcmp0(state_str, "online") == 0)
-               service->state = CONNMAN_SERVICE_STATE_ONLINE;
-       else
-               service->state = CONNMAN_SERVICE_STATE_UNKNOWN;
-
-       nm_gdbus_emit_conn_ipv4_state_changed(service->obj_path,
-                       __nm_connman_service_get_ipv4_state(service));
-
-       NM_LOGI("State [%s]", state_str);
-}
-
-static inline void __get_state_ipv6(connman_service_s *service, GVariant *value)
-{
-       const gchar *state_str = NULL;
-       state_str =  g_variant_get_string(value, NULL);
-
-       if (g_strcmp0(state_str, "idle") == 0)
-               service->state_ipv6 = CONNMAN_SERVICE_STATE_IDLE;
-       else if (g_strcmp0(state_str, "failure") == 0)
-               service->state_ipv6 = CONNMAN_SERVICE_STATE_FAILURE;
-       else if (g_strcmp0(state_str, "association") == 0)
-               service->state_ipv6 = CONNMAN_SERVICE_STATE_ASSOCIATION;
-       else if (g_strcmp0(state_str, "configuration") == 0)
-               service->state_ipv6 = CONNMAN_SERVICE_STATE_CONFIGURATION;
-       else if (g_strcmp0(state_str, "ready") == 0)
-               service->state_ipv6 = CONNMAN_SERVICE_STATE_READY;
-       else if (g_strcmp0(state_str, "disconnect") == 0)
-               service->state_ipv6 = CONNMAN_SERVICE_STATE_DISCONNECT;
-       else if (g_strcmp0(state_str, "online") == 0)
-               service->state_ipv6 = CONNMAN_SERVICE_STATE_ONLINE;
-       else
-               service->state_ipv6 = CONNMAN_SERVICE_STATE_UNKNOWN;
-
-       nm_gdbus_emit_conn_ipv6_state_changed(service->obj_path,
-                       __nm_connman_service_get_ipv6_state(service));
-
-       NM_LOGI("IP V6 state [%s]", state_str);
-}
-
-static inline void __get_error(connman_service_s *service, GVariant *value)
-{
-       const gchar *err_str = NULL;
-       err_str =  g_variant_get_string(value, NULL);
-
-       if (g_strcmp0(err_str, "invalid-key") == 0)
-               service->error = CONNMAN_SERVICE_ERROR_INVALID_KEY;
-       else if (g_strcmp0(err_str, "connect-failed") == 0)
-               service->error = CONNMAN_SERVICE_ERROR_CONNECT_FAILED;
-       else if (g_strcmp0(err_str, "auth-failed") == 0)
-               service->error = CONNMAN_SERVICE_ERROR_AUTH_FAILED;
-       else if (g_strcmp0(err_str, "login-failed") == 0)
-               service->error = CONNMAN_SERVICE_ERROR_LOGIN_FAILED;
-       else if (g_strcmp0(err_str, "dhcp-failed") == 0)
-               service->error = CONNMAN_SERVICE_ERROR_DHCP_FAILED;
-       else if (g_strcmp0(err_str, "out-of-range") == 0)
-               service->error = CONNMAN_SERVICE_ERROR_OUT_OF_RANGE;
-       else if (g_strcmp0(err_str, "pin-missing") == 0)
-               service->error = CONNMAN_SERVICE_ERROR_PIN_MISSING;
-       else
-               service->error = CONNMAN_SERVICE_ERROR_UNKNOWN;
-
-       NM_LOGI("error [%s]", err_str);
-
-       if (g_conn_error_cb)
-               g_conn_error_cb(service->error);
-}
-
-static inline void __get_name(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-       str =  g_variant_get_string(value, NULL);
-
-       if (str) {
-               g_free(service->name);
-               service->name = g_strdup(str);
-       }
-
-}
-
-static inline void __get_type(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-       str =  g_variant_get_string(value, NULL);
-
-       if (g_strcmp0(str, "ethernet") == 0)
-               service->type = CONNMAN_SERVICE_TYPE_ETHERNET;
-       else if (g_strcmp0(str, "gadget") == 0)
-               service->type = CONNMAN_SERVICE_TYPE_GADGET;
-       else if (g_strcmp0(str, "wifi") == 0)
-               service->type = CONNMAN_SERVICE_TYPE_WIFI;
-       else if (g_strcmp0(str, "cellular") == 0)
-               service->type = CONNMAN_SERVICE_TYPE_CELLULAR;
-       else if (g_strcmp0(str, "bluetooth") == 0)
-               service->type = CONNMAN_SERVICE_TYPE_BLUETOOTH;
-       else if (g_strcmp0(str, "vpn") == 0)
-               service->type = CONNMAN_SERVICE_TYPE_VPN;
-       else if (g_strcmp0(str, "gps") == 0)
-               service->type = CONNMAN_SERVICE_TYPE_GPS;
-       else if (g_strcmp0(str, "system") == 0)
-               service->type = CONNMAN_SERVICE_TYPE_SYSTEM;
-       else if (g_strcmp0(str, "p2p") == 0)
-               service->type = CONNMAN_SERVICE_TYPE_P2P;
-       else
-               service->type = CONNMAN_SERVICE_TYPE_UNKNOWN;
-
-       NM_LOGI("type [%s]", str);
-}
-
-static inline void __get_strength(connman_service_s *service, GVariant *value)
-{
-       g_variant_get(value, "y", &(service->strength));
-
-       NM_LOGI("strength [%u]", service->strength);
-}
-
-static inline void __get_favorite(connman_service_s *service, GVariant *value)
-{
-       g_variant_get(value, "b", &(service->favorite));
-}
-
-static inline void __get_immutable(connman_service_s *service, GVariant *value)
-{
-       g_variant_get(value, "b", &(service->immutable));
-}
-
-static inline void __get_auto_connect(connman_service_s *service, GVariant *value)
-{
-       g_variant_get(value, "b", &(service->auto_connect));
-}
-
-static inline void __get_roaming(connman_service_s *service, GVariant *value)
-{
-       g_variant_get(value, "b", &(service->roaming));
-}
-
-static inline gboolean __check_address_type(int address_family, const char *address)
-{
-       unsigned char buf[sizeof(struct in6_addr)] = {0, };
-       int err = 0;
-
-       err = inet_pton(address_family, address, buf);
-       if (err > 0)
-               return TRUE;
-
-       return FALSE;
-}
-
-static inline void __get_dns_type(const char *type, connman_service_s *service)
-{
-       if (g_strcmp0(type, "ipv4.manual") == 0)
-               service->dns_conf_type =
-                               CONNMAN_DNS_CONFIG_TYPE_STATIC;
-       else if (g_strcmp0(type, "ipv4.dhcp") == 0)
-               service->dns_conf_type =
-                               CONNMAN_DNS_CONFIG_TYPE_DYNAMIC;
-       if (g_strcmp0(type, "ipv6.manual") == 0)
-               service->dns_conf_type_v6 =
-                               CONNMAN_DNS_CONFIG_TYPE_STATIC;
-       else if (g_strcmp0(type, "ipv6.dhcp") == 0)
-               service->dns_conf_type_v6 =
-                               CONNMAN_DNS_CONFIG_TYPE_DYNAMIC;
-       return;
-}
-
-static inline void __set_dns_addr(gchar *dns, connman_service_s *service, int *cnt)
-{
-       if (*cnt  >= MAX_DNS_ADDR)
-               return;
-
-       service->dns_addr[*cnt].addr_type =
-               CONNMAN_ADDR_IPV4;
-       inet_pton(AF_INET, dns,
-                       &service->dns_addr[*cnt].addr.ip);
-       (*cnt)++;
-       return;
-}
-
-static inline void __set_dns_addr_v6(gchar *dns, connman_service_s *service,  int *cnt)
-{
-       if (*cnt  >= MAX_DNS_ADDR)
-               return;
-
-       service->dns_addr[*cnt].addr_type =
-               CONNMAN_ADDR_IPV6;
-       inet_pton(AF_INET6, dns,
-                       &service->dns_addr[*cnt].addr.ipv6);
-       (*cnt)++;
-       return;
-}
-
-static inline void __get_name_servers(connman_service_s *service, GVariant *value)
-{
-       GVariantIter *iter = NULL;
-       int dns_cnt = 0;
-       int dns_cnt_v6 = 0;
-       gchar *dns_value = NULL;
-
-       memset(&(service->dns_addr), 0, sizeof(connman_dns_addr) * MAX_DNS_ADDR);
-
-       g_variant_get(value, "as", &iter);
-
-       while (g_variant_iter_loop(iter, "s", &dns_value)) {
-               /* Check Type of DNS Address */
-               if (__check_address_type(AF_INET6, dns_value)) {
-                       /* IPv6 */
-                       __set_dns_addr_v6(dns_value, service, &dns_cnt_v6);
-               } else if (__check_address_type(AF_INET, dns_value)) {
-                       /* IPv4 */
-                       __set_dns_addr(dns_value, service, &dns_cnt);
-               } else { /* DNS Type */
-                       __get_dns_type(dns_value, service);
-               }
-       }
-       g_variant_iter_free(iter);
-
-       service->dns_cnt= dns_cnt;
-       service->dns_cnt_v6 = dns_cnt_v6;
-
-       nm_gdbus_emit_conn_dns_changed(service->obj_path,
-                       __nm_connman_service_get_dns(service));
-}
-
-static inline void __get_conf_name_servers(connman_service_s *service, GVariant *value)
-{
-       GVariantIter *iter = NULL;
-       int dns_cnt = service->dns_cnt;
-       int dns_cnt_v6 = service->dns_cnt_v6;
-       gchar *dns_value = NULL;
-
-       g_variant_get(value, "as", &iter);
-
-       while (g_variant_iter_loop(iter, "s", &dns_value)) {
-               /* Check Type of DNS Address */
-               if (__check_address_type(AF_INET6, dns_value)) {
-                       /* IPv6 */
-                       __set_dns_addr_v6(dns_value, service, &dns_cnt_v6);
-               } else if (__check_address_type(AF_INET, dns_value)) {
-                       /* IPv4 */
-                       __set_dns_addr(dns_value, service, &dns_cnt);
-               } else { /* DNS Type */
-                       __get_dns_type(dns_value, service);
-               }
-       }
-       g_variant_iter_free(iter);
-
-       service->dns_cnt= dns_cnt;
-       service->dns_cnt_v6 = dns_cnt_v6;
-}
-
-static inline void __get_method(GVariant *value, connman_service_s *service)
-{
-       const gchar *str = NULL;
-       str = g_variant_get_string(value, NULL);
-
-       if (g_strcmp0(str, "dhcp") == 0)
-               service->ip.method = CONNMAN_IPCONFIG_METHOD_DHCP;
-       else if (g_strcmp0(str, "manual") == 0)
-               service->ip.method = CONNMAN_IPCONFIG_METHOD_MANUAL;
-       else if (g_strcmp0(str, "fixed") == 0)
-               service->ip.method = CONNMAN_IPCONFIG_METHOD_FIXED;
-       else if (g_strcmp0(str, "off") == 0)
-               service->ip.method = CONNMAN_IPCONFIG_METHOD_OFF;
-}
-
-static inline void __get_ip(connman_service_s *service, GVariant *value)
-{
-       GVariantIter *iter = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-       const gchar *str = NULL;
-
-       memset(&(service->ip), 0, sizeof(connman_ipv4_s));
-
-       g_variant_get(value, "a{sv}", &iter);
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
-               if (g_strcmp0(key, "Method") == 0) {
-                       __get_method(var, service);
-
-               } else if (g_strcmp0(key, "Address") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       inet_aton(str, &service->ip.address);
-               } else if (g_strcmp0(key, "Netmask") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       inet_aton(str, &service->ip.netmask);
-               } else if (g_strcmp0(key, "Gateway") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       inet_aton(str, &service->ip.gateway);
-               } else if (g_strcmp0(key, "DHCPServerIP") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       inet_aton(str, &service->ip.dhcp_server_ip);
-               } else if (g_strcmp0(key, "DHCPLeaseDuration") == 0) {
-                       service->ip.dhcp_lease_duration = g_variant_get_int32(var);
-               }
-       }
-       g_variant_iter_free(iter);
-
-       nm_gdbus_emit_conn_ip_changed(service->obj_path,
-                       __nm_connman_service_get_ip(service));
-}
-
-static inline void __get_conf_ip(connman_service_s *service, GVariant *value)
-{
-       GVariantIter *iter = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-       const gchar *str = NULL;
-
-       g_variant_get(value, "a{sv}", &iter);
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
-               if (g_strcmp0(key, "Method") == 0) {
-                       __get_method(var, service);
-
-               } else if (g_strcmp0(key, "Address") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       inet_aton(str, &service->ip.address);
-               } else if (g_strcmp0(key, "Netmask") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       inet_aton(str, &service->ip.netmask);
-               } else if (g_strcmp0(key, "Gateway") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       inet_aton(str, &service->ip.gateway);
-               }
-       }
-       g_variant_iter_free(iter);
-}
-
-static inline void __get_ipv6_method(GVariant *value, connman_service_s *service)
-{
-       const gchar *str = NULL;
-       str = g_variant_get_string(value, NULL);
-
-       if (g_strcmp0(str, "manual") == 0)
-               service->ipv6.method = CONNMAN_IPCONFIG_METHOD_MANUAL;
-       else if (g_strcmp0(str, "off") == 0)
-               service->ipv6.method = CONNMAN_IPCONFIG_METHOD_OFF;
-       else if (g_strcmp0(str, "auto") == 0)
-               service->ipv6.method = CONNMAN_IPCONFIG_METHOD_AUTO;
-}
-
-static inline void __get_ipv6(connman_service_s *service, GVariant *value)
-{
-       GVariantIter *iter = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-       const gchar *str = NULL;
-
-       memset(&(service->ipv6), 0, sizeof(connman_ipv6_s));
-
-       g_variant_get(value, "a{sv}", &iter);
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
-               if (g_strcmp0(key, "Method") == 0) {
-                       __get_ipv6_method(var, service);
-
-               } else if (g_strcmp0(key, "Address") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       inet_pton(AF_INET6, str, &service->ipv6.address);
-               } else if (g_strcmp0(key, "PrefixLength") == 0) {
-                       service->ipv6.prefix_length = g_variant_get_byte(var);
-               } else if (g_strcmp0(key, "Gateway") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       inet_pton(AF_INET6, str, &service->ipv6.gateway);
-               } else if (g_strcmp0(key, "Privacy") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       if (str != NULL)
-                               g_strlcpy(service->ipv6.privacy, str, IPV6_MAX_PRIVACY_LEN);
-               }
-       }
-       g_variant_iter_free(iter);
-
-}
-static inline void __get_conf_ipv6(connman_service_s *service, GVariant *value)
-{
-       GVariantIter *iter = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-       const gchar *str = NULL;
-
-       g_variant_get(value, "a{sv}", &iter);
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
-               if (g_strcmp0(key, "Method") == 0) {
-                       __get_ipv6_method(var, service);
-
-               } else if (g_strcmp0(key, "Address") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       inet_pton(AF_INET6, str, &service->ipv6.address);
-               } else if (g_strcmp0(key, "PrefixLength") == 0) {
-                       service->ipv6.prefix_length = g_variant_get_byte(var);
-               } else if (g_strcmp0(key, "Gateway") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       inet_pton(AF_INET6, str, &service->ipv6.gateway);
-               } else if (g_strcmp0(key, "Privacy") == 0) {
-                       str = g_variant_get_string(var, NULL);
-
-                       if (str != NULL)
-                               g_strlcpy(service->ipv6.privacy, str, IPV6_MAX_PRIVACY_LEN);
-               }
-       }
-       g_variant_iter_free(iter);
-
-       nm_gdbus_emit_conn_ip_changed(service->obj_path,
-                       __nm_connman_service_get_ip(service));
-}
-
-static inline void __get_proxy_method(const gchar *type, connman_service_s *service)
-{
-       if (g_strcmp0(type, "direct") == 0)
-               service->proxy.method = CONNMAN_PROXY_TYPE_DIRECT;
-       else if (g_strcmp0(type, "auto") == 0)
-               service->proxy.method = CONNMAN_PROXY_TYPE_AUTO;
-       else if (g_strcmp0(type, "manual") == 0)
-               service->proxy.method = CONNMAN_PROXY_TYPE_MANUAL;
-       else
-               service->proxy.method = CONNMAN_PROXY_TYPE_UNKNOWN;
-
-}
-
-static inline void __get_proxy(connman_service_s *service, GVariant *value)
-{
-       GVariantIter *iter = NULL;
-       GVariantIter *iter_inner = NULL;
-       GVariant *var = NULL;
-       const gchar *url = NULL;
-       const gchar *str = NULL;
-       gchar *servers = NULL;
-       gchar *key = NULL;
-
-       g_variant_get(value, "a{sv}", &iter);
-
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
-               if (g_strcmp0(key, "Method") == 0) {
-                       str = g_variant_get_string(var, NULL);
-                       __get_proxy_method(str, service);
-
-               } else if (g_strcmp0(key, "URL") == 0) {
-                       url = g_variant_get_string(var, NULL);
-               } else if (g_strcmp0(key, "Servers") == 0) {
-                       GVariantIter *iter_sub = NULL;
-
-                       g_variant_get(var, "as", &iter_inner);
-                       if (!g_variant_iter_loop(iter_inner, "s", &servers))
-                               NM_LOGI("There was no value");
-                       g_variant_iter_free(iter_sub);
-               }
-       }
-       g_variant_iter_free(iter);
-
-       if (service->proxy.method == CONNMAN_PROXY_TYPE_AUTO && url != NULL)
-               g_strlcpy(service->proxy.addr, url, MAX_PROXY_LEN);
-       else if (service->proxy.method == CONNMAN_PROXY_TYPE_MANUAL && servers != NULL)
-               g_strlcpy(service->proxy.addr, servers, MAX_PROXY_LEN);
-       else {
-               service->proxy.method = CONNMAN_PROXY_TYPE_UNKNOWN;
-               memset(service->proxy.addr, 0, MAX_PROXY_LEN + 1);
-               memset(service->proxy.addr, 0, MAX_PROXY_LEN + 1);
-       }
-
-       if (servers)
-               g_free(servers);
-
-       nm_gdbus_emit_conn_ip_changed(service->obj_path,
-                       __nm_connman_service_get_ip(service));
-
-}
-
-static inline void __get_eth(connman_service_s *service, GVariant *value)
-{
-       GVariantIter *iter = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-
-       g_variant_get(value, "a{sv}", &iter);
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
-               if (g_strcmp0(key, "Interface") == 0) {
-                       const gchar *str = NULL;
-                       str = g_variant_get_string(var, NULL);
-
-                       if (str != NULL)
-                               g_strlcpy(service->eth.interface, str, MAX_DEVICE_NAME_LEN);
-               } else if (g_strcmp0(key, "Address") == 0) {
-                       const gchar *str = NULL;
-                       str = g_variant_get_string(var, NULL);
-
-                       if (str != NULL)
-                               __ws_txt_to_mac(str, service->eth.address);
-               }
-       }
-       g_variant_iter_free(iter);
-}
-
-static inline void __get_mdns(connman_service_s *service, GVariant *value)
-{
-       g_variant_get(value, "b", &(service->mdns));
-}
-
-static inline void __get_conf_mdns(connman_service_s *service, GVariant *value)
-{
-       g_variant_get(value, "b", &(service->configured_mdns));
-}
-
-static void __destroy_service_data(gpointer user_data)
-{
-       connman_service_s *service_data = (connman_service_s *)user_data;
-       __NM_FUNC_ENTER__;
-
-       service_signal_param.subscriber_id = service_data->subscriber_id;
-       nm_gdbus_unsubscribe_signal(&(service_signal_param));
-       nm_gdbus_deregister_conn_iface(service_data->conn_obj_id);
-
-       NM_LOGI("[%s] removed", service_data->name);
-
-       g_free(service_data->name);
-       g_free(service_data);
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline void __get_mode(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-
-       str = g_variant_get_string(value, NULL);
-
-       if (g_strcmp0(str, "managed") == 0)
-               service->priv_info.wlan.mode = CONNMAN_WLAN_MODE_INFRA;
-       else if (g_strcmp0(str, "adhoc") == 0)
-               service->priv_info.wlan.mode = CONNMAN_WLAN_MODE_ADHOC;
-       else if (g_strcmp0(str, "gprs") == 0)
-               service->priv_info.cell.type = CONNMAN_PDP_TYPE_GPRS;
-       else if (g_strcmp0(str, "edge") == 0)
-               service->priv_info.cell.type = CONNMAN_PDP_TYPE_EDGE;
-       else if (g_strcmp0(str, "utms") == 0)
-               service->priv_info.cell.type = CONNMAN_PDP_TYPE_UMTS;
-}
-
-static inline void __get_setup_required(connman_service_s *service, GVariant *value)
-{
-       service->priv_info.cell.setup_required = g_variant_get_boolean(value);
-}
-
-static inline void __get_security(connman_service_s *service, GVariant *value)
-{
-       GVariantIter *iter = NULL;
-       gchar *str = NULL;
-
-       g_variant_get(value, "as", &iter);
-       while (g_variant_iter_loop(iter, "s", &str)) {
-               if (g_strcmp0(str, "none") == 0 &&
-                       service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_NONE)
-                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_NONE;
-               else if (g_strcmp0(str, "wep") == 0 &&
-                                service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_WEP)
-                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_WEP;
-               else if (g_strcmp0(str, "psk") == 0 &&
-                                service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
-                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
-               else if (g_strcmp0(str, "ft_psk") == 0 &&
-                       service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_WPA_FT_PSK)
-                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_WPA_FT_PSK;
-               else if (g_strcmp0(str, "ieee8021x") == 0 &&
-                                service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_IEEE8021X)
-                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_IEEE8021X;
-               else if (g_strcmp0(str, "wpa") == 0 &&
-                                service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
-                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
-               else if (g_strcmp0(str, "rsn") == 0 &&
-                                service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
-                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_WPA2_PSK;
-               else if (g_strcmp0(str, "wps") == 0)
-                       service->priv_info.wlan.sec_info.wps_support = TRUE;
-               else if (service->priv_info.wlan.sec_info.sec_mode < WLAN_SEC_MODE_NONE)
-                       service->priv_info.wlan.sec_info.sec_mode = WLAN_SEC_MODE_NONE;
-       }
-
-       g_variant_iter_free(iter);
-}
-
-static inline void __get_enc_mode(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-       str = g_variant_get_string(value, NULL);
-
-       if (g_strcmp0(str, "none") == 0)
-               service->priv_info.wlan.sec_info.enc_mode = WLAN_ENC_MODE_NONE;
-       else if (g_strcmp0(str, "wep") == 0)
-               service->priv_info.wlan.sec_info.enc_mode = WLAN_ENC_MODE_WEP;
-       else if (g_strcmp0(str, "tkip") == 0)
-               service->priv_info.wlan.sec_info.enc_mode = WLAN_ENC_MODE_TKIP;
-       else if (g_strcmp0(str, "aes") == 0)
-               service->priv_info.wlan.sec_info.enc_mode = WLAN_ENC_MODE_AES;
-       else if (g_strcmp0(str, "mixed") == 0)
-               service->priv_info.wlan.sec_info.enc_mode = WLAN_ENC_MODE_TKIP_AES_MIXED;
-}
-
-static inline void __get_passpoint(connman_service_s *service, GVariant *value)
-{
-       service->priv_info.wlan.passpoint = g_variant_get_boolean(value);
-}
-
-static inline void __get_passphrase(connman_service_s *service, GVariant *value)
-{
-       wlan_sec_info_s *security_info = &(service->priv_info.wlan.sec_info);
-       const gchar *str = NULL;
-
-       str = g_variant_get_string(value, NULL);
-
-       if (security_info->sec_mode == WLAN_SEC_MODE_WEP && str != NULL)
-               g_strlcpy(security_info->auth_info.wep.wepKey,
-                               str, WLAN_MAX_WEP_KEY_LEN + 1);
-       else if ((security_info->sec_mode == WLAN_SEC_MODE_WPA_PSK ||
-                               security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK) &&
-                       str != NULL)
-               g_strlcpy(security_info->auth_info.psk.pskKey,
-                               str, WLAN_MAX_PSK_PASSPHRASE_LEN+1);
-}
-
-static inline void __get_passpharase_required(connman_service_s *service, GVariant *value)
-{
-       service->priv_info.wlan.passphrase_required = g_variant_get_boolean(value);
-}
-
-
-static inline void __get_bssid(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-
-       str = g_variant_get_string(value, NULL);
-
-       if (str != NULL)
-               g_strlcpy(service->priv_info.wlan.bssid, str, WLAN_BSSID_LEN + 1);
-}
-
-static inline void __get_max_rate(connman_service_s *service, GVariant *value)
-{
-       service->priv_info.wlan.max_rate = g_variant_get_uint32(value);
-}
-
-static inline void __get_frequency(connman_service_s *service, GVariant *value)
-{
-       service->priv_info.wlan.frequency = (guint)g_variant_get_uint16(value);
-}
-
-static inline wlan_eap_type_e __convert_eap_type_from_string(const char *eap_type)
-{
-       if (eap_type == NULL)
-               return WLAN_SEC_EAP_TYPE_PEAP;
-       else if (g_strcmp0(eap_type, "peap") == 0)
-               return WLAN_SEC_EAP_TYPE_PEAP;
-       else if (g_strcmp0(eap_type, "tls") == 0)
-               return WLAN_SEC_EAP_TYPE_TLS;
-       else if (g_strcmp0(eap_type, "ttls") == 0)
-               return WLAN_SEC_EAP_TYPE_TTLS;
-       else if (g_strcmp0(eap_type, "sim") == 0)
-               return WLAN_SEC_EAP_TYPE_SIM;
-       else if (g_strcmp0(eap_type, "aka") == 0)
-               return WLAN_SEC_EAP_TYPE_AKA;
-       else
-               return WLAN_SEC_EAP_TYPE_PEAP;
-}
-
-static inline wlan_eap_auth_type_e __convert_eap_auth_from_string(const char *eap_auth)
-{
-       if (eap_auth == NULL)
-               return WLAN_SEC_EAP_AUTH_NONE;
-       else if (g_strcmp0(eap_auth, "NONE") == 0)
-               return WLAN_SEC_EAP_AUTH_NONE;
-       else if (g_strcmp0(eap_auth, "PAP") == 0)
-               return WLAN_SEC_EAP_AUTH_PAP;
-       else if (g_strcmp0(eap_auth, "MSCHAP") == 0)
-               return WLAN_SEC_EAP_AUTH_MSCHAP;
-       else if (g_strcmp0(eap_auth, "MSCHAPV2") == 0)
-               return WLAN_SEC_EAP_AUTH_MSCHAPV2;
-       else if (g_strcmp0(eap_auth, "GTC") == 0)
-               return WLAN_SEC_EAP_AUTH_GTC;
-       else if (g_strcmp0(eap_auth, "MD5") == 0)
-               return WLAN_SEC_EAP_AUTH_MD5;
-       else
-               return WLAN_SEC_EAP_AUTH_NONE;
-}
-
-static inline void __get_eap(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-
-       str = g_variant_get_string(value, NULL);
-
-       if (str != NULL)
-               service->priv_info.wlan.sec_info.auth_info.eap.eap_type =
-                               __convert_eap_type_from_string(str);
-}
-
-static inline void __get_phase2(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-
-       str = g_variant_get_string(value, NULL);
-
-       if (str != NULL)
-               service->priv_info.wlan.sec_info.auth_info.eap.eap_auth =
-                               __convert_eap_auth_from_string(str);
-}
-
-static inline void __get_identity(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-
-       str = g_variant_get_string(value, NULL);
-
-       if (str != NULL)
-               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.username,
-                               str, WLAN_USERNAME_LEN + 1);
-}
-
-static inline void __get_password(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-
-       str = g_variant_get_string(value, NULL);
-
-       if (str != NULL)
-               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.password,
-                               str, WLAN_PASSWORD_LEN + 1);
-}
-
-static inline void __get_ca_cert(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-
-       str = g_variant_get_string(value, NULL);
-
-       if (str != NULL)
-               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.ca_cert_filename,
-                               str, WLAN_CA_CERT_FILENAME_LEN + 1);
-}
-
-static inline void __get_client_cert(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-
-       str = g_variant_get_string(value, NULL);
-
-       if (str != NULL)
-               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.client_cert_filename,
-                               str, WLAN_CLIENT_CERT_FILENAME_LEN + 1);
-}
-
-static inline void __get_private_key(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-
-       str = g_variant_get_string(value, NULL);
-
-       if (str != NULL)
-               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.private_key_filename,
-                               str, WLAN_PRIVATE_KEY_FILENAME_LEN + 1);
-}
-
-static inline void __get_private_key_passphrase(connman_service_s *service, GVariant *value)
-{
-       const gchar *str = NULL;
-
-       str = g_variant_get_string(value, NULL);
-
-       if (str != NULL)
-               g_strlcpy(service->priv_info.wlan.sec_info.auth_info.eap.private_key_passwd,
-                               str, WLAN_PRIVATE_KEY_PASSWD_LEN + 1);
-}
-
-static inline void __get_keymgmt(connman_service_s *service, GVariant *value)
-{
-       service->priv_info.wlan.sec_info.keymgmt = g_variant_get_uint32(value);
-}
-
-static inline void __get_reason(connman_service_s *service, GVariant *value)
-{
-       service->priv_info.wlan.reason = g_variant_get_int32(value);
-}
-
-static inline void __get_assoc_status(connman_service_s *service, GVariant *value)
-{
-       service->priv_info.wlan.assoc_status = g_variant_get_int32(value);
-}
-
-static void __service_get_property(connman_service_s *service,
-               const gchar *key,
-               GVariant *value)
-{
-       if (g_strcmp0(key, "State") == 0)
-               __get_state(service, value);
-       else if (g_strcmp0(key, "StateIPv6") == 0)
-               __get_state_ipv6(service, value);
-       else if (g_strcmp0(key, "Error") == 0)
-               __get_error(service, value);
-       else if (g_strcmp0(key, "Name") == 0)
-               __get_name(service, value);
-       else if (g_strcmp0(key, "Type") == 0)
-               __get_type(service, value);
-       else if (g_strcmp0(key, "Security") == 0)
-               __get_security(service, value);
-       else if (g_strcmp0(key, "Strength") == 0)
-               __get_strength(service, value);
-       else if (g_strcmp0(key, "Favorite") == 0)
-               __get_favorite(service, value);
-       else if (g_strcmp0(key, "Immutable") == 0)
-               __get_immutable(service, value);
-       else if (g_strcmp0(key, "AutoConnect") == 0)
-               __get_auto_connect(service, value);
-       else if (g_strcmp0(key, "Roaming") == 0)
-               __get_roaming(service, value);
-       else if (g_strcmp0(key, "Ethernet") == 0)
-               __get_eth(service, value);
-       else if (g_strcmp0(key, "IPv4") == 0)
-               __get_ip(service, value);
-       else if (g_strcmp0(key, "IPv4.Configuration") == 0)
-               __get_conf_ip(service, value);
-       else if (g_strcmp0(key, "IPv6") == 0)
-               __get_ipv6(service, value);
-       else if (g_strcmp0(key, "IPv6.Configuration") == 0)
-               __get_conf_ipv6(service, value);
-       else if (g_strcmp0(key, "Nameservers") == 0)
-               __get_name_servers(service, value);
-       else if (g_strcmp0(key, "Nameservers.Configuration") == 0)
-               __get_conf_name_servers(service, value);
-       else if (g_strcmp0(key, "Proxy") == 0)
-               __get_proxy(service, value);
-       else if (g_strcmp0(key, "Proxy.Configuration") == 0)
-               __get_proxy(service, value);
-       else if (g_strcmp0(key, "mDNS") == 0)
-               __get_mdns(service, value);
-       else if (g_strcmp0(key, "mDNS.Configuration") == 0)
-               __get_conf_mdns(service, value);
-
-/* Tizen extension */
-       else if (g_strcmp0(key, "Mode") == 0)
-               __get_mode(service, value);
-       else if (g_strcmp0(key, "SetupRequired") == 0)
-               __get_setup_required(service, value);
-       else if (g_strcmp0(key, "EncryptionMode") == 0)
-               __get_enc_mode(service, value);
-       else if (g_strcmp0(key, "Passpoint") == 0)
-               __get_passpoint(service, value);
-       else if (g_strcmp0(key, "Passphrase") == 0)
-               __get_passphrase(service, value);
-       else if (g_strcmp0(key, "PassphraseRequired") == 0)
-               __get_passpharase_required(service, value);
-       else if (g_strcmp0(key, "BSSID") == 0)
-               __get_bssid(service, value);
-       else if (g_strcmp0(key, "MaxRate") == 0)
-               __get_max_rate(service, value);
-       else if (g_strcmp0(key, "Frequency") == 0)
-               __get_frequency(service, value);
-       else if (g_strcmp0(key, "EAP") == 0)
-               __get_eap(service, value);
-       else if (g_strcmp0(key, "Phase2") == 0)
-               __get_phase2(service, value);
-       else if (g_strcmp0(key, "Identity") == 0)
-               __get_identity(service, value);
-       else if (g_strcmp0(key, "Password") == 0)
-               __get_password(service, value);
-       else if (g_strcmp0(key, "CACertFile") == 0)
-               __get_ca_cert(service, value);
-       else if (g_strcmp0(key, "ClientCertFile") == 0)
-               __get_client_cert(service, value);
-       else if (g_strcmp0(key, "PrivateKeyFile") == 0)
-               __get_private_key(service, value);
-       else if (g_strcmp0(key, "PrivateKeyPassphrase") == 0)
-               __get_private_key_passphrase(service, value);
-       else if (g_strcmp0(key, "Keymgmt") == 0)
-               __get_keymgmt(service, value);
-       else if (g_strcmp0(key, "DisconnectReason") == 0)
-               __get_reason(service, value);
-       else if (g_strcmp0(key, "AssocStatusCode") == 0)
-               __get_assoc_status(service, value);
-}
-
-static void __service_property_changed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       gchar *key = NULL;
-       GVariant *value = NULL;
-       connman_service_s *service = NULL;
-
-       __NM_FUNC_ENTER__;
-       service = g_hash_table_lookup(service_tbl, object_path);
-       if (!service) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("Service not found");
-               return;
-       }
-       g_variant_get(parameters, "(&sv)", &key, &value);
-
-       if (key)
-               __service_get_property(service, key, value);
-
-       NM_LOGI("[%s] property changed", object_path);
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __add_wifi_priv_info(connman_service_s *service)
-{
-       /* TODO: implement */
-       return;
-}
-
-static inline void __add_cell_priv_info(connman_service_s *service)
-{
-       nm_telephony_profile_s telephony_info = {0,};
-       int ret = 0;
-       __NM_FUNC_ENTER__;
-
-       if (!service)
-               return;
-
-       ret = nm_telephony_get_pdp_profile(service->name, &telephony_info);
-       if (ret < 0)
-               NM_LOGI("get pdp profile failed");
-       else
-               memcpy(&(service->priv_info.cell),
-                               &telephony_info,
-                               sizeof(nm_telephony_profile_s));
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline void __add_priv_info(connman_service_s *service)
-{
-       if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR)
-               __add_cell_priv_info(service);
-       else if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
-               __add_wifi_priv_info(service);
-
-       return;
-}
-
-static inline int __register_service_obj(gchar *path,  connman_service_s *service)
-{
-       int ret = 0;
-       /* TODO How to create Object path? */
-       g_snprintf(service->obj_path, DBUS_OBJECT_PATH_MAX, "%s/%p", NM_CONN_OBJ, service);
-
-       ret = nm_gdbus_register_conn_iface(service->obj_path,
-                       &(service->conn_obj_id),
-                       service);
-       if (ret != 0)
-               return -1;
-
-       return 0;
-}
-
-static inline void __get_service_data(gchar *path, connman_service_s **service, GVariantBuilder *added)
-{
-       connman_service_s *ret = NULL;
-
-       ret = g_hash_table_lookup(service_tbl, path);
-       if (ret) {
-               *service = ret;
-               return;
-       }
-
-       ret = (connman_service_s *)g_try_malloc0(sizeof(connman_service_s));
-       if (!ret) {
-               NM_LOGI("Error! Failed to allocate service");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       if (__register_service_obj(path, ret) != 0) {
-               g_free(ret);
-               NM_LOGI("Error! Failed to register service object");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       if (!g_hash_table_insert(service_tbl, g_strdup(path), ret)) {
-               g_free(ret);
-               NM_LOGI("Error! Failed to insert service");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       g_variant_builder_add(added,
-                             "o",
-                             ret->obj_path);
-
-       *service = ret;
-}
-
-static inline void __subscribe_connman_service_signal(gchar *path, connman_service_s *service)
-{
-       int ret = 0;
-
-       service_signal_param.object_path = path;
-       ret = nm_gdbus_subscribe_signal(&(service_signal_param));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               NM_LOGI("Error! Failed to subscribe signal");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       service->subscriber_id = service_signal_param.subscriber_id;
-       NM_LOGI("Subscribe [%s] signal", path);
-}
-
-void nm_connman_service_add(gchar *path, GVariantIter *iter, GVariantBuilder *added)
-{
-       GVariant *value = NULL;
-       connman_service_s *service = NULL;
-       gchar *key = NULL;
-
-       __NM_FUNC_ENTER__;
-
-       if (!path || ! iter) {
-               NM_LOGI("NULL path or iter");
-               return;
-       }
-
-       __get_service_data(path, &service, added);
-       if (!service) {
-               NM_LOGI("Failed to get service");
-               return;
-       }
-
-       while (g_variant_iter_loop(iter, "{sv}", &key, &value))
-               __service_get_property(service, key, value);
-
-       __add_priv_info(service);
-
-       if (service->subscriber_id == 0)
-               __subscribe_connman_service_signal(path, service);
-       else
-               NM_LOGI("[%s] changed", path);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-void nm_connman_service_remove(gchar *path, GVariantBuilder *removed)
-{
-       connman_service_s *service = NULL;
-
-       __NM_FUNC_ENTER__;
-
-       if (!path) {
-               NM_LOGI("NULL path");
-               return;
-       }
-
-       service = g_hash_table_lookup(service_tbl, path);
-       if (!service) {
-               return;
-       }
-
-       g_variant_builder_add(removed,
-                             "o",
-                                 service->obj_path);
-
-       if (!g_hash_table_remove(service_tbl, path)) {
-               NM_LOGI("service not found");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static GVariant *__nm_connman_service_get_id(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       NM_LOGI("get id");
-
-       ret = g_variant_new_string(service->name);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_get_name(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       NM_LOGI("get name");
-
-       ret = g_variant_new_string(service->name);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_get_interface(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       NM_LOGI("get interface");
-
-       ret = g_variant_new_string(service->eth.interface);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_get_type(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       NM_LOGI("get type");
-
-       ret = g_variant_new_string(conn_type[service->type].str);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_get_iface_name(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       NM_LOGI("get iface name");
-
-       ret = g_variant_new_string(service->name);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_get_ipv4_state(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       NM_LOGI("get iface ipv4 state");
-
-       ret = g_variant_new_string(conn_state[service->state].str);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_get_ipv6_state(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       NM_LOGI("get iface ipv6 state");
-
-       ret = g_variant_new_string(conn_state[service->state_ipv6].str);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_ipv4_to_var(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-       GVariantBuilder *builder = NULL;
-       char ip_str[INET_ADDRSTRLEN] = {0,};
-       char netmask_str[INET_ADDRSTRLEN] = {0,};
-       char gateway_str[INET_ADDRSTRLEN] = {0,};
-       char dhcp_server_ip_str[INET_ADDRSTRLEN] = {0,};
-
-       NM_LOGI("get ipv4\n");
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "IpConfigType",
-                             g_variant_new("s", conn_ip_config[service->ip.method].str));
-
-       inet_ntop(AF_INET, &(service->ip.address), ip_str, INET_ADDRSTRLEN);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "IpAddress",
-                             g_variant_new("s", ip_str));
-
-       inet_ntop(AF_INET, &(service->ip.netmask), netmask_str, INET_ADDRSTRLEN);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "SubnetMask",
-                             g_variant_new("s", netmask_str));
-
-       inet_ntop(AF_INET, &(service->ip.gateway), gateway_str, INET_ADDRSTRLEN);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Gateway",
-                             g_variant_new("s", gateway_str));
-
-       inet_ntop(AF_INET, &(service->ip.dhcp_server_ip),
-                       dhcp_server_ip_str,
-                       INET_ADDRSTRLEN);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "DhcpServer",
-                             g_variant_new("s", gateway_str));
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "DhcpLeaseDuration",
-                             g_variant_new("t", service->ip.dhcp_lease_duration));
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "ProxyType",
-                             g_variant_new("s", conn_proxy_type[service->proxy.method].str));
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "ProxyAddress",
-                             g_variant_new("s", service->proxy.addr));
-
-       ret = g_variant_new("a{sv}", builder);
-       g_variant_builder_unref(builder);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_ipv6_to_var(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-       GVariantBuilder *builder = NULL;
-       char ip_str[INET6_ADDRSTRLEN] = {0,};
-       char gateway_str[INET6_ADDRSTRLEN] = {0,};
-
-       NM_LOGI("get ipv6");
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "IpConfigType",
-                             g_variant_new("s", conn_ip_config[service->ipv6.method].str));
-
-       inet_ntop(AF_INET6, &(service->ipv6.address), ip_str, INET6_ADDRSTRLEN);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "IpAddress",
-                             g_variant_new("s", ip_str));
-
-       inet_ntop(AF_INET6, &(service->ipv6.gateway), gateway_str, INET6_ADDRSTRLEN);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Gateway",
-                             g_variant_new("s", gateway_str));
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "PrefixLength",
-                             g_variant_new("i", service->ipv6.prefix_length));
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Privacy",
-                             g_variant_new("s", service->ipv6.privacy));
-
-       ret = g_variant_new("a{sv}", builder);
-       g_variant_builder_unref(builder);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_get_ip(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-       GVariantBuilder *builder = NULL;
-
-       NM_LOGI("get ip");
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       if (service->ip.method != CONNMAN_IPCONFIG_METHOD_UNKNOWN)
-               g_variant_builder_add(builder,
-                                     "{sv}",
-                                     "Ipv4",
-                                         __nm_connman_service_ipv4_to_var(service));
-
-       if (service->ipv6.method != CONNMAN_IPCONFIG_METHOD_UNKNOWN)
-               g_variant_builder_add(builder,
-                                     "{sv}",
-                                     "Ipv6",
-                                         __nm_connman_service_ipv6_to_var(service));
-
-       ret = g_variant_new("a{sv}", builder);
-       g_variant_builder_unref(builder);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_ipv4_dns_to_var(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-       GVariantBuilder *builder = NULL;
-       GVariantBuilder *dns_builder = NULL;
-       gchar ip_str[INET_ADDRSTRLEN] = {0,};
-       int cnt = 0;
-
-       NM_LOGI("get ipv4 dns");
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "ConfigType",
-                             g_variant_new("s", conn_dns_config[service->dns_conf_type].str));
-
-       dns_builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
-       for (cnt = 0; cnt < service->dns_cnt; cnt++) {
-               inet_ntop(AF_INET, &(service->dns_addr[cnt].addr.ip), ip_str, INET_ADDRSTRLEN);
-               g_variant_builder_add(dns_builder, "s", ip_str);
-       }
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Ipv4",
-                             g_variant_new("as", dns_builder));
-       g_variant_builder_unref(dns_builder);
-
-       ret = g_variant_new("a{sv}", builder);
-       g_variant_builder_unref(builder);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_ipv6_dns_to_var(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-       GVariantBuilder *builder = NULL;
-       GVariantBuilder *dns_builder = NULL;
-       gchar ip_str[INET6_ADDRSTRLEN] = {0,};
-       int cnt = 0;
-
-       NM_LOGI("get ipv6 dns");
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "ConfigType",
-                             g_variant_new("s", conn_dns_config[service->dns_conf_type_v6].str));
-
-       dns_builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
-       for (cnt = 0; cnt < service->dns_cnt_v6; cnt++) {
-               inet_ntop(AF_INET6, &(service->dns_addr_v6[cnt].addr.ipv6), ip_str, INET_ADDRSTRLEN);
-               g_variant_builder_add(dns_builder, "s", ip_str);
-       }
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Ipv6",
-                             g_variant_new("as", dns_builder));
-       g_variant_builder_unref(dns_builder);
-
-       ret = g_variant_new("a{sv}", builder);
-       g_variant_builder_unref(builder);
-
-       return ret;
-}
-
-static GVariant *__nm_connman_service_get_dns(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-       GVariantBuilder *builder = NULL;
-
-       NM_LOGI("get dns");
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       if (service->dns_conf_type != CONNMAN_DNS_CONFIG_TYPE_UNKNOWN)
-               g_variant_builder_add(builder,
-                                     "{sv}",
-                                     "DnsIpv4",
-                                         __nm_connman_service_ipv4_dns_to_var(service));
-
-       if (service->dns_conf_type_v6 != CONNMAN_IPCONFIG_METHOD_UNKNOWN)
-               g_variant_builder_add(builder,
-                                     "{sv}",
-                                     "DnsIpv6",
-                                         __nm_connman_service_ipv6_dns_to_var(service));
-
-       ret = g_variant_new("a{sv}", builder);
-       g_variant_builder_unref(builder);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_essid(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_string(service->priv_info.wlan.essid);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_bssid(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_string(service->priv_info.wlan.bssid);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_rssi(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_byte(service->strength);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_frequency(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_uint32(service->priv_info.wlan.frequency);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_max_speed(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_uint32(service->priv_info.wlan.max_rate);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_is_favorite(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_boolean(service->favorite);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_is_passpoint(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_boolean(service->priv_info.wlan.passpoint);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_sec_type(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_string(conn_sec_type[service->priv_info.wlan.sec_info.sec_mode].str);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_enc_type(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_string(conn_enc_type[service->priv_info.wlan.sec_info.enc_mode].str);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_is_pass_req(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_boolean(service->priv_info.wlan.passphrase_required);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_is_wpa_sup(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_boolean(service->priv_info.wlan.sec_info.wps_support);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_eap_pass(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_string(service->priv_info.wlan.sec_info.auth_info.eap.username);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_ca_cert(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_string(service->priv_info.wlan.sec_info.auth_info.eap.ca_cert_filename);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_client_cert(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_string(service->priv_info.wlan.sec_info.auth_info.eap.client_cert_filename);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_priv_key(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_string(service->priv_info.wlan.sec_info.auth_info.eap.private_key_filename);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_eap_type(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_string(conn_eap_type[service->priv_info.wlan.sec_info.auth_info.eap.eap_type].str);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_eap_auth_type(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_string(conn_eap_auth_type[service->priv_info.wlan.sec_info.auth_info.eap.eap_auth].str);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_reason(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_int32(service->priv_info.wlan.reason);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_get_assoc_status(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-
-       ret = g_variant_new_int32(service->priv_info.wlan.assoc_status);
-
-       return ret;
-}
-
-static inline gboolean __is_eap_pass_exist(connman_service_s *service)
-{
-       return (service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
-                       (service->priv_info.wlan.sec_info.auth_info.eap.eap_type == WLAN_SEC_EAP_TYPE_PEAP ||
-                                       service->priv_info.wlan.sec_info.auth_info.eap.eap_type == WLAN_SEC_EAP_TYPE_TTLS)
-                                       && (strlen(service->priv_info.wlan.sec_info.auth_info.eap.username) > 0));
-}
-
-static inline gboolean __is_eap_ca_cert_exist(connman_service_s *service)
-{
-       return ((service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
-                       service->priv_info.wlan.sec_info.auth_info.eap.eap_type == WLAN_SEC_EAP_TYPE_TLS) &&
-                       (strlen(service->priv_info.wlan.sec_info.auth_info.eap.ca_cert_filename) > 0));
-
-}
-
-static inline gboolean __is_eap_client_cert_exist(connman_service_s *service)
-{
-       return ((service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
-                       service->priv_info.wlan.sec_info.auth_info.eap.eap_type == WLAN_SEC_EAP_TYPE_TLS) &&
-                       (strlen(service->priv_info.wlan.sec_info.auth_info.eap.client_cert_filename) > 0));
-
-}
-
-static inline gboolean __is_eap_priv_key_exist(connman_service_s *service)
-{
-       return ((service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
-                       service->priv_info.wlan.sec_info.auth_info.eap.eap_type == WLAN_SEC_EAP_TYPE_TLS) &&
-                       (strlen(service->priv_info.wlan.sec_info.auth_info.eap.private_key_filename) > 0));
-
-}
-
-static inline GVariant * __nm_connman_service_get_wifi_info(connman_service_s *service)
-{
-       GVariant *ret = NULL;
-       GVariantBuilder *builder = NULL;
-
-       NM_LOGI("get Wi-Fi info");
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       if (strlen(service->priv_info.wlan.essid) != 0)
-               g_variant_builder_add(builder,
-                               "{sv}",
-                               "Essid",
-                               __nm_connman_service_get_essid(service));
-
-       if (strlen(service->priv_info.wlan.bssid) != 0)
-               g_variant_builder_add(builder,
-                               "{sv}",
-                               "Bssid",
-                               __nm_connman_service_get_bssid(service));
-
-       g_variant_builder_add(builder,
-                       "{sv}",
-                       "Rssi",
-                       __nm_connman_service_get_rssi(service));
-
-       g_variant_builder_add(builder,
-                       "{sv}",
-                       "Frequency",
-                       __nm_connman_service_get_frequency(service));
-
-       g_variant_builder_add(builder,
-                       "{sv}",
-                       "MaxSpeed",
-                       __nm_connman_service_get_max_speed(service));
-
-       g_variant_builder_add(builder,
-                       "{sv}",
-                       "IsFavorite",
-                       __nm_connman_service_get_is_favorite(service));
-
-       g_variant_builder_add(builder,
-                       "{sv}",
-                       "IsPasspoint",
-                       __nm_connman_service_get_is_passpoint(service));
-
-       g_variant_builder_add(builder,
-                       "{sv}",
-                       "SecurityType",
-                       __nm_connman_service_get_sec_type(service));
-
-       g_variant_builder_add(builder,
-                       "{sv}",
-                       "EncrytionType",
-                       __nm_connman_service_get_enc_type(service));
-
-       g_variant_builder_add(builder,
-                       "{sv}",
-                       "IsPassphraseRequired",
-                       __nm_connman_service_get_is_pass_req(service));
-
-       g_variant_builder_add(builder,
-                       "{sv}",
-                       "IsWpaSupported",
-                       __nm_connman_service_get_is_wpa_sup(service));
-
-       if (__is_eap_pass_exist(service))
-               g_variant_builder_add(builder,
-                               "{sv}",
-                               "EapPassphrase",
-                               __nm_connman_service_get_eap_pass(service));
-
-       if (__is_eap_ca_cert_exist(service))
-               g_variant_builder_add(builder,
-                               "{sv}",
-                               "CaCert",
-                               __nm_connman_service_get_ca_cert(service));
-
-       if (__is_eap_client_cert_exist(service))
-               g_variant_builder_add(builder,
-                               "{sv}",
-                               "ClientCert",
-                               __nm_connman_service_get_client_cert(service));
-
-       if (__is_eap_priv_key_exist(service))
-               g_variant_builder_add(builder,
-                               "{sv}",
-                               "PrivateKey",
-                               __nm_connman_service_get_priv_key(service));
-
-       if (service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
-                       service->priv_info.wlan.sec_info.auth_info.eap.eap_type != 0)
-                       g_variant_builder_add(builder,
-                                       "{sv}",
-                                       "EapType",
-                                       __nm_connman_service_get_eap_type(service));
-
-       if (service->priv_info.wlan.sec_info.sec_mode == WLAN_SEC_MODE_IEEE8021X &&
-                       service->priv_info.wlan.sec_info.auth_info.eap.eap_auth != 0)
-                       g_variant_builder_add(builder,
-                                       "{sv}",
-                                       "EapAuthType",
-                                       __nm_connman_service_get_eap_auth_type(service));
-
-       if (service->priv_info.wlan.reason != 0)
-               g_variant_builder_add(builder,
-                               "{sv}",
-                               "DisconnectReason",
-                               __nm_connman_service_get_reason(service));
-
-       if (service->priv_info.wlan.assoc_status != 0)
-               g_variant_builder_add(builder,
-                               "{sv}",
-                               "AssocStatus",
-                               __nm_connman_service_get_assoc_status(service));
-
-
-       ret = g_variant_new("a{sv}", builder);
-
-       g_variant_builder_unref(builder);
-
-       return ret;
-}
-
-static void __nm_connman_service_get_connections(gpointer key,
-               gpointer value,
-               gpointer user_data)
-{
-       GVariantBuilder *outer = NULL;
-       GVariantBuilder *inner = NULL;
-       connman_service_s *service = NULL;
-       gchar *object_path = NULL;
-
-       outer = (GVariantBuilder *)user_data;
-       service = (connman_service_s *)value;
-       object_path = (gchar *)key;
-
-       NM_LOGI("get [%s]\n", object_path);
-
-       inner = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       if (service->name) {
-               g_variant_builder_add(inner,
-                                         "{sv}",
-                                         "Id",
-                                         __nm_connman_service_get_id(service));
-               g_variant_builder_add(inner,
-                                         "{sv}",
-                                         "Name",
-                                         __nm_connman_service_get_name(service));
-       }
-       g_variant_builder_add(inner,
-                             "{sv}",
-                             "Type",
-                                 __nm_connman_service_get_type(service));
-       g_variant_builder_add(inner,
-                             "{sv}",
-                             "Interface",
-                             __nm_connman_service_get_interface(service));
-       g_variant_builder_add(inner,
-                             "{sv}",
-                             "Ipv4State",
-                                 __nm_connman_service_get_ipv4_state(service));
-       g_variant_builder_add(inner,
-                             "{sv}",
-                             "Ipv6State",
-                                 __nm_connman_service_get_ipv6_state(service));
-
-       g_variant_builder_add(inner,
-                             "{sv}",
-                             "Ip",
-                                 __nm_connman_service_get_ip(service));
-
-       g_variant_builder_add(inner,
-                             "{sv}",
-                             "Dns",
-                                 __nm_connman_service_get_dns(service));
-
-       if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
-               g_variant_builder_add(inner,
-                                     "{sv}",
-                                     "WifiInfo",
-                                         __nm_connman_service_get_wifi_info(service));
-
-       g_variant_builder_add(outer,
-                             "(oa{sv})",
-                             service->obj_path,
-                             inner);
-
-       g_variant_builder_unref(inner);
-}
-
-static inline GVariant *__nm_connman_service_to_asv(connman_service_s *service)
-{
-       GVariantBuilder *builder = NULL;
-       GVariant *ret = NULL;
-
-       if (!service) {
-               NM_LOGI("There's no current conn");
-               return NULL;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       if (service->name) {
-               g_variant_builder_add(builder,
-                                         "{sv}",
-                                         "Id",
-                                         __nm_connman_service_get_id(service));
-               g_variant_builder_add(builder,
-                                         "{sv}",
-                                         "Name",
-                                         __nm_connman_service_get_name(service));
-       }
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Type",
-                             __nm_connman_service_get_type(service));
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Interface",
-                             __nm_connman_service_get_interface(service));
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Ipv4State",
-                                 __nm_connman_service_get_ipv4_state(service));
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Ipv6State",
-                                 __nm_connman_service_get_ipv6_state(service));
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Ip",
-                                 __nm_connman_service_get_ip(service));
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Dns",
-                                 __nm_connman_service_get_dns(service));
-
-       if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
-               g_variant_builder_add(builder,
-                                     "{sv}",
-                                     "WifiInfo",
-                                         __nm_connman_service_get_wifi_info(service));
-
-       ret = g_variant_new("(a{sv})",
-                       builder);
-       g_variant_builder_unref(builder);
-
-       return ret;
-}
-
-static inline GVariant *__nm_connman_service_to_oasv(connman_service_s *service)
-{
-       GVariantBuilder *builder = NULL;
-       GVariant *ret = NULL;
-
-       if (!service) {
-               NM_LOGI("There's no current conn");
-               return NULL;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       if (service->name) {
-               g_variant_builder_add(builder,
-                                         "{sv}",
-                                         "Id",
-                                         __nm_connman_service_get_id(service));
-               g_variant_builder_add(builder,
-                                         "{sv}",
-                                         "Name",
-                                         __nm_connman_service_get_name(service));
-       }
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Type",
-                             __nm_connman_service_get_type(service));
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Interface",
-                             __nm_connman_service_get_interface(service));
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Ipv4State",
-                                 __nm_connman_service_get_ipv4_state(service));
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Ipv6State",
-                                 __nm_connman_service_get_ipv6_state(service));
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Ip",
-                                 __nm_connman_service_get_ip(service));
-
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "Dns",
-                                 __nm_connman_service_get_dns(service));
-
-       if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
-               g_variant_builder_add(builder,
-                                     "{sv}",
-                                     "WifiInfo",
-                                         __nm_connman_service_get_wifi_info(service));
-
-       ret = g_variant_new("(oa{sv})",
-                       service->obj_path,
-                       builder);
-       g_variant_builder_unref(builder);
-
-       return ret;
-}
-
-void nm_connman_service_change(GVariant *parameters)
-{
-       __NM_FUNC_ENTER__;
-       GVariantIter *added = NULL;
-       GVariantIter *removed = NULL;
-       GVariantIter *variants = NULL;
-
-       GVariantBuilder *added_builder = NULL;
-       GVariantBuilder *removed_builder = NULL;
-       GVariant *signal_arg = NULL;
-       gchar *path = NULL;
-
-       added_builder = g_variant_builder_new(G_VARIANT_TYPE("ao"));
-       removed_builder = g_variant_builder_new(G_VARIANT_TYPE("ao"));
-
-       if(!parameters) {
-               NM_LOGI("Empty parameters");
-               return;
-       }
-
-       g_variant_get(parameters, "(a(oa{sv})ao)", &added, &removed);
-
-       /* handle added service */
-       while (g_variant_iter_loop(added, "(oa{sv})", &path, &variants)) {
-
-               if (!path || !variants) {
-                       NM_LOGI("NULL path or variants");
-                       continue;
-               }
-
-               nm_connman_service_add(path, variants, added_builder);
-       }
-
-       g_variant_iter_free(added);
-
-       /* handle removed service */
-       path = NULL;
-       while (g_variant_iter_loop(removed, "o", &path)) {
-
-               if (!path) {
-                       NM_LOGI("NULL path");
-                       continue;
-               }
-
-               nm_connman_service_remove(path, removed_builder);
-       }
-
-       g_variant_iter_free(removed);
-
-       if (g_conn_changed_cb) {
-               signal_arg = g_variant_new("(aoao)", added_builder, removed_builder);
-               g_conn_changed_cb(signal_arg);
-       }
-
-       g_variant_builder_unref(added_builder);
-       g_variant_builder_unref(removed_builder);
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-void nm_connman_service_get_from_reply(GVariant *reply, gpointer user_data)
-{
-       GVariantIter *iter_outer = NULL;
-       GVariantIter *iter_inner = NULL;
-
-       GVariantBuilder *added_builder = NULL;
-       GVariant *signal_arg = NULL;
-       gchar *path = NULL;
-       __NM_FUNC_ENTER__;
-
-       added_builder = g_variant_builder_new(G_VARIANT_TYPE("ao"));
-       g_variant_get(reply, "(a(oa{sv}))", &iter_outer);
-
-       while (g_variant_iter_loop(iter_outer, "(&oa{sv})", &path, &iter_inner)) {
-
-               if (path == NULL || iter_inner == NULL)
-                       continue;
-
-               nm_connman_service_add(path, iter_inner, added_builder);
-       }
-
-       g_variant_iter_free(iter_outer);
-
-
-       if (g_conn_changed_cb) {
-               signal_arg = g_variant_new("(aoao)", added_builder, NULL);
-               g_conn_changed_cb(signal_arg);
-       }
-
-       g_variant_builder_unref(added_builder);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-int nm_connman_get_connection(gpointer user_data, GVariant **connection)
-{
-       connman_service_s *service = NULL;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       if (!user_data)
-               return -1;
-
-       service = (connman_service_s *)user_data;
-       *connection = __nm_connman_service_to_asv(service);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-
-}
-
-int nm_connman_get_current_connection(GVariant **current_conn)
-{
-       GHashTableIter iter;
-       connman_service_s *service = NULL;
-       gpointer key, value;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-
-       g_hash_table_iter_init (&iter, service_tbl);
-       while (g_hash_table_iter_next(&iter, &key, &value)) {
-
-               if (!value)
-                       continue;
-
-               service = (connman_service_s *)value;
-               NM_LOGI("%s", service->name);
-               if (service->state == CONNMAN_SERVICE_STATE_ONLINE ||
-                               service->state == CONNMAN_SERVICE_STATE_READY) {
-                       *current_conn = __nm_connman_service_to_oasv(service);
-               }
-       }
-
-       if ((*current_conn) == NULL) {
-               NM_LOGI("No current connections");
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_NO_CONNECTION;
-       }
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_connman_get_connections(GVariant **connections)
-{
-       GVariantBuilder *builder = NULL;
-       int ret = NM_CONNMAN_ERROR_NONE;
-
-       __NM_FUNC_ENTER__;
-
-       if (g_hash_table_size(service_tbl) == 0) {
-               NM_LOGI("No connections");
-               return NM_CONNMAN_ERROR_NO_CONNECTION;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a(oa{sv})"));
-       g_hash_table_foreach(service_tbl,
-                       __nm_connman_service_get_connections,
-                       builder);
-
-       *connections = g_variant_new("(a(oa{sv}))", builder);
-       g_variant_builder_unref(builder);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-
-int nm_connman_set_conn_error_callback(nm_connman_error_cb cb)
-{
-       int ret = 0;
-
-       if (service_tbl) {
-               g_conn_error_cb = cb;
-       } else {
-               NM_LOGI("Service is not initialized!");
-               ret = -1;
-       }
-
-       return ret;
-}
-
-int nm_connman_unset_conn_error_callback()
-{
-       int ret = 0;
-
-       if (service_tbl) {
-               g_conn_error_cb = NULL;
-       } else {
-               NM_LOGI("Service is not initialized!");
-               ret = -1;
-       }
-
-       return ret;
-}
-
-int nm_connman_set_conn_changed_callback(nm_connman_conn_changed_cb cb)
-{
-       int ret = 0;
-
-       if (service_tbl) {
-               g_conn_changed_cb = cb;
-       } else {
-               NM_LOGI("Service is not initialized!");
-               ret = -1;
-       }
-
-       return ret;
-}
-
-int nm_connman_unset_conn_changed_callback()
-{
-       int ret = 0;
-
-       if (service_tbl) {
-               g_conn_changed_cb = NULL;
-       } else {
-               NM_LOGI("Service is not initialized!");
-               ret = -1;
-       }
-
-       return ret;
-}
-
-int nm_connman_service_init()
-{
-       int ret = NM_CONNMAN_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-       service_tbl = g_hash_table_new_full(g_str_hash,
-                       g_str_equal,
-                       g_free,
-                       __destroy_service_data
-                       );
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_connman_service_deinit()
-{
-       int ret = NM_CONNMAN_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       g_hash_table_remove_all(service_tbl);
-       g_hash_table_unref(service_tbl);
-       service_tbl = NULL;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-connman-tech.c b/src/nm-connman-tech.c
deleted file mode 100644 (file)
index 37f033c..0000000
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling connman technology DBus interface.
- *
- * @file        nm-connman-tech.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <glib.h>
-
-#include "nm-connman.h"
-#include "nm-connman-internal.h"
-#include "nm-gdbus.h"
-#include "nm-daemon-log.h"
-
-#define CONNMAN_TECH_PATH CONNMAN_PATH "/technology"
-
-#define CONNMAN_CELL_TECH_PATH CONNMAN_TECH_PATH "/cellular"
-#define CONNMAN_ETH_TECH_PATH CONNMAN_TECH_PATH "/ethernet"
-#define CONNMAN_WIFI_TECH_PATH CONNMAN_TECH_PATH "/wifi"
-
-typedef struct {
-       /*
-        * False means that the technology is
-        * off (and is available RF-Killed) while True means
-        * that the technology is enabled
-        */
-       gboolean powered;
-
-       /*
-        * If this property is True it means that at least one
-        * service of this technology is in ready state.
-        */
-       gboolean connected;
-
-       /*
-        * Name of this technology.
-        */
-       gchar *name;
-
-       /*
-        * The technology type (for example "ethernet" etc.)
-        */
-       gchar *type;
-
-       /*
-        * This option allows to enable or disable the support
-        * for tethering. When tethering is enabled then the
-        * default service is bridged to all clients connected
-        * through the technology.
-        */
-       gboolean tethering;
-
-       /*
-        * This variable holds the subscriber id which is
-        * subscribing property changed signal of the technology.
-        */
-       guint subscriber_id;
-} connman_tech_s;
-
-nm_connman_tech_changed_cb g_tech_changed_cb = NULL;
-GHashTable *tech_tbl = NULL;
-
-const int __connman_service_type2enum(gchar *type_str)
-{
-       int type = CONNMAN_SERVICE_TYPE_UNKNOWN;
-       if (g_strcmp0(type_str, "system") == 0)
-               type = CONNMAN_SERVICE_TYPE_SYSTEM;
-       else if (g_strcmp0(type_str, "ethernet") == 0)
-               type = CONNMAN_SERVICE_TYPE_ETHERNET;
-       else if (g_strcmp0(type_str, "wifi") == 0)
-               type = CONNMAN_SERVICE_TYPE_WIFI;
-       else if (g_strcmp0(type_str, "bluetooth") == 0)
-               type = CONNMAN_SERVICE_TYPE_BLUETOOTH;
-       else if (g_strcmp0(type_str, "cellular") == 0)
-               type = CONNMAN_SERVICE_TYPE_CELLULAR;
-       else if (g_strcmp0(type_str, "gps") == 0)
-               type = CONNMAN_SERVICE_TYPE_GPS;
-       else if (g_strcmp0(type_str, "vpn") == 0)
-               type = CONNMAN_SERVICE_TYPE_VPN;
-       else if (g_strcmp0(type_str, "gadget") == 0)
-               type = CONNMAN_SERVICE_TYPE_GADGET;
-       else if (g_strcmp0(type_str, "p2p") == 0)
-               type = CONNMAN_SERVICE_TYPE_P2P;
-
-       return type;
-}
-
-const int __connman_tech_get_state(gboolean powered, gboolean connected)
-{
-       int state = 0;
-       if (!powered && !connected)
-               state = CONNMAN_TECH_STATE_POWER_OFF;
-       else if (powered && !connected)
-               state = CONNMAN_TECH_STATE_POWER_ON;
-       else if (powered && connected)
-               state = CONNMAN_TECH_STATE_CONNECTED;
-       else
-               state = CONNMAN_TECH_STATE_UNKNOWN;
-
-       return state;
-}
-
-static void __tech_property_changed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static signal_param_s tech_signal_param = {
-               .sender = CONNMAN_SERVICE,
-               .interface_name = CONNMAN_TECHNOLOGY_INTERFACE,
-               .member = DBUS_SIGNAL_PROPERTY_CHANGED,
-               .object_path = NULL,
-               .arg0 = NULL,
-               .callback = __tech_property_changed,
-               .subscriber_id  = 0,
-};
-
-static void __destroy_tech_data(gpointer data)
-{
-       connman_tech_s *tech_data = (connman_tech_s *)data;
-       __NM_FUNC_ENTER__;
-
-       tech_signal_param.subscriber_id = tech_data->subscriber_id;
-       nm_gdbus_unsubscribe_signal(&(tech_signal_param));
-       g_free(tech_data->name);
-       g_free(tech_data->type);
-
-       g_free(tech_data);
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void inline __get_powered(GVariant *value, connman_tech_s *tech)
-{
-       g_variant_get(value, "b", &(tech->powered));
-       NM_LOGI("Powered %s", (tech->powered)?"On":"Off");
-}
-
-static void inline __get_connected(GVariant *value, connman_tech_s *tech)
-{
-       g_variant_get(value, "b", &(tech->connected));
-       NM_LOGI("%s", (tech->connected)?"Connected":"Not connected");
-}
-
-static void inline __get_name(GVariant *value, connman_tech_s *tech)
-{
-       const gchar *str = NULL;
-       g_variant_get(value, "&s", &str);
-
-       if (str) {
-               g_free(tech->name);
-               tech->name = g_strdup(str);
-       }
-}
-
-static void inline __get_type(GVariant *value, connman_tech_s *tech)
-{
-       const gchar *str = NULL;
-       g_variant_get(value, "&s", &str);
-
-       if (str) {
-               g_free(tech->type);
-               tech->type = g_strdup(str);
-       }
-}
-
-static void inline __get_tethering(GVariant *value, connman_tech_s *tech)
-{
-       g_variant_get(value, "b", &(tech->tethering));
-}
-
-static void inline __tech_get_property(gchar *key, GVariant *value, connman_tech_s *tech)
-{
-       if (g_strcmp0(key, "Powered") == 0)
-               __get_powered(value, tech);
-       else if (g_strcmp0(key, "Connected") == 0)
-               __get_connected(value, tech);
-       else if (g_strcmp0(key, "Name") == 0)
-               __get_name(value, tech);
-       else if (g_strcmp0(key, "Type") == 0)
-               __get_type(value, tech);
-       else if (g_strcmp0(key, "Tethering") == 0)
-               __get_tethering(value, tech);
-}
-
-static void __tech_property_changed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       gchar *key = NULL;
-       GVariant *value = NULL;
-       connman_tech_s *tech = NULL;
-       int prev_tech_state = 0;
-       int tech_type = 0;
-       int tech_state = 0;
-
-       __NM_FUNC_ENTER__;
-
-       tech = g_hash_table_lookup(tech_tbl, object_path);
-       if (!tech) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("Tech not found");
-               return;
-       }
-       prev_tech_state = __connman_tech_get_state(tech->powered, tech->connected);
-
-       g_variant_get(parameters, "(&sv)", &key, &value);
-
-       if (key)
-               __tech_get_property(key, value, tech);
-
-       tech_state = __connman_tech_get_state(tech->powered, tech->connected);
-       if (g_tech_changed_cb && (tech_state != prev_tech_state)) {
-               tech_type = __connman_service_type2enum(tech->type);
-               NM_LOGI("State changed");
-               NM_LOGI("Notify tech type %d state %d", tech_type, tech_state);
-               g_tech_changed_cb(tech_type, tech_state);
-       }
-
-       __NM_FUNC_EXIT__;
-}
-
-int nm_connman_tech_get_state(connman_service_type_e type,
-               connman_tech_state_e *state)
-{
-       connman_tech_s *tech = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!tech_tbl) {
-               NM_LOGI("Tech is not initialized!");
-               return -1;
-       }
-
-       *state = CONNMAN_TECH_STATE_UNKNOWN;
-
-       /* We can get only three type of tech. Please add more if we need */
-
-       if (type == CONNMAN_SERVICE_TYPE_ETHERNET)
-               tech = g_hash_table_lookup(tech_tbl, CONNMAN_ETH_TECH_PATH);
-       else if (type == CONNMAN_SERVICE_TYPE_WIFI)
-               tech = g_hash_table_lookup(tech_tbl, CONNMAN_WIFI_TECH_PATH);
-       else if (type == CONNMAN_SERVICE_TYPE_CELLULAR)
-               tech = g_hash_table_lookup(tech_tbl, CONNMAN_CELL_TECH_PATH);
-
-       if (tech)
-               *state = __connman_tech_get_state(tech->powered, tech->connected);
-       else
-               *state = CONNMAN_TECH_STATE_UNKNOWN;
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-void nm_connman_tech_add(gchar *path, GVariantIter *iter)
-{
-       GVariant *value = NULL;
-       connman_tech_s *tech = NULL;
-       gchar *key = NULL;
-       gint tech_type = 0;
-       gint tech_state = 0;
-       gint ret = 0;
-
-       __NM_FUNC_ENTER__;
-
-       if (!path)
-               return;
-
-       tech = g_hash_table_lookup(tech_tbl, path);
-       if (!tech) {
-               tech = (connman_tech_s *)g_try_malloc0(sizeof(connman_tech_s));
-               if (!tech) {
-                       NM_LOGI("Error! Failed to allocate tech");
-                       __NM_FUNC_EXIT__;
-                       return;
-               }
-
-               if (!g_hash_table_insert(tech_tbl, g_strdup(path), tech)) {
-                       g_free(tech);
-                       NM_LOGI("Error! Failed to insert tech");
-                       __NM_FUNC_EXIT__;
-                       return;
-               }
-       }
-
-       while (g_variant_iter_loop(iter, "{sv}", &key, &value))
-               __tech_get_property(key, value, tech);
-
-       tech_signal_param.object_path = path;
-       ret = nm_gdbus_subscribe_signal(&(tech_signal_param));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               NM_LOGI("Error! Failed to subscribe signal");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       tech->subscriber_id = tech_signal_param.subscriber_id;
-
-       if (g_tech_changed_cb) {
-               tech_type = __connman_service_type2enum(tech->type);
-               tech_state = __connman_tech_get_state(tech->powered, tech->connected);
-               NM_LOGI("Notify tech type %d state %d", tech_type, tech_state);
-               g_tech_changed_cb(tech_type, tech_state);
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-void nm_connman_tech_remove(GVariant *parameters)
-{
-       __NM_FUNC_ENTER__;
-       connman_tech_s *tech = NULL;
-       gchar *path = NULL;
-       gint tech_type = 0;
-
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(parameters, "(&o)", &path);
-
-       if (!path)
-               return;
-
-       tech = g_hash_table_lookup(tech_tbl, path);
-       if (!tech) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       if (g_tech_changed_cb) {
-               tech_type = __connman_service_type2enum(tech->type);
-               NM_LOGI("Notify tech type %d state %d", tech_type, CONNMAN_TECH_STATE_UNKNOWN);
-               g_tech_changed_cb(tech_type, CONNMAN_TECH_STATE_UNKNOWN);
-       }
-
-       g_hash_table_remove (tech_tbl, path);
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-int nm_connman_set_tech_changed_callback(nm_connman_tech_changed_cb cb)
-{
-       int ret = 0;
-
-       if (tech_tbl) {
-               g_tech_changed_cb = cb;
-       } else {
-               NM_LOGI("Tech is not initialized!");
-               ret = -1;
-       }
-
-       return ret;
-}
-
-int nm_connman_unset_tech_changed_callback()
-{
-       int ret = 0;
-
-       if (tech_tbl) {
-               g_tech_changed_cb = NULL;
-       } else {
-               NM_LOGI("Tech is not initialized!");
-               ret = -1;
-       }
-
-       return ret;
-}
-
-int nm_connman_tech_init()
-{
-       int ret = NM_CONNMAN_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-       tech_tbl = g_hash_table_new_full(g_str_hash,
-                       g_str_equal,
-                       g_free,
-                       __destroy_tech_data
-                       );
-       g_tech_changed_cb = NULL;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_connman_tech_deinit()
-{
-       int ret = NM_CONNMAN_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       g_hash_table_remove_all(tech_tbl);
-        g_hash_table_unref(tech_tbl);
-       tech_tbl = NULL;
-       g_tech_changed_cb = NULL;
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-connman.c b/src/nm-connman.c
deleted file mode 100644 (file)
index 24afb55..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling signal from connman.
- *
- * @file        nm-connman.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-connman.h"
-#include "nm-connman-internal.h"
-
-#define CONNMAN_SIGNAL_TECHNOLOGY_ADDED                "TechnologyAdded"
-#define CONNMAN_SIGNAL_TECHNOLOGY_REMOVED      "TechnologyRemoved"
-#define CONNMAN_SIGNAL_SERVICES_CHANGED                "ServicesChanged"
-
-typedef enum {
-       SIGNAL_MGR_TECH_ADDED,
-       SIGNAL_MGR_TECH_REMOVED,
-       SIGNAL_MGR_SERVICES_CHANGED,
-       SIGNAL_MGR_PROP_CHANGED,
-       SIGNAL_TECH,
-       SIGNAL_SERVICE_PROP_CHANGED,
-       SIGNAL_NAME_OWNER_CHANGED,
-
-} connman_signal_e;
-
-typedef struct {
-       gboolean is_initialized;
-       signal_param_s *params;
-
-} connman_mon_s;
-
-connman_mon_s connman_mon;
-
-
-static void __name_owner_changed_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       gchar *name = NULL;
-       gchar *old = NULL;
-       gchar *new = NULL;
-
-       if (parameters == NULL)
-               return;
-
-       g_variant_get(parameters, "(&s&s&s)", &name, &old, &new);
-
-       if (g_strcmp0(name, CONNMAN_SERVICE) == 0 && *new == '\0') {
-               NM_LOGI("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
-
-       }
-       return;
-}
-
-static signal_param_s signal_param[] = {
-               {
-                               .sender = CONNMAN_SERVICE,
-                               .interface_name = CONNMAN_MANAGER_INTERFACE,
-                               .member = CONNMAN_SIGNAL_TECHNOLOGY_ADDED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = nm_connman_mgr_tech_added,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = CONNMAN_SERVICE,
-                               .interface_name = CONNMAN_MANAGER_INTERFACE,
-                               .member = CONNMAN_SIGNAL_TECHNOLOGY_REMOVED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = nm_connman_mgr_tech_removed,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = CONNMAN_SERVICE,
-                               .interface_name = CONNMAN_MANAGER_INTERFACE,
-                               .member = CONNMAN_SIGNAL_SERVICES_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = nm_connman_mgr_service_changed,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = CONNMAN_SERVICE,
-                               .interface_name = CONNMAN_MANAGER_INTERFACE,
-                               .member = DBUS_SIGNAL_PROPERTY_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = nm_connman_mgr_property_changed,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = CONNMAN_SERVICE,
-                               .interface_name = CONNMAN_TECHNOLOGY_INTERFACE,
-                               .member = NULL,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = NULL /* TODO */,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = CONNMAN_SERVICE,
-                               .interface_name = CONNMAN_SERVICE_INTERFACE,
-                               .member = DBUS_SIGNAL_PROPERTY_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = NULL /* TODO */,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = DBUS_SERVICE_DBUS,
-                               .interface_name = DBUS_INTERFACE_DBUS,
-                               .member = DBUS_SIGNAL_NAME_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = CONNMAN_SERVICE,
-                               .callback = __name_owner_changed_cb,
-                               .subscriber_id  = 0,
-               },
-};
-
-int nm_connman_init()
-{
-       int ret = NM_CONNMAN_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       memset(&connman_mon, 0x00, sizeof(connman_mon));
-       connman_mon.params = signal_param;
-       connman_mon.is_initialized = TRUE;
-
-       ret = nm_gdbus_subscribe_signal(&(connman_mon.params[SIGNAL_MGR_TECH_ADDED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(connman_mon.params[SIGNAL_MGR_TECH_REMOVED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(connman_mon.params[SIGNAL_MGR_SERVICES_CHANGED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(connman_mon.params[SIGNAL_NAME_OWNER_CHANGED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_connman_tech_init();
-       if (ret != NM_CONNMAN_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_TECH_INIT_FAILED;
-       }
-
-       ret = nm_connman_service_init();
-       if (ret != NM_CONNMAN_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_SRV_INIT_FAILED;
-       }
-
-
-       __NM_FUNC_EXIT__;
-       return NM_CONNMAN_ERROR_NONE;
-}
-
-int nm_connman_deinit()
-{
-       int ret = NM_CONNMAN_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!connman_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_NOT_INITIALIZED;
-       }
-
-       nm_gdbus_unsubscribe_signal(&(connman_mon.params[SIGNAL_MGR_TECH_ADDED]));
-       nm_gdbus_unsubscribe_signal(&(connman_mon.params[SIGNAL_MGR_TECH_REMOVED]));
-       nm_gdbus_unsubscribe_signal(&(connman_mon.params[SIGNAL_MGR_SERVICES_CHANGED]));
-       nm_gdbus_unsubscribe_signal(&(connman_mon.params[SIGNAL_NAME_OWNER_CHANGED]));
-
-       ret = nm_connman_tech_deinit();
-       if (ret != NM_CONNMAN_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_TECH_INIT_FAILED;
-       }
-       ret = nm_connman_service_deinit();
-       if (ret != NM_CONNMAN_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_CONNMAN_ERROR_SRV_INIT_FAILED;
-       }
-
-       connman_mon.is_initialized = FALSE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-daemon-main.c b/src/nm-daemon-main.c
deleted file mode 100644 (file)
index 15cceb6..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements Network Monitoring Daemon Main function.
- *
- * @file        nm-daemon-main.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <signal.h>
-#include <unistd.h>
-
-#include <glib.h>
-
-#include "nm-daemon.h"
-#include "nm-daemon-log.h"
-
-static GMainLoop *g_loop = NULL;
-
-static void __signal_handler(int sig)
-{
-       if (sig == SIGHUP) {
-               NM_LOGI("hangup signal catched");
-               g_main_loop_quit(g_loop);
-               return;
-       }
-
-       if (sig == SIGTERM) {
-               NM_LOGI("terminate signal catched");
-               g_main_loop_quit(g_loop);
-               return;
-       }
-}
-
-static void __add_signal_handler()
-{
-       signal(SIGCHLD, SIG_IGN); /* ignore child */
-       signal(SIGTSTP, SIG_IGN); /* ignore tty signals */
-       signal(SIGTTOU, SIG_IGN);
-       signal(SIGTTIN, SIG_IGN);
-       signal(SIGHUP, __signal_handler); /* catch hangup signal */
-       signal(SIGTERM, __signal_handler); /* catch kill signal */
-}
-
-int main(void)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-/*
-       ret = daemon(0, 0);
-       if (ret != 0) {
-               NM_LOGE("daemon function failure");
-               return -1;
-       }
-*/
-       __add_signal_handler();
-
-       g_loop = g_main_loop_new(NULL, FALSE);
-
-       ret = nm_daemon_init();
-       if (ret != 0) {
-               NM_LOGE("init daemon function failure");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       nm_daemon_set_loop(g_loop);
-
-       NM_LOGI("Run network monitoring");
-       g_main_loop_run(g_loop);
-       NM_LOGI("End network monitoring");
-
-       ret = nm_daemon_deinit();
-       if (ret != 0) {
-               NM_LOGE("deinit daemon function failure");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       g_main_loop_unref(g_loop);
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
diff --git a/src/nm-daemon.c b/src/nm-daemon.c
deleted file mode 100644 (file)
index ba4e270..0000000
+++ /dev/null
@@ -1,856 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements Network Monitoring Daemon functions.
- *
- * @file        nm-daemon.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include "nm-gdbus.h"
-#include "nm-dump.h"
-#include "nm-ip-conflict.h"
-#include "nm-iface-mon.h"
-#include "nm-supplicant.h"
-#include "nm-connman.h"
-#include "nm-daemon.h"
-#include "nm-daemon-log.h"
-#include "nm-error.h"
-
-#define IF_NAME_WLAN "wlan0"
-#define IF_NAME_ETH "eth0"
-
-typedef struct{
-       GMainLoop *loop;
-       int congestion_level;
-       int retry_tx_rate;
-       int freq;
-       double channel_interference;
-       gboolean tcpdump_state;
-       nm_ip_conflict_state_e ip_conflict_state;
-       gboolean is_wpasupplicant_enabled;
-       gboolean is_connman_enabled;
-       gboolean is_telephony_enabled;
-       gboolean is_wfd_manager_enabled;
-       gboolean is_mobileap_enabled;
-       gboolean is_stc_manager_enabled;
-} nm_daemon_s;
-
-nm_daemon_s *g_nm_daemon;
-
-void nm_daemon_set_loop(GMainLoop *loop)
-{
-       __NM_FUNC_ENTER__;
-       if (g_nm_daemon)
-               g_nm_daemon->loop = loop;
-       __NM_FUNC_EXIT__;
-}
-
-void nm_daemon_unset_loop()
-{
-       __NM_FUNC_ENTER__;
-       if (g_nm_daemon)
-               g_nm_daemon->loop = NULL;
-       __NM_FUNC_EXIT__;
-}
-
-int nm_daemon_set_tcpdump(gboolean state)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       if (state)
-               ret = nm_dump_start_tcpdump();
-       else
-               ret = nm_dump_stop_tcpdump();
-
-       if (ret == 0)
-               g_nm_daemon->tcpdump_state = state;
-
-       if (ret == NM_DUMP_IN_PROGRESS)
-               ret = NM_DAEMON_ERROR_IN_PROGRESS;
-       else if (ret == NM_DAEMON_ERROR_OPERATION_FAILED)
-               ret = NM_DAEMON_ERROR_OPERATION_FAILED;
-       else if (ret == NM_DUMP_ERROR_NONE)
-               ret = NM_DAEMON_ERROR_NONE;
-       else
-               ret = NM_DAEMON_ERROR_OPERATION_FAILED;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_daemon_get_tcpdump_state(gboolean *state)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_dump_get_tcpdump_state(state);
-
-       if (ret == NM_DUMP_ERROR_NONE)
-               ret = NM_DAEMON_ERROR_NONE;
-       else
-               ret = NM_DAEMON_ERROR_OPERATION_FAILED;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_daemon_get_ip_conflict_detect(gboolean *detect)
-{
-       __NM_FUNC_ENTER__;
-       gboolean detect_eth;
-       gboolean detect_wlan;
-       int ret = 0;
-
-
-       ret = nm_ip_conflict_is_detection_enabled(IF_NAME_ETH, &detect_eth);
-       if (ret != NM_IP_CONFLICT_ERROR_NONE)
-               return NM_DAEMON_ERROR_OPERATION_FAILED;
-
-       ret = nm_ip_conflict_is_detection_enabled(IF_NAME_WLAN, &detect_wlan);
-       if (ret != NM_IP_CONFLICT_ERROR_NONE)
-               return NM_DAEMON_ERROR_OPERATION_FAILED;
-
-       *detect = detect_eth || detect_wlan;
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_daemon_get_ip_conflict_state(gboolean *state)
-{
-       __NM_FUNC_ENTER__;
-       gboolean detect_eth;
-       gboolean detect_wlan;
-       int ret = 0;
-
-       ret = nm_ip_conflict_is_detection_enabled(IF_NAME_ETH, &detect_eth);
-       if (ret != NM_IP_CONFLICT_ERROR_NONE)
-               return NM_DAEMON_ERROR_OPERATION_FAILED;
-
-       ret = nm_ip_conflict_is_detection_enabled(IF_NAME_WLAN, &detect_wlan);
-       if (ret != NM_IP_CONFLICT_ERROR_NONE)
-               return NM_DAEMON_ERROR_OPERATION_FAILED;
-
-       if (!detect_eth && !detect_wlan)
-               *state = IP_CONFLICT_STATE_UNKNOWN;
-       else
-               *state = g_nm_daemon->ip_conflict_state;
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_daemon_get_ethernet_cable_state(gboolean *state)
-{
-       int value = 0;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_iface_mon_get_iface_state(IF_NAME_ETH, &value);
-       if (ret < 0) {
-               NM_LOGI("get iface %s state failed", IF_NAME_ETH);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       *state = value != 0;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_daemon_get_wifi_module_state(gboolean *state)
-{
-       int value = 0;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_iface_mon_get_iface_state(IF_NAME_WLAN, &value);
-       if (ret < 0) {
-               NM_LOGI("get iface %s state failed", IF_NAME_WLAN);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       *state = value != 0;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_daemon_get_congestion_level(int *level)
-{
-       __NM_FUNC_ENTER__;
-       *level = g_nm_daemon->congestion_level;
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_daemon_get_retry_tx_rate(int *rate)
-{
-       __NM_FUNC_ENTER__;
-       *rate = g_nm_daemon->retry_tx_rate;
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_daemon_get_channel_interference(double *ch_interference)
-{
-       __NM_FUNC_ENTER__;
-       *ch_interference = g_nm_daemon->channel_interference;
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_daemon_get_cellular_state(int *state)
-{
-       connman_tech_state_e value;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_connman_tech_get_state(CONNMAN_SERVICE_TYPE_CELLULAR, &value);
-       if (ret != 0) {
-               NM_LOGI("Failed to get cellular state");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-       *state = (int)value;
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_daemon_get_wifi_state(int *state)
-{
-       connman_tech_state_e value;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_connman_tech_get_state(CONNMAN_SERVICE_TYPE_WIFI, &value);
-       if (ret != 0) {
-               NM_LOGI("Failed to get wifi state");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-       *state = (int)value;
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_daemon_get_ethernet_state(int *state)
-{
-       connman_tech_state_e value;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_connman_tech_get_state(CONNMAN_SERVICE_TYPE_ETHERNET, &value);
-       if (ret != 0) {
-               NM_LOGI("Failed to get ethernet state");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-       *state = (int)value;
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_daemon_get_wifi_scan_state(gboolean *state)
-{
-       nm_supplicant_iface_s *iface = NULL;
-       int ret = 0;
-
-       ret = nm_supplicant_iface_get_iface(IF_NAME_WLAN, &iface);
-       if (ret != NM_SUPPLICANT_ERROR_NONE || iface == NULL)
-               *state = FALSE;
-       else
-               *state = iface->scanning;
-
-       return NM_DAEMON_ERROR_NONE;
-}
-
-static void __ip_conflict_cb(int state, gchar *if_name, guchar *ip, gpointer user_data)
-{
-       gchar *ip_str = NULL;
-       if (if_name)
-               NM_LOGI("User callback IP conflict %s state[%d] :", if_name, state);
-
-       ip_str = g_strdup_printf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
-       if (!ip_str)
-               return;
-
-       if (state != IP_CONFLICT_STATE_UNKNOWN)
-               g_nm_daemon->ip_conflict_state = state;
-
-       if (state == IP_CONFLICT_STATE_CONFLICT_DETECTED)
-               nm_gdbus_emit_ip_conflicted(state, if_name, ip_str);
-
-       g_free(ip_str);
-
-       return;
-}
-
-static inline void __init_ip_conflict_detect()
-{
-       __NM_FUNC_ENTER__;
-       if (ip_conflict_detection_init() < 0) {
-               NM_LOGI("ip conflict detection init failed");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       g_nm_daemon->ip_conflict_state = IP_CONFLICT_STATE_UNKNOWN;
-
-       ip_conflict_set_callback(IF_NAME_ETH, __ip_conflict_cb, NULL);
-       ip_conflict_set_callback(IF_NAME_WLAN, __ip_conflict_cb, NULL);
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __deinit_ip_conflict_detect()
-{
-       __NM_FUNC_ENTER__;
-       ip_conflict_unset_callback(IF_NAME_ETH);
-       ip_conflict_unset_callback(IF_NAME_WLAN);
-
-       if (ip_conflict_detection_deinit() < 0) {
-               NM_LOGI("ip conflict detection deinit failed");
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __ethernet_cable_state_changed_cb(char *iface_name, int state, void *user_data)
-{
-       gboolean is_attached = FALSE;
-
-       is_attached = state == 1;
-
-       NM_LOGI("%s is %s", IF_NAME_ETH, is_attached?"Attached":"Detached");
-       nm_gdbus_emit_ethernet_cable_state(is_attached);
-}
-
-
-static void __wifi_module_state_changed_cb(char *iface_name, int state, void *user_data)
-{
-       gboolean is_attached = FALSE;
-
-       is_attached = state == 1;
-
-       NM_LOGI("%s is %s", IF_NAME_WLAN, is_attached?"Attached":"Detached");
-       nm_gdbus_emit_wifi_module_state(is_attached);
-}
-
-static inline void __init_iface_monitor()
-{
-       __NM_FUNC_ENTER__;
-       if (nm_iface_mon_init() < 0) {
-               NM_LOGI("nm_iface_mon_init failed");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       if (nm_iface_mon_start_monitor(IF_NAME_ETH,
-                       __ethernet_cable_state_changed_cb,
-                       NULL) < 0)
-               NM_LOGI("nm_iface_mon_start_monitor %s failed", IF_NAME_ETH);
-
-       if (nm_iface_mon_start_monitor(IF_NAME_WLAN,
-                       __wifi_module_state_changed_cb,
-                       NULL) < 0)
-               NM_LOGI("nm_iface_mon_start_monitor %s failed", IF_NAME_WLAN);
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __deinit_iface_monitor()
-{
-       __NM_FUNC_ENTER__;
-
-       if (nm_iface_mon_stop_monitor(IF_NAME_ETH) < 0)
-               NM_LOGI("nm_iface_mon_start_monitor %s failed", IF_NAME_ETH);
-
-       if (nm_iface_mon_stop_monitor(IF_NAME_WLAN) < 0)
-               NM_LOGI("nm_iface_mon_start_monitor %s failed", IF_NAME_WLAN);
-
-       if (nm_iface_mon_deinit() < 0)
-               NM_LOGI("nm_iface_mon_deinit failed");
-
-       __NM_FUNC_EXIT__;
-}
-
-void __retry_tx_rate_cb(int retry_rate, gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       g_nm_daemon->retry_tx_rate = retry_rate;
-       nm_gdbus_emit_retry_tx_rate_changed(retry_rate);
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __init_retry_tx_rate_monitor()
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_retry_tx_rate_monitor_start(__retry_tx_rate_cb, NULL);
-       if (ret != NM_DAEMON_ERROR_NONE)
-               NM_LOGI("nm_retry_tx_rate_monitor_start failed");
-}
-
-static inline void __deinit_retry_tx_rate_monitor()
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_retry_tx_rate_monitor_stop();
-       if (ret != NM_DAEMON_ERROR_NONE)
-               NM_LOGI("nm_retry_tx_rate_monitor_stop failed");
-}
-
-void __channel_interference_cb(int freq, double channel_interference, gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       g_nm_daemon->freq = freq;
-       g_nm_daemon->channel_interference = channel_interference;
-       nm_gdbus_emit_channel_interference(freq, channel_interference);
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __init_channel_interference_monitor()
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_channel_interference_monitor_start(__channel_interference_cb, NULL);
-       if (ret != NM_DAEMON_ERROR_NONE)
-               NM_LOGI("nm_channel_interference_monitor_start failed");
-}
-
-static inline void __deinit_channel_interference_monitor()
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_channel_interference_monitor_stop();
-       if (ret != NM_DAEMON_ERROR_NONE)
-               NM_LOGI("nm_channel_interference_monitor_stop failed");
-}
-
-void __congestion_mon_cb(int congestion_level, gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       g_nm_daemon->congestion_level = congestion_level;
-       nm_gdbus_emit_congestion_level_changed(congestion_level);
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __init_congestion_mon()
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_congestion_mon_init();
-       if (ret != NM_DAEMON_ERROR_NONE) {
-               NM_LOGI("nm_congestion_mon_init failed");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       ret = nm_congestion_monitor_start(__congestion_mon_cb, NULL);
-       if (ret != NM_DAEMON_ERROR_NONE)
-               NM_LOGI("nm_congestion_monitor_start failed");
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __deinit_congestion_mon()
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_congestion_monitor_stop();
-       if (ret != NM_DAEMON_ERROR_NONE) {
-               NM_LOGI("nm_congestion_monitor_stop failed");
-       __NM_FUNC_EXIT__;
-               return;
-       }
-
-       ret = nm_congestion_mon_deinit();
-       if (ret != NM_DAEMON_ERROR_NONE)
-               NM_LOGI("nm_congestion_mon_deinit failed");
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __set_ip_detection(char *ifname, connman_tech_state_e state)
-{
-       gboolean enabled;
-       int ret = 0;
-
-       if (state == CONNMAN_TECH_STATE_CONNECTED) {
-               ret = nm_ip_conflict_enable_detection(ifname, TRUE);
-               if (ret == NM_IP_CONFLICT_ERROR_NONE)
-                       NM_LOGI("Enable ip confilct %s detection", ifname);
-       } else {
-               ret = nm_ip_conflict_is_detection_enabled(ifname, &enabled);
-               if (ret == NM_IP_CONFLICT_ERROR_NONE && enabled)
-                       ret = nm_ip_conflict_enable_detection(ifname, FALSE);
-
-               if (ret == NM_IP_CONFLICT_ERROR_NONE)
-                       NM_LOGI("Disable ip confilct %s detection", ifname);
-       }
-}
-
-static void __tech_changed_cb(connman_service_type_e type,
-               connman_tech_state_e state)
-{
-       NM_LOGI("Tech changed %d %d", type, state);
-       if (type == CONNMAN_SERVICE_TYPE_ETHERNET) {
-               nm_gdbus_emit_ethernet_state(state);
-               __set_ip_detection(IF_NAME_ETH, state);
-       } else if (type == CONNMAN_SERVICE_TYPE_WIFI) {
-               nm_gdbus_emit_wifi_state(state);
-               __set_ip_detection(IF_NAME_WLAN, state);
-       } else if (type == CONNMAN_SERVICE_TYPE_CELLULAR)
-               nm_gdbus_emit_cellular_state(state);
-}
-
-static void __conn_changed_cb(GVariant *signal_args)
-{
-       NM_LOGI("");
-       nm_gdbus_emit_connections_changed(signal_args);
-}
-
-static void __conn_error_cb(connman_service_error_e error)
-{
-       if (error != CONNMAN_SERVICE_ERROR_UNKNOWN)
-               nm_dump_log("/tmp");
-}
-
-static inline void __init_connman()
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_connman_init();
-       if (ret < 0) {
-               NM_LOGI("Init connman failed");
-       __NM_FUNC_EXIT__;
-               return;
-       }
-
-       ret = nm_connman_set_tech_changed_callback(__tech_changed_cb);
-       if (ret < 0) {
-               nm_connman_deinit();
-               NM_LOGI("Set tech changed cb failed");
-       }
-
-       ret = nm_connman_set_conn_changed_callback(__conn_changed_cb);
-       if (ret < 0) {
-               nm_connman_deinit();
-               NM_LOGI("Set connection changed cb failed");
-       }
-
-       ret = nm_connman_set_conn_error_callback(__conn_error_cb);
-       if (ret < 0) {
-               nm_connman_deinit();
-               NM_LOGI("Set connection error cb failed");
-       }
-
-       __NM_FUNC_EXIT__;
-
-}
-
-static inline void __deinit_connman()
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-
-       ret = nm_connman_unset_tech_changed_callback();
-       if (ret < 0)
-               NM_LOGI("Unset tech changed cb failed");
-
-       ret = nm_connman_unset_conn_changed_callback();
-       if (ret < 0)
-               NM_LOGI("Unset conn changed cb failed");
-
-       ret = nm_connman_unset_conn_error_callback();
-       if (ret < 0)
-               NM_LOGI("Unset connection error cb failed");
-
-       ret = nm_connman_deinit();
-       if (ret < 0) {
-               NM_LOGI("Deinit connman failed");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       __NM_FUNC_EXIT__;
-}
-
-static void __supplicant_iface_changed(
-               nm_supplicant_iface_property_e property,
-               nm_supplicant_iface_s *iface,
-               gpointer user_data)
-{
-       if (property == NM_SUPPLICANT_IFACE_PROPERTY_STATE) {
-               NM_LOGI("iface state changed");
-       } else if (property == NM_SUPPLICANT_IFACE_PROPERTY_SCANNING) {
-               NM_LOGI("iface scanning changed");
-
-               if (g_strcmp0(iface->Ifname, IF_NAME_WLAN) == 0)
-                       nm_gdbus_emit_wifi_scanning_changed(iface->scanning);
-       } else {
-               NM_LOGI("Nothing");
-       }
-}
-
-static inline void __init_supplicant()
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_supplicant_init();
-       if (ret < 0) {
-               NM_LOGI("Init supplicant failed");
-       __NM_FUNC_EXIT__;
-               return;
-       }
-
-       ret = nm_supplicant_iface_set_prop_changed_cb(__supplicant_iface_changed, NULL);
-       if (ret < 0) {
-               nm_supplicant_deinit();
-               NM_LOGI("Set supplicant iface changed cb failed");
-       }
-
-       __NM_FUNC_EXIT__;
-
-}
-
-static inline void __deinit_supplicant()
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-
-       ret = nm_supplicant_iface_unset_prop_changed_cb();
-       if (ret < 0) {
-               nm_supplicant_deinit();
-               NM_LOGI("Set supplicant iface changed cb failed");
-       }
-
-       ret = nm_supplicant_deinit();
-       if (ret < 0) {
-               NM_LOGI("Denit supplicant failed");
-       __NM_FUNC_EXIT__;
-               return;
-       }
-
-       __NM_FUNC_EXIT__;
-}
-
-static void __wpasupplicant_watching_cb(gboolean appeared)
-{
-       NM_LOGI("wpasupplicant is %s", appeared?"Enabled":"Disabled");
-       g_nm_daemon->is_wpasupplicant_enabled = appeared;
-}
-
-static void __connman_watching_cb(gboolean appeared)
-{
-       NM_LOGI("connman is %s", appeared?"Enabled":"Disabled");
-       g_nm_daemon->is_connman_enabled = appeared;
-}
-
-static void __telephony_watching_cb(gboolean appeared)
-{
-       NM_LOGI("telephony is %s", appeared?"Enabled":"Disabled");
-       g_nm_daemon->is_telephony_enabled = appeared;
-}
-
-static void __wfd_manager_watching_cb(gboolean appeared)
-{
-       NM_LOGI("wfd_manager is %s", appeared?"Enabled":"Disabled");
-       g_nm_daemon->is_wfd_manager_enabled = appeared;
-}
-
-static void __mobileap_watching_cb(gboolean appeared)
-{
-       NM_LOGI("mobileap is %s", appeared?"Enabled":"Disabled");
-       g_nm_daemon->is_mobileap_enabled = appeared;
-}
-
-static void __stc_manager_watching_cb(gboolean appeared)
-{
-       NM_LOGI("stc_manager is %s", appeared?"Enabled":"Disabled");
-       g_nm_daemon->is_stc_manager_enabled = appeared;
-}
-
-static inline void __set_watching_dbus_cbs()
-{
-       nm_gdbus_set_wpasupplicant_bus_watching_callback(__wpasupplicant_watching_cb);
-       nm_gdbus_set_connman_bus_watching_callback(__connman_watching_cb);
-       nm_gdbus_set_telephony_bus_watching_callback(__telephony_watching_cb);
-       nm_gdbus_set_wfd_manager_bus_watching_callback(__wfd_manager_watching_cb);
-       nm_gdbus_set_mobileap_bus_watching_callback(__mobileap_watching_cb);
-       nm_gdbus_set_stc_manager_bus_watching_callback(__stc_manager_watching_cb);
-}
-
-static inline void __unset_watching_dbus_cbs()
-{
-       nm_gdbus_unset_wpasupplicant_bus_watching_callback();
-       nm_gdbus_unset_connman_bus_watching_callback();
-       nm_gdbus_unset_telephony_bus_watching_callback();
-       nm_gdbus_unset_wfd_manager_bus_watching_callback();
-       nm_gdbus_unset_mobileap_bus_watching_callback();
-       nm_gdbus_unset_stc_manager_bus_watching_callback();
-}
-
-static void __gdbus_name_aquired()
-{
-       __NM_FUNC_ENTER__;
-       gboolean enabled = FALSE;
-
-       if (nm_gdbus_is_wpasupplicant_enabled(&enabled) == 0) {
-               g_nm_daemon->is_wpasupplicant_enabled  = TRUE;
-               nm_supplicant_get_properties();
-       } else
-               NM_LOGI("wpsupplicant is not enabled");
-
-       if (nm_gdbus_is_connman_enabled(&enabled) == 0) {
-               g_nm_daemon->is_connman_enabled  = TRUE;
-               nm_connman_mgr_get_properties();
-               nm_connman_mgr_get_technologies();
-               nm_connman_mgr_get_services();
-       }
-       else
-               NM_LOGI("connman is not enabled");
-
-       if (nm_gdbus_is_telephony_enabled(&enabled) == 0)
-               g_nm_daemon->is_telephony_enabled  = TRUE;
-       else
-               NM_LOGI("telephony is not enabled");
-
-       if (nm_gdbus_is_wfd_manager_enabled(&enabled) == 0)
-               g_nm_daemon->is_wfd_manager_enabled  = TRUE;
-       else
-               NM_LOGI("wfd_manager is not enabled");
-
-       if (nm_gdbus_is_mobileap_enabled(&enabled) == 0)
-               g_nm_daemon->is_mobileap_enabled  = TRUE;
-       else
-               NM_LOGI("mobileap is not enabled");
-
-       if (nm_gdbus_is_stc_manager_enabled(&enabled) == 0)
-               g_nm_daemon->is_stc_manager_enabled  = TRUE;
-       else
-               NM_LOGI("stc_manager is not enabled");
-
-       if (nm_gdbus_register_daemon_iface() < 0) {
-               g_main_loop_quit(g_nm_daemon->loop);
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       if (nm_gdbus_register_wifi_iface() < 0) {
-               g_main_loop_quit(g_nm_daemon->loop);
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       __NM_FUNC_EXIT__;
-}
-
-static void __gdbus_name_lost()
-{
-       __NM_FUNC_ENTER__;
-       g_main_loop_quit(g_nm_daemon->loop);
-       __NM_FUNC_EXIT__;
-}
-
-int nm_daemon_init()
-{
-       int ret = 0;
-       __NM_FUNC_ENTER__;
-       g_nm_daemon = g_try_malloc0(sizeof(nm_daemon_s));
-       if (!g_nm_daemon) {
-               NM_LOGI("Failed to allocate memory for daemon");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       NM_LOGI("Initialize DBus related");
-       nm_error_register();
-
-       ret = nm_gdbus_init(__gdbus_name_aquired, __gdbus_name_lost);
-       if (ret != 0) {
-               NM_LOGI("Failed to initialize gdbus");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       __set_watching_dbus_cbs();
-       __init_supplicant();
-       __init_connman();
-
-       NM_LOGI("Initialize others");
-       nm_dump_init();
-       __init_ip_conflict_detect();
-       __init_iface_monitor();
-       __init_retry_tx_rate_monitor();
-       __init_channel_interference_monitor();
-       __init_congestion_mon();
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_daemon_deinit()
-{
-       int ret = 0;
-       __NM_FUNC_ENTER__;
-
-       NM_LOGI("denitialize DBus related");
-       __unset_watching_dbus_cbs();
-       __deinit_connman();
-       __deinit_supplicant();
-       nm_error_deregister();
-       nm_gdbus_deinit();
-
-       NM_LOGI("Denitialize others");
-       nm_dump_deinit();
-       __deinit_ip_conflict_detect();
-       __deinit_iface_monitor();
-       __deinit_retry_tx_rate_monitor();
-       __deinit_channel_interference_monitor();
-       __deinit_congestion_mon();
-
-
-       g_free(g_nm_daemon);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-dump.c b/src/nm-dump.c
deleted file mode 100644 (file)
index 8e70ae3..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for dump.
- *
- * @file        nm-dump.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <glib.h>
-
-#include "nm-daemon-log.h"
-#include "nm-dump.h"
-#include "nm-util.h"
-
-//#define NETWORK_DUMP_SCRIPT  "/opt/var/lib/net-config/network_dump.sh"
-#define NETWORK_DUMP_SCRIPT  "/usr/bin/network_dump.sh"
-#define TCP_DUMP_IN_BOOT_TIME "/opt/usr/data/tcp_dump_mode"
-#define NETWORK_LOG_PATH "/opt/usr/data/network"
-#define KILLALL_EXEC_PATH "/usr/bin/killall"
-#define TCPDUMP_EXEC_PATH "/usr/sbin/tcpdump"
-
-typedef struct {
-       gboolean is_initialized;
-       gboolean is_tcpdump_running;
-} dump_mon_s;
-
-dump_mon_s dump_mon;
-
-
-static gboolean __get_dump_state(void)
-{
-       int ret = access(TCP_DUMP_IN_BOOT_TIME, F_OK);
-       if (ret != 0) {
-               NM_LOGI("Dumpstate Get Failed (%d).", ret);
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-static int __start_dump(gchar *dump_path)
-{
-       int rv = 0;
-       gchar *path = NETWORK_DUMP_SCRIPT;
-       char *const args[] = { NETWORK_DUMP_SCRIPT, dump_path, NULL };
-       char *const envs[] = { NULL };
-
-       rv = nm_execute_file(path, args, envs);
-       if (rv < 0) {
-               NM_LOGI("Fail to execute network log dump shell");
-               return -EIO;
-       }
-       return 0;
-}
-
-static gboolean __stop_tcpdump(void)
-{
-       int ret;
-       const char *path = KILLALL_EXEC_PATH;
-       char *const args[] = { KILLALL_EXEC_PATH, "tcpdump", NULL };
-       char *const envs[] = { NULL };
-
-       if (!dump_mon.is_tcpdump_running) {
-               NM_LOGI("tcpdump is not running");
-               return FALSE;
-       }
-
-       ret = nm_execute_file(path, args, envs);
-       if (ret < 0) {
-               NM_LOGI("Failed to Kill tcpdump, ret : %d\n", ret);
-               return FALSE;
-       }
-
-       dump_mon.is_tcpdump_running = FALSE;
-
-       return TRUE;
-}
-
-static gboolean __start_tcpdump(void)
-{
-       int ret;
-       const char *start_path = TCPDUMP_EXEC_PATH;
-       char filename[128] = { 0, };
-       gchar current_time_str[TIME_STR_LEN] = {0, };
-
-
-       get_current_time(current_time_str);
-       g_snprintf(filename,
-                       TIME_STR_LEN,
-                       "%s/tcpdump-%s.pcap",
-                       NETWORK_LOG_PATH,
-                       current_time_str);
-       char *const start_args[] = { TCPDUMP_EXEC_PATH,
-                       "-W", "5", "-C", "50", "-i", "any", "-s", "0", "-w", filename, NULL};
-
-       ret = nm_execute_file_no_wait(start_path, start_args);
-       if (ret < 0) {
-               NM_LOGI("Failed to start tcpdump, ret : %d", ret);
-               return FALSE;
-       }
-
-       dump_mon.is_tcpdump_running = TRUE;
-
-       return dump_mon.is_tcpdump_running;
-}
-
-int nm_dump_start_tcpdump()
-{
-       int ret = NM_DUMP_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!dump_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_DUMP_NOT_INITIALIZED;
-       }
-
-       if (dump_mon.is_tcpdump_running) {
-               __NM_FUNC_EXIT__;
-               return NM_DUMP_IN_PROGRESS;
-       }
-
-       if (!__start_tcpdump()) {
-               return NM_DUMP_OPERATION_FAILED;
-       }
-
-       NM_LOGI("Successfully started tcpdump and running..");
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_dump_stop_tcpdump()
-{
-       int ret = NM_DUMP_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!dump_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_DUMP_NOT_INITIALIZED;
-       }
-
-       if (!dump_mon.is_tcpdump_running) {
-               NM_LOGI("tcpdump not running");
-               return ret;
-       }
-
-       if (!__stop_tcpdump())
-               return NM_DUMP_OPERATION_FAILED;
-
-       NM_LOGI("Successfully stopped tcpdump");
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_dump_get_tcpdump_state(gboolean *is_running)
-{
-       int ret = NM_DUMP_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!dump_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_DUMP_NOT_INITIALIZED;
-       }
-
-       if (!is_running) {
-               __NM_FUNC_EXIT__;
-               return NM_DUMP_INVALID_PARAMETER;
-       }
-
-       NM_LOGI("tcpdump %s running", dump_mon.is_tcpdump_running ? "is" : "is not");
-
-       *is_running = dump_mon.is_tcpdump_running;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_dump_log(gchar *dump_path)
-{
-       int ret = NM_DUMP_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!dump_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_DUMP_NOT_INITIALIZED;
-       }
-
-       NM_LOGI("Dump is started");
-
-       __start_dump(dump_path);
-       __stop_tcpdump();
-
-       NM_LOGI("Dump is finished");
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_dump_check_state_and_start()
-{
-       int ret = NM_DUMP_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!dump_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_DUMP_NOT_INITIALIZED;
-       }
-       if (!__get_dump_state())
-               return NM_DUMP_OPERATION_FAILED;
-
-       if (!__start_tcpdump()) {
-               NM_LOGI("Failed to start tcpdump");
-               return NM_DUMP_OPERATION_FAILED;
-       }
-       NM_LOGI("Successfully started tcpdump and running..");
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_dump_init()
-{
-       int ret = NM_DUMP_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       memset(&dump_mon, 0x00, sizeof(dump_mon));
-       dump_mon.is_initialized = TRUE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_dump_deinit()
-{
-       int ret = NM_DUMP_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!dump_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_DUMP_NOT_INITIALIZED;
-       }
-
-       if (dump_mon.is_tcpdump_running) {
-               NM_LOGI("tcpdump is running, shutdown");
-               __stop_tcpdump();
-       }
-
-       dump_mon.is_initialized = FALSE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-error.c b/src/nm-error.c
deleted file mode 100644 (file)
index 25dfe78..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for error.
- *
- * @file        nm-error.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <glib.h>
-#include <gio/gio.h>
-
-#include "nm-daemon.h"
-#include "nm-daemon-log.h"
-#include "nm-error.h"
-#include "nm-util.h"
-
-
-#define NM_DAEMON_ERROR_QUARK g_quark_from_string("nm-daemon-error-quark")
-
-#define NM_ERR_STR_INVALID_PARAM "net.nmdaemon.Error.InvalidParameter"
-#define NM_ERR_STR_NOT_PERMITTED "net.nmdaemon.Error.NotPermitted"
-#define NM_ERR_STR_OUT_OF_MEMORY "net.nmdaemon.Error.OutOfMemory"
-#define NM_ERR_STR_OP_FAILED "net.nmdaemon.Error.OperationFailed"
-#define NM_ERR_STR_IN_PROGRESS "net.nmdaemon.Error.InProgress"
-
-//LCOV_EXCL_START
-static void nm_error_invalid_parameter(GError **error)
-{
-       *error = g_dbus_error_new_for_dbus_error(
-                       NM_ERR_STR_INVALID_PARAM,
-                       NM_ERR_STR_INVALID_PARAM);
-}
-
-static void nm_error_not_permitted(GError **error)
-{
-       *error = g_dbus_error_new_for_dbus_error(
-                       NM_ERR_STR_NOT_PERMITTED,
-                       NM_ERR_STR_NOT_PERMITTED);
-}
-
-static void nm_error_out_of_memory(GError **error)
-{
-       *error = g_dbus_error_new_for_dbus_error(
-                       NM_ERR_STR_OUT_OF_MEMORY,
-                       NM_ERR_STR_OUT_OF_MEMORY);
-}
-
-static void nm_error_operation_failed(GError **error)
-{
-       *error = g_dbus_error_new_for_dbus_error(
-                       NM_ERR_STR_OP_FAILED,
-                       NM_ERR_STR_OP_FAILED);
-}
-
-static void nm_error_in_progress(GError **error)
-{
-       *error = g_dbus_error_new_for_dbus_error(
-                       NM_ERR_STR_IN_PROGRESS,
-                       NM_ERR_STR_IN_PROGRESS);
-}
-
-
-void nm_error_set_gerror(nm_daemon_error_e error_code, GError **error)
-{
-       switch (error_code) {
-       case NM_DAEMON_ERROR_INVALID_PARAM:
-               nm_error_invalid_parameter(error);
-               break;
-       case NM_DAEMON_ERROR_NOT_PERMITTED:
-               nm_error_not_permitted(error);
-               break;
-       case NM_DAEMON_ERROR_OUT_OF_MEMORY:
-               nm_error_out_of_memory(error);
-               break;
-       case NM_DAEMON_ERROR_OPERATION_FAILED:
-               nm_error_operation_failed(error);
-               break;
-       case NM_DAEMON_ERROR_IN_PROGRESS:
-               nm_error_in_progress(error);
-               break;
-       default:
-               NM_LOGI("Error Not handled [%d]", error_code);
-               nm_error_operation_failed(error);
-       }
-}
-void nm_error_register(void)
-{
-       g_dbus_error_register_error(NM_DAEMON_ERROR_QUARK,
-                       NM_DAEMON_ERROR_INVALID_PARAM,
-                       NM_ERR_STR_INVALID_PARAM);
-
-       g_dbus_error_register_error(NM_DAEMON_ERROR_QUARK,
-                       NM_DAEMON_ERROR_NOT_PERMITTED,
-                       NM_ERR_STR_NOT_PERMITTED);
-
-       g_dbus_error_register_error(NM_DAEMON_ERROR_QUARK,
-                       NM_DAEMON_ERROR_OUT_OF_MEMORY,
-                       NM_ERR_STR_OUT_OF_MEMORY);
-
-       g_dbus_error_register_error(NM_DAEMON_ERROR_QUARK,
-                       NM_DAEMON_ERROR_OPERATION_FAILED,
-                       NM_ERR_STR_OP_FAILED);
-
-       g_dbus_error_register_error(NM_DAEMON_ERROR_QUARK,
-                       NM_DAEMON_ERROR_IN_PROGRESS,
-                       NM_ERR_STR_IN_PROGRESS);
-
-}
-
-void nm_error_deregister(void)
-{
-       g_dbus_error_unregister_error(NM_DAEMON_ERROR_QUARK,
-                       NM_DAEMON_ERROR_INVALID_PARAM,
-                       NM_ERR_STR_INVALID_PARAM);
-
-
-       g_dbus_error_unregister_error(NM_DAEMON_ERROR_QUARK,
-                       NM_DAEMON_ERROR_NOT_PERMITTED,
-                       NM_ERR_STR_NOT_PERMITTED);
-
-
-       g_dbus_error_unregister_error(NM_DAEMON_ERROR_QUARK,
-                       NM_DAEMON_ERROR_OUT_OF_MEMORY,
-                       NM_ERR_STR_OUT_OF_MEMORY);
-
-       g_dbus_error_unregister_error(NM_DAEMON_ERROR_QUARK,
-                       NM_DAEMON_ERROR_OPERATION_FAILED,
-                       NM_ERR_STR_OP_FAILED);
-
-       g_dbus_error_unregister_error(NM_DAEMON_ERROR_QUARK,
-                       NM_DAEMON_ERROR_IN_PROGRESS,
-                       NM_ERR_STR_IN_PROGRESS);
-
-}
-//LCOV_EXCL_STOP
diff --git a/src/nm-gdbus.c b/src/nm-gdbus.c
deleted file mode 100644 (file)
index dc628fc..0000000
+++ /dev/null
@@ -1,2228 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implement functions for operating GDBus.
- *
- * @file        nm-gdbus.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include "nm-connman.h"
-#include "nm-daemon.h"
-#include "nm-daemon-log.h"
-#include "nm-error.h"
-#include "nm-gdbus.h"
-
-#define NM_WIFI_SERVICE NM_DAEMON_SERVICE ".wifi"
-#define NM_WIFI_IFACE NM_DAEMON_SERVICE ".wifi"
-#define NM_WIFI_OBJ NM_DAEMON_OBJ "/wifi"
-
-#define DBUS_STD_SERVICE "org.freedesktop.DBus"
-#define DBUS_STD_INTERFACE "org.freedesktop.DBus"
-#define DBUS_STD_PATH "/org/freedesktop/DBus"
-#define DBUS_STD_PROP DBUS_STD_SERVICE ".Properties"
-#define DBUS_STD_PROP_CHANGED "PropertiesChanged"
-
-#define DBUS_STD_PEER_IFACE "org.freedesktop.DBus.Peer"
-#define DBUS_STC_PEER_IFACE_PING "Ping"
-#define DBUS_ERROR_STR_NO_OWNER "GDBus.Error:org.freedesktop.DBus.Error.NameHasNoOwner"
-
-#define WPASUPPLICANT_BUS_NAME "fi.w1.wpa_supplicant1"
-#define CONNMAN_BUS_NAME "net.connman"
-#define TELEPHONY_BUS_NAME "com.tcore.ps"
-#define WFD_MANAGER_BUS_NAME "net.wifidirect"
-#define MOBILEAP_BUS_NAME "org.tizen.MobileapAgent"
-#define STC_MANAGER_BUS_NAME "net.stc"
-
-#define WPASUPPLICANT_OBJ "/fi/w1/wpa_supplicant1"
-#define CONNMAN_OBJ "/net/connman"
-#define TELEPHONY_OBJ "/com/tcore/ps"
-#define WFD_MANAGER_OBJ "/net/wifidirect"
-#define MOBILEAP_OBJ "/org/tizen/MobileapAgent"
-#define STC_MANAGER_OBJ "/net/stc"
-
-#define DBUS_REPLY_TIMEOUT (120 * 1000)
-
-#define DEBUG_G_VARIANT(str, parameters)\
-       do {\
-               gchar *parameters_debug_str = NULL;\
-               if (parameters)\
-                       parameters_debug_str = g_variant_print(parameters, TRUE);\
-               NM_LOGI("%s[%s]", str, parameters_debug_str ? parameters_debug_str : "NULL");\
-               g_free(parameters_debug_str);\
-       } while (0)
-
-#define DEBUG_SIGNAL(sender_name, object_path, interface_name, signal_name, parameters)\
-       do {\
-               NM_LOGI("signal sender name [%s]", sender_name);\
-               NM_LOGI("signal object path [%s]", object_path);\
-               NM_LOGI("signal interface name [%s]", interface_name);\
-               NM_LOGI("signal signal name [%s]", signal_name);\
-               DEBUG_G_VARIANT("signal params ", parameters);\
-               NM_LOGI("signal params type [%s]", g_variant_get_type_string(parameters));\
-       } while (0)
-
-typedef struct {
-       GDBusConnection *conn;
-       GDBusNodeInfo *daemon_introspection;
-       GDBusNodeInfo *wifi_introspection;
-       GDBusNodeInfo *conn_introspection;
-
-       guint daemon_obj_id;
-       guint wifi_obj_id;
-       nm_gdbus_watching_bus_callback wpasupplicant_watching_cb;
-       guint wpasupplicant_watching_id;
-       nm_gdbus_watching_bus_callback connman_watching_cb;
-       guint connman_watching_id;
-       nm_gdbus_watching_bus_callback telephony_watching_cb;
-       guint telephony_watching_id;
-       nm_gdbus_watching_bus_callback wfd_manager_watching_cb;
-       guint wfd_manager_watching_id;
-       nm_gdbus_watching_bus_callback mobileap_watching_cb;
-       guint mobileap_watching_id;
-       nm_gdbus_watching_bus_callback stc_manager_watching_cb;
-       guint stc_manager_watching_id;
-
-       bus_aquired_callback bus_acquired_cb;
-       name_lost_callback name_lost_cb;
-
-       gboolean is_initialized;
-       gboolean is_bus_aquired;
-       guint owner_id;
-
-} gdbus_mon_s;
-
-typedef enum {
-       UNKNOWN,
-       POWER_OFF,
-       POWER_ON,
-       CONNECTED,
-} tech_state_e;
-
-static const gchar nm_daemon_introspection_xml[] = {
-               "<node>"
-               "<interface name='net.nm_daemon'>"
-               "<method name='GetStatistics'>"
-               "<arg type='i' name='connection_type' direction='in'/>"
-               "<arg type='i' name='statistics_type' direction='in'/>"
-               "<arg type='t' name='val' direction='out'/>"
-               "</method>"
-               "<method name='ResetStatistics'>"
-               "<arg type='i' name='connection_type' direction='in'/>"
-               "<arg type='i' name='statistics_type' direction='in'/>"
-               "</method>"
-               "<method name='GetCurrentConnection'>"
-               "<arg type='o' name='object_path' direction='out'/>"
-               "<arg type='a{sv}' name='connection' direction='out'/>"
-               "</method>"
-               "<method name='GetConnections'>"
-               "<arg type='a(oa{sv})' name='connections' direction='out'/>"
-               "</method>"
-               "<property type='b' name='EthernetCableState' access='read'/>"
-               "<property type='b' name='WifiModuleState' access='read'/>"
-               "<property type='b' name='IpConflictState' access='read'/>"
-               "<property type='b' name='IpConflictDetect' access='readwrite'/>"
-               "<property type='b' name='TcpdumpState' access='readwrite'/>"
-               "<property type='i' name='CellularState' access='read'/>"
-               "<property type='i' name='WifiState' access='read'/>"
-               "<property type='i' name='EthernetState' access='read'/>"
-               "<property type='i' name='CongestionLevel' access='read'/>"
-               "<property type='i' name='RetryTxRate' access='read'/>"
-               "<property type='d' name='ChannelInterference' access='read'/>"
-/* Test purpose --> */
-               "<property type='b' name='WritingAlwaysThrowsError' access='readwrite'/>"
-               "<property type='b' name='ReadingAlwaysThrowsError' access='read'/>"
-/* <-- Test purpose */
-               "<signal name='IpConflicted'>"
-               "</signal>"
-               "<signal name='ConnectionsChanged'>"
-               "<arg type='aoao' name='connections'/>"
-               "</signal>"
-               "</interface>"
-               "</node>"
-};
-
-static const gchar nm_wifi_introspection_xml[] = {
-       "<node>"
-               "<interface name='net.nm_daemon.wifi'>"
-                       "<method name='GetConnectedAp'>"
-                               "<arg type='a{sv}' name='ap' direction='out'/>"
-                       "</method>"
-                       "<method name='GetFoundAps'>"
-                               "<arg type='a(oa{sv})' name='connections' direction='out'/>"
-                       "</method>"
-                       "<property type='b' name='ScanState' access='read'/>"
-/* Test purpose --> */
-                       "<property type='b' name='WritingAlwaysThrowsError' access='readwrite'/>"
-                       "<property type='b' name='ReadingAlwaysThrowsError' access='read'/>"
-/* <-- Test purpose */
-               "</interface>"
-       "</node>"
-};
-
-
-static const gchar nm_conn_introspection_xml[] = {
-       "<node>"
-               "<interface name='net.nm_daemon.conn'>"
-                       "<method name='GetAll'>"
-                       "<arg type='a{sv}' name='connection' direction='out'/>"
-                       "</method>"
-                       "<property type='s' name='Id' access='read'/>"
-                       "<property type='s' name='Name' access='read'/>"
-                       "<property type='s' name='Type' access='read'/>"
-                       "<property type='s' name='IfaceName' access='read'/>"
-                       "<property type='s' name='Ipv4State' access='read'/>"
-                       "<property type='s' name='Ipv6State' access='read'/>"
-                       "<property type='a{sv}' name='Ip' access='read'/>"
-                       "<property type='a{sv}' name='Dns' access='read'/>"
-                       "<property type='s' name='Essid' access='read'/>"
-                       "<property type='s' name='RawSsid' access='read'/>"
-                       "<property type='s' name='Bssid' access='read'/>"
-                       "<property type='i' name='Rssi' access='read'/>"
-                       "<property type='i' name='Frequency' access='read'/>"
-                       "<property type='i' name='MaxSpeed' access='read'/>"
-                       "<property type='b' name='Favorite' access='read'/>"
-                       "<property type='b' name='Passpoint' access='read'/>"
-                       "<property type='s' name='SecurityType' access='read'/>"
-                       "<property type='s' name='EncryptionType' access='read'/>"
-                       "<property type='b' name='PassphraseRequired' access='read'/>"
-                       "<property type='b' name='WpsSupported' access='read'/>"
-                       "<property type='s' name='EapPassphrase' access='read'/>"
-                       "<property type='s' name='EapCaCert' access='read'/>"
-                       "<property type='s' name='EapClientCert' access='read'/>"
-                       "<property type='s' name='EapPrivateKey' access='read'/>"
-                       "<property type='s' name='EapType' access='read'/>"
-                       "<property type='s' name='EapAuthType' access='read'/>"
-                       "<property type='s' name='DisconnectReason' access='read'/>"
-                       "<property type='s' name='AssocStatus' access='read'/>"
-                       "<property type='s' name='Vsie' access='read'/>"
-/* Test purpose --> */
-                       "<property type='b' name='WritingAlwaysThrowsError' access='readwrite'/>"
-                       "<property type='b' name='ReadingAlwaysThrowsError' access='read'/>"
-/* <-- Test purpose */
-               "</interface>"
-       "</node>"
-};
-
-gdbus_mon_s gdbus_mon;
-
-GDBusConnection *nm_gdbus_get_connection(void)
-{
-       return gdbus_mon.conn;
-}
-
-gboolean nm_gdbus_emit_signal(const gchar *destination_bus_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *params)
-{
-       gboolean rv = FALSE;
-       GError *error = NULL;
-       GDBusConnection *connection;
-
-       connection = nm_gdbus_get_connection();
-       if (connection == NULL) {
-               NM_LOGE("[NET_DBUS] GDBusconnection is NULL");
-               return 0;
-       }
-
-       rv = g_dbus_connection_emit_signal(connection, destination_bus_name,
-               object_path, interface_name, signal_name, params, &error);
-       if (rv != TRUE) {
-               NM_LOGE("[NET_DBUS] Failed to emit signal, Error: %s", error->message);
-               g_clear_error(&error);
-               return rv;
-       }
-
-       NM_LOGE("Sent signal (%s), Interface (%s)", signal_name, interface_name);
-
-       return rv;
-}
-
-static void __gdbus_signal_callback(GDBusConnection *connection,
-               const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       signal_param_s *param = (signal_param_s *)user_data;
-       DEBUG_SIGNAL(sender_name, object_path, interface_name, signal_name, parameters);
-
-       if (param->callback)
-               param->callback(sender_name, object_path, interface_name, signal_name, parameters, user_data);
-
-       return;
-}
-
-int nm_gdbus_method_call(method_param_s *params,
-               handle_reply function, void *user_data)
-{
-       GVariant *reply = NULL;
-       GError *error = NULL;
-
-       if (!gdbus_mon.is_initialized)
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-
-       if (!params || !params->bus_name || !params->object_path)
-               return NM_GDBUS_ERROR_INVALID_PARAM;
-
-       NM_LOGI("method [%s]", params->method_name);
-
-       reply = g_dbus_connection_call_sync(
-                       gdbus_mon.conn,
-                       params->bus_name, /* bus name */
-                       params->object_path, /* object path */
-                       params->interface_name, /* interface name */
-                       params->method_name, /* method name */
-                       params->parameters, /* GVariant *params */
-                       NULL, /* reply_type */
-                       G_DBUS_CALL_FLAGS_NONE, /* flags */
-                       DBUS_REPLY_TIMEOUT , /* timeout */
-                       NULL, /* cancellable */
-                       &error); /* error */
-
-       if (error != NULL) {
-               NM_LOGI("Error! Failed to call method: [%s]", error->message);
-               g_error_free(error);
-               if (reply)
-                       g_variant_unref(reply);
-               return -1;
-       }
-
-       if (reply != NULL) {
-               DEBUG_G_VARIANT("Reply : ", reply);
-
-               if (function)
-                       function(reply, user_data);
-               g_variant_unref(reply);
-       } else {
-               NM_LOGI("reply is NULL");
-       }
-
-       return 0;
-}
-
-int nm_gdbus_subscribe_signal(signal_param_s *param)
-{
-       gint ret = NM_GDBUS_ERROR_NONE;
-
-
-       if (!gdbus_mon.is_initialized)
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-
-       if (!param || !param->sender || !param->interface_name)
-               return NM_GDBUS_ERROR_INVALID_PARAM;
-
-       param->subscriber_id =
-                       g_dbus_connection_signal_subscribe(
-                                       gdbus_mon.conn,
-                                       param->sender,
-                                       param->interface_name,
-                                       param->member,
-                                       param->object_path,
-                                       param->arg0,
-                                       G_DBUS_SIGNAL_FLAGS_NONE,
-                                       __gdbus_signal_callback,
-                                       param,
-                                       NULL);
-
-       if (param->subscriber_id == 0)
-               return NM_GDBUS_ERROR_OPERATION_FAILED;
-
-       return ret;
-}
-
-
-int nm_gdbus_subscribe_signal_with_data(signal_param_s *param, gpointer user_data)
-{
-       gint ret = NM_GDBUS_ERROR_NONE;
-
-       __NM_FUNC_ENTER__;
-
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (!param || !param->sender || !param->interface_name) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_INVALID_PARAM;
-       }
-
-       param->subscriber_id =
-                       g_dbus_connection_signal_subscribe(
-                                       gdbus_mon.conn,
-                                       param->sender,
-                                       param->interface_name,
-                                       param->member,
-                                       param->object_path,
-                                       param->arg0,
-                                       G_DBUS_SIGNAL_FLAGS_NONE,
-                                       (GDBusSignalCallback)param->callback_with_data,
-                                       user_data,
-                                       NULL);
-
-       if (param->subscriber_id == 0) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_OPERATION_FAILED;
-       }
-
-       __NM_FUNC_EXIT__;
-       return ret;
-
-}
-
-int nm_gdbus_unsubscribe_signal(signal_param_s *param)
-{
-       gint ret = NM_GDBUS_ERROR_NONE;
-
-       __NM_FUNC_ENTER__;
-
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (!param || !param->sender || !param->interface_name) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_INVALID_PARAM;
-       }
-
-       g_dbus_connection_signal_unsubscribe(
-                       gdbus_mon.conn,
-                       param->subscriber_id
-                       );
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-void __dbus_return_err(int ret, GDBusMethodInvocation *invocation)
-{
-       GError *err = NULL;
-       gchar* dbus_error_name = NULL;
-
-       if (!invocation)
-               return;
-
-       nm_error_set_gerror(ret, &err);
-       dbus_error_name = g_dbus_error_encode_gerror(err);
-       NM_LOGI("g_dbus_method_invocation_return_gerror with [%s]", dbus_error_name);
-       g_free(dbus_error_name);
-       g_dbus_method_invocation_return_gerror(invocation, err);
-       g_clear_error(&err);
-       return;
-}
-
-static void inline __handle_get_statistics(GVariant *parameters,
-                                          GDBusMethodInvocation *invocation)
-{
-       int connection_type = 0;
-       int statistics_type = 0;
-
-       __NM_FUNC_ENTER__;
-       g_variant_get(parameters, "(ii)", &connection_type, &statistics_type);
-
-       /* TODO get real statistics */
-
-       g_dbus_method_invocation_return_value(invocation, g_variant_new("(t)", 1000));
-       __NM_FUNC_EXIT__;
-}
-
-static void inline __handle_reset_statistics(GVariant *parameters,
-                                            GDBusMethodInvocation *invocation)
-{
-       int connection_type = 0;
-       int statistics_type = 0;
-
-       __NM_FUNC_ENTER__;
-       g_variant_get(parameters, "(ii)", &connection_type, &statistics_type);
-
-       /* TODO reset real statistics */
-
-       g_dbus_method_invocation_return_value(invocation, NULL);
-       __NM_FUNC_EXIT__;
-}
-
-static void inline __handle_get_current_connection(GVariant *parameters,
-                                                  GDBusMethodInvocation *invocation)
-{
-       GVariant *arg = NULL;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_connman_get_current_connection(&arg);
-       if (ret != NM_DAEMON_ERROR_NONE) {
-               NM_LOGI("Failed to get current connection");
-               __dbus_return_err(NM_DAEMON_ERROR_OPERATION_FAILED, invocation);
-               __NM_FUNC_EXIT__;
-               return;
-       }
-       DEBUG_G_VARIANT("ret: ", arg);
-       g_dbus_method_invocation_return_value(invocation, arg);
-       __NM_FUNC_EXIT__;
-}
-
-static void inline __handle_get_connections(GVariant *parameters,
-                                           GDBusMethodInvocation *invocation)
-{
-       GVariant *arg = NULL;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_connman_get_connections(&arg);
-       if (ret != NM_DAEMON_ERROR_NONE) {
-               NM_LOGI("Failed to get connections");
-               __dbus_return_err(NM_DAEMON_ERROR_OPERATION_FAILED, invocation);
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       g_dbus_method_invocation_return_value(invocation, arg);
-       __NM_FUNC_EXIT__;
-}
-
-static void __daemon_method_call(GDBusConnection *connection,
-                                 const gchar *sender,
-                                 const gchar *object_path,
-                                 const gchar *interface_name,
-                                 const gchar *method_name,
-                                 GVariant *parameters,
-                                 GDBusMethodInvocation *invocation,
-                                 gpointer user_data)
-{
-       if (g_strcmp0(method_name, "GetStatistics") == 0)
-               __handle_get_statistics(parameters, invocation);
-       else if (g_strcmp0(method_name, "ResetStatistics") == 0)
-               __handle_reset_statistics(parameters, invocation);
-       else if (g_strcmp0(method_name, "GetCurrentConnection") == 0)
-               __handle_get_current_connection(parameters, invocation);
-       else if (g_strcmp0(method_name, "GetConnections") == 0)
-               __handle_get_connections(parameters, invocation);
-}
-
-static inline GVariant *__get_tcpdump_state(const gchar *sender,GError **error)
-{
-       gboolean state = FALSE;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_tcpdump_state(&state);
-       if (ret != NM_DAEMON_ERROR_NONE) {
-               NM_LOGI("Failed to get");
-               nm_error_set_gerror(ret, error);
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_boolean(state);
-}
-
-static inline GVariant *__get_ip_conflict_state(const gchar *sender,GError **error)
-{
-       gboolean state = FALSE;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_ip_conflict_detect(&state);
-       if (ret < 0) {
-               NM_LOGI("Failed to get");
-               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_boolean(state);
-}
-
-static inline GVariant *__get_ip_conflict_detect(const gchar *sender,GError **error)
-{
-       gboolean detect = FALSE;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_ip_conflict_detect(&detect);
-       if (ret < 0) {
-               NM_LOGI("Failed to get");
-               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_boolean(detect);
-}
-
-static inline GVariant *__get_ethernet_cable_state(const gchar *sender,GError **error)
-{
-       gboolean state = FALSE;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_ethernet_cable_state(&state);
-       if (ret < 0) {
-               NM_LOGI("Failed to get");
-               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_boolean(state);
-}
-
-static inline GVariant *__get_wifi_module_state(const gchar *sender,GError **error)
-{
-       gboolean state = FALSE;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_wifi_module_state(&state);
-       if (ret < 0) {
-               NM_LOGI("Failed to get");
-               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_boolean(state);
-}
-
-static inline GVariant *__get_congestion_level(const gchar *sender,GError **error)
-{
-       int level = 0;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_congestion_level(&level);
-       if (ret < 0) {
-               NM_LOGI("Failed to get");
-               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_int32(level);
-}
-
-static inline GVariant *__get_retry_tx_rate(const gchar *sender,GError **error)
-{
-       int rate = 0;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_retry_tx_rate(&rate);
-       if (ret < 0) {
-               NM_LOGI("Failed to get");
-               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_int32(rate);
-}
-
-static inline GVariant *__get_channel_interference(const gchar *sender,GError **error)
-{
-       double ch_interference = 0.0;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_channel_interference(&ch_interference);
-       if (ret < 0) {
-               NM_LOGI("Failed to get channel_interference");
-               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_double(ch_interference);
-}
-
-static inline GVariant *__get_cellular_state(const gchar *sender,GError **error)
-{
-       int state = 0;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_cellular_state(&state);
-       if (ret < 0) {
-               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-               NM_LOGI("Failed to get");
-                       __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_int32(state);
-}
-
-static inline GVariant *__get_wifi_state(const gchar *sender,GError **error)
-{
-       int state = 0;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_wifi_state(&state);
-       if (ret < 0) {
-               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-               NM_LOGI("Failed to get");
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_int32(state);
-}
-
-static inline GVariant *__get_ethernet_state(const gchar *sender,GError **error)
-{
-       int state = FALSE;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_ethernet_state(&state);
-       if (ret < 0) {
-               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-               NM_LOGI("Failed to get");
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_int32(state);
-}
-
-static inline GVariant *__get_reading_error(const gchar *sender,GError **error)
-{
-       __NM_FUNC_ENTER__;
-       nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-       __NM_FUNC_EXIT__;
-       return NULL;
-}
-
-static GVariant *__daemon_get_property(GDBusConnection *connection,
-               const gchar *sender,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *property_name,
-               GError **error,
-               gpointer user_data)
-{
-       GVariant *ret = NULL;
-       ret = NULL;
-
-       if (g_strcmp0(property_name, "TcpdumpState") == 0)
-               ret = __get_tcpdump_state(sender, error);
-       else if (g_strcmp0(property_name, "IpConflictState") == 0)
-               ret = __get_ip_conflict_state(sender, error);
-       else if (g_strcmp0(property_name, "IpConflictDetect") == 0)
-               ret = __get_ip_conflict_detect(sender, error);
-       else if (g_strcmp0(property_name, "EthernetCableState") == 0)
-               ret = __get_ethernet_cable_state(sender, error);
-       else if (g_strcmp0(property_name, "WifiModuleState") == 0)
-               ret = __get_wifi_module_state(sender, error);
-       else if (g_strcmp0(property_name, "CongestionLevel") == 0)
-               ret = __get_congestion_level(sender, error);
-       else if (g_strcmp0(property_name, "RetryTxRate") == 0)
-               ret = __get_retry_tx_rate(sender, error);
-       else if (g_strcmp0(property_name, "ChannelInterference") == 0)
-               ret = __get_channel_interference(sender, error);
-       else if (g_strcmp0(property_name, "CellularState") == 0)
-               ret = __get_cellular_state(sender, error);
-       else if (g_strcmp0(property_name, "WifiState") == 0)
-               ret = __get_wifi_state(sender, error);
-       else if (g_strcmp0(property_name, "EthernetState") == 0)
-               ret = __get_ethernet_state(sender, error);
-       else if (g_strcmp0(property_name, "ReadingAlwaysThrowsError") == 0)
-               ret = __get_reading_error(sender, error);
-
-       return ret;
-}
-
-static inline void __set_tcpdump_state(const gchar *sender,
-                                      const gchar *object_path,
-                                      const gchar *interface_name,
-                                      GVariant *value,
-                                      GError **error)
-{
-       GVariantBuilder *builder = NULL;
-       GError *local_error = NULL;
-       int ret = NM_DAEMON_ERROR_NONE;
-
-       __NM_FUNC_ENTER__;
-       gboolean tcpdump_state = g_variant_get_boolean(value);
-
-       ret = nm_daemon_set_tcpdump(tcpdump_state);
-       if (ret != NM_DAEMON_ERROR_NONE) {
-               nm_error_set_gerror(ret, error);
-               return;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "TcpdumpState",
-                             g_variant_new_boolean(tcpdump_state));
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       object_path,
-                       NM_DAEMON_SERVICE,
-                       DBUS_STD_PROP_CHANGED,
-                       g_variant_new("(sa{sv}as)",
-                                       interface_name,
-                                       builder,
-                                       NULL),
-                       &local_error);
-
-       g_variant_builder_unref(builder);
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __set_writing_error(const gchar *sender,
-               const gchar *object_path,
-               const gchar *interface_name,
-               GVariant *value,
-               GError **error)
-{
-       __NM_FUNC_ENTER__;
-       nm_error_set_gerror(NM_DAEMON_ERROR_NOT_PERMITTED, error);
-       __NM_FUNC_EXIT__;
-}
-
-static gboolean __daemon_set_property(GDBusConnection *connection,
-               const gchar *sender,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *property_name,
-               GVariant *value,
-               GError **error,
-               gpointer user_data)
-{
-       if (g_strcmp0(property_name, "TcpdumpState") == 0)
-               __set_tcpdump_state(sender, object_path, interface_name, value, error);
-       else if (g_strcmp0(property_name, "WritingAlwaysThrowsError") == 0)
-               __set_writing_error(sender, object_path, interface_name, value, error);
-
-       return *error == NULL;
-}
-
-void nm_gdbus_emit_ip_conflicted(int state, gchar *if_name, gchar *ip)
-{
-       GError *error = NULL;
-       GVariantBuilder *builder = NULL;
-       GVariantBuilder *sub_builder = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       sub_builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(sub_builder, "{sv}", "Ifname", g_variant_new_string(if_name));
-       g_variant_builder_add(sub_builder, "{sv}", "Ip", g_variant_new_string(ip));
-       g_variant_builder_add(sub_builder, "{sv}", "State", g_variant_new_int32(state));
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                       "{sv}",
-                       "ConflictInfo",
-                       g_variant_builder_end(sub_builder));
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       NM_DAEMON_OBJ,
-                       NM_DAEMON_SERVICE,
-                       "IpConflicted",
-                       g_variant_new("(sa{sv}as)",
-                                       NM_DAEMON_SERVICE,
-                                       builder,
-                                       NULL),
-                                       &error);
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_ip_conflicted() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-       }
-
-       __NM_FUNC_EXIT__;
-}
-
-void nm_gdbus_emit_ethernet_cable_state(gboolean state)
-{
-       GError *error = NULL;
-       GVariantBuilder *builder = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "EthernetCableState",
-                                 g_variant_new_boolean(state));
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       NM_DAEMON_OBJ,
-                       NM_DAEMON_SERVICE,
-                       DBUS_STD_PROP_CHANGED,
-                       g_variant_new("(sa{sv}as)",
-                                       NM_DAEMON_SERVICE,
-                                       builder,
-                                       NULL),
-                                       &error);
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_ethernet_cable_state() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-       }
-
-       g_variant_builder_unref(builder);
-       __NM_FUNC_EXIT__;
-}
-
-void nm_gdbus_emit_wifi_module_state(gboolean state)
-{
-       GError *error = NULL;
-       GVariantBuilder *builder = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "WifiModuleState",
-                                 g_variant_new_boolean(state));
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       NM_DAEMON_OBJ,
-                       NM_DAEMON_SERVICE,
-                       DBUS_STD_PROP_CHANGED,
-                       g_variant_new("(sa{sv}as)",
-                                       NM_DAEMON_SERVICE,
-                                       builder,
-                                       NULL),
-                                       &error);
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_wifi_module_state() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-       }
-
-       g_variant_builder_unref(builder);
-       __NM_FUNC_EXIT__;
-}
-
-void nm_gdbus_emit_retry_tx_rate_changed(int retry_tx_rate)
-{
-       GError *error = NULL;
-       GVariantBuilder *builder = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "RetryTxRate",
-                                 g_variant_new_int32(retry_tx_rate));
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       NM_DAEMON_OBJ,
-                       NM_DAEMON_SERVICE,
-                       DBUS_STD_PROP_CHANGED,
-                       g_variant_new("(sa{sv}as)",
-                                       NM_DAEMON_SERVICE,
-                                       builder,
-                                       NULL),
-                                       &error);
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_retry_tx_rate_changed() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-       }
-
-       g_variant_builder_unref(builder);
-       __NM_FUNC_EXIT__;
-}
-
-void nm_gdbus_emit_channel_interference(int freq, double channel_intf)
-{
-       GError *error = NULL;
-       GVariantBuilder *builder = NULL;
-       GVariantBuilder *sub_builder = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-
-       sub_builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(sub_builder, "{sv}", "Frequency", g_variant_new_int32(freq));
-       g_variant_builder_add(sub_builder, "{sv}", "Interference", g_variant_new_double(channel_intf));
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "ChannelInterference",
-                               g_variant_builder_end(sub_builder));
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       NM_DAEMON_OBJ,
-                       NM_DAEMON_SERVICE,
-                       DBUS_STD_PROP_CHANGED,
-                       g_variant_new("(sa{sv}as)",
-                               NM_DAEMON_SERVICE,
-                               builder,
-                               NULL),
-                       &error);
-
-       g_variant_builder_unref(sub_builder);
-       g_variant_builder_unref(builder);
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_channel_interference() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-       }
-
-       __NM_FUNC_EXIT__;
-}
-
-void nm_gdbus_emit_congestion_level_changed(int congestion_level)
-{
-       GError *error = NULL;
-       GVariantBuilder *builder = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "CongestionLevel",
-                                 g_variant_new_int32(congestion_level));
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       NM_DAEMON_OBJ,
-                       NM_DAEMON_SERVICE,
-                       DBUS_STD_PROP_CHANGED,
-                       g_variant_new("(sa{sv}as)",
-                                       NM_DAEMON_SERVICE,
-                                       builder,
-                                       NULL),
-                                       &error);
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_congestion_level_changed() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-       }
-
-       g_variant_builder_unref(builder);
-       __NM_FUNC_EXIT__;
-}
-
-void nm_gdbus_emit_cellular_state(int state)
-{
-       GError *error = NULL;
-       GVariantBuilder *builder = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "CellularState",
-                                 g_variant_new_int32(state));
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       NM_DAEMON_OBJ,
-                       NM_DAEMON_SERVICE,
-                       DBUS_STD_PROP_CHANGED,
-                       g_variant_new("(sa{sv}as)",
-                                       NM_DAEMON_SERVICE,
-                                       builder,
-                                       NULL),
-                                       &error);
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_cellular_state() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-       }
-
-       g_variant_builder_unref(builder);
-       __NM_FUNC_EXIT__;
-}
-
-void nm_gdbus_emit_wifi_state(int state)
-{
-       GError *error = NULL;
-       GVariantBuilder *builder = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "WifiState",
-                                 g_variant_new_int32(state));
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       NM_DAEMON_OBJ,
-                       NM_DAEMON_SERVICE,
-                       DBUS_STD_PROP_CHANGED,
-                       g_variant_new("(sa{sv}as)",
-                                       NM_DAEMON_SERVICE,
-                                       builder,
-                                       NULL),
-                                       &error);
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_wifi_state() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-       }
-
-       g_variant_builder_unref(builder);
-       __NM_FUNC_EXIT__;
-}
-
-void nm_gdbus_emit_ethernet_state(int state)
-{
-       GError *error = NULL;
-       GVariantBuilder *builder = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "EthernetState",
-                                 g_variant_new_int32(state));
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       NM_DAEMON_OBJ,
-                       NM_DAEMON_SERVICE,
-                       DBUS_STD_PROP_CHANGED,
-                       g_variant_new("(sa{sv}as)",
-                                       NM_DAEMON_SERVICE,
-                                       builder,
-                                       NULL),
-                                       &error);
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_ethernet_state() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-       }
-
-       g_variant_builder_unref(builder);
-       __NM_FUNC_EXIT__;
-}
-
-void nm_gdbus_emit_connections_changed(GVariant *signal_args)
-{
-       GError *error = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       NM_DAEMON_OBJ,
-                       NM_DAEMON_SERVICE,
-                       "ConnectionsChanged",
-                       signal_args,
-                       &error);
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_connections_changed() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-       }
-
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __emit_conn_signal(const gchar *property,
-               gchar *path,
-               GVariant *signal_args)
-{
-       GError *error = NULL;
-       GVariantBuilder *builder = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                                 property,
-                                 signal_args);
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       path,
-                       NM_CONN_IFACE,
-                       DBUS_STD_PROP_CHANGED,
-                       g_variant_new("(sa{sv}as)",
-                                       NM_CONN_SERVICE,
-                                       builder,
-                                       NULL),
-                                       &error);
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_conn_%s failed. error [%d: %s]",
-                               property, error->code, error->message);
-               g_error_free(error);
-       }
-
-       g_variant_builder_unref(builder);
-       __NM_FUNC_EXIT__;
-
-}
-
-void nm_gdbus_emit_conn_ipv4_state_changed(gchar *path, GVariant *signal_args)
-{
-       __emit_conn_signal("Ipv4State", path, signal_args);
-}
-
-void nm_gdbus_emit_conn_ipv6_state_changed(gchar *path, GVariant *signal_args)
-{
-       __emit_conn_signal("Ipv6State", path, signal_args);
-}
-
-void nm_gdbus_emit_conn_ip_changed(gchar *path, GVariant *signal_args)
-{
-       __emit_conn_signal("Ip", path, signal_args);
-}
-
-void nm_gdbus_emit_conn_dns_changed(gchar *path, GVariant *signal_args)
-{
-       __emit_conn_signal("Dns", path, signal_args);
-}
-
-void nm_gdbus_emit_wifi_scanning_changed(gboolean scanning)
-{
-       GError *error = NULL;
-       GVariantBuilder *builder = NULL;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_bus_aquired) {
-               NM_LOGI("DBus is not acquired yet");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-       g_variant_builder_add(builder,
-                             "{sv}",
-                             "ScanState",
-                                 g_variant_new_boolean(scanning));
-
-       g_dbus_connection_emit_signal(gdbus_mon.conn,
-                       NULL,
-                       NM_WIFI_OBJ,
-                       NM_WIFI_IFACE,
-                       DBUS_STD_PROP_CHANGED,
-                       g_variant_new("(sa{sv}as)",
-                                       NM_WIFI_IFACE,
-                                       builder,
-                                       NULL),
-                                       &error);
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_emit_wifi_scanning_changed() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-       }
-
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __handle_get_connected_ap(GVariant *parameters,
-               GDBusMethodInvocation *invocation)
-{
-       /* TODO get & return real Wi-Fi connected AP */
-}
-
-static inline void __handle_get_found_aps(GVariant *parameters,
-               GDBusMethodInvocation *invocation)
-{
-       /* TODO get real Wi-Fi Found AP */
-}
-
-static void __wifi_method_call(GDBusConnection *connection,
-               const gchar *sender,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *method_name,
-               GVariant *parameters,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       if (g_strcmp0(method_name, "GetConnectedAp") == 0)
-               __handle_get_connected_ap(parameters, invocation);
-       else if (g_strcmp0(method_name, "GetFoundAps") == 0)
-               __handle_get_found_aps(parameters, invocation);
-}
-
-static inline GVariant *__get_scan_state(const gchar *sender, GError **error)
-{
-       gboolean wifi_scan_state = FALSE;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_daemon_get_wifi_scan_state(&wifi_scan_state);
-       if (ret < 0) {
-               nm_error_set_gerror(NM_DAEMON_ERROR_OPERATION_FAILED, error);
-               NM_LOGI("Failed to get");
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       __NM_FUNC_EXIT__;
-       return g_variant_new_boolean(wifi_scan_state);
-}
-
-static GVariant *__wifi_get_property(GDBusConnection *connection,
-               const gchar *sender,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *property_name,
-               GError **error,
-               gpointer user_data)
-{
-       GVariant *ret;
-       ret = NULL;
-
-       if (g_strcmp0(property_name, "ScanState") == 0)
-               ret = __get_scan_state(sender, error);
-       else if (g_strcmp0(property_name, "ReadingAlwaysThrowsError") == 0)
-               ret = __get_reading_error(sender, error);
-
-       return ret;
-}
-
-static gboolean __wifi_set_property(GDBusConnection *connection,
-                                      const gchar *sender,
-                                      const gchar *object_path,
-                                      const gchar *interface_name,
-                                      const gchar *property_name,
-                                      GVariant *value,
-                                      GError **error,
-                                      gpointer user_data)
-{
-       if (g_strcmp0(property_name, "WritingAlwaysThrowsError") == 0)
-               __set_writing_error(sender, object_path, interface_name, value, error);
-
-       return *error == NULL;
-}
-
-static inline void __handle_conn_get_all(gpointer user_data,
-               GVariant *parameters,
-               GDBusMethodInvocation *invocation)
-{
-       GVariant *arg = NULL;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_connman_get_connection(user_data, &arg);
-       if (ret != 0) {
-               NM_LOGI("Failed to get connection");
-               __dbus_return_err(NM_DAEMON_ERROR_OPERATION_FAILED, invocation);
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       g_dbus_method_invocation_return_value(invocation, arg);
-       __NM_FUNC_EXIT__;
-
-}
-
-static void __conn_method_call(GDBusConnection *connection,
-               const gchar *sender,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *method_name,
-               GVariant *parameters,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       if (g_strcmp0(method_name, "GetAll") == 0)
-               __handle_conn_get_all(user_data, parameters, invocation);
-}
-
-GDBusInterfaceVTable __daemon_iface_vtbl = {
-               __daemon_method_call,
-               __daemon_get_property,
-               __daemon_set_property};
-
-GDBusInterfaceVTable __wifi_iface_vtbl = {
-               __wifi_method_call,
-               __wifi_get_property,
-               __wifi_set_property};
-
-GDBusInterfaceVTable nm_conn_iface_vtbl = {
-               __conn_method_call,
-               NULL,
-               NULL};
-
-int nm_gdbus_register_conn_iface(gchar *conn_obj, guint *conn_obj_id, gpointer conn)
-{
-       GError *error = NULL;
-       guint obj_id = 0;
-
-       obj_id = g_dbus_connection_register_object(gdbus_mon.conn,
-                                                  conn_obj,
-                                                  gdbus_mon.conn_introspection->interfaces[0],
-                                                  &nm_conn_iface_vtbl,
-                                                  conn,
-                                                  NULL,
-                                                  &error);
-       if (obj_id == 0) {
-               NM_LOGI("register object failed!");
-               return -1;
-       }
-
-       if (error != NULL) {
-               NM_LOGI("nm_gdbus_register_conn_iface() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-               return -1;
-       }
-
-       NM_LOGI("register conn object");
-       *conn_obj_id = obj_id;
-
-       return 0;
-}
-
-void nm_gdbus_deregister_conn_iface(guint nm_conn_obj_id)
-{
-       g_dbus_connection_unregister_object(gdbus_mon.conn, nm_conn_obj_id);
-}
-
-int nm_gdbus_register_daemon_iface(void)
-{
-       GError *error = NULL;
-
-       __NM_FUNC_ENTER__;
-
-       gdbus_mon.daemon_obj_id = g_dbus_connection_register_object(
-                       gdbus_mon.conn,
-                       NM_DAEMON_OBJ,
-                       gdbus_mon.daemon_introspection->interfaces[0],
-                       &__daemon_iface_vtbl,
-                       NULL,
-                       NULL,
-                       &error);
-       if (gdbus_mon.daemon_obj_id == 0) {
-               NM_LOGI("register object failed!");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-       if (error != NULL) {
-               NM_LOGI("__register_nm_daemon_iface() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       NM_LOGI("register daemon object");
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_gdbus_register_wifi_iface()
-{
-       GError *error = NULL;
-       __NM_FUNC_ENTER__;
-
-       gdbus_mon.wifi_obj_id = g_dbus_connection_register_object(
-                       gdbus_mon.conn,
-                       NM_WIFI_OBJ,
-                       gdbus_mon.wifi_introspection->interfaces[0],
-                       &__wifi_iface_vtbl,
-                       NULL,
-                       NULL,
-                       &error);
-
-       if (gdbus_mon.wifi_obj_id == 0) {
-               NM_LOGI("register object failed!");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       if (error != NULL) {
-               NM_LOGI("__register_nm_wifi_iface() failed. error [%d: %s]",
-                       error->code, error->message);
-               g_error_free(error);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       NM_LOGI("register wifi object");
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_gdbus_ping(gchar *bus_name, gchar *object_name)
-{
-       GVariant *reply = NULL;
-       GError *error = NULL;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized)
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-
-       if (!bus_name || !object_name)
-               return NM_GDBUS_ERROR_INVALID_PARAM;
-
-       reply = g_dbus_connection_call_sync(
-                       gdbus_mon.conn,
-                       bus_name, /* bus name */
-                       object_name, /* object path */
-                       DBUS_STD_PEER_IFACE, /* interface name */
-                       DBUS_STC_PEER_IFACE_PING, /* method name */
-                       NULL, /* GVariant *params */
-                       NULL, /* reply_type */
-                       G_DBUS_CALL_FLAGS_NO_AUTO_START, /* flags */
-                       DBUS_REPLY_TIMEOUT , /* timeout */
-                       NULL, /* cancellable */
-                       &error); /* error */
-
-       if (error != NULL) {
-               NM_LOGI("Error! Failed to call method: [%s]", error->message);
-               if (g_strrstr(error->message, DBUS_ERROR_STR_NO_OWNER) != NULL)
-                       ret = NM_GDBUS_ERROR_HAS_NO_OWNER;
-               else
-                       ret = NM_GDBUS_ERROR_OPERATION_FAILED;
-               g_error_free(error);
-       }
-
-       if (reply != NULL)
-               g_variant_unref(reply);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_is_wpasupplicant_enabled(gboolean *enabled)
-{
-       int ret = 0;
-       __NM_FUNC_EXIT__;
-
-       ret = nm_gdbus_ping(WPASUPPLICANT_BUS_NAME, WPASUPPLICANT_OBJ);
-
-       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
-               *enabled = FALSE;
-       else
-               *enabled = TRUE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_is_connman_enabled(gboolean *enabled)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_gdbus_ping(CONNMAN_BUS_NAME, CONNMAN_OBJ);
-
-       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
-               *enabled = FALSE;
-       else
-               *enabled = TRUE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_is_telephony_enabled(gboolean *enabled)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_gdbus_ping(TELEPHONY_BUS_NAME, TELEPHONY_OBJ);
-
-       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
-               *enabled = FALSE;
-       else
-               *enabled = TRUE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_is_wfd_manager_enabled(gboolean *enabled)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_gdbus_ping(WFD_MANAGER_BUS_NAME, WFD_MANAGER_OBJ);
-
-       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
-               *enabled = FALSE;
-       else
-               *enabled = TRUE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_is_mobileap_enabled(gboolean *enabled)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_gdbus_ping(MOBILEAP_BUS_NAME, MOBILEAP_OBJ);
-
-       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
-               *enabled = FALSE;
-       else
-               *enabled = TRUE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_is_stc_manager_enabled(gboolean *enabled)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       ret = nm_gdbus_ping(STC_MANAGER_BUS_NAME, STC_MANAGER_OBJ);
-
-       if (ret == NM_GDBUS_ERROR_HAS_NO_OWNER)
-               *enabled = FALSE;
-       else
-               *enabled = TRUE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-static void __gdbus_name_appeared_cb(GDBusConnection *connection,
-               const gchar *name,
-               const gchar *name_owner,
-               gpointer user_data)
-{
-       NM_LOGI("%s is appeared", name);
-
-       if (g_strcmp0(name, WPASUPPLICANT_BUS_NAME) == 0) {
-               if (gdbus_mon.wpasupplicant_watching_cb)
-                       gdbus_mon.wpasupplicant_watching_cb(TRUE);
-       } else if (g_strcmp0(name, CONNMAN_BUS_NAME) == 0) {
-               if (gdbus_mon.connman_watching_cb)
-                       gdbus_mon.connman_watching_cb(TRUE);
-       } else if (g_strcmp0(name, TELEPHONY_BUS_NAME) == 0) {
-               if (gdbus_mon.telephony_watching_cb)
-                       gdbus_mon.telephony_watching_cb(TRUE);
-       } else if (g_strcmp0(name, WFD_MANAGER_BUS_NAME) == 0) {
-               if (gdbus_mon.wfd_manager_watching_cb)
-                       gdbus_mon.wfd_manager_watching_cb(TRUE);
-       } else if (g_strcmp0(name, MOBILEAP_BUS_NAME) == 0) {
-               if (gdbus_mon.mobileap_watching_cb)
-                       gdbus_mon.mobileap_watching_cb(TRUE);
-       } else if (g_strcmp0(name, STC_MANAGER_BUS_NAME) == 0) {
-               if (gdbus_mon.stc_manager_watching_cb)
-                       gdbus_mon.stc_manager_watching_cb(TRUE);
-       }
-}
-
-static void __gdbus_name_vanished_cb(GDBusConnection *connection,
-               const gchar *name,
-               gpointer user_data)
-{
-       NM_LOGI("%s is vanished", name);
-
-       if (g_strcmp0(name, WPASUPPLICANT_BUS_NAME) == 0) {
-               if (gdbus_mon.wpasupplicant_watching_cb)
-                       gdbus_mon.wpasupplicant_watching_cb(FALSE);
-       } else if (g_strcmp0(name, CONNMAN_BUS_NAME) == 0) {
-               if (gdbus_mon.connman_watching_cb)
-                       gdbus_mon.connman_watching_cb(FALSE);
-       } else if (g_strcmp0(name, TELEPHONY_BUS_NAME) == 0) {
-               if (gdbus_mon.telephony_watching_cb)
-                       gdbus_mon.telephony_watching_cb(FALSE);
-       } else if (g_strcmp0(name, WFD_MANAGER_BUS_NAME) == 0) {
-               if (gdbus_mon.wfd_manager_watching_cb)
-                       gdbus_mon.wfd_manager_watching_cb(FALSE);
-       } else if (g_strcmp0(name, MOBILEAP_BUS_NAME) == 0) {
-               if (gdbus_mon.mobileap_watching_cb)
-                       gdbus_mon.mobileap_watching_cb(FALSE);
-       } else if (g_strcmp0(name, STC_MANAGER_BUS_NAME) == 0) {
-               if (gdbus_mon.stc_manager_watching_cb)
-                       gdbus_mon.stc_manager_watching_cb(FALSE);
-       }
-}
-
-int nm_gdbus_set_wpasupplicant_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.wpasupplicant_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.wpasupplicant_watching_id);
-               gdbus_mon.wpasupplicant_watching_cb = NULL;
-               gdbus_mon.wpasupplicant_watching_id = 0;
-       }
-
-       gdbus_mon.wpasupplicant_watching_id =
-                       g_bus_watch_name_on_connection(gdbus_mon.conn,
-                                       WPASUPPLICANT_BUS_NAME,
-                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
-                                       __gdbus_name_appeared_cb,
-                                       __gdbus_name_vanished_cb,
-                                       NULL,
-                                       NULL);
-       if (gdbus_mon.wpasupplicant_watching_id == 0)
-               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
-       else
-               gdbus_mon.wpasupplicant_watching_cb = cb;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_unset_wpasupplicant_bus_watching_callback()
-{
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.wpasupplicant_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.wpasupplicant_watching_id);
-               gdbus_mon.wpasupplicant_watching_cb = NULL;
-               gdbus_mon.wpasupplicant_watching_id = 0;
-       }
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_gdbus_set_connman_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.connman_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.connman_watching_id);
-               gdbus_mon.connman_watching_cb = NULL;
-               gdbus_mon.connman_watching_id = 0;
-       }
-
-       gdbus_mon.connman_watching_id =
-                       g_bus_watch_name_on_connection(gdbus_mon.conn,
-                                       CONNMAN_BUS_NAME,
-                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
-                                       __gdbus_name_appeared_cb,
-                                       __gdbus_name_vanished_cb,
-                                       NULL,
-                                       NULL);
-       if (gdbus_mon.connman_watching_id == 0)
-               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
-       else
-               gdbus_mon.connman_watching_cb = cb;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_unset_connman_bus_watching_callback()
-{
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.connman_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.connman_watching_id);
-               gdbus_mon.connman_watching_cb = NULL;
-               gdbus_mon.connman_watching_id = 0;
-       }
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_gdbus_set_telephony_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.telephony_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.telephony_watching_id);
-               gdbus_mon.telephony_watching_cb = NULL;
-               gdbus_mon.telephony_watching_id = 0;
-       }
-
-       gdbus_mon.telephony_watching_id =
-                       g_bus_watch_name_on_connection(gdbus_mon.conn,
-                                       TELEPHONY_BUS_NAME,
-                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
-                                       __gdbus_name_appeared_cb,
-                                       __gdbus_name_vanished_cb,
-                                       NULL,
-                                       NULL);
-       if (gdbus_mon.telephony_watching_id == 0)
-               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
-       else
-               gdbus_mon.telephony_watching_cb = cb;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_unset_telephony_bus_watching_callback()
-{
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.telephony_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.telephony_watching_id);
-               gdbus_mon.telephony_watching_cb = NULL;
-               gdbus_mon.telephony_watching_id = 0;
-       }
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_gdbus_set_wfd_manager_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.wfd_manager_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.wfd_manager_watching_id);
-               gdbus_mon.wfd_manager_watching_cb = NULL;
-               gdbus_mon.wfd_manager_watching_id  = 0;
-       }
-
-       gdbus_mon.wfd_manager_watching_id =
-                       g_bus_watch_name_on_connection(gdbus_mon.conn,
-                                       WFD_MANAGER_BUS_NAME,
-                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
-                                       __gdbus_name_appeared_cb,
-                                       __gdbus_name_vanished_cb,
-                                       NULL,
-                                       NULL);
-       if (gdbus_mon.wfd_manager_watching_id == 0)
-               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
-       else
-               gdbus_mon.wfd_manager_watching_cb = cb;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_unset_wfd_manager_bus_watching_callback()
-{
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.wfd_manager_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.wfd_manager_watching_id);
-               gdbus_mon.wfd_manager_watching_cb = NULL;
-               gdbus_mon.wfd_manager_watching_id  = 0;
-       }
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_gdbus_set_mobileap_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.mobileap_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.mobileap_watching_id);
-               gdbus_mon.mobileap_watching_cb = NULL;
-               gdbus_mon.mobileap_watching_id = 0;
-       }
-
-       gdbus_mon.mobileap_watching_id =
-                       g_bus_watch_name_on_connection(gdbus_mon.conn,
-                                       MOBILEAP_BUS_NAME,
-                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
-                                       __gdbus_name_appeared_cb,
-                                       __gdbus_name_vanished_cb,
-                                       NULL,
-                                       NULL);
-       if (gdbus_mon.mobileap_watching_id == 0)
-               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
-       else
-               gdbus_mon.mobileap_watching_cb = cb;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_unset_mobileap_bus_watching_callback()
-{
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.mobileap_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.mobileap_watching_id);
-               gdbus_mon.mobileap_watching_cb = NULL;
-               gdbus_mon.mobileap_watching_id = 0;
-       }
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_gdbus_set_stc_manager_bus_watching_callback(nm_gdbus_watching_bus_callback cb)
-{
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.stc_manager_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.stc_manager_watching_id);
-               gdbus_mon.stc_manager_watching_cb = NULL;
-               gdbus_mon.stc_manager_watching_id = 0;
-       }
-
-       gdbus_mon.stc_manager_watching_id =
-                       g_bus_watch_name_on_connection(gdbus_mon.conn,
-                                       STC_MANAGER_BUS_NAME,
-                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
-                                       __gdbus_name_appeared_cb,
-                                       __gdbus_name_vanished_cb,
-                                       NULL,
-                                       NULL);
-       if (gdbus_mon.stc_manager_watching_id == 0)
-               ret = NM_GDBUS_ERROR_OPERATION_FAILED;
-       else
-               gdbus_mon.stc_manager_watching_cb = cb;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_unset_stc_manager_bus_watching_callback()
-{
-       __NM_FUNC_ENTER__;
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.stc_manager_watching_id != 0) {
-               g_bus_unwatch_name(gdbus_mon.stc_manager_watching_id);
-               gdbus_mon.stc_manager_watching_cb = NULL;
-               gdbus_mon.stc_manager_watching_id = 0;
-       }
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-static void __on_bus_acquired(GDBusConnection *connection,
-                              const gchar *name,
-                              gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       gdbus_mon.is_bus_aquired = TRUE;
-
-       if (gdbus_mon.bus_acquired_cb)
-               gdbus_mon.bus_acquired_cb();
-       __NM_FUNC_EXIT__;
-}
-
-static void __on_name_acquired(GDBusConnection *connection,
-                              const gchar *name,
-                              gpointer user_data)
-{
-       NM_LOGI("Bus name [%s] acquired\n", name);
-}
-
-static void __on_name_lost(GDBusConnection *connection,
-                          const gchar *name,
-                          gpointer user_data)
-{
-       gdbus_mon.is_bus_aquired = FALSE;
-
-       NM_LOGI("Bus name lost");
-       if (gdbus_mon.name_lost_cb)
-               gdbus_mon.name_lost_cb();
-}
-
-int __init_introspection()
-{
-       gdbus_mon.daemon_introspection =
-                       g_dbus_node_info_new_for_xml(nm_daemon_introspection_xml, NULL);
-
-       if (!gdbus_mon.daemon_introspection) {
-               NM_LOGI("No daemon introspection\n");
-               return -1;
-       }
-
-       gdbus_mon.wifi_introspection =
-                       g_dbus_node_info_new_for_xml(nm_wifi_introspection_xml, NULL);
-
-       if (!gdbus_mon.wifi_introspection) {
-               NM_LOGI("No wifi introspection\n");
-               if (gdbus_mon.daemon_introspection) {
-                       g_dbus_node_info_unref(gdbus_mon.daemon_introspection);
-                       gdbus_mon.daemon_introspection = NULL;
-               }
-               return -1;
-       }
-
-       gdbus_mon.conn_introspection =
-                       g_dbus_node_info_new_for_xml(nm_conn_introspection_xml, NULL);
-
-       if (!gdbus_mon.wifi_introspection) {
-               NM_LOGI("No conn introspection\n");
-               if (gdbus_mon.daemon_introspection) {
-                       g_dbus_node_info_unref(gdbus_mon.daemon_introspection);
-                       gdbus_mon.daemon_introspection = NULL;
-               }
-
-               if (gdbus_mon.wifi_introspection) {
-                       g_dbus_node_info_unref(gdbus_mon.wifi_introspection);
-                       gdbus_mon.wifi_introspection = NULL;
-               }
-               return -1;
-       }
-
-       return 0;
-}
-
-void __deinit_introspection()
-{
-       if (gdbus_mon.daemon_introspection)
-               g_dbus_node_info_unref(gdbus_mon.daemon_introspection);
-
-       if (gdbus_mon.wifi_introspection)
-               g_dbus_node_info_unref(gdbus_mon.wifi_introspection);
-
-       if (gdbus_mon.conn_introspection)
-               g_dbus_node_info_unref(gdbus_mon.conn_introspection);
-
-       gdbus_mon.daemon_introspection = NULL;
-       gdbus_mon.wifi_introspection = NULL;
-       gdbus_mon.conn_introspection = NULL;
-}
-
-int nm_gdbus_init(bus_aquired_callback bus_acquired_cb,
-                                 name_lost_callback name_lost_cb)
-{
-       gint ret = NM_GDBUS_ERROR_NONE;
-       GError *error = NULL;
-
-       __NM_FUNC_ENTER__;
-
-       memset(&gdbus_mon, 0x00, sizeof(gdbus_mon));
-       gdbus_mon.conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-       if (gdbus_mon.conn == NULL) {
-               if (error != NULL) {
-                       NM_LOGI("Error! Failed to connect to the D-BUS daemon: [%s]",
-                                       error->message);
-                       g_error_free(error);
-               }
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_OPERATION_FAILED;
-       }
-       NM_LOGI("Get System DBus");
-
-       if (__init_introspection() != 0) {
-               NM_LOGI("Introspection initialize failed");
-               g_object_unref(gdbus_mon.conn);
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_OPERATION_FAILED;
-       }
-
-       gdbus_mon.is_initialized = TRUE;
-       gdbus_mon.bus_acquired_cb = bus_acquired_cb;
-       gdbus_mon.name_lost_cb = name_lost_cb;
-
-       gdbus_mon.owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
-                       NM_DAEMON_SERVICE,
-                       G_BUS_NAME_OWNER_FLAGS_NONE,
-                       __on_bus_acquired,
-                       __on_name_acquired,
-                       __on_name_lost,
-                       NULL,
-                       NULL);
-       NM_LOGI("Request to Own [%u]", gdbus_mon.owner_id);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_gdbus_deinit()
-{
-       gint ret = NM_GDBUS_ERROR_NONE;
-
-       __NM_FUNC_ENTER__;
-
-       if (!gdbus_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_GDBUS_ERROR_NOT_INITIALIZED;
-       }
-
-       if (gdbus_mon.wifi_obj_id)
-               g_dbus_connection_unregister_object(gdbus_mon.conn,
-                               gdbus_mon.wifi_obj_id);
-
-       if (gdbus_mon.daemon_obj_id)
-               g_dbus_connection_unregister_object(gdbus_mon.conn,
-                               gdbus_mon.daemon_obj_id);
-
-       g_bus_unown_name(gdbus_mon.owner_id);
-
-       g_object_unref(gdbus_mon.conn);
-
-       __deinit_introspection();
-
-       memset(&gdbus_mon, 0x00, sizeof(gdbus_mon));
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-iface-mon.c b/src/nm-iface-mon.c
deleted file mode 100644 (file)
index 42543ce..0000000
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for monitoring interface.
- *
- * @file        nm-iface-mon.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <net/if.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#include "nm-daemon-log.h"
-#include "nm-iface-mon.h"
-#include "nm-util.h"
-
-#define IFACE_CABLE_STATUS     "/sys/class/net/%s/carrier"
-
-/*Poll the interface Plug-in /Plug-out status at every 1000 ms*/
-#define IFACE_POLLING_TIME       1000
-
-typedef struct {
-       gboolean is_initialized;
-       GHashTable *monitoring_cbs;
-} iface_mon_s;
-
-iface_mon_s iface_mon;
-
-static void __destroy_mon_data(gpointer data)
-{
-       iface_mon_data_s *mon_data = (iface_mon_data_s *)data;
-       __NM_FUNC_ENTER__;
-
-       g_free(data);
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-/*
-static gboolean __status_polling_callback(gpointer user_data)
-{
-       iface_mon_data_s *data = NULL;
-       gchar file_path[128] = {0,};
-       int status;
-
-
-       data = (iface_mon_data_s *)user_data;
-       if (!data) {
-               NM_LOGI("user data not available");
-               return TRUE;
-       }
-
-       g_snprintf(file_path, 128, IFACE_CABLE_STATUS, data->iface_name);
-       if (nm_check_cable_status(file_path, &status) < 0) {
-               __NM_FUNC_EXIT__;
-               return TRUE;
-       }
-       NM_LOGI("%s : [%d]", file_path, status);
-
-       if (data->cb)
-               data->cb(data->iface_name, status, data->cb_user_data);
-
-       return TRUE;
-}
-
-static int __attatch_monitor_file(iface_mon_data_s *data)
-{
-       __NM_FUNC_ENTER__;
-
-       data->timer_source_id = g_timeout_add(IFACE_POLLING_TIME,
-                       __status_polling_callback,
-                       data);
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-*/
-
-void __nm_wifi_module_state_changed_cb(keynode_t *node, gpointer user_data)
-{
-       iface_mon_data_s *data = NULL;
-       int device_status = 0;
-       if (!user_data) {
-               NM_LOGE("user data not available");
-               return;
-       }
-       data = (iface_mon_data_s *)user_data;
-
-       if (vconf_get_int(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT, &device_status) < 0) {
-               NM_LOGE("Unable to read status from vconf key");
-               return;
-       }
-
-       NM_LOGI("Wi-Fi Module State [%d]", device_status);
-
-       if (data->cb)
-               data->cb(data->iface_name, device_status, NULL);
-
-}
-
-static int __nm_wifi_set_module_state_changed_cb(gboolean flag, iface_mon_data_s *data)
-{
-       static __thread gint refcount = 0;
-       int ret = 0;
-
-       if (flag) {
-               if (refcount == 0) {
-                       ret = vconf_notify_key_changed(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT,
-                                       __nm_wifi_module_state_changed_cb, data);
-               }
-
-               refcount++;
-               NM_LOGI("Successfully registered(%d)", refcount);
-       } else {
-               if (refcount > 0) {
-                       if (--refcount == 0) {
-                               if (vconf_ignore_key_changed(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT,
-                                                       __nm_wifi_module_state_changed_cb) < 0) {
-                                       NM_LOGI("Error to de-register vconf callback(%d)", refcount);
-                                       return -1;
-                               } else
-                                       NM_LOGI("Successfully de-registered(%d)", refcount);
-                       }
-               }
-       }
-
-       return ret;
-}
-
-int nm_iface_mon_start_monitor(char *iface_name, nm_iface_mon_callback cb, void *user_data)
-{
-       iface_mon_data_s *data = NULL;
-       int ret = NM_IFACE_MON_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!iface_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IFACE_MON_NOT_INITIALIZED;
-       }
-
-       if (!cb || !iface_name || strlen(iface_name) == 0) {
-               __NM_FUNC_EXIT__;
-               return NM_IFACE_MON_INVALID_PARAMETER;
-}
-
-       data = (iface_mon_data_s *)g_try_malloc0(sizeof(iface_mon_data_s));
-       if (!data) {
-               __NM_FUNC_EXIT__;
-               return NM_IFACE_MON_OPERATION_FAILED;
-       }
-       data->cb = cb;
-       data->cb_user_data = user_data;
-
-       if (strncmp(iface_name, "eth", 3) == 0) {
-               /** netlink event based ethernet monitoring */
-               if (nm_rtnl_init(data) < 0) {
-                       g_free(data);
-                       __NM_FUNC_EXIT__;
-                       return NM_IFACE_MON_OPERATION_FAILED;
-               }
-       } else if (strncmp(iface_name, "wlan", 4) == 0) {
-               g_strlcpy(data->iface_name, iface_name, IFNAMSIZ);
-               if (__nm_wifi_set_module_state_changed_cb(TRUE, data) < 0) {
-                       g_free(data);
-                       __NM_FUNC_EXIT__;
-                       return NM_IFACE_MON_OPERATION_FAILED;
-               }
-       } else {
-               NM_LOGE("Invalid Interface: %s", iface_name);
-               g_free(data);
-               __NM_FUNC_EXIT__;
-               return NM_IFACE_MON_INVALID_PARAMETER;
-       }
-
-       g_hash_table_insert(iface_mon.monitoring_cbs, g_strdup(iface_name), data);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_iface_mon_stop_monitor(char *iface_name)
-{
-       int ret = NM_IFACE_MON_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!iface_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IFACE_MON_NOT_INITIALIZED;
-       }
-
-       if (!iface_name || strlen(iface_name) == 0) {
-               __NM_FUNC_EXIT__;
-               return NM_IFACE_MON_INVALID_PARAMETER;
-       }
-
-       /** Cleanup netlink socket for ethernet interface */
-       if (strncmp(iface_name, "eth", 3) == 0) {
-               nm_rtnl_cleanup();
-       } else if (strncmp(iface_name, "wlan", 4) == 0) {
-               if (__nm_wifi_set_module_state_changed_cb(FALSE, NULL) < 0) {
-                       __NM_FUNC_EXIT__;
-                       return NM_IFACE_MON_OPERATION_FAILED;
-               }
-       }
-
-       g_hash_table_remove(iface_mon.monitoring_cbs, iface_name);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_iface_mon_get_iface_state(char *iface_name, int *state)
-{
-       int ret = NM_IFACE_MON_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-       gchar file_path[128] = {0,};
-
-       if (!iface_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IFACE_MON_NOT_INITIALIZED;
-       }
-
-       if (!state || !iface_name || strlen(iface_name) == 0) {
-               __NM_FUNC_EXIT__;
-               return NM_IFACE_MON_INVALID_PARAMETER;
-       }
-       g_snprintf(file_path, 128, IFACE_CABLE_STATUS, iface_name);
-       if (nm_check_cable_status(file_path, state) < 0) {
-               __NM_FUNC_EXIT__;
-               return NM_IFACE_MON_OPERATION_FAILED;
-       }
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_iface_mon_init()
-{
-       int ret = NM_IFACE_MON_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       memset(&iface_mon, 0x00, sizeof(iface_mon));
-       iface_mon.is_initialized = TRUE;
-
-       iface_mon.monitoring_cbs = g_hash_table_new_full(g_str_hash,
-                       g_str_equal,
-                       g_free,
-                       __destroy_mon_data
-                       );
-
-       if (!iface_mon.monitoring_cbs) {
-               iface_mon.is_initialized = FALSE;
-               __NM_FUNC_EXIT__;
-               return NM_IFACE_MON_OPERATION_FAILED;
-       }
-
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_iface_mon_deinit()
-{
-       int ret = NM_IFACE_MON_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!iface_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IFACE_MON_NOT_INITIALIZED;
-       }
-
-       iface_mon.is_initialized = FALSE;
-       g_hash_table_remove_all(iface_mon.monitoring_cbs);
-       g_hash_table_unref(iface_mon.monitoring_cbs);
-       iface_mon.monitoring_cbs = NULL;
-
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-ip-conflict.c b/src/nm-ip-conflict.c
deleted file mode 100644 (file)
index 4c97b42..0000000
+++ /dev/null
@@ -1,819 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements Detecting IP conflict functions.
- *
- * @file        nm-ip-conflict.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <errno.h>
-
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <linux/if.h>
-#include <linux/if_packet.h>
-#include <linux/if_ether.h>
-#include <linux/if_arp.h>
-#include <net/ethernet.h>
-
-#include <arpa/inet.h>
-
-#include <glib.h>
-
-#include "nm-daemon-log.h"
-#include "nm-ip-conflict.h"
-#include "nm-util.h"
-
-#define ARP_PACKET_SIZE 60
-#define CONFLICT_REMOVE_ITERATION_LIMIT 4
-#define MIN_ARP_SEND_TIME 20000
-#define BURST_ARP_SEND_TIME 3000
-#define MAX_ARP_SEND_TIME 32000
-#define INITIAL_BURST_ARP_COUNT 5
-#define MSEC 1000
-#define IP_ALEN 4
-
-#ifndef MAC_FMT
-#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
-#endif
-
-#ifndef IP_FMT
-#define IP_FMT "%d.%d.%d.%d"
-#endif
-
-#define REMOVE_G_SOURCE(g_source) \
-       do { \
-               if ((g_source)) { \
-                       g_source_remove((g_source)); \
-                       (g_source) = 0; \
-               } \
-       } while (0)
-
-typedef struct __attribute__((packed))
-{
-       unsigned short arp_hrd;
-       unsigned short arp_pro;
-       unsigned char arp_hln;
-       unsigned char arp_pln;
-       unsigned short arp_op;
-       unsigned char arp_sha[ETH_ALEN];
-       unsigned char arp_sip[IP_ALEN];
-       unsigned char arp_tha[ETH_ALEN];
-       unsigned char arp_tip[IP_ALEN];
-} arp_message_s;
-
-typedef struct {
-       gboolean detection_enabled;
-
-       gchar if_name[IFNAMSIZ];
-
-       int ifindex;
-       unsigned char hwaddr[ETH_ALEN];
-       unsigned char ipaddr[IP_ALEN];
-
-       gboolean initial_bursts;
-       gint iteration;
-       guint timeout;
-
-       /* arp sock related */
-       gint sock;
-       GIOChannel * sock_io_channel;
-       guint sock_source_id;
-       guint timer_source_id;
-       guint arp_reply_timer_source_id;
-
-       struct sockaddr_ll ll_addr;
-
-       nm_ip_conflict_state_e state;
-
-       ip_conflict_callback cb;
-       gpointer cb_user_data;
-} ip_conflict_data_s;
-
-typedef struct {
-       gboolean is_initialized;
-
-       guint initial_time;
-
-       GHashTable *ip_conflict_cb_tbl;
-} ip_conflict_mon_s;
-
-ip_conflict_mon_s ip_conflict_mon;
-
-static gboolean __send_arp(gpointer user_data);
-
-static void __print_mac(guchar *mac)
-{
-       NM_LOGI(MAC_FMT "\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-}
-
-static void __print_ip(guchar *ip)
-{
-       NM_LOGI(IP_FMT "\n", ip[0], ip[1], ip[2], ip[3]);
-}
-
-static void __init_ll_addr(struct sockaddr_ll *ll_addr)
-{
-       ll_addr->sll_family = AF_PACKET;
-       ll_addr->sll_protocol = htons(ETH_P_ARP);
-       ll_addr->sll_hatype = htons(ARPHRD_ETHER);
-       ll_addr->sll_pkttype = (PACKET_BROADCAST);
-       ll_addr->sll_halen = ETH_ALEN;
-       ll_addr->sll_addr[6] = 0x00;
-       ll_addr->sll_addr[7] = 0x00;
-       return;
-}
-
-static void __init_ip_conflict_sock_data(ip_conflict_data_s *ip_conflict_data)
-{
-       ip_conflict_data->initial_bursts = TRUE;
-       ip_conflict_data->sock = -1;
-       ip_conflict_data->sock_io_channel = NULL;
-       ip_conflict_data->sock_source_id = 0;
-       ip_conflict_data->timer_source_id = 0;
-       ip_conflict_data->iteration = 0;
-       ip_conflict_data->state = IP_CONFLICT_STATE_UNKNOWN;
-       ip_conflict_data->detection_enabled = FALSE;
-
-       return;
-}
-
-static gboolean __arp_reply_timeout_cb(gpointer data)
-{
-       __NM_FUNC_ENTER__;
-       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)data;
-
-       ip_conflict_data->iteration++;
-       REMOVE_G_SOURCE(ip_conflict_data->arp_reply_timer_source_id);
-       REMOVE_G_SOURCE(ip_conflict_data->timer_source_id);
-
-       if (ip_conflict_data->state != IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED &&
-                       ip_conflict_data->iteration == CONFLICT_REMOVE_ITERATION_LIMIT) {
-               ip_conflict_data->iteration = 0;
-               ip_conflict_data->state = IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED;
-               ip_conflict_data->initial_bursts = TRUE;
-               if (ip_conflict_data->cb)
-                       ip_conflict_data->cb(ip_conflict_data->state,
-                                       ip_conflict_data->if_name,
-                                       ip_conflict_data->ipaddr,
-                                       ip_conflict_data->cb_user_data);
-       }
-
-       ip_conflict_data->timer_source_id = g_timeout_add(ip_conflict_data->timeout, __send_arp, ip_conflict_data);
-       __NM_FUNC_EXIT__;
-       return G_SOURCE_REMOVE;
-}
-
-static gboolean __check_arp_receive(GIOChannel *source,
-                                                 GIOCondition condition, gpointer data)
-{
-       arp_message_s *ah = NULL;
-       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)data;
-       gchar buf[ARP_PACKET_SIZE] = {0, };
-       gchar *ptr = NULL;
-       gsize bytes_read = 0;
-       GError *error = NULL;
-
-       if (g_io_channel_read_chars(source, buf, ARP_PACKET_SIZE,
-                               &bytes_read, &error) != G_IO_STATUS_NORMAL) {
-               NM_LOGI("Failure received arp packet[%d]:[%s]",
-                               error->code, error->message);
-               g_error_free(error);
-               return TRUE;
-       }
-
-       ptr = buf + ETH_HLEN;
-       ah = (arp_message_s *)ptr;
-
-       /* Only handle ARP replies */
-       if (ah->arp_op != htons(ARPOP_REPLY)) {
-               return TRUE;
-       }
-
-       if (memcmp(ah->arp_sha, ip_conflict_data->hwaddr, ETH_ALEN) == 0 ||
-               memcmp(ah->arp_sip, ip_conflict_data->ipaddr, 4) != 0) {
-               NM_LOGI("Packet not intended to us.\n");
-               return TRUE;
-       }
-
-       ip_conflict_data->iteration = 0;
-       NM_LOGI("ip conflict is detected !\n");
-       ip_conflict_data->state = IP_CONFLICT_STATE_CONFLICT_DETECTED;
-       ip_conflict_data->timeout = BURST_ARP_SEND_TIME;
-       if (ip_conflict_data->cb)
-               ip_conflict_data->cb(ip_conflict_data->state,
-                               ip_conflict_data->if_name,
-                               ip_conflict_data->ipaddr,
-                               ip_conflict_data->cb_user_data);
-
-       REMOVE_G_SOURCE(ip_conflict_data->arp_reply_timer_source_id);
-       REMOVE_G_SOURCE(ip_conflict_data->timer_source_id);
-       ip_conflict_data->timer_source_id =
-                       g_timeout_add(ip_conflict_data->timeout, __send_arp, NULL);
-
-       return TRUE;
-}
-
-int __get_iface_info(ip_conflict_data_s *ip_conflict_data)
-{
-       struct ifreq ifr;
-       char err_str[128] = {0,};
-       int sock = -1;
-
-       __NM_FUNC_ENTER__;
-
-       /* TODO laod local Iface info */
-
-       memset(&ifr, 0x00, sizeof(ifr));
-       if (strlen(ip_conflict_data->if_name) == 0)
-               return -1;
-
-       g_strlcpy(ifr.ifr_name, ip_conflict_data->if_name, strlen(ip_conflict_data->if_name) + 1);
-       NM_LOGI("get %s info\n", ifr.ifr_name);
-       sock = socket(AF_INET, SOCK_DGRAM, 0);
-       if (sock < 0) {
-               strerror_r(errno, err_str, 128);
-               NM_LOGE("errno[%d]: %s\n", errno, err_str);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       if (ioctl(sock, SIOCGIFHWADDR, &ifr) <0) {
-               strerror_r(errno, err_str, 128);
-               NM_LOGE("errno[%d]: %s\n", errno, err_str);
-               __NM_FUNC_EXIT__;
-               close(sock);
-               return -1;
-       }
-
-       memcpy(ip_conflict_data->hwaddr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
-       NM_LOGI("Successfully got our MAC address: ");
-       __print_mac(ip_conflict_data->hwaddr);
-
-       if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0) {
-               strerror_r(errno, err_str, 128);
-               NM_LOGE("errno[%d]: %s\n", errno, err_str);
-               __NM_FUNC_EXIT__;
-               close(sock);
-               return -1;
-       }
-       ip_conflict_data->ifindex = ifr.ifr_ifindex;
-       NM_LOGI("Successfully got interface index: %i\n", ip_conflict_data->ifindex);
-
-       if (ioctl(sock, SIOCGIFADDR, &ifr) < 0) {
-               strerror_r(errno, err_str, 128);
-               NM_LOGE("errno[%d]: %s\n", errno, err_str);
-               close(sock);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       if (ifr.ifr_addr.sa_family != AF_INET) {
-               NM_LOGE("addr is not AF_INET\n");
-               close(sock);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       memcpy(ip_conflict_data->ipaddr, &(ifr.ifr_addr.sa_data[2]), 4);
-       NM_LOGI("IP addr: ");
-       __print_ip(ip_conflict_data->ipaddr);
-       close(sock);
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-void __set_defend_arp_ethhdr(ip_conflict_data_s *ip_conflict_data, struct ethhdr *eh)
-{
-       memset(eh->h_dest, 0xff, ETH_ALEN);
-       memcpy(eh->h_source, ip_conflict_data->hwaddr, ETH_ALEN);
-       eh->h_proto = htons(ETH_P_ARP);
-       return;
-}
-
-void __set_defend_arp(ip_conflict_data_s *ip_conflict_data, arp_message_s *ah)
-{
-       ah->arp_hrd = htons(ARPHRD_ETHER);
-       ah->arp_pro = htons(ETH_P_IP);
-       ah->arp_hln = ETH_ALEN;
-       ah->arp_pln = 4;
-       ah->arp_op = htons(ARPOP_REQUEST);
-
-       memcpy(ah->arp_sha, ip_conflict_data->hwaddr, ETH_ALEN);
-       /* by RFC 5227 2.1.1.  Probe Details,
-        'sender IP address' field MUST be set to all zeroes;
-        this is to avoid polluting ARP caches in other hosts
-        on the same link in the case where the address turns
-        out to be already in use by another host. */
-
-       memset(ah->arp_sip, 0x00, 4);
-       //memcpy(ah->arp_sip, ip_conflict_mons.ipaddr, 4);
-
-       memset(ah->arp_tha, 0x00, ETH_ALEN);
-
-       memcpy(ah->arp_tip, ip_conflict_data->ipaddr, 4);
-       return;
-}
-
-static int __recover_socket(ip_conflict_data_s *ip_conflict_data)
-{
-       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
-       if (ip_conflict_data->sock >= 0) {
-               close(ip_conflict_data->sock);
-               ip_conflict_data->sock = -1;
-       }
-
-       /* reopen socket */
-       if ((ip_conflict_data->sock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ARP))) == -1) {
-               NM_LOGI("socket %d", ip_conflict_data->sock);
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               NM_LOGI("socket Failed. Error = %s\n", error_buf);
-       }
-
-       return ip_conflict_data->sock;
-}
-
-static gboolean __send_arp(gpointer user_data)
-{
-       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)user_data;
-       static gint initial_send_arp_count = 0;
-       guchar buf[60] = {0,};
-       guchar *pos = NULL;
-       gint ret = 0;
-
-       if (ip_conflict_data->initial_bursts &&
-                       initial_send_arp_count >= INITIAL_BURST_ARP_COUNT) {
-               ip_conflict_data->initial_bursts = FALSE;
-               initial_send_arp_count = 0;
-       }
-
-       if (ip_conflict_data->initial_bursts)
-               initial_send_arp_count++;
-
-       __get_iface_info(ip_conflict_data);
-
-       pos = buf;
-       __set_defend_arp_ethhdr(ip_conflict_data, (struct ethhdr *)pos);
-
-       pos = buf + ETH_HLEN;
-       __set_defend_arp(ip_conflict_data, (arp_message_s *)pos);
-
-       /* Construct the destination address */
-       memcpy(ip_conflict_data->ll_addr.sll_addr, ip_conflict_data->hwaddr, ETH_ALEN);
-       ip_conflict_data->ll_addr.sll_ifindex = ip_conflict_data->ifindex;
-
-       ret = sendto(ip_conflict_data->sock, buf, 42, 0,
-               (struct sockaddr *) &(ip_conflict_data->ll_addr),
-               sizeof(struct sockaddr_ll));
-
-       if (ret == -1 && __recover_socket(ip_conflict_data) < 0) {
-               REMOVE_G_SOURCE(ip_conflict_data->timer_source_id);
-               ip_conflict_data->timer_source_id =
-                               g_timeout_add(ip_conflict_data->timeout, __send_arp, ip_conflict_data);
-       } else {
-               NM_LOGD("Sent ARP Packet \n");
-               REMOVE_G_SOURCE(ip_conflict_data->timer_source_id);
-
-               if (ip_conflict_data->state == IP_CONFLICT_STATE_CONFLICT_DETECTED ||
-                               ip_conflict_data->initial_bursts)
-                       ip_conflict_data->timeout = BURST_ARP_SEND_TIME;
-               else
-                       ip_conflict_data->timeout = ip_conflict_mon.initial_time;
-
-               /* Adding timeout callback for arp request */
-               ip_conflict_data->arp_reply_timer_source_id =
-                               g_timeout_add(1000, __arp_reply_timeout_cb, ip_conflict_data);
-       }
-
-       return FALSE;
-}
-
-static void __start_ip_conflict_mon(gpointer key,
-        gpointer value,
-        gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       gchar error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
-       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)value;
-       ip_conflict_mon_s *mon = (ip_conflict_mon_s *)user_data;
-
-       gint sock = -1;
-
-       if (!ip_conflict_data->detection_enabled) {
-               NM_LOGI("IP conflict detection disabled");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       __init_ip_conflict_sock_data(ip_conflict_data);
-
-       sock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ARP));
-       if (sock < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               NM_LOGI("socket Failed. Error = %s\n", error_buf);
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       ip_conflict_data->sock = sock;
-       ip_conflict_data->sock_io_channel = g_io_channel_unix_new(sock);
-       if (!ip_conflict_data->sock_io_channel) {
-               NM_LOGI("Failed to create channel");
-               ip_conflict_data->sock = -1;
-               close(sock);
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       g_io_channel_set_close_on_unref(ip_conflict_data->sock_io_channel, TRUE);
-
-       if (G_IO_STATUS_NORMAL !=
-                       g_io_channel_set_encoding(ip_conflict_data->sock_io_channel,
-                                       NULL, NULL))
-               NM_LOGI("Failed to set encoding NULL on io channel");
-
-       if (G_IO_STATUS_NORMAL !=
-                       g_io_channel_set_flags(ip_conflict_data->sock_io_channel,
-                                       G_IO_FLAG_NONBLOCK, NULL))
-               NM_LOGI("Failed to set flags on io channel");
-
-       ip_conflict_data->sock_source_id =
-                       g_io_add_watch(ip_conflict_data->sock_io_channel, G_IO_IN,
-                                       __check_arp_receive, ip_conflict_data);
-       NM_LOGD("socket %d", sock);
-
-       ip_conflict_data->timeout = mon->initial_time;
-       __send_arp(ip_conflict_data);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __stop_ip_conflict_mon(gpointer key,
-        gpointer value,
-        gpointer user_data)
-{
-       GError* error = NULL;
-       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)value;
-
-       __NM_FUNC_ENTER__;
-
-       REMOVE_G_SOURCE(ip_conflict_data->timer_source_id);
-
-       if (ip_conflict_data->sock < 0) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       if (G_IO_STATUS_NORMAL !=
-               g_io_channel_shutdown(ip_conflict_data->sock_io_channel,
-                               FALSE,
-                               &error)) {
-               NM_LOGI("Failure received while shutdown io channel[%d]:[%s]",
-                               error->code, error->message);
-               g_error_free(error);
-       }
-
-       g_io_channel_unref(ip_conflict_data->sock_io_channel);
-       REMOVE_G_SOURCE(ip_conflict_data->sock_source_id);
-       close(ip_conflict_data->sock);
-       ip_conflict_data->sock = -1;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-int nm_ip_conflict_enable_detection(gchar *if_name, gboolean enable)
-{
-       gint ret = NM_IP_CONFLICT_ERROR_NONE;
-       ip_conflict_data_s *ip_conflict_data = NULL;
-
-       __NM_FUNC_ENTER__;
-
-       if (!ip_conflict_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
-       }
-
-       ip_conflict_data =
-                       g_hash_table_lookup(ip_conflict_mon.ip_conflict_cb_tbl, if_name);
-       if (!ip_conflict_data) {
-               NM_LOGI("ip_conflict_data not found");
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
-       }
-
-       if (enable) {
-               if (ip_conflict_data->sock != -1) {
-                       __NM_FUNC_EXIT__;
-                       return NM_IP_CONFLICT_ERROR_IN_PROGRESS;
-               }
-
-               ip_conflict_data->detection_enabled = TRUE;
-               ip_conflict_data->state = IP_CONFLICT_STATE_UNKNOWN;
-
-               __start_ip_conflict_mon(if_name, ip_conflict_data, &ip_conflict_mon);
-               if (!ip_conflict_data->sock_source_id == 0) {
-                       NM_LOGI("Failed to start IP conflict monitoring");
-                       ip_conflict_data->detection_enabled = FALSE;
-                       return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
-               }
-       } else {
-               if (ip_conflict_data->sock != -1) {
-                       __stop_ip_conflict_mon(if_name, ip_conflict_data, &ip_conflict_mon);
-                       ip_conflict_data->detection_enabled = FALSE;
-                       ip_conflict_data->state = IP_CONFLICT_STATE_UNKNOWN;
-               }
-       }
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_ip_conflict_get_detection_period(guint *period)
-{
-       gint ret = NM_IP_CONFLICT_ERROR_NONE;
-
-       __NM_FUNC_ENTER__;
-
-       if (!ip_conflict_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
-       }
-
-       if (!period) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
-       }
-
-       *period = ip_conflict_mon.initial_time / MSEC;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_ip_conflict_set_detection_period(guint period)
-{
-       gint ret = NM_IP_CONFLICT_ERROR_NONE;
-
-       __NM_FUNC_ENTER__;
-
-       if (!ip_conflict_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
-       }
-
-       if (period < MAX_ARP_SEND_TIME && period > MIN_ARP_SEND_TIME) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
-       }
-
-       ip_conflict_mon.initial_time = period * MSEC;
-
-       g_hash_table_foreach(ip_conflict_mon.ip_conflict_cb_tbl,
-                       __stop_ip_conflict_mon,
-                       &ip_conflict_mon);
-       g_hash_table_foreach(ip_conflict_mon.ip_conflict_cb_tbl,
-                       __start_ip_conflict_mon,
-                       &ip_conflict_mon);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_ip_conflict_get_state(gchar *if_name, guint *state)
-{
-       gint ret = NM_IP_CONFLICT_ERROR_NONE;
-       ip_conflict_data_s *ip_conflict_data = NULL;
-
-       __NM_FUNC_ENTER__;
-
-       if (!ip_conflict_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
-       }
-
-       if (!state) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
-       }
-
-       ip_conflict_data =
-                       g_hash_table_lookup(ip_conflict_mon.ip_conflict_cb_tbl, if_name);
-       if (!ip_conflict_data) {
-               NM_LOGI("ip_conflict_data not found");
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
-       }
-
-       *state = ip_conflict_data->state;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_ip_conflict_is_detection_enabled(gchar *if_name, gboolean *enabled)
-{
-       gint ret = NM_IP_CONFLICT_ERROR_NONE;
-       ip_conflict_data_s *ip_conflict_data = NULL;
-
-       __NM_FUNC_ENTER__;
-
-       if (!ip_conflict_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
-       }
-
-       if (!enabled) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
-       }
-
-       ip_conflict_data =
-                       g_hash_table_lookup(ip_conflict_mon.ip_conflict_cb_tbl, if_name);
-       if (!ip_conflict_data) {
-               NM_LOGI("ip_conflict_data not found");
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
-       }
-
-       *enabled = ip_conflict_data->detection_enabled;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-ip_conflict_data_s *__create_ip_confilct_data(gchar *if_name)
-{
-       ip_conflict_data_s *ip_conflict_data = NULL;
-
-       ip_conflict_data =
-                       g_hash_table_lookup(ip_conflict_mon.ip_conflict_cb_tbl, if_name);
-       if (ip_conflict_data)
-               return ip_conflict_data;
-
-       ip_conflict_data =
-                       (ip_conflict_data_s *)g_try_malloc0(sizeof(ip_conflict_data_s));
-       if (!ip_conflict_data) {
-               NM_LOGI("Error! Failed to allocate memory");
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       if (!g_hash_table_insert(
-                       ip_conflict_mon.ip_conflict_cb_tbl,
-                       g_strdup(if_name),
-                       ip_conflict_data)) {
-               g_free(ip_conflict_data);
-               NM_LOGI("Error! Failed to insert ip_conflict_data");
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       __init_ip_conflict_sock_data(ip_conflict_data);
-       __init_ll_addr((struct sockaddr_ll *)&(ip_conflict_data->ll_addr));
-
-       return ip_conflict_data;
-}
-
-void __destroy_ip_conflict_data(gpointer user_data)
-{
-       ip_conflict_data_s *ip_conflict_data = (ip_conflict_data_s *)user_data;
-
-       if (!ip_conflict_data)
-               return;
-
-       __stop_ip_conflict_mon(ip_conflict_data->if_name, ip_conflict_data, &ip_conflict_mon);
-       g_free(ip_conflict_data);
-
-       return;
-}
-
-int ip_conflict_set_callback(gchar *if_name, ip_conflict_callback cb, gpointer user_data)
-{
-       gint ret = NM_IP_CONFLICT_ERROR_NONE;
-       ip_conflict_data_s *ip_conflict_data = NULL;
-
-       __NM_FUNC_ENTER__;
-
-       if (!ip_conflict_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
-       }
-
-       if (!if_name) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
-       }
-
-       ip_conflict_data = __create_ip_confilct_data(if_name);
-       if (!ip_conflict_data) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
-       }
-
-       g_strlcpy(ip_conflict_data->if_name, if_name, IFNAMSIZ);
-       ip_conflict_data->cb = cb;
-       ip_conflict_data->cb_user_data = user_data;
-
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int ip_conflict_unset_callback(gchar *if_name)
-{
-       gint ret = NM_IP_CONFLICT_ERROR_NONE;
-       ip_conflict_data_s *ip_conflict_data = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (!ip_conflict_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
-       }
-
-       if (!if_name) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_INVALID_PARAM;
-       }
-
-       ip_conflict_data =
-                       g_hash_table_lookup(ip_conflict_mon.ip_conflict_cb_tbl, if_name);
-       if (!ip_conflict_data) {
-               NM_LOGI("ip_conflict_data not found");
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_OPERATION_FAILED;
-       }
-
-       g_hash_table_remove(ip_conflict_mon.ip_conflict_cb_tbl, ip_conflict_data);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int ip_conflict_detection_init()
-{
-       gint ret = NM_IP_CONFLICT_ERROR_NONE;
-
-       __NM_FUNC_ENTER__;
-
-       memset(&ip_conflict_mon, 0x00, sizeof(ip_conflict_mon));
-
-       ip_conflict_mon.is_initialized = TRUE;
-       ip_conflict_mon.initial_time = MIN_ARP_SEND_TIME;
-
-       ip_conflict_mon.ip_conflict_cb_tbl = g_hash_table_new_full(g_str_hash,
-                       g_str_equal,
-                       g_free,
-                       __destroy_ip_conflict_data
-                       );
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int ip_conflict_detection_deinit()
-{
-       gint ret = NM_IP_CONFLICT_ERROR_NONE;
-
-       __NM_FUNC_ENTER__;
-
-       if (!ip_conflict_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_IP_CONFLICT_ERROR_NOT_INITIALIZED;
-       }
-
-       g_hash_table_remove_all(ip_conflict_mon.ip_conflict_cb_tbl);
-       g_hash_table_unref(ip_conflict_mon.ip_conflict_cb_tbl);
-
-       memset(&ip_conflict_mon, 0x00, sizeof(ip_conflict_mon));
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-mobileap.c b/src/nm-mobileap.c
deleted file mode 100644 (file)
index 94e3f96..0000000
+++ /dev/null
@@ -1,966 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling signal from Wi-Fi Direct manager.
- *
- * @file        nm-wfd-manager.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-mobileap.h"
-
-#define IP_ADDR_LEN 4
-#define MAC_ADDR_LEN 6
-#define MOBILEAP_STR_INFO_LEN 41
-
-#define TETHER_SIGNAL_NET_CLOSED                               "net_closed"
-#define TETHER_SIGNAL_STA_CONNECT                              "sta_connected"
-#define TETHER_SIGNAL_STA_DISCONNECT                   "sta_disconnected"
-#define TETHER_SIGNAL_WIFI_ON                                  "wifi_on"
-#define TETHER_SIGNAL_WIFI_OFF                                 "wifi_off"
-#define TETHER_SIGNAL_USB_ON                                   "usb_on"
-#define TETHER_SIGNAL_USB_OFF                                  "usb_off"
-#define TETHER_SIGNAL_BT_ON                                            "bluetooth_on"
-#define TETHER_SIGNAL_BT_OFF                                   "bluetooth_off"
-#define TETHER_SIGNAL_WIFI_AP_ON                               "wifi_ap_on"
-#define TETHER_SIGNAL_WIFI_AP_OFF                              "wifi_ap_off"
-#define TETHER_SIGNAL_NO_DATA_TIMEOUT                  "no_data_timeout"
-#define TETHER_SIGNAL_LOW_BATTERY                              "low_batt_mode"
-#define TETHER_SIGNAL_FLIGHT_MODE                              "flight_mode"
-#define TETHER_SIGNAL_SECURITY_TYPE_CHANGED            "security_type_changed"
-#define TETHER_SIGNAL_SSID_VISIBILITY_CHANGED  "ssid_visibility_changed"
-#define TETHER_SIGNAL_PASSPHRASE_CHANGED               "passphrase_changed"
-#define TETHER_SIGNAL_DHCP_STATUS                              "dhcp_status"
-
-#define SOFTAP_SIGNAL_STA_CONNECT                              "sta_connected"
-#define SOFTAP_SIGNAL_STA_DISCONNECT                   "sta_disconnected"
-#define SOFTAP_SIGNAL_ON                                               "soft_ap_on"
-#define SOFTAP_SIGNAL_OFF                                              "soft_ap_off"
-#define SOFTAP_SIGNAL_NO_DATA_TIMEOUT                  "no_data_timeout"
-#define SOFTAP_SIGNAL_LOW_BATTERY                              "low_batt_mode"
-#define SOFTAP_SIGNAL_FLIGHT_MODE                              "flight_mode"
-#define SOFTAP_SIGNAL_SECURITY_TYPE_CHANGED            "security_type_changed"
-#define SOFTAP_SIGNAL_SSID_VISIBLITY_CHANGED   "ssid_visibility_changed"
-#define SOFTAP_SIGNAL_PASSPHRASECHANGED                        "passphrase_changed"
-#define SOFTAP_SIGNAL_DHCP_STATUS                              "dhcp_status"
-
-typedef enum {
-       MOBILEAP_SIGNAL_NAME_OWENER_CHANGED,
-       MOBILEAP_SIGNAL_TETHER_NET_CLOSED,
-       MOBILEAP_SIGNAL_TETHER_STA_CONNECT,
-       MOBILEAP_SIGNAL_TETHER_STA_DISCONNECT,
-       MOBILEAP_SIGNAL_TETHER_WIFI_ON,
-       MOBILEAP_SIGNAL_TETHER_WIFI_OFF,
-       MOBILEAP_SIGNAL_TETHER_USB_ON,
-       MOBILEAP_SIGNAL_TETHER_USB_OFF,
-       MOBILEAP_SIGNAL_TETHER_BT_ON,
-       MOBILEAP_SIGNAL_TETHER_BT_OFF,
-       MOBILEAP_SIGNAL_TETHER_WIFI_AP_ON,
-       MOBILEAP_SIGNAL_TETHER_WIFI_AP_OFF,
-       MOBILEAP_SIGNAL_TETHER_NO_DATA_TIMeOUT,
-       MOBILEAP_SIGNAL_TETHER_LOW_BATTERY,
-       MOBILEAP_SIGNAL_TETHER_FLIGHT_MODE,
-       MOBILEAP_SIGNAL_TETHER_SECURITY_TYPE_CHANGED,
-       MOBILEAP_SIGNAL_TETHER_SSID_VISIBILITY_CHANGED,
-       MOBILEAP_SIGNAL_TETHER_PASSPHRASE_CHANGED,
-       MOBILEAP_SIGNAL_TETHER_DHCP_STATUS,
-       MOBILEAP_SIGNAL_SOFTAP_STA_CONNECT,
-       MOBILEAP_SIGNAL_SOFTAP_STA_DISCONNECT,
-       MOBILEAP_SIGNAL_SOFTAP_ON,
-       MOBILEAP_SIGNAL_SOFTAP_OFF,
-       MOBILEAP_SIGNAL_SOFTAP_NO_DATA_TIMEOUT,
-       MOBILEAP_SIGNAL_SOFTAP_LOW_BATTERY,
-       MOBILEAP_SIGNAL_SOFTAP_FLIGHT_MODE,
-       MOBILEAP_SIGNAL_SOFTAP_SECURITY_TYPE_CHANGED,
-       MOBILEAP_SIGNAL_SOFTAP_SSID_VISIBLITY_CHANGED,
-       MOBILEAP_SIGNAL_SOFTAP_PASSPHRASECHANGED,
-       MOBILEAP_SIGNAL_SOFTAP_DHCP_STATUS,
-       MOBILEAP_SIGNAL_MAX,
-} mobileap_signal_e;
-
-typedef enum {
-       MOBILEAP_TYPE_NONE,
-       MOBILEAP_TYPE_WIFI,
-       MOBILEAP_TYPE_USB,
-       MOBILEAP_TYPE_BT,
-       MOBILEAP_TYPE_P2P,
-       MOBILEAP_TYPE_WIFI_AP,
-       MOBILEAP_TYPE_MAX,
-} mobileap_type_e;
-
-typedef struct {
-       mobileap_type_e interface;                                      /* interface type */
-       guchar ip[IP_ADDR_LEN];                                         /**< assigned IP address */
-       guchar mac[MAC_ADDR_LEN];                                               /**< MAC Address */
-       gchar hostname[MOBILEAP_STR_INFO_LEN +1];       /**< Device name */
-       guint32 tm;                                                                     /**< connection time*/
-} mobileap_sta_s;
-
-typedef struct {
-       mobileap_type_e interface;                                              /* interface type */
-       gchar interface_name[MOBILEAP_STR_INFO_LEN +1]; /**< interface alphanumeric name */
-       guchar ip_address[IP_ADDR_LEN];                                 /**< assigned ip addresss to interface */
-       guchar gateway_address[IP_ADDR_LEN];                            /**< gateway address of interface */
-       guchar subnet_mask[IP_ADDR_LEN];                                        /**< subnet mask of interface */
-} mobileap_iface_s;
-
-typedef struct {
-       mobileap_iface_s iface_info;
-       GHashTable *sta_info;
-
-} tethering_mon_s;
-
-typedef struct {
-       mobileap_iface_s iface_info;
-       GHashTable *sta_info;
-} softap_mon_s;
-
-typedef struct {
-       gboolean is_initialized;
-       softap_mon_s softap;
-       tethering_mon_s tether;
-} mobileap_mon_s;
-
-mobileap_mon_s mobileap_mon;
-
-static DECLARE_DBUS_SIGNAL_HANDLER(name_owner_changed_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_net_closed_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_sta_connected_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_sta_disconnected_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_on_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_off_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_usb_on_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_usb_off_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_bt_on_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_bt_off_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_ap_on_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_ap_off_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_no_data_timeout_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_low_battery_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_flight_mode_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_security_type_changed_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_ssid_visibility_changed_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_passphrase_changed_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_dhcp_status_cb);
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_sta_connect_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_sta_disconnect_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_on_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_off_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_no_data_timeout_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_low_battery_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_flight_mode_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_security_type_changed_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_ssid_visibility_changed_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_passphrase_changed_cb);
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_dhcp_status_cb);
-
-static signal_param_s mobileap_signal_param[] = {
-               {
-                               .sender = DBUS_SERVICE_DBUS,
-                               .interface_name = DBUS_INTERFACE_DBUS,
-                               .member = DBUS_SIGNAL_NAME_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = MOBILEAP_SERVICE,
-                               .callback = __name_owner_changed_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_NET_CLOSED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_net_closed_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_STA_CONNECT,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_sta_connected_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_STA_DISCONNECT,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_sta_disconnected_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_WIFI_ON,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_wifi_on_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_WIFI_OFF,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_wifi_off_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_USB_ON,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_usb_on_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_USB_OFF,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_usb_off_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_BT_ON,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_bt_on_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_BT_OFF,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_bt_off_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_WIFI_AP_ON,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_wifi_ap_on_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_WIFI_AP_OFF,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_wifi_ap_off_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_NO_DATA_TIMEOUT,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_no_data_timeout_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_LOW_BATTERY,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_low_battery_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_FLIGHT_MODE,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_flight_mode_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_SECURITY_TYPE_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_security_type_changed_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_SSID_VISIBILITY_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_ssid_visibility_changed_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_PASSPHRASE_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_passphrase_changed_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = TETHERING_INTERFACE,
-                               .member = TETHER_SIGNAL_DHCP_STATUS,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __tether_dhcp_status_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = SOFTAP_INTERFACE,
-                               .member = SOFTAP_SIGNAL_STA_CONNECT,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __softap_sta_connect_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = SOFTAP_INTERFACE,
-                               .member = SOFTAP_SIGNAL_STA_DISCONNECT,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __softap_sta_disconnect_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = SOFTAP_INTERFACE,
-                               .member = SOFTAP_SIGNAL_ON,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __softap_on_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = SOFTAP_INTERFACE,
-                               .member = SOFTAP_SIGNAL_OFF,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __softap_off_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = SOFTAP_INTERFACE,
-                               .member = SOFTAP_SIGNAL_NO_DATA_TIMEOUT,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __softap_no_data_timeout_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = SOFTAP_INTERFACE,
-                               .member = SOFTAP_SIGNAL_LOW_BATTERY,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __softap_low_battery_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = SOFTAP_INTERFACE,
-                               .member = SOFTAP_SIGNAL_FLIGHT_MODE,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __softap_flight_mode_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = SOFTAP_INTERFACE,
-                               .member = SOFTAP_SIGNAL_SECURITY_TYPE_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __softap_security_type_changed_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = SOFTAP_INTERFACE,
-                               .member = SOFTAP_SIGNAL_SSID_VISIBLITY_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __softap_ssid_visibility_changed_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = SOFTAP_INTERFACE,
-                               .member = SOFTAP_SIGNAL_PASSPHRASECHANGED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __softap_passphrase_changed_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = MOBILEAP_SERVICE,
-                               .interface_name = SOFTAP_INTERFACE,
-                               .member = SOFTAP_SIGNAL_DHCP_STATUS,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __softap_dhcp_status_cb,
-                               .subscriber_id  = 0,
-               },
-};
-
-static gint __txt_to_mac(const gchar *txt, guchar *mac)
-{
-       int i = 0;
-
-       if (!txt || !mac) {
-               NM_LOGI("Invalid parameter");
-               return -1;
-       }
-
-       for (;;) {
-               mac[i++] = (char) strtoul((char *)txt, (char **)&txt, 16);
-               if (!*txt++ || i == 6)
-                       break;
-       }
-
-       if (i != MAC_ADDR_LEN)
-               return -1;
-
-       return 0;
-}
-
-static gint __txt_to_ip(const gchar *txt, guchar *ip)
-{
-       int i = 0;
-
-       for (;;) {
-               ip[i++] = (char) strtoul((char *)txt, (char **)&txt, 10);
-               if (i == IP_ADDR_LEN || !*txt++)
-                       break;
-       }
-
-       if (i != IP_ADDR_LEN)
-               return -1;
-
-       return 0;
-}
-
-static inline void __tether_init(mobileap_type_e type)
-{
-
-       mobileap_mon.tether.iface_info.interface = type;
-       mobileap_mon.tether.sta_info = g_hash_table_new_full(
-                       g_str_hash,
-                       g_str_equal,
-                       g_free,
-                       g_free);
-}
-
-
-static inline void __tether_deinit()
-{
-       mobileap_mon.tether.iface_info.interface = MOBILEAP_TYPE_NONE;
-       if (mobileap_mon.tether.sta_info) {
-               g_hash_table_remove_all(mobileap_mon.tether.sta_info);
-               g_hash_table_unref(mobileap_mon.tether.sta_info);
-               mobileap_mon.tether.sta_info = NULL;
-       }
-}
-
-static inline void __softap_init()
-{
-       mobileap_mon.softap.sta_info = g_hash_table_new_full(
-                       g_str_hash,
-                       g_str_equal,
-                       g_free,
-                       g_free);
-}
-
-static inline void __softap_deinit()
-{
-       mobileap_mon.softap.iface_info.interface = MOBILEAP_TYPE_NONE;
-       if (mobileap_mon.softap.sta_info) {
-               g_hash_table_remove_all(mobileap_mon.softap.sta_info);
-               g_hash_table_unref(mobileap_mon.softap.sta_info);
-               mobileap_mon.softap.sta_info = NULL;
-       }
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(name_owner_changed_cb)
-{
-       gchar *name = NULL;
-       gchar *old = NULL;
-       gchar *new = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (parameters == NULL)
-               return;
-
-       g_variant_get(parameters, "(&s&s&s)", &name, &old, &new);
-
-       if (g_strcmp0(name, MOBILEAP_SERVICE) == 0 && *new == '\0')
-               NM_LOGI("wfd-manager destroyed: name %s, old %s, new %s", name, old, new);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_net_closed_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_sta_connected_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_sta_disconnected_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_on_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __tether_init(MOBILEAP_TYPE_WIFI);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_off_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __tether_deinit();
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_usb_on_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __tether_init(MOBILEAP_TYPE_USB);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_usb_off_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __tether_deinit();
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_bt_on_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __tether_init(MOBILEAP_TYPE_BT);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_bt_off_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __tether_deinit();
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_ap_on_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __tether_init(MOBILEAP_TYPE_WIFI_AP);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_wifi_ap_off_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __tether_deinit();
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_no_data_timeout_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_low_battery_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_flight_mode_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_security_type_changed_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_ssid_visibility_changed_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_passphrase_changed_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(tether_dhcp_status_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       mobileap_sta_s *sta = NULL;
-       const gchar *event = NULL;
-       const guint32 type = 0;
-       const gchar *ip_addr = NULL;
-       const gchar *mac_addr = NULL;
-       const gchar *name = NULL;
-       const guint32 time = 0;
-
-       if (!parameters) {
-               NM_LOGI("Invalid parameters");
-               return;
-       }
-
-       g_variant_get(parameters, "(&su&s&s&su)",
-                       &event, &type, &ip_addr, &mac_addr, &name, &time);
-
-       if (!event || !ip_addr || !mac_addr || !name) {
-               NM_LOGI("failed to get parameters");
-               return;
-       }
-
-       if (!mobileap_mon.tether.sta_info) {
-               NM_LOGI("hash table empty");
-               return;
-       }
-
-       if (g_strcmp0("DhcpConnected", event) == 0) {
-
-               sta = g_try_malloc0(sizeof(mobileap_sta_s));
-               if (!sta) {
-                       NM_LOGI("malloc failed");
-                       return;
-               }
-
-               sta->interface = type;
-               __txt_to_mac(mac_addr, sta->mac);
-               __txt_to_ip(ip_addr, sta->ip);
-               g_strlcpy(sta->hostname, name, MOBILEAP_STR_INFO_LEN);
-               sta->tm = time;
-               g_hash_table_replace(mobileap_mon.tether.sta_info,
-                               strdup(mac_addr), sta);
-
-       } else if (g_strcmp0("DhcpLeaseDeleted", event) == 0) {
-               if(g_hash_table_remove(mobileap_mon.tether.sta_info, mac_addr))
-                       NM_LOGI("%s is removed", mac_addr);
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_sta_connect_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_sta_disconnect_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_on_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __softap_init();
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_off_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __softap_deinit();
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_no_data_timeout_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_low_battery_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_flight_mode_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_security_type_changed_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_ssid_visibility_changed_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_passphrase_changed_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER(softap_dhcp_status_cb)
-{
-       __NM_FUNC_ENTER__;
-
-       mobileap_sta_s *sta = NULL;
-       const gchar *event = NULL;
-       const gchar *ip_addr = NULL;
-       const gchar *mac_addr = NULL;
-       const gchar *name = NULL;
-       const guint32 time = 0;
-
-       if (!parameters) {
-               NM_LOGI("Invalid parameters");
-               return;
-       }
-
-       g_variant_get(parameters, "(&s&s&s&su)",
-                       &event, &ip_addr, &mac_addr, &name, &time);
-
-       if (!event || !ip_addr || !mac_addr || !name) {
-               NM_LOGI("failed to get parameters");
-               return;
-       }
-
-       if (!mobileap_mon.softap.sta_info) {
-               NM_LOGI("hash table empty");
-               return;
-       }
-
-       if (g_strcmp0("DhcpConnected", event) == 0) {
-
-               sta = g_try_malloc0(sizeof(mobileap_sta_s));
-               if (!sta) {
-                       NM_LOGI("malloc failed");
-                       return;
-               }
-
-               __txt_to_mac(mac_addr, sta->mac);
-               __txt_to_ip(ip_addr, sta->ip);
-               g_strlcpy(sta->hostname, name, MOBILEAP_STR_INFO_LEN);
-               sta->tm = time;
-               g_hash_table_replace(mobileap_mon.softap.sta_info,
-                               strdup(mac_addr), sta);
-
-       } else if (g_strcmp0("DhcpLeaseDeleted", event) == 0) {
-               if(g_hash_table_remove(mobileap_mon.softap.sta_info, mac_addr))
-                       NM_LOGI("%s is removed", mac_addr);
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-
-static inline void __subscribe_mobileap_signal()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-       int signal_idx = 0;
-       __NM_FUNC_ENTER__;
-
-       for (signal_idx = MOBILEAP_SIGNAL_NAME_OWENER_CHANGED;
-                       signal_idx < MOBILEAP_SIGNAL_MAX; signal_idx++) {
-               ret = nm_gdbus_subscribe_signal(&(mobileap_signal_param[signal_idx]));
-               if (ret != NM_GDBUS_ERROR_NONE)
-                       NM_LOGI("Error! Failed to subscribe signal");
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline void __unsubscribe_mobileap_signal()
-{
-       int signal_idx = 0;
-       int ret = NM_GDBUS_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       for (signal_idx = MOBILEAP_SIGNAL_NAME_OWENER_CHANGED;
-                       signal_idx < MOBILEAP_SIGNAL_MAX; signal_idx++) {
-
-               if (mobileap_signal_param[signal_idx].subscriber_id == 0)
-                       continue;
-
-               ret = nm_gdbus_unsubscribe_signal(&(mobileap_signal_param[signal_idx]));
-               if (ret != NM_GDBUS_ERROR_NONE)
-                       NM_LOGI("Error! Failed to unsubscribe signal");
-               else
-                       mobileap_signal_param[signal_idx].subscriber_id = 0;
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-int nm_mobileap_init()
-{
-       __NM_FUNC_ENTER__;
-
-       memset(&mobileap_mon, 0x00, sizeof(mobileap_mon));
-       mobileap_mon.is_initialized = TRUE;
-       __subscribe_mobileap_signal();
-
-       __NM_FUNC_EXIT__;
-       return NM_MOBILEAP_ERROR_NONE;
-}
-
-int nm_mobileap_deinit()
-{
-       __NM_FUNC_ENTER__;
-
-       if (!mobileap_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_MOBILEAP_ERROR_NOT_INITIALIZED;
-       }
-       __unsubscribe_mobileap_signal();
-       memset(&mobileap_mon, 0x00, sizeof(mobileap_mon));
-
-       __NM_FUNC_EXIT__;
-       return NM_MOBILEAP_ERROR_NONE;
-}
-
diff --git a/src/nm-net-access.c b/src/nm-net-access.c
deleted file mode 100644 (file)
index 730177f..0000000
+++ /dev/null
@@ -1,708 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for monitoring internet accessibility.
- *
- * @file        nm-net-access.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-
-#include <net/if.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/inotify.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netinet/if_ether.h>
-#include <net/if_arp.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-#include <net/route.h>
-#include <glib.h>
-#include <gio/gio.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-
-#include "nm-daemon-log.h"
-#include "nm-util.h"
-#include "nm-net-access.h"
-
-#define BUF_SIZE 2048
-#define NM_INTERNET_CHECK_TIMEOUT      3
-#define HTTP_STATUS_CODE_OK    "HTTP/1.1 200"
-#define HTTP_STATUS_CODE_FOUND "HTTP/1.1 302"
-
-#define HTTP_STR_AUTH_ACTION   "auth action"
-#define HTTP_STR_LOCATION              "Location: "
-#define HTTP_STR_REQ_DATA              "GET /index.html HTTP/1.1\r\nHost: connman.net\r\n\r\n"
-
-#define URL_LIST_NUM           6
-
-typedef enum {
-       INTERNET_CHECK_STATE_NONE                       = 0,
-       INTERNET_CHECK_STATE_DNS_CHECK          = 1,
-       INTERNET_CHECK_STATE_PACKET_CHECK       = 2
-} nm_internet_check_state_e;
-
-typedef struct {
-       int fd;
-       char *addr;
-       int port;
-       guint transport_watch;
-       guint send_watch;
-       gboolean header_done;
-       gboolean request_started;
-} nm_internet_param_s;
-
-static const char* url_list[] = {
-        "www.google.com",
-        "www.msn.com",
-        "www.yahoo.com",
-        "m.google.com",
-        "www.amazon.com",
-        "www.youtube.com"
-};
-
-typedef struct {
-       GCancellable *cancellable;
-       nm_internet_param_s *net_params;
-       char *proxy_addr;
-       int url_index;
-       char *redirect_url1;
-       char *redirect_url2;
-       gboolean perform_recheck;
-       gboolean is_internet_available;
-       nm_internet_check_state_e check_state;
-       guint timer_source_id;
-} nm_net_access_mon_s;
-
-static nm_net_access_mon_s net_access_mon = {0, };
-
-static void __connect_sockets(void);
-static void __internet_check_state(nm_internet_check_state_e state);
-
-gboolean nm_net_access_get_status()
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return net_access_mon.is_internet_available;
-}
-
-static inline gboolean __is_http_status_ok_and_auth(unsigned char *reply)
-{
-       return (NULL != g_strrstr((char*)reply, HTTP_STATUS_CODE_OK)) &&
-                       (NULL != g_strrstr((char*)reply, HTTP_STR_AUTH_ACTION));
-}
-
-static inline gboolean __is_http_status_found(unsigned char *reply)
-{
-       return (NULL != g_strrstr((char*)reply, HTTP_STATUS_CODE_FOUND));
-}
-
-static inline gboolean __does_http_have_location(unsigned char *reply, char *temp)
-{
-       return ((temp = g_strrstr((char*)reply, HTTP_STR_LOCATION)) != NULL);
-}
-
-static inline gboolean __is_url1_null()
-{
-       return (net_access_mon.redirect_url1 == NULL);
-}
-
-static inline gboolean __is_url2_null()
-{
-       return (net_access_mon.redirect_url2 == NULL);
-}
-
-static inline gboolean __both_urls_not_null()
-{
-       return !(net_access_mon.redirect_url1 == NULL &&
-                       net_access_mon.redirect_url2 == NULL);
-}
-
-static inline gboolean __are_urls_same()
-{
-       return (g_strcmp0(net_access_mon.redirect_url1,
-                       net_access_mon.redirect_url2) == 0);
-}
-
-static inline void __process_urls()
-{
-       NM_LOGI("[%s] [%s]", net_access_mon.redirect_url1,
-                       net_access_mon.redirect_url2);
-
-       if (__are_urls_same()) {
-               NM_LOGI("Internet is un-available(Redirection to Error page)");
-               net_access_mon.is_internet_available = FALSE;
-       } else
-               net_access_mon.is_internet_available = TRUE;
-
-       g_free(net_access_mon.redirect_url1);
-       g_free(net_access_mon.redirect_url2);
-       net_access_mon.redirect_url1 = NULL;
-       net_access_mon.redirect_url2 = NULL;
-
-}
-
-static inline void __get_redirect_urls(char *temp)
-{
-       char *saveptr = NULL;
-       char * location = NULL;
-       int location_str_len = strlen(HTTP_STR_LOCATION);
-
-       location = strtok_r(temp, "\r", &saveptr);
-       if (!location)
-               return;
-
-       NM_LOGI("%s", location);
-
-       if (__is_url1_null())
-               net_access_mon.redirect_url1 = g_strdup(location + location_str_len);
-       else if (__is_url2_null())
-               net_access_mon.redirect_url2 = g_strdup(location + location_str_len);
-
-       if (__both_urls_not_null())
-               __process_urls();
-}
-
-static void __update_internet_status(unsigned char *reply)
-{
-       /* If the HTTP response is either 302 or 200 with redirection,
-        * then no Internet is available */
-       char *temp = NULL;
-       net_access_mon.is_internet_available = FALSE;
-
-       if (NULL != reply) {
-               if (__is_http_status_ok_and_auth(reply)) {
-                       NM_LOGI("200 OK but redirection found so:: Internet is un-available");
-               } else if (__is_http_status_found(reply)) {
-                       NM_LOGI("302:: Internet is un-available");
-               } else if (__does_http_have_location(reply, temp)) {
-                       __get_redirect_urls(temp);
-               } else {
-                       net_access_mon.is_internet_available = TRUE;
-                       NM_LOGI("Internet is available");
-               }
-       }
-
-       /* TODO: decide what will we do here */
-       /*
-       if (net_access_mon.is_internet_available == TRUE)
-       */
-}
-
-static gboolean __data_activity_timeout(gpointer data)
-{
-       nm_internet_param_s *net_params = NULL;
-       nm_internet_check_state_e prev_state =
-                       (nm_internet_check_state_e)GPOINTER_TO_INT(data);
-       __NM_FUNC_ENTER__;
-
-
-       NM_LOGI("Prev_state: state=%d (1:dns check / 2:packet check)", prev_state);
-
-       net_params = net_access_mon.net_params;
-       if (net_access_mon.net_params == NULL)
-               return FALSE;
-
-       if (TRUE == net_access_mon.perform_recheck &&
-                       prev_state != INTERNET_CHECK_STATE_NONE) {
-               net_access_mon.perform_recheck = FALSE;
-               if (prev_state == INTERNET_CHECK_STATE_DNS_CHECK) {
-                       net_params->request_started = FALSE;
-                       nm_net_access_start_checking();
-               } else
-                       __connect_sockets();
-       } else {
-               net_access_mon.perform_recheck = TRUE;
-               __internet_check_state(INTERNET_CHECK_STATE_NONE);
-       }
-
-       return FALSE;
-}
-
-static void __internet_check_timer_stop(void)
-{
-       if (net_access_mon.timer_source_id != 0) {
-               g_source_remove(net_access_mon.timer_source_id);
-               net_access_mon.timer_source_id = 0;
-       }
-       return;
-}
-
-static void __internet_check_timer_start(nm_internet_check_state_e state)
-{
-       static guint timeout = 0;
-       if (net_access_mon.timer_source_id != 0) {
-               NM_LOGI("netconfig_data_activity_timer is already running, so stop it");
-               __internet_check_timer_stop();
-       }
-
-       if (state == INTERNET_CHECK_STATE_NONE)
-               return;
-       else if (state == INTERNET_CHECK_STATE_DNS_CHECK)
-               timeout = NM_INTERNET_CHECK_TIMEOUT;
-       else if (state == INTERNET_CHECK_STATE_PACKET_CHECK)
-               timeout = NM_INTERNET_CHECK_TIMEOUT;
-
-       net_access_mon.timer_source_id = g_timeout_add_seconds(timeout,
-                       __data_activity_timeout,
-                       GINT_TO_POINTER(state));
-}
-
-static void __internet_check_state(nm_internet_check_state_e state)
-{
-       nm_internet_check_state_e prev_state = net_access_mon.check_state;
-
-       if (prev_state == state)
-               return;
-
-       NM_LOGI("state change (%d) -> (%d)", prev_state, state);
-       net_access_mon.check_state = state;
-
-       switch (state) {
-       case INTERNET_CHECK_STATE_DNS_CHECK:
-               __internet_check_timer_start(state);
-               break;
-       case INTERNET_CHECK_STATE_PACKET_CHECK:
-               if (prev_state == INTERNET_CHECK_STATE_DNS_CHECK)
-                       __internet_check_timer_stop();
-
-               __internet_check_timer_start(state);
-               break;
-       case INTERNET_CHECK_STATE_NONE:
-               switch (prev_state) {
-               case INTERNET_CHECK_STATE_DNS_CHECK:
-               case INTERNET_CHECK_STATE_PACKET_CHECK:
-                       __internet_check_timer_stop();
-                       nm_net_access_stop_checking();
-                       break;
-               default:
-                       break;
-               }
-               break;
-       }
-}
-
-static gboolean __received_data_event(GIOChannel *channel,
-               GIOCondition condition, gpointer data)
-{
-       nm_internet_param_s *net_params = NULL;
-       int n, fd;
-       unsigned char buf[BUF_SIZE] = {0, };
-       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
-
-       net_params = net_access_mon.net_params;
-       if (net_params == NULL)
-               return FALSE;
-
-       if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
-               goto cleanup;
-
-       fd = g_io_channel_unix_get_fd(channel);
-       if (fd < 0)
-               goto cleanup;
-
-       n = read(fd, buf, BUF_SIZE - 1);
-       NM_LOGI("Received %d bytes[%s]", n, buf);
-       buf[BUF_SIZE - 1] = '\0';
-
-       if (n < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               NM_LOGI("read failed. %s", error_buf);
-
-               goto cleanup;
-       } else if (n == 0) {
-               NM_LOGI("connection closed");
-
-               goto cleanup;
-       }
-
-       /* We got data from server successfully */
-       __update_internet_status(buf);
-       __internet_check_state(INTERNET_CHECK_STATE_NONE);
-
-       return TRUE;
-
-cleanup:
-       /* Fail to get data from server */
-       __internet_check_state(INTERNET_CHECK_STATE_NONE);
-
-       return FALSE;
-}
-
-static gboolean __send_data_event(GIOChannel *channel,
-               GIOCondition condition, gpointer data)
-{
-       nm_internet_param_s *net_params = NULL;
-       gchar error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
-       int n, fd;
-       const char *request_data = HTTP_STR_REQ_DATA;
-
-       net_params = net_access_mon.net_params;
-       if (net_params == NULL)
-               return FALSE;
-
-       if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
-               goto cleanup;
-
-       fd = g_io_channel_unix_get_fd(channel);
-       if (fd < 0)
-               goto cleanup;
-
-       /* We don't need to send anymore. Just return here.*/
-       /* Socket will be closed received part*/
-       if (net_params->header_done == TRUE)
-               return FALSE;
-
-       n = send(fd, request_data, strlen(request_data), MSG_NOSIGNAL);
-       NM_LOGI("Sent %d bytes", n);
-
-       if (n < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               NM_LOGI("send failed. %s", error_buf);
-
-               goto cleanup;
-       } else if (n == 0) {
-               NM_LOGI("connection closed");
-
-               goto cleanup;
-       }
-
-       net_params->header_done = TRUE;
-       return TRUE;
-
-cleanup:
-       __internet_check_state(INTERNET_CHECK_STATE_NONE);
-
-       return FALSE;
-}
-
-static void __connect_sockets(void)
-{
-       nm_internet_param_s *net_params = NULL;
-       GIOFlags flags;
-       struct sockaddr_in addr;
-       GIOChannel *channel = NULL;
-       int sock;
-
-       net_params = net_access_mon.net_params;
-       if (net_params == NULL || net_params->addr == NULL)
-               return;
-
-       sock = socket(PF_INET, SOCK_STREAM, 0);
-       if (sock < 0)
-               goto cleanup;
-
-       /* TODO: check below. What will be the ifname? */
-       /*
-       if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE,
-                       WIFI_IFNAME, strlen(WIFI_IFNAME) + 1) < 0) {
-               ERR("Bind to device error");
-               close(sock);
-               goto cleanup;
-       }
-       */
-
-       memset(&addr, 0, sizeof(struct sockaddr_in));
-       addr.sin_family = AF_INET;
-       addr.sin_addr.s_addr = inet_addr(net_params->addr);
-       addr.sin_port = htons(net_params->port);
-
-       /* Register Watch */
-       channel = g_io_channel_unix_new(sock);
-
-       flags = g_io_channel_get_flags(channel);
-       g_io_channel_set_flags(channel, flags | G_IO_FLAG_NONBLOCK, NULL);
-       g_io_channel_set_encoding(channel, NULL, NULL);
-       g_io_channel_set_buffered(channel, FALSE);
-
-       if (connect(sock, (struct sockaddr *)&addr,
-                       sizeof(struct sockaddr_in)) < 0) {
-               if (errno != EINPROGRESS) {
-                       NM_LOGI("connect fail");
-                       close(sock);
-                       goto cleanup;
-               }
-       }
-
-       NM_LOGI("Connect successful");
-
-       net_params->fd = sock;
-       net_params->transport_watch = g_io_add_watch(channel,
-                       (GIOCondition) (G_IO_IN | G_IO_HUP | G_IO_NVAL | G_IO_ERR),
-                       (GIOFunc) __received_data_event, NULL);
-       net_params->send_watch = g_io_add_watch(channel,
-                       (GIOCondition) (G_IO_OUT | G_IO_HUP | G_IO_NVAL | G_IO_ERR),
-                       (GIOFunc) __send_data_event, NULL);
-
-       __internet_check_state(INTERNET_CHECK_STATE_PACKET_CHECK);
-       return;
-
-cleanup:
-       __internet_check_state(INTERNET_CHECK_STATE_NONE);
-}
-
-static void __obtain_host_ip_addr_cb(GObject *src,
-               GAsyncResult *res,
-               gpointer user_data)
-{
-       nm_internet_param_s *net_params = NULL;
-       GList *list, *cur;
-       GInetAddress *addr;
-       gchar *str_addr;
-       GError *error = NULL;
-
-       net_params = net_access_mon.net_params;
-       if (net_params == NULL)
-               return;
-
-       if (net_access_mon.check_state == INTERNET_CHECK_STATE_NONE)
-               return;
-
-       list = g_resolver_lookup_by_name_finish((GResolver *)src, res, &error);
-       if (error != NULL) {
-               if (error->code == G_IO_ERROR_CANCELLED)
-                       NM_LOGI("G_IO_ERROR_CANCELLED is called[%s]", error->message);
-               g_error_free(error);
-       }
-
-       if (!list) {
-               NM_LOGI("no data");
-               goto cleanup;
-       }
-
-       for (cur = list; cur; cur = cur->next) {
-               addr = cur->data;
-               str_addr = g_inet_address_to_string(addr);
-               if (!str_addr)
-                       continue;
-
-               if (net_params != NULL) {
-                       g_free(net_params->addr);
-                       net_params->addr = str_addr;
-               }
-
-               g_object_unref(cur->data);
-               break;
-       }
-
-       g_list_free(list);
-
-       if (net_params->addr == NULL)
-               goto cleanup;
-
-       net_params->port = 80;
-       __connect_sockets();
-
-       return;
-
-cleanup:
-       __internet_check_state(INTERNET_CHECK_STATE_NONE);
-}
-
-gboolean __obtain_host_ip_addr(void)
-{
-       nm_internet_param_s *net_params = NULL;
-       char *host, *addr, *port;
-       char *saveptr = NULL;
-
-       net_params = net_access_mon.net_params;
-       if (net_params == NULL)
-               return FALSE;
-
-       if (net_params->request_started == TRUE)
-               return FALSE;
-       else
-               net_params->request_started = TRUE;
-
-       if (net_params->addr != NULL)
-               return TRUE;
-
-       net_access_mon.proxy_addr = nm_util_get_default_proxy();
-       NM_LOGI("Proxy(%s)", net_access_mon.proxy_addr);
-
-       if (++net_access_mon.url_index >= URL_LIST_NUM)
-               net_access_mon.url_index = 0;
-
-       NM_LOGI("addr (%s)", url_list[net_access_mon.url_index]);
-
-       /* FIXME: domain proxy should be resolved */
-       if (net_access_mon.proxy_addr == NULL) {
-               GResolver *r = NULL;
-               r = g_resolver_get_default();
-
-               g_resolver_lookup_by_name_async(r,
-                               url_list[net_access_mon.url_index],
-                               net_access_mon.cancellable,
-                               __obtain_host_ip_addr_cb,
-                               NULL);
-               __internet_check_state(INTERNET_CHECK_STATE_DNS_CHECK);
-
-               g_object_unref(r);
-               return FALSE;
-       } else {
-               host = g_strdup(net_access_mon.proxy_addr);
-               if (host == NULL)
-                       goto cleanup;
-
-               addr = strtok_r(host, ":", &saveptr);
-               if (addr == NULL)
-                       goto cleanup;
-
-               port = strrchr(net_access_mon.proxy_addr, ':');
-               if (port == NULL)
-                       goto cleanup;
-               else {
-                       char *end;
-                       int tmp = strtol(port + 1, &end, 10);
-
-                       if (*end == '\0') {
-                               *port = '\0';
-                               net_params->port = tmp;
-                       }
-               }
-               g_free(net_params->addr);
-               net_params->addr = g_strdup(addr);
-
-               g_free(host);
-       }
-       return TRUE;
-
-cleanup:
-       g_free(host);
-       nm_net_access_stop_checking();
-
-       return FALSE;
-}
-
-void nm_net_access_start_checking(void)
-{
-       nm_internet_param_s *net_params = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (net_access_mon.net_params == NULL) {
-               net_params = g_try_malloc0(sizeof(nm_internet_param_s));
-               if (net_params == NULL) {
-                       __NM_FUNC_EXIT__;
-                       return;
-               }
-               net_params->fd = -1;
-       } else {
-               net_params = net_access_mon.net_params;
-       }
-
-       if ((net_access_mon.check_state != INTERNET_CHECK_STATE_NONE) ||
-                       (net_params->request_started == TRUE)) {
-               NM_LOGI("Older query in progress");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       net_access_mon.is_internet_available = FALSE;
-
-       /* If the host IP is resolved, directly go for connecting to sockets*/
-       if (__obtain_host_ip_addr() == TRUE)
-               __connect_sockets();
-       __NM_FUNC_EXIT__;
-}
-
-void nm_net_access_stop_checking(void)
-{
-       nm_internet_param_s *net_params = NULL;
-
-       __NM_FUNC_ENTER__;
-       net_params = net_access_mon.net_params;
-       if (net_params == NULL) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       net_params->header_done = FALSE;
-       net_params->request_started = FALSE;
-
-       if (g_cancellable_is_cancelled(net_access_mon.cancellable) == FALSE) {
-               g_cancellable_cancel(net_access_mon.cancellable);
-               NM_LOGI("g_cancellable_cancel is called and return stop_internet_check");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       if (net_params->transport_watch > 0) {
-               g_source_remove(net_params->transport_watch);
-               net_params->transport_watch = 0;
-       }
-
-       if (net_params->send_watch > 0) {
-               g_source_remove(net_params->send_watch);
-               net_params->send_watch = 0;
-       }
-
-       if (net_params->fd > 0) {
-               close(net_params->fd);
-               net_params->fd = -1;
-       }
-
-       if (net_params->addr != NULL) {
-               g_free(net_params->addr);
-               net_params->addr = NULL;
-       }
-
-       if (net_access_mon.proxy_addr) {
-               g_free(net_access_mon.proxy_addr);
-               net_access_mon.proxy_addr = NULL;
-       }
-
-       g_free(net_params);
-       net_access_mon.net_params = NULL;
-
-       if (net_access_mon.redirect_url1) {
-               g_free(net_access_mon.redirect_url1);
-               net_access_mon.redirect_url1 = NULL;
-       }
-
-       if (net_access_mon.redirect_url2) {
-               g_free(net_access_mon.redirect_url2);
-               net_access_mon.redirect_url2 = NULL;
-       }
-       __NM_FUNC_EXIT__;
-}
-
-void nm_net_access_init(void)
-{
-       __NM_FUNC_ENTER__;
-       net_access_mon.cancellable = g_cancellable_new();
-       __NM_FUNC_EXIT__;
-}
-
-void nm_net_access_deinit(void)
-{
-       __NM_FUNC_ENTER__;
-       g_object_unref(net_access_mon.cancellable);
-       __NM_FUNC_EXIT__;
-}
-
diff --git a/src/nm-netaccess.c b/src/nm-netaccess.c
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/src/nm-netlink.c b/src/nm-netlink.c
deleted file mode 100644 (file)
index 9932248..0000000
+++ /dev/null
@@ -1,1013 +0,0 @@
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-#include <netinet/ether.h>
-#include <netinet/icmp6.h>
-#include <net/if_arp.h>
-#include <linux/if.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-
-#include <netlink/genl/genl.h>
-#include <netlink/genl/ctrl.h>
-
-#include <glib.h>
-#include "nm-iface-mon.h"
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-util.h"
-#include "nm-daemon.h"
-
-#define NMDAEMON_NETWORK_PATH                  "/net/nmdaemon/network"
-#define NMDAEMON_NETWORK_INTERFACE             "net.nmdaemon.network"
-
-#define NETWORK_RETRY_RATE_MON_INTERVAL                5*1000
-#define NETWORK_CHANNEL_MON_INTERVAL           5*1000
-#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
-
-static GIOChannel *channel = NULL;
-static guint channel_watch = 0;
-
-static nmdaemon_request_table_s request_table[NMDAEMON_MONITOR_TYPE_MAX];
-static nmdaemon_htmode_e g_htmode;
-
-static void __destroy_mon_data(gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       nmdaemon_mon_data_s *mon_data = (nmdaemon_mon_data_s *)user_data;
-
-       g_source_remove(mon_data->timer_source_id);
-       mon_data->timer_source_id = 0;
-
-       nl_socket_free(mon_data->nl_global->socket);
-       g_free(mon_data->nl_global);
-       g_free(mon_data);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-static const char *operstate2str(unsigned char operstate)
-{
-       switch (operstate) {
-       case IF_OPER_UNKNOWN:
-               return "UNKNOWN";
-       case IF_OPER_NOTPRESENT:
-               return "NOT-PRESENT";
-       case IF_OPER_DOWN:
-               return "DOWN";
-       case IF_OPER_LOWERLAYERDOWN:
-               return "LOWER-LAYER-DOWN";
-       case IF_OPER_TESTING:
-               return "TESTING";
-       case IF_OPER_DORMANT:
-               return "DORMANT";
-       case IF_OPER_UP:
-               return "UP";
-       }
-
-       return "";
-}
-
-/*
-static void __nm_notify_ethernet_cable_state(const char *sig_name, const char *key)
-{
-       GVariantBuilder *builder;
-       GVariant *params;
-
-       NM_LOGE("[Signal] %s %s", sig_name, key);
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-       g_variant_builder_add(builder, "{sv}", "key", g_variant_new_string(key));
-
-       params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
-       g_variant_builder_unref(builder);
-
-       nm_gdbus_emit_signal(NULL,
-                               NMDAEMON_NETWORK_PATH,
-                               NMDAEMON_NETWORK_INTERFACE,
-                               sig_name,
-                               params);
-
-       return;
-}
-*/
-
-static gboolean __nm_extract_link(struct ifinfomsg *msg, int bytes,
-               const char **ifname, unsigned char *operstate)
-{
-       struct rtattr *attr;
-
-       if (!ifname || !operstate)
-               return FALSE;
-
-       for (attr = IFLA_RTA(msg); RTA_OK(attr, bytes);
-                                       attr = RTA_NEXT(attr, bytes)) {
-               switch (attr->rta_type) {
-               case IFLA_IFNAME:
-                       *ifname = RTA_DATA(attr);
-                       break;
-               case IFLA_OPERSTATE:
-                       *operstate = *((unsigned char *) RTA_DATA(attr));
-                       break;
-               }
-       }
-
-       if (*ifname == NULL && *operstate == 0xff)
-               return FALSE;
-
-       return TRUE;
-}
-
-static void __nl_message(void *buf, size_t length, gpointer user_data)
-{
-       NM_LOGE("");
-       while (length > 0) {
-               struct nlmsghdr *hdr = buf;
-               iface_mon_data_s *data = (iface_mon_data_s *)user_data;
-               if (!data)
-                       NM_LOGI("user data not available");
-
-               if (!NLMSG_OK(hdr, length))
-                       break;
-
-               if (hdr->nlmsg_type == RTM_NEWLINK) {
-                       unsigned char operstate = 0xff;
-                       const char *ifname = NULL;
-                       struct ifinfomsg *msg = (struct ifinfomsg *) NLMSG_DATA(hdr);
-
-                       if (!__nm_extract_link(msg, IFA_PAYLOAD(hdr), &ifname, &operstate))
-                               return;
-
-                       if (strncmp(ifname, "eth", 3) == 0 && operstate != 0xff) {
-                               NM_LOGI("%s {newlink} index %d operstate %u <%s>", ifname, msg->ifi_index,
-                                               operstate, operstate2str(operstate));
-
-                               int status = 0;
-                               if (operstate == IF_OPER_UP) {
-                                       NM_LOGI("ATTACHED");
-                                       status = 1;
-                               } else if (operstate == IF_OPER_DOWN) {
-                                       NM_LOGI("DETACHED");
-                                       status = 0;
-                               }
-
-                               if (data->cb)
-                                       data->cb((char *)ifname, status, data->cb_user_data);
-                       }
-               }
-
-               length -= hdr->nlmsg_len;
-               buf += hdr->nlmsg_len;
-       }
-}
-
-static gboolean __nm_netlink_event(GIOChannel *channel, GIOCondition cond, gpointer user_data)
-{
-       NM_LOGE("");
-       struct sockaddr_nl nladdr;
-       socklen_t addr_len = sizeof(nladdr);
-       unsigned char buf[4096];
-       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
-       int fd, length = 0;
-
-       if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR))
-               return FALSE;
-
-       memset(buf, 0, sizeof(buf));
-       memset(&nladdr, 0, sizeof(nladdr));
-
-       fd = g_io_channel_unix_get_fd(channel);
-
-       length = recvfrom(fd, buf, sizeof(buf), 0,
-                       (struct sockaddr *) &nladdr, &addr_len);
-       if (length < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               NM_LOGE("Failed to get netlink message [error: %s]", error_buf);
-               if (errno == EINTR || errno == EAGAIN)
-                       return TRUE;
-
-               return FALSE;
-       }
-
-       if (length == 0)
-               return FALSE;
-
-       if (nladdr.nl_pid != 0) { /* not sent by kernel, ignore */
-               NM_LOGE("Received msg from %u, ignoring it", nladdr.nl_pid);
-               return TRUE;
-       }
-
-       __nl_message(buf, length, user_data);
-
-       return TRUE;
-}
-
-int nm_rtnl_init(gpointer user_data)
-{
-       NM_LOGE("");
-       struct sockaddr_nl addr;
-       int fd;
-
-       memset(&addr, 0, sizeof(addr));
-       addr.nl_family = AF_NETLINK;
-       addr.nl_groups = RTMGRP_LINK;
-
-       fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
-       if (fd < 0) {
-               NM_LOGI("Failed to create socket");
-               return -1;
-       }
-
-       if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-               NM_LOGI("Failed to bin socket");
-               close(fd);
-               return -1;
-       }
-
-       channel = g_io_channel_unix_new(fd);
-       g_io_channel_set_close_on_unref(channel, TRUE);
-
-       g_io_channel_set_encoding(channel, NULL, NULL);
-       g_io_channel_set_buffered(channel, FALSE);
-
-       channel_watch = g_io_add_watch(channel,
-                               G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
-                               __nm_netlink_event, user_data);
-
-       return 0;
-}
-
-void nm_rtnl_cleanup(void)
-{
-       NM_LOGE("");
-       if (channel_watch) {
-               NM_LOGI("Remove channel watch");
-               g_source_remove(channel_watch);
-               channel_watch = 0;
-       }
-
-       g_io_channel_shutdown(channel, TRUE, NULL);
-       g_io_channel_unref(channel);
-
-       channel = NULL;
-}
-
-/** Retry Tx Rate monitor */
-static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
-                        void *user_data)
-{
-       int *ret = user_data;
-       *ret = err->error;
-       NM_LOGI("Error: %d", err->error);
-
-       return NL_STOP;
-}
-
-static int finish_handler(struct nl_msg *msg, void *arg)
-{
-       int *ret = arg;
-       *ret = 0;
-       return NL_SKIP;
-}
-
-static int ack_handler(struct nl_msg *msg, void *arg)
-{
-       int *ret = arg;
-       *ret = 0;
-       return NL_STOP;
-}
-
-static const char *ht_secondary_offset[4] = {
-        "no secondary",
-        "above",
-        "[reserved!]",
-        "below",
-};
-
-struct nmdaemon_ie_print {
-        const char *name;
-        void (*print)(nmdaemon_mon_data_s *data, const uint8_t type, uint8_t len, const uint8_t *ie);
-        uint8_t minlen, maxlen;
-        uint8_t flags;
-};
-
-static void __nmdaemon_print_ht_op(nmdaemon_mon_data_s *data, const uint8_t type, uint8_t len, const uint8_t *ie)
-{
-       strncpy(data->sec_chan_offset, ht_secondary_offset[ie[1] & 0x3], SEC_OFFSET_LEN);
-}
-
-static const struct nmdaemon_ie_print ie_printers[] = {
-       [61] = { "HT operation", __nmdaemon_print_ht_op, 22, 22, 1, },
-};
-
-static void nmdaemon_print_ie(nmdaemon_mon_data_s *data, const struct nmdaemon_ie_print *p, const uint8_t type,
-                     uint8_t len, const uint8_t *ie)
-{
-        if (!p->print)
-                return;
-
-       if (len < p->minlen || len > p->maxlen) {
-
-               int i;
-               if (len > 1) {
-                       NM_LOGE(" <invalid: %d bytes:", len);
-                       for (i = 0; i < len; i++)
-                               NM_LOGE(" %.02x", ie[i]);
-               } else if (len)
-                       NM_LOGE("invalid: 1 byte: %.02x", ie[0]);
-               else
-                       NM_LOGE("invalid: no data");
-
-               return;
-       }
-
-        p->print(data, type, len, ie);
-}
-
-static void __nmdaemon_print_ies(nmdaemon_mon_data_s *data, unsigned char *ie, int ielen)
-{
-       while (ielen >= 2 && ielen >= ie[1]) {
-               if (ie[0] < ARRAY_SIZE(ie_printers) &&
-                               ie_printers[ie[0]].name) {
-                       nmdaemon_print_ie(data, &ie_printers[ie[0]], ie[0], ie[1], ie + 2);
-               }
-               ielen -= ie[1] + 2;
-               ie += ie[1] + 2;
-       }
-}
-
-static nmdaemon_chan_info_s *__nmdaemon_find_chan(nmdaemon_chan_intf_info_s *intf_info, int freq)
-{
-       nmdaemon_chan_info_s *chan = NULL;
-       int i;
-       for (i = 0; i < intf_info->cur_pos; i++) {
-               chan = &intf_info->chan[i];
-
-               if (chan->freq == freq)
-                       return chan;
-       }
-
-       return NULL;
-}
-
-static gboolean __nmdaemon_is_2_4Ghz_band(int freq)
-{
-       if ((freq >= 2412) && (freq <= 2472))
-               return TRUE;
-
-       return FALSE;
-}
-
-static double __nmdaemon_get_channel_interference(nmdaemon_mon_data_s *data)
-{
-       nmdaemon_chan_info_s *chan, *adj_chan = NULL;
-       nmdaemon_chan_intf_info_s *intf_info = (nmdaemon_chan_intf_info_s *)data->intf_info;
-       int n_chans = 1;
-       int j;
-       double total_weight = 0;
-       double total_intf = 0;
-
-       if (intf_info->htmode == NMDAEMON_HTMODE_HT40) {
-               n_chans = 2;
-       }
-
-       if (intf_info->htmode == NMDAEMON_HTMODE_HT80) {
-               n_chans = 4;
-       }
-
-       chan = &intf_info->chan[intf_info->home_channel_pos];
-       total_intf = chan->intf_factor;
-       total_weight = 1;
-
-       for (j = 1; j < n_chans; j++) {
-               if (!strcmp(data->sec_chan_offset, "above")) {
-                       adj_chan = __nmdaemon_find_chan(intf_info, chan->freq + (j * 20));
-                       if (!adj_chan) {
-                               break;
-                       }
-               }
-
-               if (!strcmp(data->sec_chan_offset, "below")) {
-                       adj_chan = __nmdaemon_find_chan(intf_info, chan->freq - (j * 20));
-                       if (!adj_chan) {
-                               break;
-                       }
-               }
-
-               if (adj_chan) {
-                       total_intf += adj_chan->intf_factor;
-                       total_weight += 1;
-               }
-
-       }
-
-       if (intf_info->is_2_4Ghz_band) {
-               for (j = 0; j < n_chans; j++) {
-                       if (!strcmp(data->sec_chan_offset, "above")) {
-                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq + (j * 20) - 5);
-                               if (adj_chan) {
-                                       total_intf += (0.85 * adj_chan->intf_factor);
-                                       total_weight += 0.85;
-                               }
-
-                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq + (j * 20) - 10);
-                               if (adj_chan) {
-                                       total_intf += (0.55 * adj_chan->intf_factor);
-                                       total_weight += 0.55;
-                               }
-
-                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq + (j * 20) + 5);
-                               if (adj_chan) {
-                                       total_intf += (0.85 * adj_chan->intf_factor);
-                                       total_weight += 0.85;
-                               }
-
-                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq + (j * 20) + 10);
-                               if (adj_chan) {
-                                       total_intf += (0.55 * adj_chan->intf_factor);
-                                       total_weight += 0.55;
-                               }
-                       }
-
-                       if (!strcmp(data->sec_chan_offset, "below")) {
-                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq - (j * 20) + 5);
-                               if (adj_chan) {
-                                       total_intf += (0.85 * adj_chan->intf_factor);
-                                       total_weight += 0.85;
-                               }
-
-                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq - (j * 20) + 10);
-                               if (adj_chan) {
-                                       total_intf += (0.55 * adj_chan->intf_factor);
-                                       total_weight += 0.55;
-                               }
-
-                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq - (j * 20) - 5);
-                               if (adj_chan) {
-                                       total_intf += (0.85 * adj_chan->intf_factor);
-                                       total_weight += 0.85;
-                               }
-
-                               adj_chan = __nmdaemon_find_chan(intf_info, chan->freq - (j * 20) - 10);
-                               if (adj_chan) {
-                                       total_intf += (0.55 * adj_chan->intf_factor);
-                                       total_weight += 0.55;
-                               }
-                       }
-               }
-       }
-
-       total_intf = total_intf/total_weight;
-       NM_LOGI("total_intf: %lf", total_intf);
-
-       return total_intf;
-}
-
-static int nl_scan_info(struct nl_msg *msg, void *user_data)
-{
-       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s *)user_data;
-       struct nlattr *tb[NL80211_ATTR_MAX + 1];
-       struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
-       struct nlattr *bss[NL80211_BSS_MAX + 1];
-
-       static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
-               [NL80211_BSS_TSF] = { .type = NLA_U64 },
-               [NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
-               [NL80211_BSS_BSSID] = { },
-               [NL80211_BSS_BEACON_INTERVAL] = { .type = NLA_U16 },
-               [NL80211_BSS_CAPABILITY] = { .type = NLA_U16 },
-               [NL80211_BSS_INFORMATION_ELEMENTS] = { },
-               [NL80211_BSS_SIGNAL_MBM] = { .type = NLA_U32 },
-               [NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 },
-               [NL80211_BSS_STATUS] = { .type = NLA_U32 },
-               [NL80211_BSS_SEEN_MS_AGO] = { .type = NLA_U32 },
-               [NL80211_BSS_BEACON_IES] = { },
-       };
-
-       nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
-                       genlmsg_attrlen(gnlh, 0), NULL);
-
-       if (!tb[NL80211_ATTR_BSS]) {
-               NM_LOGE("bss info missing!\n");
-               return NL_SKIP;
-       }
-
-       if (nla_parse_nested(bss, NL80211_BSS_MAX,
-                               tb[NL80211_ATTR_BSS],
-                               bss_policy)) {
-               NM_LOGE("failed to parse nested attributes!");
-               return NL_SKIP;
-       }
-
-       if (!bss[NL80211_BSS_BSSID])
-               return NL_SKIP;
-
-       if (bss[NL80211_BSS_STATUS]) {
-               if (nla_get_u32(bss[NL80211_BSS_STATUS]) != NL80211_BSS_STATUS_ASSOCIATED) {
-                       NM_LOGE("sta is not associated to this AP");
-                       return NL_SKIP;
-               }
-       } else {
-               return NL_SKIP;
-       }
-
-       if (bss[NL80211_BSS_FREQUENCY]) {
-               data->freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
-               NM_LOGI("data->freq: %d", data->freq);
-       }
-
-       if (bss[NL80211_BSS_INFORMATION_ELEMENTS]) {
-               if (bss[NL80211_BSS_BEACON_IES])
-                       NM_LOGI("Information elements from Probe Response frame:");
-               __nmdaemon_print_ies(data, nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]),
-                               nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]));
-       }
-
-       return NL_SKIP;
-}
-
-static int nl_survey_info(struct nl_msg *msg, void *user_data)
-{
-       __NM_FUNC_ENTER__;
-       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s *)user_data;
-       nmdaemon_chan_intf_info_s *intf_info = (nmdaemon_chan_intf_info_s *)data->intf_info;
-       struct nlattr *tb[NL80211_ATTR_MAX + 1];
-       struct genlmsghdr *genlh = nlmsg_data(nlmsg_hdr(msg));
-       struct nlattr *survey_info[NL80211_SURVEY_INFO_MAX + 1];
-
-       static struct nla_policy survey_policy[NL80211_SURVEY_INFO_MAX + 1] = {
-               [NL80211_SURVEY_INFO_FREQUENCY] = { .type = NLA_U32 },
-               [NL80211_SURVEY_INFO_NOISE] = { .type = NLA_U8 },
-       };
-       unsigned int freq = 0;
-       unsigned long long ch_active_time = 0;
-       unsigned long long ch_busy_time = 0;
-       unsigned long long ch_tx_time = 0;
-       gboolean is_2_4Ghz_band = TRUE;
-
-       nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(genlh, 0),
-                       genlmsg_attrlen(genlh, 0), NULL);
-
-       if (!tb[NL80211_ATTR_SURVEY_INFO]) {
-               NM_LOGE("survey data missing!");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       if (nla_parse_nested(survey_info, NL80211_SURVEY_INFO_MAX,
-                               tb[NL80211_ATTR_SURVEY_INFO],
-                               survey_policy)) {
-               NM_LOGE("failed to parse nested attributes!");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       if (survey_info[NL80211_SURVEY_INFO_FREQUENCY]) {
-               freq = nla_get_u32(survey_info[NL80211_SURVEY_INFO_FREQUENCY]);
-               NM_LOGI("frequency: %u MHz%s", freq,
-                               survey_info[NL80211_SURVEY_INFO_IN_USE] ? " [in use]" : "");
-               is_2_4Ghz_band = __nmdaemon_is_2_4Ghz_band(freq);
-       }
-
-       if (is_2_4Ghz_band == intf_info->is_2_4Ghz_band) {
-               intf_info->chan[intf_info->cur_pos].freq = freq;
-
-               if (survey_info[NL80211_SURVEY_INFO_TIME]) {
-                       ch_active_time = (unsigned long long)nla_get_u64(survey_info[NL80211_SURVEY_INFO_TIME]);
-                       NM_LOGI("channel active time: %llu ms", ch_active_time);
-               }
-               if (survey_info[NL80211_SURVEY_INFO_TIME_BUSY]) {
-                       ch_busy_time = (unsigned long long)nla_get_u64(survey_info[NL80211_SURVEY_INFO_TIME_BUSY]);
-                       NM_LOGI("channel busy time: %llu ms", ch_busy_time);
-               }
-               if (survey_info[NL80211_SURVEY_INFO_TIME_TX]) {
-                       ch_tx_time = (unsigned long long)nla_get_u64(survey_info[NL80211_SURVEY_INFO_TIME_TX]);
-                       NM_LOGI("channel transmit time: %llu ms", ch_tx_time);
-               }
-
-               if (survey_info[NL80211_SURVEY_INFO_IN_USE]) {
-                       intf_info->home_channel_pos = intf_info->cur_pos;
-               }
-
-               intf_info->chan[intf_info->cur_pos].intf_factor = (((double)(ch_busy_time - ch_tx_time)) / ((double)(ch_active_time - ch_tx_time)));
-               intf_info->cur_pos++;
-       }
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-static int nl_station_info(struct nl_msg* msg, void *user_data)
-{
-       __NM_FUNC_ENTER__;
-       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s *)user_data;
-       int retry_rate = 0;
-       float tx_retries = 0.0, tx_packets = 0.0, tx_failed = 0.0;
-       struct nlattr *tb[NL80211_ATTR_MAX + 1];
-       struct genlmsghdr *genlh = nlmsg_data(nlmsg_hdr(msg));
-       struct nlattr *sta_info[NL80211_STA_INFO_MAX + 1];
-       char mac_addr[20];
-       static struct nla_policy station_stats[NL80211_STA_INFO_MAX + 1] = {
-               [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
-               [NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
-               [NL80211_STA_INFO_TX_RETRIES] = { .type = NLA_U32 },
-               [NL80211_STA_INFO_TX_FAILED] = { .type = NLA_U32 },
-               [NL80211_STA_INFO_TX_BITRATE] = { .type = NLA_NESTED },
-       };
-
-       struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
-        static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
-                [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
-                [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
-        };
-
-       nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(genlh, 0),
-                       genlmsg_attrlen(genlh, 0), NULL);
-
-       if (!tb[NL80211_ATTR_STA_INFO]) {
-               NM_LOGE("sta info missing");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-       if (nla_parse_nested(sta_info, NL80211_STA_INFO_MAX,
-                               tb[NL80211_ATTR_STA_INFO],
-                               station_stats)) {
-               NM_LOGE("Failed to parse nested station info");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       nmdaemon_convert_byte_to_string(mac_addr, nla_data(tb[NL80211_ATTR_MAC]));
-       NM_LOGI("Station %s)", mac_addr);
-
-       if (sta_info[NL80211_STA_INFO_INACTIVE_TIME])
-               NM_LOGI("Inactive time: %u ms",
-                               nla_get_u32(sta_info[NL80211_STA_INFO_INACTIVE_TIME]));
-       if (sta_info[NL80211_STA_INFO_TX_PACKETS]) {
-               tx_packets = (float)nla_get_u32(sta_info[NL80211_STA_INFO_TX_PACKETS]);
-               NM_LOGI("Tx packets: %f", tx_packets);
-       }
-       if (sta_info[NL80211_STA_INFO_TX_RETRIES]) {
-               tx_retries = (float)nla_get_u32(sta_info[NL80211_STA_INFO_TX_RETRIES]);
-               NM_LOGI("Tx retries: %f", tx_retries);
-       }
-       if (sta_info[NL80211_STA_INFO_TX_FAILED]) {
-               tx_failed = (float)nla_get_u32(sta_info[NL80211_STA_INFO_TX_FAILED]);
-               NM_LOGI("Tx failed: %f", tx_failed);
-       }
-       if (sta_info[NL80211_STA_INFO_TX_BITRATE]) {
-               if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
-                                       sta_info[NL80211_STA_INFO_TX_BITRATE], rate_policy)) {
-                       NM_LOGE("failed to parse nested rate attributes!");
-                       g_htmode = NMDAEMON_HTMODE_UNKNOWN;
-                       __NM_FUNC_EXIT__;
-                       return -1;
-               }
-
-               g_htmode = NMDAEMON_HTMODE_HT20;
-               if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
-                       g_htmode = NMDAEMON_HTMODE_HT40;
-               else if (rinfo[NL80211_RATE_INFO_80_MHZ_WIDTH])
-                       g_htmode = NMDAEMON_HTMODE_HT80;
-       }
-
-       retry_rate = (tx_retries/tx_packets) * 100;
-
-       if (data->tx_cb)
-               data->tx_cb(retry_rate, data->cb_user_data);
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-static int __nmdaemon_initialize_nl80211(gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s*)user_data;
-       nmdaemon_nl_global_s *global = (nmdaemon_nl_global_s *)data->nl_global;
-       int err = 0;
-
-       global->if_index = nmdaemon_get_interface_index(WIFI_IFNAME);
-       if (global->if_index < 0) {
-               NM_LOGE("Failed to get interface index");
-               return -1;
-       }
-
-       global->socket = nl_socket_alloc();
-       if (!global->socket) {
-               NM_LOGE("Failed to allocate netlink socket.");
-               return -ENOMEM;
-       }
-
-       global->cb = nl_cb_alloc(NL_CB_DEFAULT);
-       if (!global->cb) {
-               NM_LOGE("Failed to allocate netlink callbacks.");
-               err = -ENOMEM;
-               goto fail;
-       }
-       if (genl_connect(global->socket)) {
-               NM_LOGE("Failed to connect to generic netlink.");
-               err = -ENOLINK;
-               goto fail;
-       }
-
-       global->id = genl_ctrl_resolve(global->socket, "nl80211");
-       if (global->id < 0) {
-               NM_LOGE("Failed to find the nl80211 driver");
-               err = -ENOENT;
-               goto fail;
-       }
-       NM_LOGI("ID [%d]", global->id);
-
-       __NM_FUNC_EXIT__;
-       return 0;
-
-fail:
-       nl_cb_put(global->cb);
-       nl_socket_free(global->socket);
-
-       __NM_FUNC_EXIT__;
-       return err;
-}
-
-static gboolean __nmdaemon_send_netlink_cmd(gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       int err;
-       struct nl_msg *msg;
-       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s*)user_data;
-       nmdaemon_nl_global_s *global = (nmdaemon_nl_global_s *)data->nl_global;
-
-       if (data->timer_source_id == 0) {
-               NM_LOGI("monitoring stopped, timer_source_id: %d.", data->timer_source_id);
-               __NM_FUNC_EXIT__;
-               return FALSE;
-       }
-
-       /** allocate a message */
-       msg = nlmsg_alloc();
-       if (msg == NULL) {
-               NM_LOGE("Failed to allocate netlink message");
-               __NM_FUNC_EXIT__;
-               return FALSE;
-       }
-
-       /** setup the command into message */
-       genlmsg_put(msg, 0, 0, global->id, 0, NLM_F_DUMP, global->cmd, 0);
-
-       /** add message attributes */
-       err = nla_put_u32(msg, NL80211_ATTR_IFINDEX, global->if_index);
-       if (err < 0) {
-               NM_LOGE("Failed to add integer attribute, error (%d:%s)", err, nl_geterror(-err));
-               goto out;
-       }
-
-       /** send the messge */
-       err = nl_send_auto_complete(global->socket, msg);
-       if (err < 0) {
-               NM_LOGE("Failed to send nl message, error (%d:%s)", err, nl_geterror(-err));
-               goto out;
-       }
-       NM_LOGI("nl80211 cmd[%d] sent %d bytes to the kernel", global->cmd, err);
-
-       err = 1;
-       nl_cb_err(global->cb, NL_CB_CUSTOM, error_handler, &err);
-       nl_cb_set(global->cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
-       nl_cb_set(global->cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
-
-       switch(global->cmd) {
-       case NL80211_CMD_GET_SCAN:
-               nl_cb_set(global->cb, NL_CB_VALID, NL_CB_CUSTOM, nl_scan_info, user_data);
-               break;
-       case NL80211_CMD_GET_STATION:
-               nl_cb_set(global->cb, NL_CB_VALID, NL_CB_CUSTOM, nl_station_info, user_data);
-               break;
-       case NL80211_CMD_GET_SURVEY:
-               nl_cb_set(global->cb, NL_CB_VALID, NL_CB_CUSTOM, nl_survey_info, user_data);
-               break;
-       default:
-               goto out;
-       }
-
-       /** Receive the kernel message. */
-       while (err > 0)
-               nl_recvmsgs(global->socket, global->cb);
-
-out:
-       nlmsg_free(msg);
-       __NM_FUNC_EXIT__;
-       return TRUE;
-}
-
-int nm_retry_tx_rate_monitor_start(nm_retry_tx_rate_callback cb, void *user_data)
-{
-       __NM_FUNC_ENTER__;
-       nmdaemon_mon_data_s *data = NULL;
-
-       if (!cb) {
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_INVALID_PARAM;
-       }
-
-       request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].is_initialized = TRUE;
-       request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table = g_hash_table_new_full(g_direct_hash,
-                       g_direct_equal,
-                       NULL,
-                       __destroy_mon_data
-                       );
-
-       if (!request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table) {
-               request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].is_initialized = FALSE;
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_OPERATION_FAILED;
-       }
-
-       data = (nmdaemon_mon_data_s *)g_try_malloc0(sizeof(nmdaemon_mon_data_s));
-       if (!data) {
-               NM_LOGE("Failed to allocate memory to data variable.");
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
-       }
-
-       data->tx_cb = cb;
-       data->cb_user_data = user_data;
-
-       data->nl_global = (nmdaemon_nl_global_s *)g_try_malloc0(sizeof(nmdaemon_nl_global_s));
-       if (!data->nl_global) {
-               NM_LOGE("Failed to allocate memory to nl_global.");
-               g_free(data);
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
-       }
-
-       /** Initialize netlink socket */
-       data->nl_global->cmd = NL80211_CMD_GET_STATION;
-       int err = __nmdaemon_initialize_nl80211(data);
-       if (err < 0) {
-               NM_LOGE("__nmdaemon_initialize_nl80211() failed, error %d", err);
-               g_free(data->nl_global);
-               g_free(data);
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
-       }
-
-       data->timer_source_id = g_timeout_add(NETWORK_RETRY_RATE_MON_INTERVAL,
-                       __nmdaemon_send_netlink_cmd, data);
-
-       g_hash_table_insert(request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table,
-                       GINT_TO_POINTER(NL80211_CMD_GET_STATION), data);
-
-       __NM_FUNC_EXIT__;
-       return NM_DAEMON_ERROR_NONE;
-}
-
-int nm_retry_tx_rate_monitor_stop()
-{
-       __NM_FUNC_ENTER__;
-       gint ret = NM_DAEMON_ERROR_NONE;
-
-       if (!request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_NOT_INITIALIZED;
-       }
-
-       request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].is_initialized = FALSE;
-       g_hash_table_remove_all(request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table);
-       g_hash_table_unref(request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table);
-       request_table[NMDAEMON_MONITOR_TYPE_RETRY_TX_RATE].mon_table = NULL;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-static gboolean __nmdaemon_monitor_channel_interference(void *user_data)
-{
-       nmdaemon_mon_data_s *data = (nmdaemon_mon_data_s*)user_data;
-       gboolean ret;
-
-       data->nl_global->cmd = NL80211_CMD_GET_SCAN;
-       ret = __nmdaemon_send_netlink_cmd(data);
-       if (ret == FALSE)
-               return FALSE;
-
-       /** Fill Channel Information */
-       nmdaemon_chan_intf_info_s *intf_info = (nmdaemon_chan_intf_info_s *)data->intf_info;
-       intf_info->home_channel_freq = data->freq;
-       intf_info->is_2_4Ghz_band = __nmdaemon_is_2_4Ghz_band(intf_info->home_channel_freq);
-       intf_info->cur_pos = 0;
-       intf_info->home_channel_pos = -1;
-
-       /** get htmode */
-       data->nl_global->cmd = NL80211_CMD_GET_STATION;
-       ret = __nmdaemon_send_netlink_cmd(data);
-       if (ret == FALSE)
-               return FALSE;
-       intf_info->htmode = g_htmode;
-
-       data->nl_global->cmd = NL80211_CMD_GET_SURVEY;
-       ret = __nmdaemon_send_netlink_cmd(data);
-       if (ret == FALSE)
-               return FALSE;
-
-       double channel_intf = __nmdaemon_get_channel_interference(data);
-
-       if (data->ch_cb)
-               data->ch_cb(data->freq, channel_intf, data->cb_user_data);
-
-       return TRUE;
-}
-
-int nm_channel_interference_monitor_start(nm_channel_interference_callback cb, void *user_data)
-{
-       __NM_FUNC_ENTER__;
-       nmdaemon_mon_data_s *data = NULL;
-
-       if (!cb) {
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_INVALID_PARAM;
-       }
-
-       request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].is_initialized = TRUE;
-       request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table = g_hash_table_new_full(g_direct_hash,
-                       g_direct_equal,
-                       NULL,
-                       __destroy_mon_data
-                       );
-
-       if (!request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table) {
-               request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].is_initialized = FALSE;
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_OPERATION_FAILED;
-       }
-
-       data = (nmdaemon_mon_data_s*)g_try_malloc0(sizeof(nmdaemon_mon_data_s));
-       if (!data) {
-               NM_LOGE("Failed to allocate memory to data variable");
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
-       }
-
-       data->ch_cb = cb;
-       data->cb_user_data = user_data;
-
-       data->nl_global = (nmdaemon_nl_global_s*)g_try_malloc0(sizeof(nmdaemon_nl_global_s));
-       if (!data->nl_global) {
-               NM_LOGE("Failed to allocate memory to nl_global.");
-               g_free(data);
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
-       }
-
-       data->intf_info = (nmdaemon_chan_intf_info_s *)g_try_malloc0(sizeof(nmdaemon_chan_intf_info_s));
-       if (!data->intf_info) {
-               NM_LOGE("Failed to allocate memory to intf_info.");
-               g_free(data->nl_global);
-               g_free(data);
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
-       }
-
-       /** Initialize netlink socket */
-       int err = __nmdaemon_initialize_nl80211(data);
-       if (err < 0) {
-               NM_LOGE("__nmdaemon_initialize_nl80211() failed, error %d", err);
-               g_free(data->intf_info);
-               g_free(data->nl_global);
-               g_free(data);
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_OUT_OF_MEMORY;
-       }
-
-       data->timer_source_id = g_timeout_add(NETWORK_CHANNEL_MON_INTERVAL,
-                       __nmdaemon_monitor_channel_interference, data);
-
-       g_hash_table_insert(request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table,
-                       GINT_TO_POINTER(NL80211_CMD_GET_SURVEY), data);
-
-       __NM_FUNC_EXIT__;
-       return NM_DAEMON_ERROR_NONE;
-}
-
-int nm_channel_interference_monitor_stop()
-{
-       __NM_FUNC_ENTER__;
-       gint ret = NM_DAEMON_ERROR_NONE;
-
-       if (!request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_DAEMON_ERROR_NOT_INITIALIZED;
-       }
-
-       request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].is_initialized = FALSE;
-       g_hash_table_remove_all(request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table);
-       g_hash_table_unref(request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table);
-       request_table[NMDAEMON_MONITOR_TYPE_CHANNEL_INTERFERENCE].mon_table = NULL;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-statistics.c b/src/nm-statistics.c
deleted file mode 100644 (file)
index ac2b9b7..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for Monitoring /proc/.
- *
- * @file        nm-statistics.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include "nm-daemon-log.h"
-#include "nm-statistics.h"
-
-/*Poll the interface statistics at every 1000 ms*/
-#define STAT_POLLING_TIME       1000
-
-#define NM_PROC_DEV "/proc/net/dev"
-
-typedef struct {
-       gboolean is_initialized;
-       gboolean is_enabled;
-       guint timer_source_id;
-       nm_statistics_callback cb;
-       gpointer cb_user_data;
-} statistics_mon_s;
-
-statistics_mon_s stat_mon = {0,};
-
-
-static gboolean __get_statistics(gpointer user_data)
-{
-       nm_statistic_s stats;
-       FILE *fp;
-       gchar buf[1024];
-       gchar *p_ifname = NULL, *p_entry = NULL;
-       gchar *ret = NULL;
-
-       __NM_FUNC_ENTER__;
-
-       if (!stat_mon.cb) {
-               __NM_FUNC_EXIT__;
-               return TRUE;
-       }
-
-       fp = fopen(NM_PROC_DEV, "r");
-       if (fp == NULL) {
-               NM_LOGI("Failed to open %s", NM_PROC_DEV);
-               __NM_FUNC_EXIT__;
-               return TRUE;
-       }
-
-       ret = fgets(buf, sizeof(buf), fp);
-       if (ret == NULL) {
-               NM_LOGI("Nothing to read from %s", NM_PROC_DEV);
-               fclose(fp);
-               return TRUE;
-       }
-
-       p_ifname = buf;
-       while (*p_ifname == ' ') p_ifname++;
-       p_entry = strchr(p_ifname, ':');
-       if (p_entry != NULL) {
-               *p_entry++ = '\0';
-               g_strlcpy(stats.ifname, p_ifname, IFNAMSIZ);
-
-               /* read interface statistics */
-               sscanf(p_entry,
-                               "%llu %llu %lu %lu %lu %lu %lu %lu "
-                               "%llu %llu %lu %lu %lu %lu %lu %lu",
-                               (long long unsigned int *)&stats.rx_bytes, /* rx bytes */
-                               &stats.rx_packets,              /* rx packet */
-                               &stats.rx_errs,                 /* rx errors */
-                               &stats.rx_drop,                 /* rx dropped */
-                               &stats.rx_fifo,                 /* rx fifo errors */
-                               &stats.rx_frame,                /* rx frame errors */
-                               &stats.rx_compressed,   /* rx compressed */
-                               &stats.rx_multicast,    /* rx multicast */
-
-                               (long long unsigned int *)&stats.tx_bytes, /* tx bytes */
-                               &stats.tx_packets,              /* tx packet */
-                               &stats.tx_errs,                 /* tx errors */
-                               &stats.tx_drop,                 /* tx dropped */
-                               &stats.tx_fifo,                 /* tx fifo errors */
-                               &stats.tx_cols,                 /* collisions */
-                               &stats.tx_carrier,              /* tx carrier errors */
-                               &stats.tx_compressed    /* tx compressed */
-                               );
-               stat_mon.cb(&stats, user_data);
-       } else {
-               NM_LOGI("No matched Iface name in proc file");
-       }
-
-       fclose(fp);
-
-       __NM_FUNC_EXIT__;
-       return TRUE;
-}
-
-int nm_statistics_start_monitor(nm_statistics_callback cb, void *user_data)
-{
-       gint ret = NM_STATISTICS_ERROR_NONE;
-       guint source_id = 0;
-       __NM_FUNC_ENTER__;
-
-       if (!cb) {
-               __NM_FUNC_ENTER__;
-               return NM_STATISTICS_ERROR_INVALID_PARAM;
-       }
-
-       source_id = g_timeout_add(STAT_POLLING_TIME,
-                       __get_statistics, NULL);
-
-       if (stat_mon.timer_source_id >  0)
-               g_source_remove(stat_mon.timer_source_id);
-
-       stat_mon.timer_source_id = source_id;
-       stat_mon.cb = cb;
-       stat_mon.cb_user_data = user_data;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_statistics_stop_monitor()
-{
-       int ret = NM_STATISTICS_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!stat_mon.is_enabled) {
-               __NM_FUNC_ENTER__;
-               return NM_STATISTICS_ERROR_NONE;
-       }
-
-       if (stat_mon.timer_source_id >  0) {
-               g_source_remove(stat_mon.timer_source_id);
-               stat_mon.timer_source_id = 0;
-       }
-
-       stat_mon.cb = NULL;
-       stat_mon.cb_user_data = NULL;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_statistics_is_enabled(gboolean *enabled)
-{
-       int ret = NM_STATISTICS_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!enabled) {
-               __NM_FUNC_ENTER__;
-               return NM_STATISTICS_ERROR_INVALID_PARAM;
-       }
-
-       *enabled = stat_mon.is_enabled;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_statistics_init()
-{
-       int ret = NM_STATISTICS_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_statistics_deinit()
-{
-       int ret = NM_STATISTICS_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-stc-manager.c b/src/nm-stc-manager.c
deleted file mode 100644 (file)
index 7559284..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling signal from STC manager.
- *
- * @file        nm-stc-manager.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-stc-manager.h"
-
-typedef enum {
-       STC_SIGNAL_NAME_OWENER_CHANGED,
-       STC_SIGNAL_MAX,
-} stc_manager_signal_e;
-
-typedef struct {
-       gboolean is_initialized;
-
-} stc_manager_mon_s;
-
-stc_manager_mon_s stc_manager_mon;
-
-static void __name_owner_changed_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-static signal_param_s signal_param[] = {
-               {
-                               .sender = DBUS_SERVICE_DBUS,
-                               .interface_name = DBUS_INTERFACE_DBUS,
-                               .member = DBUS_SIGNAL_NAME_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = STC_MANAGER_SERVICE,
-                               .callback = __name_owner_changed_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = STC_MANAGER_SERVICE,
-                               .interface_name = STC_MANAGER_STATS_INTERFACE,
-                               .member = NULL/* TODO */,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = NULL /* TODO */,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = STC_MANAGER_SERVICE,
-                               .interface_name = STC_MANAGER_RESTRICTION_INTERFACE,
-                               .member = NULL/* TODO */,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = NULL /* TODO */,
-                               .subscriber_id  = 0,
-               },
-};
-
-static void __name_owner_changed_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       gchar *name = NULL;
-       gchar *old = NULL;
-       gchar *new = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (parameters == NULL)
-               return;
-
-       g_variant_get(parameters, "(&s&s&s)", &name, &old, &new);
-
-       if (g_strcmp0(name, STC_MANAGER_SERVICE) == 0 && *new == '\0')
-               NM_LOGI("stc-manager destroyed: name %s, old %s, new %s", name, old, new);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-int nm_stc_manager_init()
-{
-       int ret = NM_STC_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       memset(&stc_manager_mon, 0x00, sizeof(stc_manager_mon));
-       stc_manager_mon.is_initialized = TRUE;
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[STC_SIGNAL_NAME_OWENER_CHANGED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_STC_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_STC_ERROR_NONE;
-}
-
-int nm_stc_manager_deinit()
-{
-       int ret = NM_STC_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!stc_manager_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_STC_ERROR_NOT_INITIALIZED;
-       }
-
-       nm_gdbus_unsubscribe_signal(&(signal_param[STC_SIGNAL_NAME_OWENER_CHANGED]));
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
diff --git a/src/nm-supplicant-bss.c b/src/nm-supplicant-bss.c
deleted file mode 100644 (file)
index 023363a..0000000
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling signal from WPA Supplicant BSS interface.
- *
- * @file        nm-supplicant-bss.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-supplicant.h"
-#include "nm-supplicant-internal.h"
-
-#define DEBUG_G_VARIANT(str, parameters)\
-       do {\
-               gchar *parameters_debug_str = NULL;\
-               if (parameters)\
-                       parameters_debug_str = g_variant_print(parameters, TRUE);\
-               NM_LOGI("%s[%s]", str, parameters_debug_str ? parameters_debug_str : "NULL");\
-               g_free(parameters_debug_str);\
-       } while (0)
-#define DEBUG_SIGNAL(sender_name, object_path, interface_name, signal_name, parameters)\
-       do {\
-               NM_LOGI("signal sender name [%s]", sender_name);\
-               NM_LOGI("signal object path [%s]", object_path);\
-               NM_LOGI("signal interface name [%s]", interface_name);\
-               NM_LOGI("signal signal name [%s]", signal_name);\
-               DEBUG_G_VARIANT("signal params ", parameters);\
-               NM_LOGI("signal params type [%s]", g_variant_get_type_string(parameters));\
-       } while (0)
-
-typedef enum {
-       BSS_SIGNAL_PROPERTIESCHANGED,
-       BSS_SIGNAL_MAX,
-} supplicant_bss_signal_e;
-
-typedef struct {
-       guint key_mgmt;
-       guint pairwaise;
-       guint group;
-} wpa_s;
-
-typedef struct {
-       guint key_mgmt;
-       guint pairwaise;
-       guint group;
-       guint mgmt_group;
-} rsn_s;
-
-typedef struct {
-       /*
-        * BSSID of the BSS.
-        */
-       guchar bssid[BSSID_LEN];
-       /*
-        * SSID of the BSS.
-        */
-       gchar ssid[SSID_LEN + 1];
-       /*
-        * WPA information of the BSS.
-        */
-       wpa_s wpa;
-       /*
-        * RSN information of the BSS.
-        */
-       rsn_s rsn;
-       /*
-        * WPS information of the BSS.
-        */
-       guint wps_type;
-       /*
-        * indicates if BSS supports privacy.
-        */
-       gboolean private;
-       /*
-        * Describes mode of the BSS.
-        * Possible values are: "ad-hoc" and "infrastructure".
-        */
-       guint mode;
-       /*
-        * Frequency of the BSS in MHz.
-        */
-       guint16 frequency;
-
-       /*
-        * Signal strength of the BSS.
-        */
-       gint16 signal;
-       /*
-        * Number of seconds since the BSS was last seen.
-        */
-       guint age;
-
-       guint subscriber_id[BSS_SIGNAL_MAX];
-} supplicant_bss_s;
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(bss_properties_changed);
-
-static signal_param_s bss_signal_params[] = {
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_BSS,
-                       .member = DBUS_SIGNAL_PROPERTIES_CHANGED,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __bss_properties_changed,
-                       .subscriber_id  = 0,
-               }
-};
-
-static method_param_s get_bss_property_method_param = {
-               .bus_name = SUPPLICANT_SERVICE,
-               .object_path = NULL,
-               .interface_name = DBUS_PROPERTIES_INTERFACE,
-               .method_name = DBUS_PROPERTIES_METHOD_GETALL,
-               .parameters = NULL,
-};
-
-static inline int __subscribe_bss_signal(const gchar *path, supplicant_bss_s *bss_data)
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-       int signal_idx = 0;
-       __NM_FUNC_ENTER__;
-
-       if (!path || !bss_data) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       NM_LOGI("path [%s]", path);
-       for (signal_idx = BSS_SIGNAL_PROPERTIESCHANGED; signal_idx < BSS_SIGNAL_MAX; signal_idx++) {
-               bss_signal_params[signal_idx].object_path = path;
-               ret = nm_gdbus_subscribe_signal_with_data(&(bss_signal_params[signal_idx]), bss_data);
-               if (ret != NM_GDBUS_ERROR_NONE)
-                       NM_LOGI("Error! Failed to subscribe signal");
-               else
-                       bss_data->subscriber_id[signal_idx] =
-                                       bss_signal_params[signal_idx].subscriber_id;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_SUPPLICANT_ERROR_NONE;
-}
-
-static inline int __unsubscribe_bss_signal(supplicant_bss_s *bss_data)
-{
-       int signal_idx = 0;
-       int ret = NM_GDBUS_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!bss_data) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       for (signal_idx = BSS_SIGNAL_PROPERTIESCHANGED; signal_idx < BSS_SIGNAL_MAX; signal_idx++) {
-
-               if (bss_data->subscriber_id[signal_idx] == 0)
-                       continue;
-
-               bss_signal_params[signal_idx].subscriber_id = bss_data->subscriber_id[signal_idx];
-               ret = nm_gdbus_unsubscribe_signal(&(bss_signal_params[signal_idx]));
-               if (ret != NM_GDBUS_ERROR_NONE)
-                       NM_LOGI("Error! Failed to unsubscribe signal");
-               else
-                       bss_data->subscriber_id[signal_idx] = 0;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_SUPPLICANT_ERROR_NONE;
-}
-
-void nm_supplicant_bss_destroy(gpointer data)
-{
-       supplicant_bss_s *bss_data = (supplicant_bss_s *)data;
-       __NM_FUNC_ENTER__;
-
-       NM_LOGI("BSS destroyed [%s]", bss_data->ssid);
-
-       __unsubscribe_bss_signal(bss_data);
-
-       g_free(bss_data);
-       __NM_FUNC_EXIT__;
-       return;
-}
-/*
-static void inline __get_pairwise(GVariant *value, guint *pairwaise)
-{
-       GVariantIter *iter = NULL;
-       const gchar *str = NULL;
-
-       g_variant_get(value, "as", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       *pairwaise = 0;
-       while (g_variant_iter_loop(iter, "&s", &str)) {
-               if (g_strcmp0(str, "none") == 0)
-                       *pairwaise = *pairwaise | PAIRWISE_CAP_NONE;
-               else if (g_strcmp0(str, "ccmp") == 0)
-                       *pairwaise = *pairwaise | PAIRWISE_CAP_CCMP;
-               else if (g_strcmp0(str, "tkip") == 0)
-                       *pairwaise = *pairwaise | PAIRWISE_CAP_TKIP;
-       }
-       g_variant_iter_free(iter);
-}
-
-static void inline __get_group(GVariant *value, guint *group)
-{
-       GVariantIter *iter = NULL;
-       const gchar *str = NULL;
-
-       g_variant_get(value, "as", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       *group = 0;
-       while (g_variant_iter_loop(iter, "&s", &str)) {
-               if (g_strcmp0(str, "none") == 0)
-                       *group = *group | GROUP_CAP_CCMP;
-               else if (g_strcmp0(str, "ccmp") == 0)
-                       *group = *group | GROUP_CAP_TKIP;
-               else if (g_strcmp0(str, "wep104") == 0)
-                       *group = *group | GROUP_CAP_WEP104;
-               else if (g_strcmp0(str, "wep40") == 0)
-                       *group = *group | GROUP_CAP_WEP40;
-       }
-
-       g_variant_iter_free(iter);
-}
-
-static void inline __get_key_mgmt(GVariant *value, guint *key_mgmt)
-{
-       GVariantIter *iter = NULL;
-       const gchar *str = NULL;
-
-       g_variant_get(value, "as", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       *key_mgmt = 0;
-       while (g_variant_iter_loop(iter, "&s", &str)) {
-               if (g_strcmp0(str, "none") == 0)
-                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_NONE;
-               else if (g_strcmp0(str, "wpa-psk") == 0)
-                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_PSK;
-               else if (g_strcmp0(str, "wpa-ft-psk") == 0)
-                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_FT_PSK;
-               else if (g_strcmp0(str, "wpa-psk-sha256") == 0)
-                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_PSK_SHA256;
-               else if (g_strcmp0(str, "wpa-eap") == 0)
-                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_EAP;
-               else if (g_strcmp0(str, "wpa-ft-eap") == 0)
-                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_FT_EAP;
-               else if (g_strcmp0(str, "wpa-eap-sha256") == 0)
-                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_EAP_SHA256;
-               else if (g_strcmp0(str, "ieee8021x") == 0)
-                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_IEEE8021X;
-               else if (g_strcmp0(str, "wpa-none") == 0)
-                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPA_NONE;
-               else if (g_strcmp0(str, "wps") == 0)
-                       *key_mgmt = *key_mgmt | KEY_MGMT_CAP_WPS;
-       }
-       g_variant_iter_free(iter);
-}
-*/
-
-static gboolean __unpack_ays(unsigned char *dst, GVariant *src, int size)
-{
-       GVariantIter *iter = NULL;
-       int length = 0;
-       int res = FALSE;
-
-       if (!dst || !src || size == 0) {
-               NM_LOGI("Invalid parameter");
-               return FALSE;
-       }
-
-       g_variant_get(src, "ay", &iter);
-       if (iter == NULL) {
-               NM_LOGI("failed to get iterator");
-               return FALSE;
-       }
-
-       while (g_variant_iter_loop(iter, "y", &dst[length])) {
-               length++;
-               if (length >= size)
-                       break;
-       }
-       g_variant_iter_free(iter);
-
-       return res;
-}
-
-static void inline __get_bss_bssid(GVariant *value, supplicant_bss_s *bss)
-{
-       __unpack_ays(bss->bssid, value, BSSID_LEN);
-}
-
-static void inline __get_bss_ssid(GVariant *value, supplicant_bss_s *bss)
-{
-       __unpack_ays((unsigned char *)bss->ssid, value, SSID_LEN);
-}
-
-static void inline __get_bss_privacy(GVariant *value, supplicant_bss_s *bss)
-{
-       g_variant_get(value, "b", &(bss->private));
-}
-
-static void inline __get_bss_mode(GVariant *value, supplicant_bss_s *bss)
-{
-       const gchar *str = NULL;
-       g_variant_get(value, "&s", &str);
-
-       bss->mode = 0;
-       if (g_strcmp0(str, "infrastructure") == 0)
-               bss->mode |= MODE_INFRA;
-       else if (g_strcmp0(str, "ad-hoc") == 0)
-               bss->mode |= MODE_ADHOC;
-       else if (g_strcmp0(str, "ap") == 0)
-               bss->mode |= MODE_AP;
-       else if (g_strcmp0(str, "p2p") == 0)
-               bss->mode |= MODE_P2P;
-}
-
-static void inline __get_bss_freq(GVariant *value, supplicant_bss_s *bss)
-{
-       g_variant_get(value, "q", &(bss->frequency));
-}
-
-static void inline __get_bss_signal(GVariant *value, supplicant_bss_s *bss)
-{
-       g_variant_get(value, "n", &(bss->signal));
-}
-
-static void inline __get_bss_property(const gchar *key, GVariant *value, supplicant_bss_s *bss)
-{
-       if (g_strcmp0(key, "BSSID") == 0)
-               __get_bss_bssid(value, bss);
-       else if (g_strcmp0(key, "SSID") == 0)
-               __get_bss_ssid(value, bss);
-       else if (g_strcmp0(key, "Privacy") == 0)
-               __get_bss_privacy(value, bss);
-       else if (g_strcmp0(key, "Mode") == 0)
-               __get_bss_mode(value, bss);
-       else if (g_strcmp0(key, "Frequency") == 0)
-               __get_bss_freq(value, bss);
-       else if (g_strcmp0(key, "Signal") == 0)
-               __get_bss_signal(value, bss);
-}
-
-static inline int __init_bss(const gchar *path, supplicant_bss_s *bss, GHashTable *bss_tbl)
-{
-       gchar *key = NULL;
-       gint ret = 0;
-       __NM_FUNC_ENTER__;
-
-       key = g_strdup(path);
-       if (g_hash_table_replace(bss_tbl, key, bss))
-               NM_LOGI("BSS replaced");
-
-       ret = __subscribe_bss_signal(path, bss);
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               g_hash_table_steal(bss_tbl, key);
-               g_free(key);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       NM_LOGI("BSS replaced [%s]", path);
-       return 0;
-}
-
-int nm_supplicant_bss_add(const gchar *path, GVariantIter *iter, GHashTable *bss_tbl)
-{
-       supplicant_bss_s *bss = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!path || !iter) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       bss = (supplicant_bss_s *)g_try_malloc0(sizeof(supplicant_bss_s));
-       if (!bss) {
-               NM_LOGI("Error! Failed to allocate bss");
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       if (__init_bss(path, bss, bss_tbl) < 0) {
-               NM_LOGI("Error! Failed to init bss");
-               g_free(bss);
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
-               __get_bss_property(key, var, bss);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_supplicant_bss_remove(const gchar *path, GHashTable *bss_tbl)
-{
-       supplicant_bss_s *bss = NULL;
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-
-       if (!path || !bss_tbl) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       bss = g_hash_table_lookup(bss_tbl, path);
-       if (!bss) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       g_hash_table_remove(bss_tbl, path);
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-void __get_bss_properties(GVariant *value, gpointer user_data)
-{
-       GVariantIter *iter = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-       supplicant_bss_s *bss = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (!value || !user_data) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       g_variant_get(value, "(a{sv})", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       bss = (supplicant_bss_s *)user_data;
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
-               __get_bss_property(key, var, bss);
-
-       g_variant_iter_free(iter);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(bss_properties_changed)
-{
-       supplicant_bss_s *bss = NULL;
-
-       __NM_FUNC_ENTER__;
-
-       DEBUG_SIGNAL(sender_name, object_path, interface_name, signal, parameters);
-       bss = (supplicant_bss_s *)user_data;
-       if (!bss) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("bss not found");
-               return;
-       }
-
-       if (parameters)
-               __get_bss_properties(parameters, bss);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline gboolean __dbus_get_bss_properties(const gchar *path, supplicant_bss_s *bss)
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       get_bss_property_method_param.object_path = path;
-       get_bss_property_method_param.parameters = g_variant_new("(s)",
-                       SUPPLICANT_IFACE_BSS);
-
-       ret = nm_gdbus_method_call(&get_bss_property_method_param,
-                       __get_bss_properties,
-                       (gpointer)bss);
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               NM_LOGI("get property all failure");
-               return FALSE;
-       }
-
-       __NM_FUNC_EXIT__;
-       return TRUE;
-}
-
-int nm_supplicant_bss_add_by_path(const gchar *path, GHashTable *bsss)
-{
-       supplicant_bss_s *bss = NULL;
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-
-       if (!path) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       bss = (supplicant_bss_s *)g_try_malloc0(sizeof(supplicant_bss_s));
-       if (!bss) {
-               NM_LOGI("Error! Failed to allocate bss");
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       if (__init_bss(path, bss, bsss) < 0) {
-               NM_LOGI("Error! Failed to init bss");
-               g_free(bss);
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-
-       __dbus_get_bss_properties(path, bss);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-supplicant-iface.c b/src/nm-supplicant-iface.c
deleted file mode 100644 (file)
index bf68cb5..0000000
+++ /dev/null
@@ -1,1486 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling signal from WPA Supplicant network interface.
- *
- * @file        nm-supplicant-iface.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-supplicant.h"
-#include "nm-supplicant-internal.h"
-
-static void __handle_scan_done(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_bss_added(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_bss_removed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_blob_added(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_blob_removed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_network_added(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_network_removed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_network_selected(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_sta_authorized(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_sta_deauthorized(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __iface_properties_changed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_certification(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_eap(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_network_request(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_probe_request(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_wps_event(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static void __handle_wps_credentials(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data);
-
-static signal_param_s iface_signal_params[] = {
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "ScanDone",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_scan_done,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "BSSAdded",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_bss_added,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "BSSRemoved",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_bss_removed,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "BlobAdded",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_blob_added,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "BlobRemoved",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_blob_removed,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "NetworkAdded",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_network_added,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "NetworkRemoved",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_network_removed,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "NetworkSelected",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_network_selected,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "StaAuthorized",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_sta_authorized,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "StaDeauthorized",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_sta_deauthorized,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = DBUS_SIGNAL_PROPERTIES_CHANGED,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __iface_properties_changed,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "Certification",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_certification,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "EAP",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_eap,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "NetworkRequest",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_network_request,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_INTERFACE,
-                       .member = "ProbeRequest",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_probe_request,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_WPS,
-                       .member = "Event",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_wps_event,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_WPS,
-                       .member = "Credentials",
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback = __handle_wps_credentials,
-                       .subscriber_id  = 0,
-               },
-};
-
-static method_param_s get_iface_property_method_param = {
-               .bus_name = SUPPLICANT_SERVICE,
-               .object_path = NULL,
-               .interface_name = DBUS_PROPERTIES_INTERFACE,
-               .method_name = DBUS_PROPERTIES_METHOD_GETALL,
-               .parameters = NULL,
-};
-
-static method_param_s signal_poll_method_param = {
-               .bus_name = SUPPLICANT_SERVICE,
-               .object_path = NULL,
-               .interface_name = SUPPLICANT_IFACE_INTERFACE,
-               .method_name = "SignalPoll",
-               .parameters = NULL,
-};
-
-nm_supplicant_iface_changed_callback g_iface_prop_changed_cb;
-gpointer g_iface_prop_changed_cb_user_data;
-GHashTable *g_supplicant_iface_tbl = NULL;
-
-static inline int __subscribe_iface_signal(const gchar *path, nm_supplicant_iface_s *iface_data)
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-       int signal_idx = 0;
-       __NM_FUNC_ENTER__;
-
-       if (!path || !iface_data) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       NM_LOGI("path [%s]", path);
-       for (signal_idx = IFACE_SIGNAL_SCANDONE; signal_idx < IFACE_SIGNAL_MAX; signal_idx++) {
-               iface_signal_params[signal_idx].object_path = path;
-               ret = nm_gdbus_subscribe_signal(&(iface_signal_params[signal_idx]));
-               if (ret != NM_GDBUS_ERROR_NONE)
-                       NM_LOGI("Error! Failed to subscribe signal");
-               else
-                       iface_data->subscriber_id[signal_idx] =
-                                       iface_signal_params[signal_idx].subscriber_id;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_SUPPLICANT_ERROR_NONE;
-}
-
-static inline int __unsubscribe_iface_signal(nm_supplicant_iface_s *iface_data)
-{
-       int signal_idx = 0;
-       int ret = NM_GDBUS_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!iface_data) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       for (signal_idx = IFACE_SIGNAL_SCANDONE; signal_idx < IFACE_SIGNAL_PROBEREQUEST; signal_idx++) {
-
-               if (iface_data->subscriber_id[signal_idx] == 0)
-                       continue;
-
-               iface_signal_params[signal_idx].subscriber_id = iface_data->subscriber_id[signal_idx];
-               ret = nm_gdbus_unsubscribe_signal(&(iface_signal_params[signal_idx]));
-               if (ret != NM_GDBUS_ERROR_NONE)
-                       NM_LOGI("Error! Failed to unsubscribe signal");
-               else
-                       iface_data->subscriber_id[signal_idx] = 0;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_SUPPLICANT_ERROR_NONE;
-}
-
-static void __destroy_iface_data(gpointer data)
-{
-       nm_supplicant_iface_s *iface_data = (nm_supplicant_iface_s *)data;
-       __NM_FUNC_ENTER__;
-
-       g_hash_table_remove_all(iface_data->bss_tbl);
-       g_hash_table_unref(iface_data->bss_tbl);
-       iface_data->bss_tbl = NULL;
-
-       __unsubscribe_iface_signal(iface_data);
-
-       g_free(iface_data);
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void inline __get_cap_pairwise(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       GVariantIter *iter = NULL;
-       const gchar *str = NULL;
-
-       g_variant_get(value, "as", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface->cap.pairwise = 0;
-       while (g_variant_iter_loop(iter, "&s", &str)) {
-               if (g_strcmp0(str, "none") == 0)
-                       iface->cap.pairwise |= PAIRWISE_CAP_NONE;
-               else if (g_strcmp0(str, "ccmp") == 0)
-                       iface->cap.pairwise |= PAIRWISE_CAP_CCMP;
-               else if (g_strcmp0(str, "tkip") == 0)
-                       iface->cap.pairwise |= PAIRWISE_CAP_TKIP;
-       }
-       g_variant_iter_free(iter);
-}
-
-static void inline __get_cap_group(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       GVariantIter *iter = NULL;
-       const gchar *str = NULL;
-
-       g_variant_get(value, "as", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface->cap.group = 0;
-       while (g_variant_iter_loop(iter, "&s", &str)) {
-               if (g_strcmp0(str, "none") == 0)
-                       iface->cap.group |= GROUP_CAP_CCMP;
-               else if (g_strcmp0(str, "ccmp") == 0)
-                       iface->cap.pairwise |= GROUP_CAP_TKIP;
-               else if (g_strcmp0(str, "wep104") == 0)
-                       iface->cap.pairwise |= GROUP_CAP_WEP104;
-               else if (g_strcmp0(str, "wep40") == 0)
-                       iface->cap.pairwise |= GROUP_CAP_WEP40;
-       }
-
-       g_variant_iter_free(iter);
-}
-
-static void inline __get_cap_key_mgmt(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       GVariantIter *iter = NULL;
-       const gchar *str = NULL;
-
-       g_variant_get(value, "as", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface->cap.key_mgmt = 0;
-       while (g_variant_iter_loop(iter, "&s", &str)) {
-               if (g_strcmp0(str, "none") == 0)
-                       iface->cap.key_mgmt |= KEY_MGMT_CAP_NONE;
-               else if (g_strcmp0(str, "wpa-psk") == 0)
-                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_PSK;
-               else if (g_strcmp0(str, "wpa-ft-psk") == 0)
-                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_FT_PSK;
-               else if (g_strcmp0(str, "wpa-psk-sha256") == 0)
-                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_PSK_SHA256;
-               else if (g_strcmp0(str, "wpa-eap") == 0)
-                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_EAP;
-               else if (g_strcmp0(str, "wpa-ft-eap") == 0)
-                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_FT_EAP;
-               else if (g_strcmp0(str, "wpa-eap-sha256") == 0)
-                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_EAP_SHA256;
-               else if (g_strcmp0(str, "ieee8021x") == 0)
-                       iface->cap.key_mgmt |= KEY_MGMT_CAP_IEEE8021X;
-               else if (g_strcmp0(str, "wpa-none") == 0)
-                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPA_NONE;
-               else if (g_strcmp0(str, "wps") == 0)
-                       iface->cap.key_mgmt |= KEY_MGMT_CAP_WPS;
-       }
-       g_variant_iter_free(iter);
-}
-
-static void inline __get_cap_proto(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       GVariantIter *iter = NULL;
-       const gchar *str = NULL;
-
-       g_variant_get(value, "as", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface->cap.proto = 0;
-       while (g_variant_iter_loop(iter, "&s", &str)) {
-               if (g_strcmp0(str, "rsn") == 0)
-                       iface->cap.proto |= PROTOCOL_RSN;
-               else if (g_strcmp0(str, "wpa") == 0)
-                       iface->cap.proto |= PROTOCOL_WPA;
-       }
-
-       g_variant_iter_free(iter);
-}
-
-static void inline __get_cap_auth_alg(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       GVariantIter *iter = NULL;
-       const gchar *str = NULL;
-
-       g_variant_get(value, "as", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface->cap.auth_alg = 0;
-       while (g_variant_iter_loop(iter, "&s", &str)) {
-               if (g_strcmp0(str, "open") == 0)
-                       iface->cap.auth_alg |= AUTH_ALG_OPEN;
-               else if (g_strcmp0(str, "shared") == 0)
-                       iface->cap.auth_alg |= AUTH_ALG_SHARED;
-               else if (g_strcmp0(str, "leap") == 0)
-                       iface->cap.auth_alg |= AUTH_ALG_LEAP;
-       }
-
-       g_variant_iter_free(iter);
-}
-
-static void inline __get_cap_scan(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       GVariantIter *iter = NULL;
-       const gchar *str = NULL;
-
-       g_variant_get(value, "as", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface->cap.scan = 0;
-       while (g_variant_iter_loop(iter, "&s", &str)) {
-               if (g_strcmp0(str, "active") == 0)
-                       iface->cap.scan |= SCAN_ACTIVE;
-               else if (g_strcmp0(str, "passive") == 0)
-                       iface->cap.scan |= SCAN_PASSIVE;
-               else if (g_strcmp0(str, "ssid") == 0)
-                       iface->cap.scan |= SCAN_SSID;
-       }
-
-       g_variant_iter_free(iter);
-}
-
-static void inline __get_cap_mode(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       GVariantIter *iter = NULL;
-       const gchar *str = NULL;
-       g_variant_get(value, "as", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface->cap.modes = 0;
-       while (g_variant_iter_loop(iter, "&s", &str)) {
-               if (g_strcmp0(str, "infrastructure") == 0)
-                       iface->cap.modes |= MODE_INFRA;
-               else if (g_strcmp0(str, "ad-hoc") == 0)
-                       iface->cap.modes |= MODE_ADHOC;
-               else if (g_strcmp0(str, "ap") == 0)
-                       iface->cap.modes |= MODE_AP;
-               else if (g_strcmp0(str, "p2p") == 0)
-                       iface->cap.modes |= MODE_P2P;
-       }
-
-       g_variant_iter_free(iter);
-}
-static void inline __get_iface_capabilities(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       GVariantIter *iter = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-
-       g_variant_get(value, "a{sv}", &iter);
-       if (!iter)
-               return;
-
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
-               if (g_strcmp0(key, "Pairwise") == 0)
-                       __get_cap_pairwise(var, iface);
-               else if (g_strcmp0(key, "Group") == 0)
-                       __get_cap_group(var, iface);
-               else if (g_strcmp0(key, "KeyMgmt") == 0)
-                       __get_cap_key_mgmt(var, iface);
-               else if (g_strcmp0(key, "Protocol") == 0)
-                       __get_cap_proto(var, iface);
-               else if (g_strcmp0(key, "AuthAlg") == 0)
-                       __get_cap_auth_alg(var, iface);
-               else if (g_strcmp0(key, "Scan") == 0)
-                       __get_cap_scan(var, iface);
-               else if (g_strcmp0(key, "Modes") == 0)
-                       __get_cap_mode(var, iface);
-       }
-
-       g_variant_iter_free(iter);
-}
-
-static void inline __get_iface_state(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       const gchar *str = NULL;
-
-       g_variant_get(value, "&s", &str);
-
-       if (g_strcmp0(str, "unknown") == 0)
-               iface->state = IFACE_STATE_UNKNOWN;
-       else if (g_strcmp0(str, "disconnected") == 0)
-               iface->state = IFACE_STATE_DISCONNECTED;
-       else if (g_strcmp0(str, "inactive") == 0)
-               iface->state = IFACE_STATE_INACTIVE;
-       else if (g_strcmp0(str, "scanning") == 0)
-               iface->state = IFACE_STATE_SCANNING;
-       else if (g_strcmp0(str, "authenticating") == 0)
-               iface->state = IFACE_STATE_AUTHENTICATING;
-       else if (g_strcmp0(str, "associating") == 0)
-               iface->state = IFACE_STATE_ASSOCIATING;
-       else if (g_strcmp0(str, "associated") == 0)
-               iface->state = IFACE_STATE_ASSOCIATED;
-       else if (g_strcmp0(str, "4way_handshake") == 0)
-               iface->state = IFACE_STATE_4WAY_HANDSHAKE;
-       else if (g_strcmp0(str, "group_handshake") == 0)
-               iface->state = IFACE_STATE_GROUP_HANDSHAKE;
-       else if (g_strcmp0(str, "completed") == 0)
-               iface->state = IFACE_STATE_COMPLETED;
-
-       NM_LOGI("state [%s]", str);
-}
-
-static void inline __get_iface_scanning(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       g_variant_get(value, "b", &(iface->scanning));
-
-       NM_LOGI("%s", (iface->scanning)?"Scanning":"Not scanning");
-}
-
-static void inline __get_iface_ifname(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       const gchar *str = NULL;
-
-       g_variant_get(value, "&s", &str);
-       g_strlcpy(iface->Ifname, str, IFNAME_MAX + 1);
-
-       NM_LOGI("state [%s]", str);
-}
-
-static void inline __get_iface_current_bss(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       const gchar *path = NULL;
-       gpointer bss = NULL;
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(value, "&o", &path);
-       if (!path)
-               return;
-
-       if (g_strcmp0(path, "/") == 0) {
-               NM_LOGI("Null path");
-               iface->current_bss = NULL;
-               return;
-       }
-
-       bss = g_hash_table_lookup(iface->bss_tbl, path);
-       if (bss)
-               iface->current_bss = bss;
-       else
-               iface->current_bss = NULL;
-
-       __NM_FUNC_EXIT__;
-}
-
-static void inline __get_iface_bsss(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       GVariantIter *iter = NULL;
-       const gchar *obj = NULL;
-
-       g_variant_get(value, "ao", &iter);
-       if (!iter || !iface) {
-               NM_LOGI("Invalid params");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       while (g_variant_iter_loop(iter, "o", &obj))
-               nm_supplicant_bss_add_by_path(obj, iface->bss_tbl);
-
-       g_variant_iter_free(iter);
-}
-
-static void inline __get_iface_current_network(GVariant *value, nm_supplicant_iface_s *iface)
-{
-       const gchar *obj = NULL;
-
-       g_variant_get(value, "&o", &obj);
-
-       g_free(iface->current_network);
-       iface->current_network = NULL;
-
-       if (g_strcmp0(obj, "/") == 0) {
-               NM_LOGI("Null path");
-               return;
-       }
-
-       nm_supplicant_network_add_by_path(obj, &(iface->current_network));
-       return;
-}
-
-static void inline __get_iface_property(const gchar *key, GVariant *value, nm_supplicant_iface_s *iface)
-{
-       if (g_strcmp0(key, "Capabilities") == 0)
-               __get_iface_capabilities(value, iface);
-       else if (g_strcmp0(key, "State") == 0)
-               __get_iface_state(value, iface);
-       else if (g_strcmp0(key, "Scanning") == 0)
-               __get_iface_scanning(value, iface);
-       else if (g_strcmp0(key, "Ifname") == 0)
-               __get_iface_ifname(value, iface);
-       else if (g_strcmp0(key, "CurrentBSS") == 0)
-               __get_iface_current_bss(value, iface);
-       else if (g_strcmp0(key, "BSSs") == 0)
-               __get_iface_bsss(value, iface);
-       else if (g_strcmp0(key, "CurrentNetwork") == 0)
-               __get_iface_current_network(value, iface);
-/*
-       else if (g_strcmp0(key, "CurrentAuthMode") == 0)
-               __get_iface_current_auth_mode(value, iface);
-       else if (g_strcmp0(key, "Blobs") == 0)
-               __get_iface_blobs(value, iface);
-       else if (g_strcmp0(key, "Networks") == 0)
-               __get_iface_networks(value, iface);
-*/
-}
-
-static void inline __get_iface_property_without_bss(const gchar *key, GVariant *value, nm_supplicant_iface_s *iface)
-{
-       NM_LOGI("Prop %s", key);
-       if (g_strcmp0(key, "Capabilities") == 0)
-               __get_iface_capabilities(value, iface);
-       else if (g_strcmp0(key, "State") == 0)
-               __get_iface_state(value, iface);
-       else if (g_strcmp0(key, "Scanning") == 0)
-               __get_iface_scanning(value, iface);
-       else if (g_strcmp0(key, "Ifname") == 0)
-               __get_iface_ifname(value, iface);
-       else if (g_strcmp0(key, "CurrentBSS") == 0)
-               __get_iface_current_bss(value, iface);
-       else if (g_strcmp0(key, "CurrentNetwork") == 0)
-               __get_iface_current_network(value, iface);
-/*
-       else if (g_strcmp0(key, "CurrentAuthMode") == 0)
-               __get_iface_current_auth_mode(value, iface);
-       else if (g_strcmp0(key, "Blobs") == 0)
-               __get_iface_blobs(value, iface);
-       else if (g_strcmp0(key, "Networks") == 0)
-               __get_iface_networks(value, iface);
-*/
-}
-
-void __get_iface_properties(GVariant *value, gpointer user_data)
-{
-       GVariantIter *iter = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-       nm_supplicant_iface_s *iface = NULL;
-
-       if (!value || !user_data)
-               return;
-
-       g_variant_get(value, "(a{sv})", &iter);
-       if (!iter)
-               return;
-
-       iface = (nm_supplicant_iface_s *)user_data;
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
-               __get_iface_property(key, var, iface);
-
-       g_variant_iter_free(iter);
-
-       return;
-}
-
-void __get_iface_properties_without_bss(GVariant *value, gpointer user_data)
-{
-       GVariantIter *iter = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-       nm_supplicant_iface_s *iface = NULL;
-
-       if (!value || !user_data)
-               return;
-
-       g_variant_get(value, "(a{sv})", &iter);
-       if (!iter) {
-               NM_LOGI("null iter!");
-               return;
-       }
-
-       iface = (nm_supplicant_iface_s *)user_data;
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
-               __get_iface_property_without_bss(key, var, iface);
-
-       g_variant_iter_free(iter);
-
-       return;
-}
-static void __handle_scan_done(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_bss_added(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       nm_supplicant_iface_s *iface = NULL;
-       GVariantIter *iter = NULL;
-       const gchar *path = NULL;
-       gint ret = 0;
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(parameters, "(oa{sv})", &path, &iter);
-       if (!path || !iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
-       if (!iface) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("iface not found");
-               return;
-       }
-
-       ret = nm_supplicant_bss_add(path, iter, iface->bss_tbl);
-       if (ret < 0) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("nm_supplicant_bss_add failed");
-               return;
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_bss_removed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       nm_supplicant_iface_s *iface = NULL;
-       const gchar *path = NULL;
-       gint ret = 0;
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(parameters, "(o)", &path);
-       if (!path) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
-       if (!iface) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("iface not found");
-               return;
-       }
-
-       ret = nm_supplicant_bss_remove(path, iface->bss_tbl);
-       if (ret < 0) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("nm_supplicant_bss_remove failed");
-               return;
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_blob_added(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_blob_removed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_network_added(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_ENTER__;
-       nm_supplicant_iface_s *iface = NULL;
-       GVariantIter *iter = NULL;
-       const gchar *path = NULL;
-       gint ret = 0;
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(parameters, "(oa{sv})", &path, &iter);
-       if (!path || !iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
-       if (!iface) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("iface not found");
-               return;
-       }
-
-       ret = nm_supplicant_network_add(path, iter, &(iface->current_network));
-       if (ret < 0) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("nm_supplicant_network_add failed");
-               return;
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_network_removed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       nm_supplicant_iface_s *iface = NULL;
-       const gchar *path = NULL;
-       gint ret = 0;
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(parameters, "(o)", &path);
-       if (!path) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
-       if (!iface) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("iface not found");
-               return;
-       }
-
-       ret = nm_supplicant_network_remove(path, iface->current_network);
-       if (ret < 0) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("nm_supplicant_network_remove failed");
-               return;
-       }
-       iface->current_network = NULL;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_network_selected(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       nm_supplicant_iface_s *iface = NULL;
-       const gchar *path = NULL;
-       gint ret = 0;
-
-       g_variant_get(parameters, "(o)", &path);
-       if (!path) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
-       if (!iface) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("iface not found");
-               return;
-       }
-
-       ret = nm_supplicant_network_select(path, iface->current_network);
-       if (ret < 0) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("nm_supplicant_network_select failed");
-               return;
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_sta_authorized(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_sta_deauthorized(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_certification(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_eap(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_network_request(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_probe_request(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_wps_event(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       GVariantIter *iter = NULL;
-       const gchar *event = NULL;
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(parameters, "(s(a{sv}))", &event, &iter);
-       if (!event || !iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       nm_supplicant_wps_handle_event_signal(event, iter);
-
-       g_variant_iter_free(iter);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __handle_wps_credentials(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       nm_supplicant_wps_handle_event_credentials(parameters);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __iface_properties_changed(const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       nm_supplicant_iface_s *iface = NULL;
-       nm_supplicant_iface_property_e changed = NM_SUPPLICANT_IFACE_PROPERTY_NONE;
-       guint state;
-       gboolean scanning;
-
-       __NM_FUNC_ENTER__;
-
-       iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
-       if (!iface) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("iface not found");
-               return;
-       }
-
-       state = iface->state;
-       scanning = iface->scanning;
-
-       if (parameters)
-               __get_iface_properties_without_bss(parameters, iface);
-
-       if (iface->state == IFACE_STATE_COMPLETED)
-               nm_supplicant_iface_signal_poll(object_path);
-
-       if (iface->state != state)
-               changed |= NM_SUPPLICANT_IFACE_PROPERTY_STATE;
-
-       if (iface->scanning != scanning)
-               changed |= NM_SUPPLICANT_IFACE_PROPERTY_SCANNING;
-
-
-       if (g_iface_prop_changed_cb)
-               g_iface_prop_changed_cb(changed, iface, g_iface_prop_changed_cb_user_data);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline int __init_iface(const gchar *path, nm_supplicant_iface_s *iface)
-{
-       gchar *key = NULL;
-       gint ret = 0;
-       __NM_FUNC_ENTER__;
-       iface->bss_tbl = g_hash_table_new_full(g_str_hash,
-                       g_str_equal,
-                       g_free,
-                       nm_supplicant_bss_destroy
-                       );
-
-       if (!iface->bss_tbl) {
-               NM_LOGI("Error! Failed to allocate bss tbl");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       key = g_strdup(path);
-       if (g_hash_table_replace(g_supplicant_iface_tbl, key, iface))
-               NM_LOGI("Iface replaced");
-
-       ret = __subscribe_iface_signal(path, iface);
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               g_hash_table_steal(g_supplicant_iface_tbl, key);
-               g_free(key);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       ret = nm_supplicant_p2p_init(path, &(iface->p2p));
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("nm_supplicant_p2p_init failed");
-
-       return 0;
-}
-
-int nm_supplicant_iface_add(const gchar *path, GVariantIter *iter)
-{
-       nm_supplicant_iface_s *iface = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!path || !iter) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       iface = (nm_supplicant_iface_s *)g_try_malloc0(sizeof(nm_supplicant_iface_s));
-       if (!iface) {
-               NM_LOGI("Error! Failed to allocate iface");
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       if (__init_iface(path, iface) < 0) {
-               __NM_FUNC_EXIT__;
-               g_free(iface);
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
-               __get_iface_property(key, var, iface);
-
-       if (g_iface_prop_changed_cb)
-               g_iface_prop_changed_cb(NM_SUPPLICANT_IFACE_PROPERTY_SCANNING |
-                               NM_SUPPLICANT_IFACE_PROPERTY_STATE,
-                               iface,
-                               g_iface_prop_changed_cb_user_data);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_supplicant_iface_remove(const gchar *path)
-{
-       nm_supplicant_iface_s *iface = NULL;
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-
-       if (!path) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       iface = g_hash_table_lookup(g_supplicant_iface_tbl, path);
-       if (!iface) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       ret = nm_supplicant_p2p_deinit(iface->p2p);
-       if (ret != NM_SUPPLICANT_ERROR_NONE)
-               NM_LOGI("nm_supplicant_p2p_deinit failed");
-       iface->p2p = NULL;
-
-       g_hash_table_remove(g_supplicant_iface_tbl, path);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-static inline void __dbus_get_iface_properties(const gchar *path, nm_supplicant_iface_s *iface)
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       get_iface_property_method_param.object_path = path;
-       get_iface_property_method_param.parameters = g_variant_new("(s)",
-                       SUPPLICANT_IFACE_INTERFACE);
-
-       ret = nm_gdbus_method_call(&get_iface_property_method_param,
-                       __get_iface_properties,
-                       (gpointer)iface);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get property all failure");
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline void __iface_signal_poll(GVariant *value, gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       /* TODO: get iface info from signal poll
-       nm_supplicant_iface_s *iface = (nm_supplicant_iface_s *)user_data;
-
-       if (!value || !user_data)
-               return;
-
-*/
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-int nm_supplicant_iface_signal_poll(const gchar *path)
-{
-       nm_supplicant_iface_s *iface = NULL;
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       iface = g_hash_table_lookup(g_supplicant_iface_tbl, path);
-       if (!iface) {
-               __NM_FUNC_EXIT__;
-               NM_LOGI("iface not found");
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       signal_poll_method_param.object_path = path;
-
-       ret = nm_gdbus_method_call(&signal_poll_method_param,
-                       __iface_signal_poll,
-                       (gpointer)iface);
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               NM_LOGI("signal poll failure");
-               ret = NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       __NM_FUNC_EXIT__;
-       return ret;
-
-}
-
-int nm_supplicant_iface_add_by_path(const gchar *path)
-{
-       nm_supplicant_iface_s *iface = NULL;
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-
-       if (!path) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       iface = (nm_supplicant_iface_s *)g_try_malloc0(sizeof(nm_supplicant_iface_s));
-       if (!iface) {
-               NM_LOGI("Error! Failed to allocate iface");
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       if (__init_iface(path, iface) < 0) {
-               __NM_FUNC_EXIT__;
-               g_free(iface);
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       __dbus_get_iface_properties(path, iface);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-
-int nm_supplicant_iface_set_prop_changed_cb(nm_supplicant_iface_changed_callback cb, gpointer user_data)
-{
-
-       if (!g_supplicant_iface_tbl)
-               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
-
-       g_iface_prop_changed_cb = cb;
-       g_iface_prop_changed_cb_user_data = user_data;
-
-       return NM_SUPPLICANT_ERROR_NONE;
-}
-
-int nm_supplicant_iface_unset_prop_changed_cb()
-{
-       if (!g_supplicant_iface_tbl)
-               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
-
-       g_iface_prop_changed_cb = NULL;
-       g_iface_prop_changed_cb_user_data = NULL;
-
-       return NM_SUPPLICANT_ERROR_NONE;
-
-}
-
-int nm_supplicant_iface_get_iface(gchar *iface_name, nm_supplicant_iface_s **iface)
-{
-       GHashTableIter iter;
-       gpointer key, value;
-       nm_supplicant_iface_s *iface_data = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (!g_supplicant_iface_tbl)
-               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
-
-
-       g_hash_table_iter_init (&iter, g_supplicant_iface_tbl);
-       while (g_hash_table_iter_next (&iter, &key, &value)) {
-               iface_data = (nm_supplicant_iface_s *)value;
-               if (iface_data == NULL)
-                       continue;
-
-               NM_LOGI("%s is iface name", iface_data->Ifname);
-               if (g_strcmp0(iface_name, iface_data->Ifname) == 0) {
-                       *iface = iface_data;
-                       return NM_SUPPLICANT_ERROR_NONE;
-               }
-
-               iface_data = NULL;
-       }
-
-       return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       __NM_FUNC_EXIT__;
-}
-
-int nm_supplicant_iface_init()
-{
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-       g_supplicant_iface_tbl = g_hash_table_new_full(g_str_hash,
-                       g_str_equal,
-                       g_free,
-                       __destroy_iface_data
-                       );
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_supplicant_iface_deinit()
-{
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       g_hash_table_remove_all(g_supplicant_iface_tbl);
-       g_hash_table_unref(g_supplicant_iface_tbl);
-       g_supplicant_iface_tbl = NULL;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-supplicant-internal.h b/src/nm-supplicant-internal.h
deleted file mode 100644 (file)
index 70afce5..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file defines macro and declares functions for handling signal from WPA Supplicant.
- *
- * @file        nm-supplicant-internal.h
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-#ifndef __NM_SUPPLICANT_INTERNAL_H__
-#define __NM_SUPPLICANT_INTERNAL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SUPPLICANT_SERVICE                             "fi.w1.wpa_supplicant1"
-#define SUPPLICANT_PATH                                        "/fi/w1/wpa_supplicant1"
-
-#define SUPPLICANT_INTERFACE                   "fi.w1.wpa_supplicant1"
-#define SUPPLICANT_IFACE_INTERFACE             SUPPLICANT_INTERFACE ".Interface"
-#define SUPPLICANT_IFACE_WPS                   SUPPLICANT_IFACE_INTERFACE ".WPS"
-#define SUPPLICANT_IFACE_P2P                   SUPPLICANT_IFACE_INTERFACE ".P2PDevice"
-#define SUPPLICANT_IFACE_BSS                   SUPPLICANT_INTERFACE ".BSS"
-#define SUPPLICANT_IFACE_NETWORK               SUPPLICANT_INTERFACE ".NETWORK"
-
-typedef enum {
-       EAP_METHOD_UNKNOWN = 0x00,
-       EAP_METHOD_MD5 = 0x01,
-       EAP_METHOD_TLS = 0x02,
-       EAP_METHOD_MSCHPV2 = 0x04,
-       EAP_METHOD_PEAP = 0x08,
-       EAP_METHOD_TTLS = 0x10,
-       EAP_METHOD_GTC = 0x20,
-       EAP_METHOD_OTP = 0x40,
-       EAP_METHOD_LEAP = 0x80,
-       EAP_METHOD_WSC = 0x100,
-} supplicant_eap_method_e;
-
-typedef enum {
-
-       CAPABILITY_UNKNOWN = 0x00,
-       CAPABILITY_AP = 0x01,
-       CAPABILITY_IBSS_RSN = 0x02,
-       CAPABILITY_P2P = 0x04,
-       CAPABILITY_INTERWORKING = 0x08,
-} supplicant_capability_e;
-
-typedef enum {
-       PAIRWISE_CAP_NONE = 0x01,
-       PAIRWISE_CAP_CCMP = 0x02,
-       PAIRWISE_CAP_TKIP = 0x04,
-} pairwise_cap_e;
-
-typedef enum {
-       GROUP_CAP_CCMP = 0x01,
-       GROUP_CAP_TKIP = 0x02,
-       GROUP_CAP_WEP104 = 0x04,
-       GROUP_CAP_WEP40 = 0x08,
-} gruop_cap_e;
-
-typedef enum {
-       KEY_MGMT_CAP_NONE = 0x01,
-       KEY_MGMT_CAP_WPA_PSK = 0x02,
-       KEY_MGMT_CAP_WPA_FT_PSK = 0x04,
-       KEY_MGMT_CAP_WPA_PSK_SHA256 = 0x08,
-       KEY_MGMT_CAP_WPA_EAP = 0x10,
-       KEY_MGMT_CAP_WPA_FT_EAP = 0x20,
-       KEY_MGMT_CAP_WPA_EAP_SHA256 = 0x40,
-       KEY_MGMT_CAP_IEEE8021X = 0x80,
-       KEY_MGMT_CAP_WPA_NONE = 0x100,
-       KEY_MGMT_CAP_WPS = 0x200,
-} key_mgmt_cap_e;
-
-typedef enum {
-       PROTOCOL_RSN = 0x01,
-       PROTOCOL_WPA = 0x02,
-} protocol_e;
-
-typedef enum {
-       AUTH_ALG_OPEN = 0x01,
-       AUTH_ALG_SHARED = 0x02,
-       AUTH_ALG_LEAP = 0x03,
-} auth_alg_e;
-
-typedef enum {
-       SCAN_ACTIVE = 0x01,
-       SCAN_PASSIVE = 0x02,
-       SCAN_SSID = 0x04,
-} scan_e;
-
-typedef enum {
-       MODE_INFRA = 0x01,
-       MODE_ADHOC = 0x02,
-       MODE_AP = 0x04,
-       MODE_P2P = 0x08,
-} modes_e;
-
-typedef enum {
-       IFACE_STATE_UNKNOWN,
-       IFACE_STATE_DISCONNECTED,
-       IFACE_STATE_INACTIVE,
-       IFACE_STATE_SCANNING,
-       IFACE_STATE_AUTHENTICATING,
-       IFACE_STATE_ASSOCIATING,
-       IFACE_STATE_ASSOCIATED,
-       IFACE_STATE_4WAY_HANDSHAKE,
-       IFACE_STATE_GROUP_HANDSHAKE,
-       IFACE_STATE_COMPLETED,
-} iface_state_e;
-
-typedef enum {
-       P2P_PEER_STATE_FOUND,
-       P2P_PEER_STATE_PD,
-       P2P_PEER_STATE_GO_NEG,
-       P2P_PEER_STATE_WPS,
-       P2P_PEER_STATE_CONNECTED,
-       P2P_PEER_STATE_PD_FAIL,
-       P2P_PEER_STATE_GO_NEG_FAIL,
-       P2P_PEER_STATE_WPS_FAIL,
-       P2P_PEER_STATE_GROUP_FAIL,
-} p2p_peer_state_e;
-
-typedef enum {
-       P2P_ROLE_NONE,
-       P2P_ROLE_GC,
-       P2P_ROLE_GO,
-}p2p_role_e;
-
-int nm_supplicant_get_eap_methods(unsigned int *eap_methods);
-int nm_supplicant_get_capabilities(unsigned int *capabilities);
-int nm_supplicant_get_wfd_ies(unsigned char *ies, unsigned int *length);
-int nm_supplicant_iface_state_changed(nm_supplicant_iface_s *iface);
-
-int nm_supplicant_iface_init();
-int nm_supplicant_iface_deinit();
-int nm_supplicant_iface_add(const gchar *path, GVariantIter *iter);
-int nm_supplicant_iface_remove(const gchar *path);
-int nm_supplicant_iface_add_by_path(const gchar *path);
-int nm_supplicant_iface_signal_poll(const gchar *path);
-
-void nm_supplicant_wps_handle_event_signal(const gchar *event, GVariantIter *iter);
-void nm_supplicant_wps_handle_event_credentials(GVariant *credentials);
-
-int nm_supplicant_bss_add(const gchar *path, GVariantIter *iter, GHashTable *bss_tbl);
-int nm_supplicant_bss_add_by_path(const gchar *path, GHashTable *bss_tbl);
-int nm_supplicant_bss_remove(const gchar *path, GHashTable *bss_tbls);
-void nm_supplicant_bss_destroy(gpointer data);
-
-int nm_supplicant_network_add(const gchar *path, GVariantIter *iter, gpointer *network);
-int nm_supplicant_network_add_by_path(const gchar *path, gpointer *network);
-int nm_supplicant_network_remove(const gchar *path, gpointer network);
-int nm_supplicant_network_select(const gchar *path, gpointer network);
-void nm_supplicant_network_destroy(gpointer data);
-
-int nm_supplicant_p2p_init(const gchar *path, gpointer *p2p);
-int nm_supplicant_p2p_deinit(gpointer p2p);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NM_SUPPLICANT_INTERNAL_H__ */
-
diff --git a/src/nm-supplicant-network.c b/src/nm-supplicant-network.c
deleted file mode 100644 (file)
index 2692fac..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling signal from WPA Supplicant network interface.
- *
- * @file        nm-supplicant-network.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-supplicant.h"
-#include "nm-supplicant-internal.h"
-
-#define DEBUG_G_VARIANT(str, parameters)\
-       do {\
-               gchar *parameters_debug_str = NULL;\
-               if (parameters)\
-                       parameters_debug_str = g_variant_print(parameters, TRUE);\
-               NM_LOGI("%s[%s]", str, parameters_debug_str ? parameters_debug_str : "NULL");\
-               g_free(parameters_debug_str);\
-       } while (0)
-
-#define DEBUG_SIGNAL(sender_name, object_path, interface_name, signal_name, parameters)\
-       do {\
-               NM_LOGI("signal sender name [%s]", sender_name);\
-               NM_LOGI("signal object path [%s]", object_path);\
-               NM_LOGI("signal interface name [%s]", interface_name);\
-               NM_LOGI("signal signal name [%s]", signal_name);\
-               DEBUG_G_VARIANT("signal params ", parameters);\
-               NM_LOGI("signal params type [%s]", g_variant_get_type_string(parameters));\
-       } while (0)
-typedef enum {
-       NETWORK_SIGNAL_PROPERTIESCHANGED,
-       NETWORK_SIGNAL_MAX,
-} supplicant_network_signal_e;
-
-typedef struct {
-       gchar *path;
-       gboolean enable;
-       gboolean selected;
-       uint subscriber_id[NETWORK_SIGNAL_MAX];
-} supplicant_network_s;
-
-static method_param_s get_net_property_method_param = {
-               .bus_name = SUPPLICANT_SERVICE,
-               .object_path = NULL,
-               .interface_name = DBUS_PROPERTIES_INTERFACE,
-               .method_name = DBUS_PROPERTIES_METHOD_GETALL,
-               .parameters = NULL,
-};
-
-static void inline __get_network_enabled(GVariant *value, supplicant_network_s *net)
-{
-       g_variant_get(value, "b", &(net->enable));
-
-       NM_LOGI("Network %s", (net->enable)?"Enabled":"Disabled");
-}
-
-static void inline __get_network_property(const gchar *key, GVariant *value, supplicant_network_s *net)
-{
-       __NM_FUNC_ENTER__;
-
-       if (g_strcmp0(key, "Enabled") == 0)
-               __get_network_enabled(value, net);
-
-       __NM_FUNC_EXIT__;
-}
-
-void __get_network_properties(GVariant *value, gpointer user_data)
-{
-       GVariantIter *iter = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-       supplicant_network_s *net = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (!value || !user_data) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       g_variant_get(value, "(a{sv})", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       net = (supplicant_network_s *)user_data;
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
-               __get_network_property(key, var, net);
-
-       g_variant_iter_free(iter);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline int __init_net(const gchar *path, supplicant_network_s *net)
-{
-       gchar *key = NULL;
-
-       __NM_FUNC_ENTER__;
-
-       key = g_strdup(path);
-       if (!key) {
-               NM_LOGI("Error! Failed to get key");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       if (net->path)
-               g_free(net->path);
-       net->path = key;
-
-       return 0;
-}
-
-int nm_supplicant_network_add(const gchar *path, GVariantIter *iter, gpointer *network)
-{
-       supplicant_network_s *net = NULL;
-       const gchar *key = NULL;
-       GVariant *var = NULL;
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!path || !iter || !network) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       net = (supplicant_network_s *)g_try_malloc0(sizeof(supplicant_network_s));
-       if (!net) {
-               NM_LOGI("Error! Failed to allocate net");
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       if (__init_net(path, net) < 0) {
-               NM_LOGI("Error! Failed to init net");
-               g_free(net);
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
-               __get_network_property(key, var, net);
-
-       *network = net;
-       __NM_FUNC_EXIT__;
-       return ret;
-
-}
-
-static inline void __dbus_get_net_properties(const gchar *path, supplicant_network_s *net)
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       get_net_property_method_param.object_path = path;
-       get_net_property_method_param.parameters = g_variant_new("(s)",
-                       SUPPLICANT_IFACE_NETWORK);
-
-       ret = nm_gdbus_method_call(&get_net_property_method_param,
-                       __get_network_properties,
-                       (gpointer)net);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get property all failure");
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-int nm_supplicant_network_add_by_path(const gchar *path, gpointer *network)
-{
-       supplicant_network_s *net = NULL;
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-
-       if (!path) {
-               NM_LOGI("NULL obj");
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       net = (supplicant_network_s *)g_try_malloc0(sizeof(supplicant_network_s));
-       if (!net) {
-               NM_LOGI("Error! Failed to allocate net");
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       if (__init_net(path, net) < 0) {
-               __NM_FUNC_EXIT__;
-               g_free(net);
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       __dbus_get_net_properties(path, net);
-
-       *network = net;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_supplicant_network_remove(const gchar *path, gpointer network)
-{
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-
-       if (!path || !network) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       nm_supplicant_network_destroy(network);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_supplicant_network_select(const gchar *path, gpointer network)
-{
-       supplicant_network_s *net = NULL;
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-
-       if (!path || !network) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       net = (supplicant_network_s *)network;
-       net->selected = TRUE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-
-}
-
-void nm_supplicant_network_destroy(gpointer data)
-{
-       supplicant_network_s *network = NULL;
-       __NM_FUNC_ENTER__;
-
-
-       if (!data) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-       network = (supplicant_network_s *)data;
-
-       g_free(network->path);
-       g_free(network);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
diff --git a/src/nm-supplicant-p2p.c b/src/nm-supplicant-p2p.c
deleted file mode 100644 (file)
index 1912189..0000000
+++ /dev/null
@@ -1,786 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling signal from WPA Supplicant P2P interface.
- *
- * @file        nm-supplicant-p2p.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-supplicant.h"
-#include "nm-supplicant-internal.h"
-
-#define DEVICE_NAME_LEN 32
-#define MAC_ADDR_LEN 6
-
-#define SUPPLICANT_P2P_SIGNAL_DEVICE_FOUND             "DeviceFound"
-#define SUPPLICANT_P2P_SIGNAL_DEVICE_LOST              "DeviceLost"
-#define SUPPLICANT_P2P_SIGNAL_PD_REQ_DISPLAY   "ProvisionDiscoveryRequestDisplayPin"
-#define SUPPLICANT_P2P_SIGNAL_PD_RESP_DISPLAY  "ProvisionDiscoveryResponseDisplayPin"
-#define SUPPLICANT_P2P_SIGNAL_PD_REQ_KEYPAD            "ProvisionDiscoveryRequestEnterPin"
-#define SUPPLICANT_P2P_SIGNAL_PD_RESP_KEYPAD   "ProvisionDiscoveryResponseEnterPin"
-#define SUPPLICANT_P2P_SIGNAL_PD_REQ_PBC               "ProvisionDiscoveryPBCRequest"
-#define SUPPLICANT_P2P_SIGNAL_PD_RESP_PBC              "ProvisionDiscoveryPBCResponse"
-#define SUPPLICANT_P2P_SIGNAL_PD_FAILURE               "ProvisionDiscoveryFailure"
-#define SUPPLICANT_P2P_SIGNAL_GROUP_STARTED            "GroupStarted"
-#define SUPPLICANT_P2P_SIGNAL_GO_NEG_SUCCESS   "GONegotiationSuccess"
-#define SUPPLICANT_P2P_SIGNAL_GO_NEG_FAILURE   "GONegotiationFailure"
-#define SUPPLICANT_P2P_SIGNAL_GO_NEG_REQ               "GONegotiationRequest"
-#define SUPPLICANT_P2P_SIGNAL_INVITE_REUSLT            "InvitationResult"
-#define SUPPLICANT_P2P_SIGNAL_GROUP_FINISHED   "GroupFinished"
-#define SUPPLICANT_P2P_SIGNAL_WPS_FAILED               "WpsFailed"
-#define SUPPLICANT_P2P_SIGNAL_INVITATION_RECEIVED              "InvitationReceived"
-#define SUPPLICANT_P2P_SIGNAL_GROUP_FORMATION_FAILURE          "GroupFormationFailure"
-
-typedef enum {
-       P2P_SIGNAL_DEVICE_FOUND,
-       P2P_SIGNAL_DEVICE_LOST,
-       P2P_SIGNAL_PD_REQ_DISPLAY,
-       P2P_SIGNAL_PD_RESP_DISPLAY,
-       P2P_SIGNAL_PD_REQ_KEYPAD,
-       P2P_SIGNAL_PD_RESP_KEYPAD,
-       P2P_SIGNAL_PD_REQ_PBC,
-       P2P_SIGNAL_PD_RESP_PBC,
-       P2P_SIGNAL_PD_FAILURE,
-       P2P_SIGNAL_GROUP_STRARTED,
-       P2P_SIGNAL_GO_NEG_SUCCESS,
-       P2P_SIGNAL_GO_NEG_FAILURE,
-       P2P_SIGNAL_GO_NEG_REQ,
-       P2P_SIGNAL_INVITE_RESULT,
-       P2P_SIGNAL_GROUP_FINISHED,
-       P2P_SIGNAL_WPS_FAILED,
-       P2P_SIGNAL_INVITE_RECEIVED,
-       P2P_SIGNAL_GROUP_FORMATION_FAILURE,
-       P2P_SIGNAL_MAX,
-} p2p_signal_e;
-
-typedef struct {
-       gchar device_name[DEVICE_NAME_LEN];
-       gint level;
-       guchar device_cap;
-       guchar group_cap;
-       gchar dev_addr[MAC_ADDR_LEN];
-       gint state;
-} supplicant_p2p_peer_s;
-
-typedef struct {
-
-} supplicant_p2p_group_s;
-
-typedef struct {
-       gchar device_name[DEVICE_NAME_LEN];
-       guint go_intent;
-       gboolean persistent_reconnect;
-       guint listen_reg_class;
-       guint listen_channel;
-       guint op_reg_class;
-       guint op_channel;
-
-       /*
-        * List of BSSs known to the interface
-        */
-       GHashTable *peers;
-       supplicant_p2p_group_s *group;
-       guint role;
-       guint subscriber_id[P2P_SIGNAL_MAX];
-} supplicant_p2p_s;
-
-typedef void (*handle_p2p_device_signal_properties) (
-               gchar *key,
-               GVariant *value,
-               supplicant_p2p_s *p2p);
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_device_found);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_device_lost);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_display);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_display);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_keypad);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_keypad);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_pbc);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_pbc);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_started);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_neg_success);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_go_neg_failure);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_go_neg_req);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_invite_result);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_finished);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_wps_failed);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_invitation_receivced);
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_formation_failure);
-
-static signal_param_s p2p_signal_params[] = {
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_DEVICE_FOUND,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_device_found,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_DEVICE_LOST,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_device_lost,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_PD_REQ_DISPLAY,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_pd_req_display,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_PD_RESP_DISPLAY,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_pd_resp_display,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_PD_REQ_KEYPAD,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_pd_req_keypad,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_PD_RESP_KEYPAD,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_device_found,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_PD_REQ_PBC,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_pd_resp_keypad,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_PD_RESP_PBC,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_pd_req_pbc,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_PD_FAILURE,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_pd_resp_pbc,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_GROUP_STARTED,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_group_started,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_GO_NEG_SUCCESS,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_neg_success,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_GO_NEG_FAILURE,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_go_neg_failure,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_GO_NEG_REQ,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_go_neg_req,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_INVITE_REUSLT,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_invite_result,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_GROUP_FINISHED,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_group_finished,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_WPS_FAILED,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_wps_failed,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_INVITATION_RECEIVED,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_invitation_receivced,
-                       .subscriber_id  = 0,
-               },
-               {
-                       .sender = SUPPLICANT_SERVICE,
-                       .interface_name = SUPPLICANT_IFACE_P2P,
-                       .member = SUPPLICANT_P2P_SIGNAL_GROUP_FORMATION_FAILURE,
-                       .object_path = NULL,
-                       .arg0 = NULL,
-                       .callback_with_data = __p2p_group_formation_failure,
-                       .subscriber_id  = 0,
-               },
-};
-
-/*
-static method_param_s get_p2p_property_method_param = {
-               .bus_name = SUPPLICANT_SERVICE,
-               .object_path = NULL,
-               .interface_name = DBUS_PROPERTIES_INTERFACE,
-               .method_name = DBUS_PROPERTIES_METHOD_GETALL,
-               .parameters = NULL,
-};
-
-static inline void __get_peer_property(gchar *key, GVariant *value, supplicant_p2p_peer_s *peer)
-{
-
-}
-
-static inline void __get_peer_properties(GVariant *param, supplicant_p2p_peer_s *peer)
-{
-       GVariantIter *iter = NULL;
-       gchar *key = NULL;
-       GVariant *value = NULL;
-
-       g_variant_get(param, "(a{sv})", &iter);
-       if (!iter)
-               return;
-       while (g_variant_iter_loop (iter, "{sv}", &key, &value))
-               __get_peer_property(key, value, peer);
-
-       g_variant_iter_free(iter);
-
-       return;
-}
-*/
-
-static void __supplicant_peer_destroy(gpointer data)
-{
-       supplicant_p2p_peer_s *peer = NULL;
-
-       if (!data)
-               return;
-
-       peer = (supplicant_p2p_peer_s *)data;
-
-       g_free(peer);
-}
-
-static inline supplicant_p2p_peer_s * __get_peer(const char *path, gpointer user_data)
-{
-       supplicant_p2p_s *p2p_data = NULL;
-       if (!path || !user_data)
-               return NULL;
-
-       p2p_data = (supplicant_p2p_s *)user_data;
-
-       return g_hash_table_lookup(p2p_data->peers, path);
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_device_found)
-{
-       __NM_FUNC_ENTER__;
-       supplicant_p2p_s *p2p_data = NULL;
-       supplicant_p2p_peer_s *peer = NULL;
-       const char *path = NULL;
-
-       g_variant_get(parameters, "(&o)", &path);
-       if (!path)
-               return;
-
-       p2p_data = (supplicant_p2p_s *)user_data;
-       if (!user_data)
-               return;
-
-       peer = g_try_malloc0(sizeof(supplicant_p2p_peer_s));
-       if (!peer)
-               return;
-
-       g_hash_table_replace(p2p_data->peers, g_strdup(path), peer);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_device_lost)
-{
-       __NM_FUNC_ENTER__;
-       supplicant_p2p_s *p2p_data = NULL;
-       const char *path = NULL;
-
-       g_variant_get(parameters, "(&o)", &path);
-       if (!path)
-               return;
-
-       p2p_data = (supplicant_p2p_s *)user_data;
-       if (!user_data)
-               return;
-
-       g_hash_table_remove(p2p_data->peers, path);
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_display)
-{
-       __NM_FUNC_ENTER__;
-       supplicant_p2p_peer_s *peer = NULL;
-       const char *path = NULL;
-       const char *pin;
-
-       g_variant_get(parameters, "(&o&s)", &path, &pin);
-       peer = __get_peer(path, user_data);
-       if (!peer)
-               return;
-
-       peer->state = P2P_PEER_STATE_PD;
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_display)
-{
-       __NM_FUNC_ENTER__;
-       supplicant_p2p_peer_s *peer = NULL;
-       const char *path = NULL;
-       const char *pin;
-
-       g_variant_get(parameters, "(&o&s)", &path, &pin);
-       peer = __get_peer(path, user_data);
-       if (!peer)
-               return;
-
-       peer->state = P2P_PEER_STATE_PD;
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_keypad)
-{
-       __NM_FUNC_ENTER__;
-       supplicant_p2p_peer_s *peer = NULL;
-       const char *path = NULL;
-
-       g_variant_get(parameters, "(&o)", &path);
-       peer = __get_peer(path, user_data);
-       if (!peer)
-               return;
-
-       peer->state = P2P_PEER_STATE_PD;
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_keypad)
-{
-       __NM_FUNC_ENTER__;
-       supplicant_p2p_peer_s *peer = NULL;
-       const char *path = NULL;
-
-       g_variant_get(parameters, "(&o)", &path);
-       peer = __get_peer(path, user_data);
-       if (!peer)
-               return;
-
-       peer->state = P2P_PEER_STATE_PD;
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_req_pbc)
-{
-       __NM_FUNC_ENTER__;
-       supplicant_p2p_peer_s *peer = NULL;
-       const char *path = NULL;
-
-       g_variant_get(parameters, "(&o)", &path);
-       peer = __get_peer(path, user_data);
-       if (!peer)
-               return;
-
-       peer->state = P2P_PEER_STATE_PD;
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_pd_resp_pbc)
-{
-       __NM_FUNC_ENTER__;
-       supplicant_p2p_peer_s *peer = NULL;
-       const char *path = NULL;
-
-       g_variant_get(parameters, "(&o)", &path);
-       peer = __get_peer(path, user_data);
-       if (!peer)
-               return;
-
-       peer->state = P2P_PEER_STATE_PD;
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-
-static inline void __handle_p2p_device_event_variant(
-               handle_p2p_device_signal_properties handler,
-               GVariant *param,
-               gpointer user_data
-               )
-{
-       GVariantIter *iter = NULL;
-       gchar *key = NULL;
-       GVariant *value = NULL;
-
-       g_variant_get(param, "(a{sv})", &iter);
-       if (!iter)
-               return;
-
-       while (g_variant_iter_loop(iter, "{sv}", &key, &value))
-               handler(key, value, (supplicant_p2p_s *)user_data);
-
-       g_variant_iter_free(iter);
-
-       return;
-}
-
-static inline void __get_group_started_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
-{
-
-}
-
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_started)
-{
-       __NM_FUNC_ENTER__;
-
-       __handle_p2p_device_event_variant(
-                       __get_group_started_property,
-                       user_data,
-                       parameters);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline void __get_go_neg_success_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
-{
-
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_neg_success)
-{
-       __NM_FUNC_ENTER__;
-
-       __handle_p2p_device_event_variant(
-                       __get_go_neg_success_property,
-                       user_data,
-                       parameters);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline void __get_go_neg_fail_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
-{
-
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_go_neg_failure)
-{
-       __NM_FUNC_ENTER__;
-
-       __handle_p2p_device_event_variant(
-                       __get_go_neg_fail_property,
-                       user_data,
-                       parameters);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_go_neg_req)
-{
-       __NM_FUNC_ENTER__;
-       supplicant_p2p_peer_s *peer = NULL;
-       const char *path = NULL;
-       guint16 dev_passwd_id = 0;
-       guchar go_intent = 0;
-
-       g_variant_get(parameters, "(&oqy)", &path, &dev_passwd_id, &go_intent);
-       peer = __get_peer(path, user_data);
-       if (!peer)
-               return;
-
-       peer->state = P2P_PEER_STATE_GO_NEG;
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_invite_result)
-{
-       __NM_FUNC_ENTER__;
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline void __get_group_finished_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
-{
-
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_finished)
-{
-       __NM_FUNC_ENTER__;
-
-       __handle_p2p_device_event_variant(
-                       __get_group_finished_property,
-                       user_data,
-                       parameters);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline void __get_wps_failed_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
-{
-
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_wps_failed)
-{
-       __NM_FUNC_ENTER__;
-
-       __handle_p2p_device_event_variant(
-                       __get_wps_failed_property,
-                       user_data,
-                       parameters);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-
-static inline void __get_invitation_received_property(gchar *key, GVariant *value, supplicant_p2p_s *p2p)
-{
-
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_invitation_receivced)
-{
-       __NM_FUNC_ENTER__;
-
-       __handle_p2p_device_event_variant(
-                       __get_invitation_received_property,
-                       user_data,
-                       parameters);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static DECLARE_DBUS_SIGNAL_HANDLER_W_DATA(p2p_group_formation_failure)
-{
-       __NM_FUNC_ENTER__;
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline int __subscribe_p2p_signal(const gchar *path, supplicant_p2p_s *data)
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-       int signal_idx = 0;
-       __NM_FUNC_ENTER__;
-
-       if (!path || !data) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       NM_LOGI("path [%s]", path);
-       for (signal_idx = P2P_SIGNAL_DEVICE_FOUND; signal_idx < P2P_SIGNAL_MAX; signal_idx++) {
-               p2p_signal_params[signal_idx].object_path = path;
-               ret = nm_gdbus_subscribe_signal_with_data(&(p2p_signal_params[signal_idx]), data);
-               if (ret != NM_GDBUS_ERROR_NONE)
-                       NM_LOGI("Error! Failed to subscribe signal");
-               else
-                       data->subscriber_id[signal_idx] =
-                                       p2p_signal_params[signal_idx].subscriber_id;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_SUPPLICANT_ERROR_NONE;
-}
-
-static inline int __unsubscribe_p2p_signal(supplicant_p2p_s *data)
-{
-       int signal_idx = 0;
-       int ret = NM_GDBUS_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!data) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       for (signal_idx = P2P_SIGNAL_DEVICE_FOUND; signal_idx < P2P_SIGNAL_MAX; signal_idx++) {
-
-               if (data->subscriber_id[signal_idx] == 0)
-                       continue;
-
-               p2p_signal_params[signal_idx].subscriber_id = data->subscriber_id[signal_idx];
-               ret = nm_gdbus_unsubscribe_signal(&(p2p_signal_params[signal_idx]));
-               if (ret != NM_GDBUS_ERROR_NONE)
-                       NM_LOGI("Error! Failed to unsubscribe signal");
-               else
-                       data->subscriber_id[signal_idx] = 0;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_SUPPLICANT_ERROR_NONE;
-}
-
-int nm_supplicant_p2p_init(const gchar *path, gpointer *p2p)
-{
-       supplicant_p2p_s *p2p_data = NULL;
-       gint ret = 0;
-       __NM_FUNC_ENTER__;
-
-       if (!path || !p2p) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       p2p_data = (supplicant_p2p_s *)g_try_malloc0(sizeof(supplicant_p2p_s));
-       if (!p2p_data) {
-               NM_LOGI("Error! Failed to allocate net");
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_OPERATION_FAILED;
-       }
-
-       p2p_data->peers = g_hash_table_new_full(g_str_hash,
-                       g_str_equal,
-                       g_free,
-                       __supplicant_peer_destroy
-                       );
-
-       if (!p2p_data->peers) {
-               NM_LOGI("Error! Failed to allocate bss tbl");
-               g_free(p2p_data);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-
-       ret = __subscribe_p2p_signal(path, p2p_data);
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               g_hash_table_destroy(p2p_data->peers);
-               g_free(p2p_data);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       *p2p = p2p_data;
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_supplicant_p2p_deinit(gpointer p2p)
-{
-       supplicant_p2p_s *p2p_data = NULL;
-       gint ret = 0;
-       __NM_FUNC_ENTER__;
-
-       if (!p2p) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       p2p_data = (supplicant_p2p_s *)p2p;
-       ret = __unsubscribe_p2p_signal(p2p_data);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("__unsubscribe_p2p_signal failed");
-
-       g_hash_table_destroy(p2p_data->peers);
-
-       g_free(p2p);
-       __NM_FUNC_EXIT__;
-       return 0;
-}
diff --git a/src/nm-supplicant-wps.c b/src/nm-supplicant-wps.c
deleted file mode 100644 (file)
index 9a0d385..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling signal from WPA Supplicant WPS interface.
- *
- * @file        nm-supplicant-wps.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-
-#include "nm-daemon-log.h"
-#include "nm-supplicant.h"
-#include "nm-supplicant-internal.h"
-
-void nm_supplicant_wps_handle_event_signal(const gchar *event, GVariantIter *iter)
-{
-       __NM_FUNC_ENTER__;
-
-       if (!event || ! iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-
-}
-
-void nm_supplicant_wps_handle_event_credentials(GVariant *credentials)
-{
-       __NM_FUNC_ENTER__;
-
-       if (!credentials) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       __NM_FUNC_EXIT__;
-       return;
-
-
-}
diff --git a/src/nm-supplicant.c b/src/nm-supplicant.c
deleted file mode 100644 (file)
index 9cc037c..0000000
+++ /dev/null
@@ -1,534 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling signal from WPA Supplicant.
- *
- * @file        nm-supplicant.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-supplicant.h"
-#include "nm-supplicant-internal.h"
-
-#define SUPPPLICANT_SIGNAL_IFACE_ADDED         "InterfaceAdded"
-#define SUPPPLICANT_SIGNAL_IFACE_REMOVED               "InterfaceRemoved"
-
-#define WFDIE_SUBELEM_LEN_DEV_INFO 6
-
-typedef enum {
-       SIGNAL_IFACE_ADDED,
-       SIGNAL_IFACE_REMOVED,
-       SIGNAL_PROP_CHANGED,
-       SIGNAL_NAME_OWNER_CHANGED,
-       SIGNAL_MAX,
-
-} supplicant_signal_e;
-
-typedef struct {
-       gboolean is_initialized;
-       guint eap_methods;
-       guint capabilities;
-       guchar ies[WFDIE_SUBELEM_LEN_DEV_INFO + 3];
-
-} supplicant_mon_s;
-
-supplicant_mon_s supplicant_mon;
-
-void __iface_added(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-void __iface_removed(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-void __supplicant_properties_changed(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-static void __name_owner_changed_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-static signal_param_s signal_param[] = {
-               {
-                               .sender = SUPPLICANT_SERVICE,
-                               .interface_name = SUPPLICANT_INTERFACE,
-                               .member = SUPPPLICANT_SIGNAL_IFACE_ADDED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __iface_added,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = SUPPLICANT_SERVICE,
-                               .interface_name = SUPPLICANT_INTERFACE,
-                               .member = SUPPPLICANT_SIGNAL_IFACE_REMOVED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __iface_removed,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = SUPPLICANT_SERVICE,
-                               .interface_name = SUPPLICANT_INTERFACE,
-                               .member = DBUS_SIGNAL_PROPERTIES_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = NULL,
-                               .callback = __supplicant_properties_changed,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = DBUS_SERVICE_DBUS,
-                               .interface_name = DBUS_INTERFACE_DBUS,
-                               .member = DBUS_SIGNAL_NAME_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = SUPPLICANT_SERVICE,
-                               .callback = __name_owner_changed_cb,
-                               .subscriber_id  = 0,
-               },
-};
-
-static method_param_s get_supplicant_property_method_param = {
-               .bus_name = SUPPLICANT_SERVICE,
-               .object_path = SUPPLICANT_PATH,
-               .interface_name = DBUS_PROPERTIES_INTERFACE,
-               .method_name = DBUS_PROPERTIES_METHOD_GETALL,
-               .parameters = NULL,
-};
-
-static gboolean __unpack_ays(unsigned char *dst, GVariant *src, int size)
-{
-       GVariantIter *iter = NULL;
-       int length = 0;
-       int res = FALSE;
-
-       if (!dst || !src || size == 0) {
-               NM_LOGI("Invalid parameter");
-               return FALSE;
-       }
-
-       g_variant_get(src, "ay", &iter);
-       if (iter == NULL) {
-               NM_LOGI("failed to get iterator");
-               return FALSE;
-       }
-
-       while (g_variant_iter_loop(iter, "y", &dst[length])) {
-               length++;
-               if (length >= size)
-                       break;
-       }
-       g_variant_iter_free(iter);
-
-       if (length < size) {
-               NM_LOGI("array is shorter than size");
-               res = FALSE;
-       }
-
-       return res;
-}
-
-static void __name_owner_changed_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       gchar *name = NULL;
-       gchar *old = NULL;
-       gchar *new = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (parameters == NULL)
-               return;
-
-       g_variant_get(parameters, "(&s&s&s)", &name, &old, &new);
-
-       if (g_strcmp0(name, SUPPLICANT_SERVICE) == 0 && *new == '\0')
-               NM_LOGI("Supplicant destroyed: name %s, old %s, new %s", name, old, new);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline void __get_supplicant_interface(GVariant *value)
-{
-       GVariantIter *iter = NULL;
-       const gchar *obj = NULL;
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(value, "ao", &iter);
-
-       while (g_variant_iter_loop(iter, "o", &obj))
-               nm_supplicant_iface_add_by_path(obj);
-
-       g_variant_iter_free(iter);
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __get_supplicant_eap_method(GVariant *value, supplicant_mon_s *supp)
-{
-       GVariantIter *iter = NULL;
-       const gchar *method = NULL;
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(value, "as", &iter);
-
-       supp->eap_methods = EAP_METHOD_UNKNOWN;
-       while (g_variant_iter_loop(iter, "s", &method)) {
-               /* Check Type of DNS Address */
-               if (g_strcmp0(method, "MD5") == 0)
-                       supp->eap_methods |= CAPABILITY_AP;
-               else if (g_strcmp0(method, "TLS") == 0)
-                       supp->eap_methods |= EAP_METHOD_TLS;
-               else if (g_strcmp0(method, "MSCHAPV2") == 0)
-                       supp->eap_methods |= EAP_METHOD_MSCHPV2;
-               else if (g_strcmp0(method, "PEAP") == 0)
-                       supp->eap_methods |= EAP_METHOD_PEAP;
-               else if (g_strcmp0(method, "TTLS") == 0)
-                       supp->eap_methods |= EAP_METHOD_TTLS;
-               else if (g_strcmp0(method, "GTC") == 0)
-                       supp->eap_methods |= EAP_METHOD_GTC;
-               else if (g_strcmp0(method, "OTP") == 0)
-                       supp->eap_methods |= EAP_METHOD_OTP;
-               else if (g_strcmp0(method, "LEAP") == 0)
-                       supp->eap_methods |= EAP_METHOD_LEAP;
-               else if (g_strcmp0(method, "WSC") == 0)
-                       supp->eap_methods |= EAP_METHOD_WSC;
-       }
-       g_variant_iter_free(iter);
-       __NM_FUNC_EXIT__;
-}
-
-static inline void __get_supplicant_capability(GVariant *value, supplicant_mon_s *supp)
-{
-       GVariantIter *iter = NULL;
-       const gchar *cap = NULL;
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(value, "as", &iter);
-
-       supp->capabilities = CAPABILITY_UNKNOWN;
-       while (g_variant_iter_loop(iter, "s", &cap)) {
-               /* Check Type of DNS Address */
-               if (g_strcmp0(cap, "ap") == 0)
-                       supp->capabilities |= CAPABILITY_AP;
-               else if (g_strcmp0(cap, "ibss-rsn") == 0)
-                       supp->capabilities |= CAPABILITY_IBSS_RSN ;
-               else if (g_strcmp0(cap, "p2p") == 0)
-                       supp->capabilities |= CAPABILITY_P2P ;
-               else if (g_strcmp0(cap, "interworking") == 0)
-                       supp->capabilities |= CAPABILITY_INTERWORKING  ;
-       }
-       g_variant_iter_free(iter);
-       __NM_FUNC_EXIT__;
-}
-
-void __get_supplicant_property(gchar *key, GVariant *value, supplicant_mon_s *supp)
-{
-       __NM_FUNC_ENTER__;
-
-       if (g_strcmp0(key, "Interfaces") == 0)
-               __get_supplicant_interface(value);
-       else if (g_strcmp0(key, "EapMethods") == 0)
-               __get_supplicant_eap_method(value, supp);
-       else if (g_strcmp0(key, "Capabilities") == 0)
-               __get_supplicant_capability(value, supp);
-       else if (g_strcmp0(key, "WFDIEs") == 0)
-               if (__unpack_ays(supp->ies, value, WFDIE_SUBELEM_LEN_DEV_INFO + 3)) {
-                       NM_LOGI("WFDIEs valid");
-       }
-
-       __NM_FUNC_EXIT__;
-}
-
-void __get_supplicant_properties(GVariant *value, void *user_data)
-{
-       GVariantIter *iter = NULL;
-       gchar *key = NULL;
-       GVariant *var = NULL;
-       supplicant_mon_s *supp = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (!value || !user_data) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       g_variant_get(value, "(a{sv})", &iter);
-       if (!iter) {
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       supp = (supplicant_mon_s *)user_data;
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var))
-               __get_supplicant_property(key, var, supp);
-
-       g_variant_iter_free(iter);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-void __iface_added(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       const gchar *path = NULL;
-       GVariantIter *iter = NULL;
-
-       g_variant_get(parameters, "(oa{sv})", &path, &iter);
-
-       if (path && iter)
-               nm_supplicant_iface_add(path, iter);
-       else
-               NM_LOGI("NULL path or variants");
-
-       g_variant_iter_free(iter);
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-void __iface_removed(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-       const gchar *path = NULL;
-
-       g_variant_get(parameters, "(o)", &path);
-       if (path)
-               nm_supplicant_iface_remove(path);
-       else
-               NM_LOGI("NULL path");
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-void __supplicant_properties_changed(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       if (parameters)
-               __get_supplicant_properties(parameters, &supplicant_mon);
-
-       __NM_FUNC_EXIT__;
-}
-
-
-int nm_supplicant_get_properties()
-{
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       get_supplicant_property_method_param.parameters = g_variant_new("(s)",
-                       SUPPLICANT_INTERFACE);
-
-       ret = nm_gdbus_method_call(&get_supplicant_property_method_param,
-                       __get_supplicant_properties,
-                       (gpointer)&supplicant_mon);
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_METHOD_CALL_FAILED;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_SUPPLICANT_ERROR_NONE;
-}
-
-int nm_supplicant_get_eap_methods(unsigned int *eap_methods)
-{
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!supplicant_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
-       }
-
-       if (!eap_methods) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       *eap_methods = supplicant_mon.eap_methods;
-
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_supplicant_get_capabilities(unsigned int *capabilities)
-{
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!supplicant_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
-       }
-
-       if (!capabilities) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       *capabilities = supplicant_mon.capabilities;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_supplicant_get_wfd_ies(unsigned char *ies, unsigned int *length)
-{
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!supplicant_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
-       }
-
-       if (!ies || !length) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_INVALID_PARAM;
-       }
-
-       memcpy(ies, supplicant_mon.ies, WFDIE_SUBELEM_LEN_DEV_INFO + 3);
-       *length = WFDIE_SUBELEM_LEN_DEV_INFO + 3;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-int nm_supplicant_init()
-{
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       memset(&supplicant_mon, 0x00, sizeof(supplicant_mon));
-       supplicant_mon.is_initialized = TRUE;
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[SIGNAL_IFACE_ADDED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[SIGNAL_IFACE_REMOVED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[SIGNAL_PROP_CHANGED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[SIGNAL_NAME_OWNER_CHANGED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_supplicant_iface_init();
-       if (ret != NM_SUPPLICANT_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_SUPPLICANT_ERROR_NONE;
-}
-
-int nm_supplicant_deinit()
-{
-       int ret = NM_SUPPLICANT_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       if (!supplicant_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_NOT_INITIALIZED;
-       }
-
-       ret = nm_supplicant_iface_deinit();
-       if (ret != NM_SUPPLICANT_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       nm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_IFACE_ADDED]));
-       nm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_IFACE_REMOVED]));
-       nm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_PROP_CHANGED]));
-       nm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_NAME_OWNER_CHANGED]));
-
-       memset(&supplicant_mon, 0x00, sizeof(supplicant_mon));
-       supplicant_mon.is_initialized = FALSE;
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
diff --git a/src/nm-telephony.c b/src/nm-telephony.c
deleted file mode 100644 (file)
index a99ea24..0000000
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions to get information from telephony module.
- *
- * @file        nm-telephony.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-telephony.h"
-
-#define TELEPHONY_SERVICE                              "com.tcore.ps"
-#define TELEPHONY_MASTER_PATH                  "/"
-#define TELEPHONY_MASTER_INTERFACE             TELEPHONY_SERVICE ".master"
-#define TELEPHONY_MODEM_INTERFACE              TELEPHONY_SERVICE ".modem"
-#define TELEPHONY_NETWORK_INTERFACE            TELEPHONY_SERVICE ".network"
-#define TELEPHONY_PROFILE_INTERFACE            TELEPHONY_SERVICE ".context"
-
-enum {
-       TELEPHONY_CMD_GET_MODEMS,
-       TELEPHONY_CMD_GET_PROFILE_LIST,
-       TELEPHONY_CMD_GET_PROFILE,
-};
-
-/**
- * Below structure is used to export profile name
- */
-typedef struct
-{
-       /** Profile name */
-       gchar profile_name[NM_PROFILE_NAME_LEN_MAX + 1];
-} nm_profile_name_s;
-
-static method_param_s tel_method_params[] = {
-               {
-                               .bus_name = TELEPHONY_SERVICE,
-                               .object_path = TELEPHONY_MASTER_PATH,
-                               .interface_name = TELEPHONY_MASTER_INTERFACE,
-                               .method_name = "GetModems",
-                               .parameters = NULL,
-               },
-               {
-                               .bus_name = TELEPHONY_SERVICE,
-                               .object_path = NULL,
-                               .interface_name = TELEPHONY_MODEM_INTERFACE,
-                               .method_name = "GetProfileList",
-                               .parameters = NULL,
-               },
-               {
-                               .bus_name = TELEPHONY_SERVICE,
-                               .object_path = NULL,
-                               .interface_name = TELEPHONY_PROFILE_INTERFACE,
-                               .method_name = "GetProfile",
-                               .parameters = NULL,
-               },
-};
-
-static void __get_modem_properties(GVariant *reply, gpointer user_data)
-{
-       GVariantIter *iter = NULL;
-       GVariantIter *modem_properties = NULL;
-       GSList **modem_path_list;
-       const char *modem_path;
-       __NM_FUNC_ENTER__;
-
-       if (!reply || !user_data)
-               return;
-
-       modem_path_list = (GSList **)user_data;
-
-       g_variant_get(reply, "(a{sa{ss}})", &iter);
-       while (g_variant_iter_loop(iter, "{sa{ss}}", &modem_path, &modem_properties)) {
-               *modem_path_list = g_slist_append(*modem_path_list, g_strdup(modem_path));
-               NM_LOGI("modem object path: %s", modem_path);
-       }
-
-       g_variant_iter_free(iter);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static int __get_modem_object_path(GSList **modem_path_list)
-{
-
-       int ret = 0;
-       __NM_FUNC_ENTER__;
-
-       ret = nm_gdbus_method_call(
-                       &(tel_method_params[TELEPHONY_CMD_GET_MODEMS]),
-                       __get_modem_properties,
-                       (gpointer)modem_path_list);
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               NM_LOGI("Failed to get modem paths");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-static void __get_profiles(GVariant *reply, gpointer user_data)
-{
-       GVariantIter *iter = NULL;
-       const char *str = NULL;
-       GSList **profiles = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (!reply || !user_data)
-               return;
-
-       profiles = (GSList **)user_data;
-
-       g_variant_get(reply, "(as)", &iter);
-       while (g_variant_iter_loop(iter, "s", &str))
-               *profiles = g_slist_append(*profiles, g_strdup(str));
-
-       g_variant_iter_free(iter);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static GSList *__get_profile_list()
-{
-       GSList *profile_list = NULL, *list = NULL;
-       GSList *modem_path_list = NULL;
-       const char *path = NULL;
-       int ret = 0;
-
-       __NM_FUNC_ENTER__;
-
-       ret = __get_modem_object_path(&modem_path_list);
-       if (ret < 0) {
-               NM_LOGI("Failed to get modems path list");
-
-               g_slist_free_full(modem_path_list, g_free);
-               __NM_FUNC_EXIT__;
-               return NULL;
-       }
-
-       for (list = modem_path_list; list != NULL; list = list->next) {
-               path = (const char *)list->data;
-
-               NM_LOGI("path: %s", path);
-               tel_method_params[TELEPHONY_CMD_GET_PROFILE_LIST].object_path = path;
-               ret = nm_gdbus_method_call(
-                               &(tel_method_params[TELEPHONY_CMD_GET_PROFILE_LIST]),
-                               __get_profiles,
-                               (gpointer)&profile_list);
-               if (ret != NM_GDBUS_ERROR_NONE) {
-                       NM_LOGI("Failed to get profiles: %s", path);
-                       continue;
-               }
-       }
-
-       g_slist_free_full(modem_path_list, g_free);
-       __NM_FUNC_EXIT__;
-       return profile_list;
-}
-
-static int __get_profile_names(nm_profile_name_s **profile_names,
-               int *profile_cnt)
-{
-
-       int ret = 0;
-       int count = 0, i = 0;
-       GSList *profile_list = NULL, *list = NULL;
-       nm_profile_name_s *p_profile_name = NULL;
-
-       profile_list = __get_profile_list();
-       count = g_slist_length(profile_list);
-       NM_LOGI("[%d] profile found", count);
-       if (count > 0) {
-               p_profile_name = (nm_profile_name_s*)malloc(sizeof(nm_profile_name_s) * count);
-               ret = 0;
-       } else {
-               *profile_cnt = 0;
-               goto out;
-       }
-
-       if (p_profile_name == NULL) {
-               NM_LOGI("Failed to allocate memory");
-               *profile_cnt = 0;
-               ret = -1;
-               goto out;
-       }
-
-       for (list = profile_list, i = 0; list != NULL; list = list->next, i++)
-               g_strlcpy(p_profile_name[i].profile_name,
-                               (const char *)list->data, NM_PROFILE_NAME_LEN_MAX);
-
-       *profile_names = p_profile_name;
-       *profile_cnt = count;
-
-out:
-       g_slist_free_full(profile_list, g_free);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-static int __find_matching_profile(char *profile_name, nm_profile_name_s *profile_list, int profile_cnt)
-{
-       gchar *connman_profile_name = NULL;
-       gchar *telephony_profile_name = NULL;
-       gchar *str_ptr = NULL;
-       int i = 0;
-
-       NM_LOGI("search connman profile name[%s] from %d list",
-                       profile_name, profile_cnt);
-       connman_profile_name = strrchr(profile_name, '/') + 1;
-       for (i = 0; i < profile_cnt; i++) {
-               telephony_profile_name = strrchr(profile_list[i].profile_name, '/') + 1;
-               str_ptr = strstr(connman_profile_name, telephony_profile_name);
-
-               if (str_ptr != NULL && g_strcmp0(str_ptr, telephony_profile_name) == 0) {
-
-                       NM_LOGI("PDP profile name found in cellular profile: %s, %d",
-                                       telephony_profile_name, i);
-                       break;
-               } else {
-                       NM_LOGI("[%s] not matched", telephony_profile_name);
-               }
-       }
-
-       return i;
-}
-
-static int __search_pdp_profile(char* profile_name, nm_telephony_profile_s *profile_info)
-{
-
-       int ret = 0;
-       nm_profile_name_s *profile_list = NULL;
-       int profile_cnt = 0;
-       int idx = 0;
-
-       __NM_FUNC_ENTER__;
-
-       /* Get pdp profile list from telephony service */
-       ret = __get_profile_names(&profile_list, &profile_cnt);
-       if (ret < 0) {
-               NM_LOGI("Failed to get profile list from telephony service");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       if (profile_list == NULL || profile_cnt <= 0) {
-               NM_LOGI("There is no PDP profiles");
-               g_free(profile_list);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       /* Find matching profile */
-       idx = __find_matching_profile(profile_name, profile_list, profile_cnt);
-       if (idx >= profile_cnt) {
-               NM_LOGI("There is no matching PDP profiles");
-               ret = -1;;
-       } else {
-               g_strlcpy(profile_info->profile_name,
-                               profile_list[idx].profile_name, NM_PROFILE_NAME_LEN_MAX);
-       }
-
-       g_free(profile_list);
-
-       __NM_FUNC_EXIT__;
-       return ret;
-}
-
-static inline void __get_path(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       if (value != NULL)
-               g_strlcpy(profile_info->profile_name, value, NM_PROFILE_NAME_LEN_MAX);
-}
-
-static inline void __get_svc_ctg_id(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       net_service_type_e service_type = NET_SERVICE_UNKNOWN;
-
-       if (value != NULL)
-               service_type = atoi(value);
-
-       if (service_type > NET_SERVICE_UNKNOWN)
-               profile_info->service_type = service_type;
-}
-
-static inline void __get_apn(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       if (value != NULL)
-               g_strlcpy(profile_info->apn, value, NM_PDP_APN_LEN_MAX);
-}
-
-static inline void __get_pdp_protocol(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       net_pdn_type_e pdn_type = NET_PDN_TYPE_UNKNOWN;
-
-       if (value != NULL)
-               pdn_type = atoi(value);
-
-       if (pdn_type == NET_PDN_TYPE_IPV4)
-               profile_info->pdn_type = NET_PDN_TYPE_IPV4;
-       else if (pdn_type == NET_PDN_TYPE_IPV6)
-               profile_info->pdn_type = NET_PDN_TYPE_IPV6;
-       else if (pdn_type == NET_PDN_TYPE_IPV4_IPV6)
-               profile_info->pdn_type = NET_PDN_TYPE_IPV4_IPV6;
-}
-
-static inline void __get_auth_type(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       net_auth_type_e auth_type = NET_PDP_AUTH_NONE;
-
-       if (value != NULL)
-               auth_type = atoi(value);
-
-       if (auth_type == NET_PDP_AUTH_PAP)
-               profile_info->auth_info.auth_type = NET_PDP_AUTH_PAP;
-       else if (auth_type == NET_PDP_AUTH_CHAP)
-               profile_info->auth_info.auth_type = NET_PDP_AUTH_CHAP;
-}
-
-static inline void __get_user_name(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       if (value != NULL)
-               g_strlcpy(profile_info->auth_info.user_name, value, NM_PDP_AUTH_USERNAME_LEN_MAX);
-
-}
-
-static inline void __get_password(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       if (value != NULL)
-               g_strlcpy(profile_info->auth_info.password, value, NM_PDP_AUTH_PASSWORD_LEN_MAX);
-}
-
-static inline void __get_proxy_addr(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       if (value != NULL)
-               g_strlcpy(profile_info->proxy_addr, value, NET_PROXY_LEN_MAX);
-}
-
-static inline void __get_home_url(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       if (value != NULL)
-               g_strlcpy(profile_info->home_url, value, NM_HOME_URL_LEN_MAX);
-}
-
-static inline void __get_default_conn(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       if (value == NULL)
-               return;
-
-       if (g_strcmp0(value, "TRUE") == 0)
-               profile_info->default_conn = TRUE;
-       else
-               profile_info->default_conn = FALSE;
-}
-
-static inline void __get_keyword(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       if (value != NULL)
-               g_strlcpy(profile_info->keyword, value, NM_PDP_APN_LEN_MAX);
-}
-
-static inline void __get_editable(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       if (value == NULL)
-               return;
-
-       if (g_strcmp0(value, "TRUE") == 0)
-               profile_info->editable = TRUE;
-       else
-               profile_info->editable = FALSE;
-
-       return;
-}
-
-static inline void __get_hidden(const gchar *value, nm_telephony_profile_s *profile_info)
-{
-       if (value == NULL)
-               return;
-
-       if (g_strcmp0(value, "TRUE") == 0)
-               profile_info->hidden = TRUE;
-       else
-               profile_info->hidden = FALSE;
-
-       return;
-}
-
-static void __get_profile_properties(GVariant *reply, gpointer user_data)
-{
-       GVariantIter *iter;
-       nm_telephony_profile_s *profile_info = NULL;
-       const gchar *key = NULL;
-       const gchar *value = NULL;
-
-       if (!reply || ! user_data)
-               return;
-
-       profile_info = (nm_telephony_profile_s *)user_data;
-
-       g_variant_get(reply, "(a{ss})", &iter);
-       while (g_variant_iter_loop(iter, "{ss}", &key, &value)) {
-               if (g_strcmp0(key, "path") == 0)
-                       __get_path(value, profile_info);
-               else if (g_strcmp0(key, "svc_ctg_id") == 0)
-                       __get_svc_ctg_id(value, profile_info);
-               else if (g_strcmp0(key, "apn") == 0)
-                       __get_apn(value, profile_info);
-               else if (g_strcmp0(key, "pdp_protocol") == 0)
-                       __get_pdp_protocol(value, profile_info);
-               else if (g_strcmp0(key, "roam_pdp_protocol") == 0)
-                       __get_auth_type(value, profile_info);
-               else if (g_strcmp0(key, "auth_type") == 0)
-                       __get_auth_type(value, profile_info);
-               else if (g_strcmp0(key, "auth_id") == 0)
-                       __get_user_name(value, profile_info);
-               else if (g_strcmp0(key, "auth_pwd") == 0)
-                       __get_password(value, profile_info);
-               else if (g_strcmp0(key, "proxy_addr") == 0)
-                       __get_proxy_addr(value, profile_info);
-               else if (g_strcmp0(key, "home_url") == 0)
-                       __get_home_url(value, profile_info);
-               else if (g_strcmp0(key, "default_internet_conn") == 0)
-                       __get_default_conn(value, profile_info);
-               else if (g_strcmp0(key, "profile_name") == 0)
-                       __get_keyword(value, profile_info);
-               else if (g_strcmp0(key, "editable") == 0)
-                       __get_editable(value, profile_info);
-               else if (g_strcmp0(key, "hidden") == 0)
-                       __get_hidden(value, profile_info);
-       }
-
-       g_variant_iter_free(iter);
-       return;
-}
-
-static int __get_profile_info(nm_telephony_profile_s *profile_info)
-{
-       int ret = 0;
-       __NM_FUNC_ENTER__;
-
-       if (profile_info == NULL) {
-               NM_LOGI("Invalid parameter!");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       tel_method_params[TELEPHONY_CMD_GET_PROFILE].object_path = profile_info->profile_name;
-       ret = nm_gdbus_method_call(
-                       &(tel_method_params[TELEPHONY_CMD_GET_PROFILE]),
-                       __get_profile_properties,
-                       (gpointer)profile_info);
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               NM_LOGI("Failed to get profile");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
-
-int nm_telephony_get_pdp_profile(gchar *path, nm_telephony_profile_s *profile_info)
-{
-       int ret = 0;
-       __NM_FUNC_ENTER__;
-
-       ret = __search_pdp_profile(path, profile_info);
-       if (ret < 0 || strlen(profile_info->profile_name) <= 0)
-               return -1;
-
-       /* Get profile info from telephony service */
-       ret = __get_profile_info(profile_info);
-       if (ret < 0)
-               return -1;
-
-       __NM_FUNC_EXIT__;
-       return 0;
-}
diff --git a/src/nm-util.c b/src/nm-util.c
deleted file mode 100644 (file)
index eae00aa..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements utility functions used by network monitoring daemon.
- *
- * @file        nm-util.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <signal.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#include "nm-util.h"
-#include "nm-daemon-log.h"
-
-int nm_execute_file(const char *file_path,
-               char *const args[], char *const envs[])
-{
-       pid_t pid = 0;
-       int status = 0;
-       int rv = 0;
-       errno = 0;
-       register unsigned int index = 0;
-       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
-
-       __NM_FUNC_ENTER__;
-
-       while (args[index] != NULL) {
-               NM_LOGI("%s", args[index]);
-               index++;
-       }
-
-       if (!(pid = fork())) {
-               NM_LOGI("pid(%d), ppid (%d)", getpid(), getppid());
-               NM_LOGI("Inside child, exec (%s) command", file_path);
-
-               errno = 0;
-               if (execve(file_path, args, envs) == -1) {
-                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-                       NM_LOGI("Fail to execute command (%s)", error_buf);
-                       exit(1);
-               }
-       } else if (pid > 0) {
-               if (waitpid(pid, &status, 0) == -1)
-                       NM_LOGI("wait pid (%u) status (%d)", pid, status);
-
-               if (WIFEXITED(status)) {
-                       rv = WEXITSTATUS(status);
-                       NM_LOGI("exited, status=%d", rv);
-               } else if (WIFSIGNALED(status)) {
-                       NM_LOGI("killed by signal %d", WTERMSIG(status));
-               } else if (WIFSTOPPED(status)) {
-                       NM_LOGI("stopped by signal %d", WSTOPSIG(status));
-               } else if (WIFCONTINUED(status)) {
-                       NM_LOGI("continued");
-               }
-
-               __NM_FUNC_EXIT__;
-               return rv;
-       }
-
-       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-       NM_LOGI("failed to fork(%s)", error_buf);
-       __NM_FUNC_EXIT__;
-       return -EIO;
-}
-
-static void __no_wait_signal_handler()
-{
-       pid_t child_pid = 0;
-       int state = 0;
-
-       child_pid = waitpid(-1, &state, WNOHANG);
-
-       NM_LOGI("child_id(%d) state(%d)", child_pid, WEXITSTATUS(state));
-}
-
-int nm_execute_file_no_wait(const char *file_path, char *const args[])
-{
-       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
-       pid_t pid = 0;
-       int rv = 0;
-       errno = 0;
-       register unsigned int index = 0;
-
-       struct sigaction act;
-       int state = 0;
-
-       __NM_FUNC_ENTER__;
-
-       act.sa_handler = __no_wait_signal_handler;
-       sigemptyset(&act.sa_mask);
-       act.sa_flags = 0;
-
-       state = sigaction(SIGCHLD, &act, 0);
-       if (state != 0) {
-               NM_LOGI("sigaction() : %d");
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       while (args[index] != NULL) {
-               NM_LOGI("%s", args[index]);
-               index++;
-       }
-
-       if (!(pid = fork())) {
-               NM_LOGI("pid(%d), ppid (%d)", getpid(), getppid());
-               NM_LOGI("Inside child, exec (%s) command", file_path);
-
-               errno = 0;
-               if (execvp(file_path, args) == -1) {
-                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-                       NM_LOGI("Fail to execute command (%s)", error_buf);
-                       __NM_FUNC_EXIT__;
-                       return -1;
-               }
-       } else if (pid > 0) {
-               NM_LOGI("Successfully launched child process");
-               __NM_FUNC_EXIT__;
-               return rv;
-       }
-
-       __NM_FUNC_EXIT__;
-       return -EIO;
-}
-
-void get_current_time(gchar *time_str)
-{
-       struct timeval mytime;
-       struct tm stTempTime;
-
-       if (!time_str)
-               return;
-
-
-       struct tm {
-               int tm_sec; // Seconds
-               int tm_min; // Minutes
-               int tm_hour; // Hour (0--23)
-               int tm_mday; // Day of month (1--31)
-               int tm_mon; // Month (0--11)
-               int tm_year; // Year (calendar year minus 1900)
-               int tm_wday; // Weekday (0--6; Sunday = 0)
-               int tm_yday; // Day of year (0--365)
-               int tm_isdst; // 0 if daylight savings time is not in effect)
-       };
-
-       gettimeofday(&mytime, NULL);
-       localtime_r(&mytime.tv_sec, &stTempTime);
-       g_snprintf(time_str, TIME_STR_LEN, "%04d.%02d.%02d-%02d_%02d_%02d",
-                       stTempTime.tm_year + 1900, stTempTime.tm_mon + 1, stTempTime.tm_mday,
-                       stTempTime.tm_hour, stTempTime.tm_min, stTempTime.tm_sec);
-       time_str[TIME_STR_LEN - 1] = '\0';
-
-       return;
-}
-
-int nm_check_cable_status(const char *file_path, int *status)
-{
-       int ret = 0;
-       int carrier = 0;
-       FILE *fd = NULL;
-       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0,};
-
-       __NM_FUNC_ENTER__;
-       ret = access(file_path, F_OK);
-       if (ret < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               NM_LOGI("Could not access %s [%s]", file_path, error_buf);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       fd = fopen(file_path, "r");
-       if (fd == NULL) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               NM_LOGI("Could not open %s [%s]", file_path, error_buf);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       ret = fscanf(fd, "%d", &carrier);
-       if (ret < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               NM_LOGI("Could not scan [%s]", error_buf);
-               fclose(fd);
-               __NM_FUNC_EXIT__;
-               return -1;
-       }
-
-       NM_LOGI("carrier state is [%d]", carrier);
-       *status = carrier;
-       fclose(fd);
-       __NM_FUNC_EXIT__;
-       return 0;
-
-}
-
-int nmdaemon_get_interface_index(const char *interface_name)
-{
-       struct ifreq ifr;
-       int sock = 0;
-       int result = 0;
-       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
-
-       if (interface_name == NULL) {
-               NM_LOGE("Inteface name is NULL");
-               return -1;
-       }
-
-       errno = 0;
-       sock = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
-       if (sock < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               NM_LOGE("Failed to create socket : %s", error_buf);
-               return -1;
-       }
-
-       memset(&ifr, 0, sizeof(ifr));
-       strncpy(ifr.ifr_name, interface_name, sizeof(ifr.ifr_name) - 1);
-       result = ioctl(sock, SIOCGIFINDEX, &ifr);
-       close(sock);
-
-       if (result < 0) {
-               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
-               NM_LOGE("Failed to get ifr index: %s", error_buf);
-               return -1;
-       }
-
-       return ifr.ifr_ifindex;
-}
-
-void nmdaemon_convert_byte_to_string(char *bssid, unsigned char *user_data)
-{
-       int i;
-
-       for (i = 0; i < MAC_ADDR_LEN; i++) {
-               if (i == 0) {
-                       snprintf(bssid, 3, "%02x", user_data[i]);
-                       bssid += 2;
-               } else {
-                       snprintf(bssid, 4, ":%02x", user_data[i]);
-                       bssid += 3;
-               }
-       }
-}
-
-gchar* nm_util_get_default_proxy()
-{
-       char *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
-       gchar *ret = NULL;
-
-       if (proxy) {
-               ret = g_strdup(proxy);
-               free(proxy);
-       }
-       return ret;
-}
diff --git a/src/nm-wfd-manager.c b/src/nm-wfd-manager.c
deleted file mode 100644 (file)
index ff92389..0000000
+++ /dev/null
@@ -1,1068 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements functions for handling signal from Wi-Fi Direct manager.
- *
- * @file        nm-wfd-manager.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-
-#include "nm-daemon-log.h"
-#include "nm-gdbus.h"
-#include "nm-wfd-manager.h"
-
-#define WFD_EVENT_CONNECTION_RSP 3
-
-#define DEVICE_NAME_LEN 32
-#define MAC_ADDR_LEN 6
-#define MAC_STR_LEN 18
-#define IP_ADDR_LEN 4
-
-#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
-#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
-
-#define WFD_SIGNAL_ACTIVATION          "Activation"
-#define WFD_SIGNAL_DEACTIVATION                "Deactivation"
-#define WFD_SIGNAL_CREATED                     "Created"
-#define WFD_SIGNAL_DESTROYED           "Destroyed"
-#define WFD_SIGNAL_CONNECTION          "Connection"
-#define WFD_SIGNAL_PEERIPASSIGNED      "PeerIPAssigned"
-#define WFD_SIGNAL_DISCONNECTION       "Disconnection"
-
-#define WFD_METHOD_GET_GO_INTENT       "GetGoIntent"
-#define WFD_METHOD_GET_MAX_CLIENT      "GetMaxClient"
-#define WFD_METHOD_GET_REQ_WPS_MODE    "GetReqWpsMode"
-#define WFD_METHOD_GET_MAC_ADDR                "GetMacAddress"
-#define WFD_METHOD_GET_DEVICE_NAME     "GetDeviceName"
-
-#define WFD_METHOD_GET_IP_ADDR         "GetIPAddress"
-#define WFD_METHOD_GET_SUBNET_MASK     "GetSubnetMask"
-#define WFD_METHOD_GET_GATEWAY         "GetGateway"
-#define WFD_METHOD_GET_OP_CHANNEL      "GetOperatingChannel"
-#define WFD_METHOD_IS_GROUP_OWNER      "IsGroupOwner"
-#define WFD_METHOD_GET_CONNECTED       "GetConnectedPeers"
-
-typedef enum {
-       WFD_SIGNAL_NAME_OWENER_CHANGED,
-       WFD_MANAGE_SIGNAL_ACTIVATION,
-       WFD_MANAGE_SIGNAL_DEACTIVATION,
-       WFD_MANAGE_SIGNAL_GROUP_CREATED,
-       WFD_MANAGE_SIGNAL_GROUP_DESTROYED,
-       WFD_MANAGE_SIGNAL_CONNECTION,
-       WFD_MANAGE_SIGNAL_PEERIPASSIGNED,
-       WFD_MANAGE_SIGNAL_DISCONNECTION,
-       WFD_MANAGE_SIGNAL_MAX,
-} wfd_manager_signal_e;
-
-typedef struct {
-       gchar device_name[DEVICE_NAME_LEN + 1];
-       guchar mac_addr[MAC_ADDR_LEN];
-       guchar intf_addr[MAC_ADDR_LEN];
-       guchar ip_addr[IP_ADDR_LEN];
-} wfd_peer_s;
-
-typedef struct {
-       gboolean is_initialized;
-       gboolean activated;
-       guint device_role;
-       gint go_intent;
-       gint max_client;
-       gint op_channel;
-       gint req_wps_mode;
-       gchar device_name[DEVICE_NAME_LEN + 1];
-       guchar mac_addr[MAC_ADDR_LEN];
-
-       gchar group_iface_name[DEVICE_NAME_LEN + 1];
-       guchar ip_addr[IP_ADDR_LEN];
-       guchar subnet_mask[IP_ADDR_LEN];
-       guchar gateway_addr[IP_ADDR_LEN];
-
-       GHashTable *connected_peer;
-
-} wfd_manager_mon_s;
-
-wfd_manager_mon_s wfd_manager_mon;
-
-static void __name_owner_changed_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-static void __activation_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-static void __deactivation_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-static void __group_created_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-static void __group_destroyed_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-static void __connection_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-static void __peer_ip_assigned_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-static void __disconnection_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data);
-
-static signal_param_s signal_param[] = {
-               {
-                               .sender = DBUS_SERVICE_DBUS,
-                               .interface_name = DBUS_INTERFACE_DBUS,
-                               .member = DBUS_SIGNAL_NAME_CHANGED,
-                               .object_path = NULL,
-                               .arg0 = WFD_MANAGER_SERVICE,
-                               .callback = __name_owner_changed_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = WFD_MANAGER_SERVICE,
-                               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
-                               .member = WFD_SIGNAL_ACTIVATION,
-                               .object_path = WFD_MANAGER_PATH,
-                               .arg0 = NULL,
-                               .callback = __activation_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = WFD_MANAGER_SERVICE,
-                               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
-                               .member = WFD_SIGNAL_DEACTIVATION,
-                               .object_path = WFD_MANAGER_PATH,
-                               .arg0 = NULL,
-                               .callback = __deactivation_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = WFD_MANAGER_SERVICE,
-                               .interface_name = WFD_MANAGER_GROUP_INTERFACE,
-                               .member = WFD_SIGNAL_CREATED,
-                               .object_path = WFD_MANAGER_PATH,
-                               .arg0 = NULL,
-                               .callback = __group_created_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = WFD_MANAGER_SERVICE,
-                               .interface_name = WFD_MANAGER_GROUP_INTERFACE,
-                               .member = WFD_SIGNAL_DESTROYED,
-                               .object_path = WFD_MANAGER_PATH,
-                               .arg0 = NULL,
-                               .callback = __group_destroyed_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = WFD_MANAGER_SERVICE,
-                               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
-                               .member = WFD_SIGNAL_CONNECTION,
-                               .object_path = WFD_MANAGER_PATH,
-                               .arg0 = NULL,
-                               .callback = __connection_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = WFD_MANAGER_SERVICE,
-                               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
-                               .member = WFD_SIGNAL_PEERIPASSIGNED,
-                               .object_path = WFD_MANAGER_PATH,
-                               .arg0 = NULL,
-                               .callback = __peer_ip_assigned_cb,
-                               .subscriber_id  = 0,
-               },
-               {
-                               .sender = WFD_MANAGER_SERVICE,
-                               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
-                               .member = WFD_SIGNAL_DISCONNECTION,
-                               .object_path = WFD_MANAGER_PATH,
-                               .arg0 = NULL,
-                               .callback = __disconnection_cb,
-                               .subscriber_id  = 0,
-               },
-};
-
-static method_param_s get_manager_conf_param = {
-               .bus_name = WFD_MANAGER_SERVICE,
-               .object_path = WFD_MANAGER_PATH,
-               .interface_name = WFD_MANAGER_CONFIG_INTERFACE,
-               .method_name = NULL,
-               .parameters = NULL,
-};
-
-static method_param_s get_manager_group_param = {
-               .bus_name = WFD_MANAGER_SERVICE,
-               .object_path = WFD_MANAGER_PATH,
-               .interface_name = WFD_MANAGER_GROUP_INTERFACE,
-               .method_name = NULL,
-               .parameters = NULL,
-};
-
-static method_param_s get_manager_manage_param = {
-               .bus_name = WFD_MANAGER_SERVICE,
-               .object_path = WFD_MANAGER_PATH,
-               .interface_name = WFD_MANAGER_MANAGE_INTERFACE,
-               .method_name = NULL,
-               .parameters = NULL,
-};
-
-static gint __txt_to_mac(const gchar *txt, guchar *mac)
-{
-       int i = 0;
-
-       if (!txt || !mac) {
-               NM_LOGI("Invalid parameter");
-               return -1;
-       }
-
-       for (;;) {
-               mac[i++] = (char) strtoul((char *)txt, (char **)&txt, 16);
-               if (!*txt++ || i == 6)
-                       break;
-       }
-
-       if (i != MAC_ADDR_LEN)
-               return -1;
-
-       return 0;
-}
-
-static gint __txt_to_ip(const gchar *txt, guchar *ip)
-{
-       int i = 0;
-
-       for (;;) {
-               ip[i++] = (char) strtoul((char *)txt, (char **)&txt, 10);
-               if (i == IP_ADDR_LEN || !*txt++)
-                       break;
-       }
-
-       if (i != IP_ADDR_LEN)
-               return -1;
-
-       return 0;
-}
-
-static gboolean __unpack_ays(unsigned char *dst, GVariant *src, int size)
-{
-       GVariantIter *iter = NULL;
-       int length = 0;
-       int res = FALSE;
-
-       if (!dst || !src || size == 0) {
-               NM_LOGI("Invalid parameter");
-               return FALSE;
-       }
-
-       g_variant_get(src, "ay", &iter);
-       if (iter == NULL) {
-               NM_LOGI("failed to get iterator");
-               return FALSE;
-       }
-
-       while (g_variant_iter_loop(iter, "y", &dst[length])) {
-               length++;
-               if (length >= size)
-                       break;
-       }
-       g_variant_iter_free(iter);
-
-       return res;
-}
-
-static void __name_owner_changed_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       gchar *name = NULL;
-       gchar *old = NULL;
-       gchar *new = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (parameters == NULL)
-               return;
-
-       g_variant_get(parameters, "(&s&s&s)", &name, &old, &new);
-
-       if (g_strcmp0(name, WFD_MANAGER_SERVICE) == 0 && *new == '\0')
-               NM_LOGI("wfd-manager destroyed: name %s, old %s, new %s", name, old, new);
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __get_go_intent(GVariant *value, gpointer user_data)
-{
-       gint ret = 0;
-
-       if (!value || !user_data)
-               return;
-
-       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
-
-       g_variant_get(value, "(ii)", &ret, &(manager->go_intent));
-
-       return;
-}
-
-static inline void __get_wfd_manager_go_intent()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-
-       get_manager_conf_param.method_name = WFD_METHOD_GET_GO_INTENT;
-
-       ret = nm_gdbus_method_call(&get_manager_conf_param,
-                       __get_go_intent,
-                       (gpointer)&wfd_manager_mon);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get go intent failure");
-
-       return;
-}
-
-static void __get_max_client(GVariant *value, gpointer user_data)
-{
-       gint ret = 0;
-
-       if (!value || !user_data)
-               return;
-
-       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
-
-       g_variant_get(value, "(ii)", &ret, &(manager->max_client));
-
-       return;
-}
-
-static inline void __get_wfd_manager_max_client()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-
-       get_manager_conf_param.method_name = WFD_METHOD_GET_MAX_CLIENT;
-
-       ret = nm_gdbus_method_call(&get_manager_conf_param,
-                       __get_max_client,
-                       (gpointer)&wfd_manager_mon);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get max_client failure");
-
-       return;
-}
-
-static void __get_req_wps_mode(GVariant *value, gpointer user_data)
-{
-       gint ret = 0;
-
-       if (!value || !user_data)
-               return;
-
-       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
-
-       g_variant_get(value, "(ii)", &ret, &(manager->req_wps_mode));
-
-       return;
-}
-
-static inline void __get_wfd_manager_req_wps_mode()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-
-       get_manager_conf_param.method_name = WFD_METHOD_GET_REQ_WPS_MODE;
-
-       ret = nm_gdbus_method_call(&get_manager_conf_param,
-                       __get_req_wps_mode,
-                       (gpointer)&wfd_manager_mon);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get requested wps mode failure");
-
-       return;
-}
-
-static void __get_device_name(GVariant *value, gpointer user_data)
-{
-       gint ret = 0;
-       const gchar *str;
-
-       if (!value || !user_data)
-               return;
-
-       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
-
-       g_variant_get(value, "(i&s)", &ret, &str);
-
-       g_strlcpy(manager->device_name, str, DEVICE_NAME_LEN + 1);
-
-       return;
-}
-
-static inline void __get_wfd_manager_device_name()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-
-       get_manager_conf_param.method_name = WFD_METHOD_GET_DEVICE_NAME;
-
-       ret = nm_gdbus_method_call(&get_manager_conf_param,
-                       __get_device_name,
-                       (gpointer)&wfd_manager_mon);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get mac address failure");
-
-       return;
-}
-
-static void __get_mac_addr(GVariant *value, gpointer user_data)
-{
-       gint ret = 0;
-       const gchar *str;
-
-       if (!value || !user_data)
-               return;
-
-       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
-
-       g_variant_get(value, "(i&s)", &ret, &str);
-
-       __txt_to_mac(str, manager->mac_addr);
-
-       return;
-}
-
-static inline void __get_wfd_manager_mac_addr()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-
-       get_manager_conf_param.method_name = WFD_METHOD_GET_MAC_ADDR;
-
-       ret = nm_gdbus_method_call(&get_manager_conf_param,
-                       __get_mac_addr,
-                       (gpointer)&wfd_manager_mon);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get mac address failure");
-
-       return;
-}
-
-
-static void __get_op_channel(GVariant *value, gpointer user_data)
-{
-       gint ret = 0;
-
-       if (!value || !user_data)
-               return;
-
-       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
-
-       g_variant_get(value, "(ii)", &ret, &(manager->op_channel));
-
-       return;
-}
-
-static inline void __get_wfd_manager_op_channel()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-
-       get_manager_conf_param.method_name = WFD_METHOD_GET_OP_CHANNEL;
-
-       ret = nm_gdbus_method_call(&get_manager_conf_param,
-                       __get_op_channel,
-                       (gpointer)&wfd_manager_mon);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get op channel failure");
-
-       return;
-}
-
-static void __get_ip_addr(GVariant *value, gpointer user_data)
-{
-       gint ret = 0;
-       const gchar *str;
-
-       if (!value || !user_data)
-               return;
-
-       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
-
-       g_variant_get(value, "(i&s)", &ret, &str);
-
-       __txt_to_ip(str, manager->ip_addr);
-
-       return;
-}
-
-static inline void __get_wfd_manager_ip_addr()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-
-       get_manager_conf_param.method_name = WFD_METHOD_GET_IP_ADDR;
-
-       ret = nm_gdbus_method_call(&get_manager_conf_param,
-                       __get_ip_addr,
-                       (gpointer)&wfd_manager_mon);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get mac address failure");
-
-       return;
-}
-
-static void __get_subnet_mask(GVariant *value, gpointer user_data)
-{
-       gint ret = 0;
-       const gchar *str;
-
-       if (!value || !user_data)
-               return;
-
-       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
-
-       g_variant_get(value, "(i&s)", &ret, &str);
-
-       __txt_to_ip(str, manager->subnet_mask);
-
-       return;
-}
-
-static inline void __get_wfd_manager_subnet_mask()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-
-       get_manager_conf_param.method_name = WFD_METHOD_GET_SUBNET_MASK;
-
-       ret = nm_gdbus_method_call(&get_manager_conf_param,
-                       __get_subnet_mask,
-                       (gpointer)&wfd_manager_mon);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get mac address failure");
-
-       return;
-}
-
-static void __get_gateway(GVariant *value, gpointer user_data)
-{
-       gint ret = 0;
-       const gchar *str;
-
-       if (!value || !user_data)
-               return;
-
-       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
-
-       g_variant_get(value, "(i&s)", &ret, &str);
-
-       __txt_to_ip(str, manager->gateway_addr);
-
-       return;
-}
-
-static inline void __get_wfd_manager_gateway()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-
-       get_manager_conf_param.method_name = WFD_METHOD_GET_GATEWAY;
-
-       ret = nm_gdbus_method_call(&get_manager_conf_param,
-                       __get_gateway,
-                       (gpointer)&wfd_manager_mon);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get gateway address failure");
-
-       return;
-}
-
-static inline void __get_wfd_manager_group_info()
-{
-       __get_wfd_manager_ip_addr();
-       __get_wfd_manager_subnet_mask();
-       __get_wfd_manager_gateway();
-       __get_wfd_manager_op_channel();
-}
-
-static inline void __reset_wfd_manager_group_info()
-{
-       wfd_manager_mon.device_role = NM_WFD_DEVICE_NONE;
-       memset(wfd_manager_mon.ip_addr, 0x00, IP_ADDR_LEN);
-       memset(wfd_manager_mon.gateway_addr, 0x00, IP_ADDR_LEN);
-       memset(wfd_manager_mon.subnet_mask, 0x00, IP_ADDR_LEN);
-       wfd_manager_mon.op_channel = 0;
-}
-
-static inline void __clear_wfd_manager_info()
-{
-       if(wfd_manager_mon.connected_peer) {
-               g_hash_table_remove_all(wfd_manager_mon.connected_peer);
-               g_hash_table_unref(wfd_manager_mon.connected_peer);
-               wfd_manager_mon.connected_peer = NULL;
-       }
-
-       __reset_wfd_manager_group_info();
-
-       wfd_manager_mon.activated = FALSE;
-       memset(wfd_manager_mon.ip_addr, 0x00, IP_ADDR_LEN);
-       memset(wfd_manager_mon.gateway_addr, 0x00, IP_ADDR_LEN);
-       memset(wfd_manager_mon.subnet_mask, 0x00, IP_ADDR_LEN);
-       wfd_manager_mon.op_channel = 0;
-}
-
-static void __activation_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       wfd_manager_mon.activated = TRUE;
-       __get_wfd_manager_go_intent();
-       __get_wfd_manager_max_client();
-       __get_wfd_manager_req_wps_mode();
-       __get_wfd_manager_mac_addr();
-       __get_wfd_manager_device_name();
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __deactivation_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       __clear_wfd_manager_info();
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __group_created_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       wfd_manager_mon.device_role = NM_WFD_DEVICE_GO;
-       __get_wfd_manager_group_info();
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __group_destroyed_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       if(wfd_manager_mon.connected_peer) {
-               g_hash_table_remove_all(wfd_manager_mon.connected_peer);
-               g_hash_table_unref(wfd_manager_mon.connected_peer);
-               wfd_manager_mon.connected_peer = NULL;
-       }
-
-       __reset_wfd_manager_group_info();
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static void __is_group_owner(GVariant *value, gpointer user_data)
-{
-       gboolean is_group_owner;
-
-       if (!value || !user_data)
-               return;
-
-       wfd_manager_mon_s *manager = (wfd_manager_mon_s *)user_data;
-
-       g_variant_get(value, "(b)", &is_group_owner);
-       if (is_group_owner)
-               manager->device_role = NM_WFD_DEVICE_GO;
-       else
-               manager->device_role = NM_WFD_DEVICE_GC;
-
-       return;
-}
-
-static inline void __is_wfd_manager_group_owner()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-
-       get_manager_group_param.method_name = WFD_METHOD_IS_GROUP_OWNER;
-
-       ret = nm_gdbus_method_call(&get_manager_group_param,
-                       __is_group_owner,
-                       (gpointer)&wfd_manager_mon);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get device role failure");
-
-       return;
-}
-
-static inline void __get_peer_info(GVariantIter *iter, wfd_manager_mon_s *manager)
-{
-       GVariant *var = NULL;
-       gchar *key = NULL;
-       wfd_peer_s *peer;
-       __NM_FUNC_ENTER__;
-
-       gchar hash_key[MAC_STR_LEN] = {0, };
-
-       if (!iter) {
-               __NM_FUNC_ENTER__;
-               return;
-       }
-
-       peer = g_try_malloc0(sizeof(wfd_peer_s));
-       if (!peer) {
-               __NM_FUNC_ENTER__;
-               return;
-       }
-
-       while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
-               if (!g_strcmp0(key, "DeviceName")) {
-                       const char *str = NULL;
-                       g_variant_get(var, "&s", &str);
-                       g_strlcpy(peer->device_name, str, DEVICE_NAME_LEN);
-               } else if (!g_strcmp0(key, "DeviceAddress")) {
-                       __unpack_ays(peer->mac_addr, var, MAC_ADDR_LEN);
-               } else if (!g_strcmp0(key, "InterfaceAddress")) {
-                       __unpack_ays(peer->intf_addr, var, MAC_ADDR_LEN);
-               } else if (!g_strcmp0(key, "IPAddress")) {
-                       __unpack_ays(peer->ip_addr, var, IP_ADDR_LEN);
-               } else {
-                       ;/* Do Nothing */
-               }
-       }
-       g_snprintf(hash_key, MAC_STR_LEN, MACSTR, MAC2STR(peer->mac_addr));
-       g_hash_table_replace(manager->connected_peer, g_strdup(hash_key), peer);
-       NM_LOGI("Peer %s is added", hash_key);
-
-       return;
-}
-
-static void __get_connected_peers(GVariant *value, gpointer user_data)
-{
-       GVariantIter *iter_peers = NULL;
-       GVariantIter *iter_peer = NULL;
-       gint ret = 0;
-       __NM_FUNC_ENTER__;
-
-       if (!value) {
-               __NM_FUNC_ENTER__;
-               return;
-       }
-
-       g_variant_get(value, "(iaa{sv})", &ret, &iter_peers);
-       if (ret != 0) {
-               __NM_FUNC_ENTER__;
-               return;
-       }
-
-       while (g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
-               if (!wfd_manager_mon.connected_peer) {
-                       NM_LOGI("Create hash table for peers");
-                       wfd_manager_mon.connected_peer = g_hash_table_new_full(g_str_hash,
-                                       g_str_equal,
-                                       g_free,
-                                       g_free);
-               }
-
-               __get_peer_info(iter_peer, &wfd_manager_mon);
-       }
-
-
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-static inline void __get_wfd_manager_connected_peers()
-{
-       int ret = NM_GDBUS_ERROR_NONE;
-
-       get_manager_manage_param.method_name = WFD_METHOD_GET_CONNECTED;
-
-       ret = nm_gdbus_method_call(&get_manager_manage_param,
-                       __get_connected_peers,
-                       (gpointer)&wfd_manager_mon);
-       if (ret != NM_GDBUS_ERROR_NONE)
-               NM_LOGI("get connected failure");
-
-       return;
-}
-
-static inline gboolean __is_connected(GVariant *parameters)
-{
-       gint error_code;
-       gint connection_state;
-       gchar *peer_mac_address;
-
-       g_variant_get(parameters, "(ii&s)",
-                       &error_code, &connection_state, &peer_mac_address);
-
-       return error_code == 0 &&
-                       connection_state == WFD_EVENT_CONNECTION_RSP &&
-                       peer_mac_address;
-
-}
-
-static void __connection_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       __NM_FUNC_ENTER__;
-
-       if (!__is_connected(parameters)) {
-               __NM_FUNC_ENTER__;
-               return;
-       }
-
-       __get_wfd_manager_group_info();
-       __is_wfd_manager_group_owner();
-       __get_wfd_manager_connected_peers();
-
-       __NM_FUNC_EXIT__;
-       return;
-
-}
-
-static void __peer_ip_assigned_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       wfd_peer_s *peer;
-       gchar *peer_mac = NULL;
-       gchar *peer_ip = NULL;
-       __NM_FUNC_ENTER__;
-
-       if (!wfd_manager_mon.connected_peer) {
-               NM_LOGI("Wired, there's no connected");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       g_variant_get(parameters, "(&s&s)", &peer_mac, &peer_ip);
-       if (!peer_mac || !peer_ip) {
-               NM_LOGI("Invalied parameters");
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       peer = g_hash_table_lookup(wfd_manager_mon.connected_peer, peer_mac);
-       if (!peer) {
-               NM_LOGI("Peer %s not matched", peer_mac);
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       __txt_to_ip(peer_ip, peer->ip_addr);
-       __NM_FUNC_EXIT__;
-
-}
-
-static void __disconnection_cb(
-               const gchar *sender_name,
-        const gchar *object_path,
-        const gchar *interface_name,
-        const gchar *signal_name,
-        GVariant *parameters,
-        gpointer user_data)
-{
-       gint ret = 0;
-       gint state = 0;
-       gchar *peer_mac = NULL;
-       __NM_FUNC_ENTER__;
-
-       g_variant_get(parameters, "(ii&s)", &ret, &state, &peer_mac);
-       if(!g_hash_table_remove(wfd_manager_mon.connected_peer, peer_mac)) {
-               NM_LOGI("there's no peer [%s]", peer_mac);
-               __NM_FUNC_EXIT__;
-               return;
-       }
-
-       __is_wfd_manager_group_owner();
-       if (wfd_manager_mon.device_role != NM_WFD_DEVICE_GO) {
-
-               if (wfd_manager_mon.connected_peer) {
-                       g_hash_table_remove_all(wfd_manager_mon.connected_peer);
-                       g_hash_table_unref(wfd_manager_mon.connected_peer);
-                       wfd_manager_mon.connected_peer = NULL;
-               }
-               __reset_wfd_manager_group_info();
-       }
-       __NM_FUNC_EXIT__;
-       return;
-}
-
-int nm_wfd_manager_init()
-{
-       int ret = NM_WFD_ERROR_NONE;
-       __NM_FUNC_ENTER__;
-
-       memset(&wfd_manager_mon, 0x00, sizeof(wfd_manager_mon));
-       wfd_manager_mon.is_initialized = TRUE;
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_SIGNAL_NAME_OWENER_CHANGED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_ACTIVATION]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_DEACTIVATION]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_GROUP_CREATED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_GROUP_DESTROYED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_CONNECTION]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_PEERIPASSIGNED]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       ret = nm_gdbus_subscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_DISCONNECTION]));
-       if (ret != NM_GDBUS_ERROR_NONE) {
-               __NM_FUNC_EXIT__;
-               return NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED;
-       }
-
-       __NM_FUNC_EXIT__;
-       return NM_WFD_ERROR_NONE;
-}
-
-int nm_wfd_manager_deinit()
-{
-       __NM_FUNC_ENTER__;
-
-       if (!wfd_manager_mon.is_initialized) {
-               __NM_FUNC_EXIT__;
-               return NM_WFD_ERROR_NOT_INITIALIZED;
-       }
-       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_SIGNAL_NAME_OWENER_CHANGED]));
-       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_ACTIVATION]));
-       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_DEACTIVATION]));
-       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_GROUP_CREATED]));
-       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_GROUP_DESTROYED]));
-       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_CONNECTION]));
-       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_PEERIPASSIGNED]));
-       nm_gdbus_unsubscribe_signal(&(signal_param[WFD_MANAGE_SIGNAL_DISCONNECTION]));
-
-       __clear_wfd_manager_info();
-
-       __NM_FUNC_EXIT__;
-       return NM_WFD_ERROR_NONE;
-}
-
diff --git a/src/nm-wfdmanager.c b/src/nm-wfdmanager.c
deleted file mode 100644 (file)
index e69de29..0000000
index 88975c710e9370bbe59ed75ebd576a937fb6a340..b8e00ababcfd5ee9f1db4379083f31f5eaaceab4 100644 (file)
@@ -22,9 +22,9 @@ LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 
 FILE(GLOB TEST_APP_SRCS *.cpp ${CMAKE_SOURCE_DIR}/src/*.c)
-LIST(REMOVE_ITEM TEST_APP_SRCS ${CMAKE_SOURCE_DIR}/src/nm-daemon-main.c)
+LIST(REMOVE_ITEM TEST_APP_SRCS ${CMAKE_SOURCE_DIR}/src/inm-daemon-main.c)
 
-SET(TEST_APP_SRCS ${TEST_APP_SRCS} nm-test.c)
+SET(TEST_APP_SRCS ${TEST_APP_SRCS} inm-test.c)
 
 INCLUDE(FindPkgConfig)
 PKG_CHECK_MODULES(test_app_pkgs REQUIRED dlog glib-2.0 gio-2.0 vconf libnl-2.0)
diff --git a/test/inm-test.c b/test/inm-test.c
new file mode 100644 (file)
index 0000000..d130346
--- /dev/null
@@ -0,0 +1,1402 @@
+/*
+ * Network Monitoring Module
+ *
+ * Copyright (c) 2018 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.
+ *
+ */
+
+/**
+ * This file implements application for testing network monitoring functions.
+ *
+ * @file        nm-test.c
+ * @author      Jiung Yu (jiung.yu@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#include <assert.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "inm-daemon-log.h"
+#include "inm-daemon.h"
+#include "inm-ip-conflict.h"
+#include "inm-iface-mon.h"
+#include "inm-statistics.h"
+#include "inm-dump.h"
+#include "inm-gdbus.h"
+#include "inm-connman.h"
+#include "inm-supplicant.h"
+#include "inm-wfd-manager.h"
+#include "inm-mobileap.h"
+
+#define RESET_COLOR "\e[m"
+#define MAKE_RED "\e[31m"
+#define MAKE_GREEN "\e[32m"
+
+enum {
+       CMD_QUIT,
+       CMD_FULL_MENU,
+       CMD_IP_CONFLICT_INIT,
+       CMD_IP_CONFLICT_DEINIT,
+       CMD_IP_CONFLICT_GET_DETECTION_PERIOD,
+       CMD_IP_CONFLICT_SET_DETECTION_PERIOD,
+       CMD_IP_CONFLICT_GET_STATE,
+       CMD_IP_CONFLICT_IS_DETECTION_ENABLED,
+       CMD_IP_CONFLICT_ENABLE_DETECTION,
+       CMD_IP_CONFLICT_SET_CB,
+       CMD_IP_CONFLICT_UNSET_CB,
+       CMD_DUMP_INIT,
+       CMD_DUMP_DEINIT,
+       CMD_DUMP_START_TCPDUMP,
+       CMD_DUMP_STOP_TCPDUMP,
+       CMD_DUMP_GET_TCPDUMP_STATE,
+       CMD_DUMP_LOG,
+       CMD_DUMP_CHECK_STATE_AND_START,
+       CMD_IFACE_MON_INIT,
+       CMD_IFACE_MON_DEINIT,
+       CMD_IFACE_MON_START,
+       CMD_IFACE_MON_STOP,
+       CMD_IFACE_MON_GET_STATE,
+
+       CMD_GDBUS_INIT,
+       CMD_GDBUS_DEINIT,
+
+       CMD_CONNMAN_INIT,
+       CMD_CONNMAN_DEINIT,
+       CMD_CONNMAN_MGR_GET_PROPERTIES,
+       CMD_CONNMAN_MGR_GET_SERVICES,
+       CMD_CONNMAN_MGR_GET_TECHNOLOGIES,
+
+       CMD_SUPPLICANT_INIT,
+       CMD_SUPPLICANT_DEINIT,
+       CMD_SUPPLICANT_GET_PROPERTIES,
+
+       CMD_WFD_MANAGER_INIT,
+       CMD_WFD_MANAGER_DEINIT,
+
+       CMD_MOBILEAP_INIT,
+       CMD_MOBILEAP_DEINIT,
+
+       CMD_STATISTICS_MON_START,
+       CMD_STATISTICS_MON_STOP,
+       CMD_STATISTICS_IS_ENABLED,
+
+       CMD_CONG_MON_INIT,
+       CMD_CONG_MON_DEINIT,
+       CMD_CONG_MON_START,
+       CMD_CONG_MON_STOP,
+
+       CMD_RETRY_TX_RATE_MON_START,
+       CMD_RETRY_TX_RATE_MON_STOP,
+
+       CMD_CHANNEL_INTERFERENCE_MON_START,
+       CMD_CHANNEL_INTERFERENCE_MON_STOP,
+
+       CMD_MAX,
+};
+
+typedef struct {
+       int cmd;
+       char* menu_str;
+} menu_str_t;
+
+
+menu_str_t g_menu_str[] = {
+               { CMD_QUIT, "CMD_QUIT" },
+               { CMD_FULL_MENU, "CMD_FULL_MENU" },
+               { CMD_IP_CONFLICT_INIT, "CMD_IP_CONFLICT_INIT" },
+               { CMD_IP_CONFLICT_DEINIT, "CMD_IP_CONFLICT_DEINIT" },
+               { CMD_IP_CONFLICT_GET_DETECTION_PERIOD, "CMD_IP_CONFLICT_GET_DETECTION_PERIOD" },
+               { CMD_IP_CONFLICT_SET_DETECTION_PERIOD, "CMD_IP_CONFLICT_SET_DETECTION_PERIOD" },
+               { CMD_IP_CONFLICT_GET_STATE, "CMD_IP_CONFLICT_GET_STATE" },
+               { CMD_IP_CONFLICT_IS_DETECTION_ENABLED, "CMD_IP_CONFLICT_IS_DETECTION_ENABLED" },
+               { CMD_IP_CONFLICT_ENABLE_DETECTION, "CMD_IP_CONFLICT_ENABLE_DETECTION" },
+               { CMD_IP_CONFLICT_SET_CB, "CMD_IP_CONFLICT_SET_CB" },
+               { CMD_IP_CONFLICT_UNSET_CB, "CMD_IP_CONFLICT_UNSET_CB" },
+               { CMD_DUMP_INIT, "CMD_DUMP_INIT" },
+               { CMD_DUMP_DEINIT, "CMD_DUMP_DEINIT" },
+               { CMD_DUMP_START_TCPDUMP, "CMD_DUMP_START_TCPDUMP" },
+               { CMD_DUMP_STOP_TCPDUMP, "CMD_DUMP_STOP_TCPDUMP" },
+               { CMD_DUMP_GET_TCPDUMP_STATE, "CMD_DUMP_GET_TCPDUMP_STATE" },
+               { CMD_DUMP_LOG, "CMD_DUMP_LOG" },
+               { CMD_IFACE_MON_INIT, "CMD_IFACE_MON_INIT" },
+               { CMD_IFACE_MON_DEINIT, "CMD_IFACE_MON_DEINIT" },
+               { CMD_IFACE_MON_START, "CMD_IFACE_MON_START" },
+               { CMD_IFACE_MON_STOP, "CMD_IFACE_MON_STOP" },
+               { CMD_IFACE_MON_GET_STATE, "CMD_IFACE_MON_GET_STATE" },
+
+               {CMD_GDBUS_INIT, "CMD_GDBUS_INIT"},
+               {CMD_GDBUS_DEINIT, "CMD_GDBUS_DEINIT"},
+
+               {CMD_CONNMAN_INIT, "CMD_CONNMAN_INIT"},
+               {CMD_CONNMAN_DEINIT, "CMD_CONNMAN_DEINIT"},
+               {CMD_CONNMAN_MGR_GET_PROPERTIES, "CMD_CONNMAN_MGR_GET_PROPERTIES"},
+               {CMD_CONNMAN_MGR_GET_SERVICES, "CMD_CONNMAN_MGR_GET_SERVICES"},
+               {CMD_CONNMAN_MGR_GET_TECHNOLOGIES, "CMD_CONNMAN_MGR_GET_TECHNOLOGIES"},
+
+               {CMD_SUPPLICANT_INIT, "CMD_SUPPLICANT_INIT"},
+               {CMD_SUPPLICANT_DEINIT, "CMD_SUPPLICANT_DEINIT"},
+               {CMD_SUPPLICANT_GET_PROPERTIES, "CMD_SUPPLICANT_GET_PROPERTIES"},
+
+
+               {CMD_WFD_MANAGER_INIT, "CMD_WFD_MANAGER_INIT"},
+               {CMD_WFD_MANAGER_DEINIT, "CMD_WFD_MANAGER_DEINIT"},
+
+               {CMD_MOBILEAP_INIT, "CMD_MOBILEAP_INIT"},
+               {CMD_MOBILEAP_DEINIT, "CMD_MOBILEAP_DEINIT"},
+
+               {CMD_STATISTICS_MON_START, "CMD_STATISTICS_MON_START"},
+               {CMD_STATISTICS_MON_STOP, "CMD_STATISTICS_MON_STOP"},
+               {CMD_STATISTICS_IS_ENABLED, "CMD_STATISTICS_IS_ENABLED"},
+
+               {CMD_CONG_MON_INIT, "CMD_CONG_MON_INIT" },
+               {CMD_CONG_MON_DEINIT, "CMD_CONG_MON_DEINIT" },
+               {CMD_CONG_MON_START, "CMD_CONG_MON_START" },
+               {CMD_CONG_MON_STOP, "CMD_CONG_MON_STOP" },
+
+               {CMD_RETRY_TX_RATE_MON_START, "CMD_RETRY_TX_RATE_MON_START"},
+               {CMD_RETRY_TX_RATE_MON_STOP, "CMD_RETRY_TX_RATE_MON_STOP"},
+
+               {CMD_CHANNEL_INTERFERENCE_MON_START, "CMD_CHANNEL_INTERFERENCE_MON_START"},
+               {CMD_CHANNEL_INTERFERENCE_MON_STOP, "CMD_CHANNEL_INTERFERENCE_MON_STOP"},
+
+               { -1, NULL }, };
+
+GMainLoop* g_event_loop;
+
+char* print_ip_conflict_err(nm_ip_conflict_error_e err)
+{
+       if (err == NM_IP_CONFLICT_ERROR_NONE)
+               return "ERROR_NONE";
+       if (err == NM_IP_CONFLICT_ERROR_NOT_INITIALIZED)
+               return "NOT_INITIALIZED";
+       if (err == NM_IP_CONFLICT_ERROR_INVALID_PARAM)
+               return "INVALID_PARAM";
+       if (err == NM_IP_CONFLICT_ERROR_ALREADY_EXIST)
+               return "ALREADY_EXIST";
+       if (err == NM_IP_CONFLICT_ERROR_OPERATION_FAILED)
+               return "OPERATION_FAILED";
+
+       return "Unknown err";
+}
+
+char* print_ip_conflict_state(nm_ip_conflict_state_e state)
+{
+       if (state == IP_CONFLICT_STATE_UNKNOWN)
+               return "UNKNOWN";
+       if (state == IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED)
+               return "NOT_DETECTED";
+       if (state == IP_CONFLICT_STATE_CONFLICT_DETECTED)
+               return "DETECTED";
+
+       return "Unknown state";
+}
+
+char* print_dump_err(nm_dump_error_e err)
+{
+       if (err == NM_DUMP_ERROR_NONE)
+               return "ERROR_NONE";
+       if (err == NM_DUMP_NOT_INITIALIZED)
+               return "NOT_INITIALIZED";
+       if (err == NM_DUMP_INVALID_PARAMETER)
+               return "INVALID_PARAM";
+       if (err == NM_DUMP_OPERATION_FAILED)
+               return "OPERATION_FAILED";
+
+       return "Unknown err";
+}
+
+char* print_iface_mon_err(nm_iface_mon_error_e err)
+{
+       if (err == NM_IFACE_MON_ERROR_NONE)
+               return "ERROR_NONE";
+       if (err == NM_IFACE_MON_NOT_INITIALIZED)
+               return "NOT_INITIALIZED";
+       if (err == NM_IFACE_MON_INVALID_PARAMETER)
+               return "INVALID_PARAM";
+       if (err == NM_IFACE_MON_OPERATION_FAILED)
+               return "OPERATION_FAILED";
+
+       return "Unknown err";
+}
+
+char* print_gdbus_err(nm_gdbus_error_e err)
+{
+       if (err == NM_GDBUS_ERROR_NONE)
+               return "ERROR_NONE";
+       if (err == NM_GDBUS_ERROR_NOT_INITIALIZED)
+               return "NOT_INITIALIZED";
+       if (err == NM_GDBUS_ERROR_INVALID_PARAM)
+               return "INVALID_PARAM";
+       if (err == NM_GDBUS_ERROR_OPERATION_FAILED)
+               return "OPERATION_FAILED";
+
+       return "Unknown err";
+}
+
+char* print_connman_err(nm_connman_error_e err)
+{
+       if (err == NM_CONNMAN_ERROR_NONE)
+               return "ERROR_NONE";
+       if (err == NM_CONNMAN_ERROR_NOT_INITIALIZED)
+               return "NOT_INITIALIZED";
+       if (err == NM_CONNMAN_ERROR_INVALID_PARAM)
+               return "INVALID_PARAM";
+       if (err == NM_CONNMAN_ERROR_OPERATION_FAILED)
+               return "OPERATION_FAILED";
+       if (err == NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED)
+               return "SIGNAL_SUBSCRIBE_FAILED";
+       if (err == NM_CONNMAN_ERROR_METHOD_CALL_FAILED)
+               return "METHOD_CALL_FAILED";
+
+       return "Unknown err";
+}
+
+char* print_supplicant_err(nm_supplicant_error_e err)
+{
+       if (err == NM_SUPPLICANT_ERROR_NONE)
+               return "ERROR_NONE";
+       if (err == NM_SUPPLICANT_ERROR_NOT_INITIALIZED)
+               return "NOT_INITIALIZED";
+       if (err == NM_SUPPLICANT_ERROR_INVALID_PARAM)
+               return "INVALID_PARAM";
+       if (err == NM_SUPPLICANT_ERROR_OPERATION_FAILED)
+               return "OPERATION_FAILED";
+       if (err == NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED)
+               return "SIGNAL_SUBSCRIBE_FAILED";
+       if (err == NM_SUPPLICANT_ERROR_METHOD_CALL_FAILED)
+               return "METHOD_CALL_FAILED";
+
+       return "Unknown err";
+}
+
+char* print_wfd_manager_err(nm_wfd_error_e err)
+{
+       if (err == NM_WFD_ERROR_NONE)
+               return "ERROR_NONE";
+       if (err == NM_WFD_ERROR_NOT_INITIALIZED)
+               return "NOT_INITIALIZED";
+       if (err == NM_WFD_ERROR_INVALID_PARAM)
+               return "INVALID_PARAM";
+       if (err == NM_WFD_ERROR_OPERATION_FAILED)
+               return "OPERATION_FAILED";
+       if (err == NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED)
+               return "SIGNAL_SUBSCRIBE_FAILED";
+       if (err == NM_WFD_ERROR_METHOD_CALL_FAILED)
+               return "METHOD_CALL_FAILED";
+
+       return "Unknown err";
+}
+
+char* print_mobileap_err(nm_mobileap_error_e err)
+{
+       if (err == NM_MOBILEAP_ERROR_NONE)
+               return "ERROR_NONE";
+       if (err == NM_MOBILEAP_ERROR_NOT_INITIALIZED)
+               return "NOT_INITIALIZED";
+       if (err == NM_MOBILEAP_ERROR_INVALID_PARAM)
+               return "INVALID_PARAM";
+       if (err == NM_MOBILEAP_ERROR_OPERATION_FAILED)
+               return "OPERATION_FAILED";
+       if (err == NM_MOBILEAP_ERROR_SIGNAL_SUBSCRIBE_FAILED)
+               return "SIGNAL_SUBSCRIBE_FAILED";
+       if (err == NM_MOBILEAP_ERROR_METHOD_CALL_FAILED)
+               return "METHOD_CALL_FAILED";
+
+       return "Unknown err";
+}
+
+char* print_statistics_err(nm_statistics_error_e err)
+{
+       if (err == NM_STATISTICS_ERROR_NONE)
+               return "ERROR_NONE";
+       if (err == NM_STATISTICS_ERROR_NOT_INITIALIZED)
+               return "NOT_INITIALIZED";
+       if (err == NM_STATISTICS_ERROR_INVALID_PARAM)
+               return "INVALID_PARAM";
+       if (err == NM_STATISTICS_ERROR_OPERATION_FAILED)
+               return "OPERATION_FAILED";
+
+       return "Unknown err";
+}
+
+const char *print_nmdaemon_err(nm_daemon_error_e err_type)
+{
+       switch (err_type) {
+       case NM_DAEMON_ERROR_NONE:
+               return "ERROR_NONE";
+       case NM_DAEMON_ERROR_NOT_INITIALIZED:
+               return "NOT_INITIALIZED";
+       case NM_DAEMON_ERROR_INVALID_PARAM:
+               return "INVALID_PARAM";
+       case NM_DAEMON_ERROR_OUT_OF_MEMORY:
+               return "OUT_OF_MEMORY";
+       case NM_DAEMON_ERROR_OPERATION_FAILED:
+               return "OPERATION_FAILED";
+       default:
+               return "ERROR_UNKNOWN";
+       }
+}
+
+void usage()
+{
+       printf("Call Test Program\n");
+       printf(" %d: quit\n", CMD_QUIT);
+       printf(" %d: Full menu\n", CMD_FULL_MENU);
+}
+
+char* cmd_transform(char*str)
+{
+       int i, j;
+       int len;
+       static char static_buffer[255];
+
+       if (str == NULL)
+               return "";
+
+       len = strlen(str);
+       if (len == 0)
+               return "";
+
+       /* remove "CMD_" */
+       /* lower char */
+       /* replance "_" to space */
+       for (i = 0, j = 4; i < len; i++, j++) {
+
+               if (str[j] >= 'A' && str[j] <= 'Z')
+                       static_buffer[i] = str[j] + 'a' - 'A';
+               else if (str[j] == '_')
+                       static_buffer[i] = ' ';
+               else
+                       static_buffer[i] = str[j];
+       }
+       static_buffer[j] = '\0';
+
+       return static_buffer;
+}
+
+void usage_full()
+{
+       int i;
+       printf("Call Test Program\n");
+
+       for (i = 0; g_menu_str[i].cmd != -1; i++) {
+               if (i%3 == 0)
+                       printf("\n");
+               if (i == 2 || i == 4 || i == 6 || i == 12 || i == 17 ||
+                               i == 20 || i == 24 || i == 26 || i == 28 || i == 36)
+                       printf(MAKE_GREEN);
+               printf(" %02d: %-32s ", g_menu_str[i].cmd,
+                               cmd_transform(g_menu_str[i].menu_str));
+               if (i == 2 || i == 4 || i == 6 || i == 12 || i == 17 ||
+                               i == 20 || i == 24 || i == 26 || i == 28 || i == 36)
+                       printf(RESET_COLOR);
+
+       }
+       printf("\n");
+}
+
+int is_digit(const char* str)
+{
+       int len;
+       int i;
+
+       if (str == NULL)
+               return -1;
+
+       if (strlen(str) == 0)
+               return -1;
+
+       len = strlen(str);
+       for (i = 0; i < len; i++)       {
+               if (str[i] < '0' || str[i] > '9')
+                       return -2;
+       }
+
+       return 0;
+}
+
+void ip_con_callback(int state, unsigned char *arp_sha, gpointer user_data)
+{
+       printf("User callback IP conflict state[%s] :", print_ip_conflict_state(state));
+       if (arp_sha)
+               printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
+                               arp_sha[0], arp_sha[1], arp_sha[2],
+                               arp_sha[3], arp_sha[4], arp_sha[5]);
+       return;
+}
+
+void iface_mon_callback(char *iface_name, int state, void *user_data)
+{
+       printf("%s changed [%s]\n", iface_name, (state == 1)?"ATTACHED":"DETACHED");
+
+       return;
+}
+
+void congestion_mon_callback(int cong_status, void *user_data)
+{
+       if (cong_status > 40)
+               printf("Alert very High Congestion(%d), Please take necessary action\n", cong_status);
+       else if (cong_status > 25)
+               printf("High Congestion(%d), Excessive re-transmissions\n", cong_status);
+       else if( cong_status > 15 )
+               printf("Warning, moderate congestion(%d)\n", cong_status);
+       else
+               printf("Low congestion: %d\n", cong_status);
+}
+
+void test_full_menu()
+{
+       usage_full();
+
+       return;
+}
+
+void test_quit()
+{
+       printf("Bye\n");
+       g_main_loop_quit(g_event_loop);
+
+       return;
+}
+
+void test_ip_conflict_detection_init()
+{
+       int ret = 0;
+
+       ret = ip_conflict_detection_init();
+       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
+               printf(MAKE_GREEN"ip_conflict_detection_init"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"ip_conflict_detection_init : %s ",
+                               print_ip_conflict_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_ip_conflict_detection_deinit()
+{
+       int ret = 0;
+       ret = ip_conflict_detection_deinit();
+       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
+               printf(MAKE_GREEN"ip_conflict_detection_deinit"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"ip_conflict_detection_deinit : %s ",
+                               print_ip_conflict_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_ip_conflict_get_detection_period()
+{
+       unsigned int period = 0;
+       int ret = 0;
+
+       ret = nm_ip_conflict_get_detection_period(&period);
+       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_ip_conflict_get_detection_period"RESET_COLOR"\n");
+               printf("period : %u secs\n", period);
+       } else {
+               printf(MAKE_RED"nm_ip_conflict_get_detection_period : %s ",
+                               print_ip_conflict_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_ip_conflict_set_detection_period()
+{
+       unsigned int period = 0;
+       int ret = 0;
+
+       printf("Enter IP conflict detection period : \n");
+       if (scanf("%u", &period) < 0)
+               return;
+
+       ret = nm_ip_conflict_set_detection_period(period);
+       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_ip_conflict_set_detection_period"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_ip_conflict_set_detection_period : %s ",
+                               print_ip_conflict_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_ip_conflict_get_state()
+{
+       unsigned int state = 0;
+       int ret = 0;
+
+       ret = nm_ip_conflict_get_state("wlan0", &state);
+       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_ip_conflict_get_state"RESET_COLOR"\n");
+               printf("state : [%s]\n", print_ip_conflict_state(state));
+       } else {
+               printf(MAKE_RED"nm_ip_conflict_get_state : %s ",
+                               print_ip_conflict_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_ip_conflict_is_detection_enabled()
+{
+       gboolean enabled = FALSE;
+       int ret = 0;
+
+       ret = nm_ip_conflict_is_detection_enabled("wlan0", &enabled);
+       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_ip_conflict_is_detection_enabled"RESET_COLOR"\n");
+               printf("enabled : [%s]\n", (enabled)?"YES":"NO");
+       } else {
+               printf(MAKE_RED"nm_ip_conflict_is_detection_enabled : %s ",
+                               print_ip_conflict_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_ip_conflict_enable_detection()
+{
+       unsigned char enable = 0;
+       int ret = 0;
+
+       printf("Enter Enabling detection : ");
+       printf("0 = Disable\n");
+       printf("1 = Enable\n");
+       if (scanf("%hhu", &enable) < 0)
+               return;
+
+       ret = nm_ip_conflict_enable_detection("wlan0", enable == 1);
+       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_ip_conflict_enable_detection"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_ip_conflict_enable_detection : %s ",
+                               print_ip_conflict_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_ip_conflict_set_callback()
+{
+       int ret = 0;
+
+       ret = ip_conflict_set_callback("wlan0", ip_con_callback, NULL);
+       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
+               printf(MAKE_GREEN"ip_conflict_set_callback"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"ip_conflict_set_callback : %s ",
+                               print_ip_conflict_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_ip_conflict_unset_callback()
+{
+       int ret = 0;
+
+       ret = ip_conflict_unset_callback("wlan0");
+       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
+               printf(MAKE_GREEN"ip_conflict_unset_callback"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"ip_conflict_unset_callback : %s ",
+                               print_ip_conflict_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+       return;
+}
+
+void test_nm_dump_init()
+{
+       int ret = 0;
+
+       ret = nm_dump_init();
+       if (ret == NM_DUMP_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_dump_init"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_dump_init : %s ",
+                               print_dump_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_dump_deinit()
+{
+       int ret = 0;
+       ret = nm_dump_deinit();
+       if (ret == NM_DUMP_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_dump_deinit"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_dump_deinit : %s ",
+                               print_dump_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_dump_start_tcpdump()
+{
+       int ret = 0;
+       ret = nm_dump_start_tcpdump();
+       if (ret == NM_DUMP_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_dump_start_tcpdump"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_dump_start_tcpdump : %s ",
+                               print_dump_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_dump_stop_tcpdump()
+{
+       int ret = 0;
+       ret = nm_dump_stop_tcpdump();
+       if (ret == NM_DUMP_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_dump_stop_tcpdump"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_dump_stop_tcpdump : %s ",
+                               print_dump_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_dump_get_tcpdump_state()
+{
+       gboolean is_running = FALSE;
+       int ret = 0;
+
+       ret = nm_dump_get_tcpdump_state(&is_running);
+       if (ret == NM_DUMP_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_dump_get_tcpdump_state"RESET_COLOR"\n");
+               printf("is_running : [%s]\n", (is_running)?"YES":"NO");
+       } else {
+               printf(MAKE_RED"nm_dump_get_tcpdump_state : %s ",
+                               print_dump_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_dump_log()
+{
+       int ret = 0;
+       ret = nm_dump_log("/home/jiung/share/");
+       if (ret == NM_DUMP_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_dump_log"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_dump_log : %s ",
+                               print_dump_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_dump_check_state_and_start()
+{
+       int ret = 0;
+       ret = nm_dump_check_state_and_start();
+       if (ret == NM_DUMP_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_dump_check_state_and_start"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_dump_check_state_and_start : %s ",
+                               print_dump_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_iface_mon_init()
+{
+       int ret = 0;
+
+       ret = nm_iface_mon_init();
+       if (ret == NM_IFACE_MON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_iface_mon_init"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_iface_mon_init : %s ",
+                               print_iface_mon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_iface_mon_deinit()
+{
+       int ret = 0;
+
+       ret = nm_iface_mon_deinit();
+       if (ret == NM_IFACE_MON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_iface_mon_deinit"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_iface_mon_deinit : %s ",
+                               print_iface_mon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_iface_mon_start_monitor()
+{
+       char iface_name[17] = {0, };
+       int ret = 0;
+    printf("Input iface_name :\n");
+    if (scanf(" %17[^\n]s", iface_name) < 0)
+            return;
+
+    if (strlen(iface_name) <= 0) {
+            printf("invalid iface_name !!\n");
+            return;
+    }
+
+       ret = nm_iface_mon_start_monitor(iface_name, iface_mon_callback, NULL);
+       if (ret == NM_IFACE_MON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_iface_mon_start_monitor"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_iface_mon_start_monitor : %s ",
+                               print_iface_mon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_iface_mon_stop_monitor()
+{
+       char iface_name[17] = {0, };
+       int ret = 0;
+    printf("Input iface_name :\n");
+    if (scanf(" %17[^\n]s", iface_name) < 0)
+            return;
+
+    if (strlen(iface_name) <= 0) {
+            printf("invalid iface_name !!\n");
+            return;
+    }
+
+       ret = nm_iface_mon_stop_monitor(iface_name);
+       if (ret == NM_IFACE_MON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_iface_mon_stop_monitor"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_iface_mon_stop_monitor : %s ",
+                               print_iface_mon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_iface_mon_get_iface_state()
+{
+       char iface_name[17] = {0, };
+       int status = 0;
+       int ret = 0;
+    printf("Input iface_name :\n");
+    if (scanf(" %17[^\n]s", iface_name) < 0)
+            return;
+
+    if (strlen(iface_name) <= 0) {
+            printf("invalid iface_name !!\n");
+            return;
+    }
+
+       ret = nm_iface_mon_get_iface_state(iface_name, &status);
+       if (ret == NM_IFACE_MON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_iface_mon_get_iface_state [%d]"RESET_COLOR"\n", status);
+       } else {
+               printf(MAKE_RED"nm_iface_mon_get_iface_state : %s ",
+                               print_iface_mon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_gdbus_init()
+{
+       int ret = 0;
+
+       ret = nm_gdbus_init(NULL, NULL);
+       if (ret == NM_GDBUS_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_gdbus_init"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_gdbus_init : %s ",
+                               print_gdbus_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_gdbus_deinit()
+{
+       int ret = 0;
+
+       ret = nm_gdbus_deinit();
+       if (ret == NM_GDBUS_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_gdbus_deinit"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_gdbus_deinit : %s ",
+                               print_gdbus_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_connman_init()
+{
+       int ret = 0;
+
+       ret = nm_connman_init();
+       if (ret == NM_CONNMAN_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_connman_init"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_connman_init : %s ",
+                               print_connman_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_connman_deinit()
+{
+       int ret = 0;
+
+       ret = nm_connman_deinit();
+       if (ret == NM_CONNMAN_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_connman_deinit"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_connman_deinit : %s ",
+                               print_connman_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_connman_mgr_get_properties()
+{
+       int ret = 0;
+
+       ret = nm_connman_mgr_get_properties();
+       if (ret == NM_CONNMAN_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_connman_mgr_get_properties"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_connman_mgr_get_properties : %s ",
+                               print_connman_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_connman_mgr_get_services()
+{
+       int ret = 0;
+
+       ret = nm_connman_mgr_get_services();
+       if (ret == NM_CONNMAN_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_connman_mgr_get_services"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_connman_mgr_get_services : %s ",
+                               print_connman_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_connman_mgr_get_technologies()
+{
+       int ret = 0;
+
+       ret = nm_connman_mgr_get_technologies();
+       if (ret == NM_CONNMAN_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_connman_mgr_get_technologies"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_connman_mgr_get_technologies : %s ",
+                               print_connman_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_supplicant_init()
+{
+       int ret = 0;
+
+       ret = nm_supplicant_init();
+       if (ret == NM_SUPPLICANT_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_supplicant_init"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_supplicant_init : %s ",
+                               print_supplicant_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_supplicant_deinit()
+{
+       int ret = 0;
+
+       ret = nm_supplicant_deinit();
+       if (ret == NM_SUPPLICANT_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_supplicant_deinit"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_supplicant_deinit : %s ",
+                               print_supplicant_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_supplicant_get_properties()
+{
+       int ret = 0;
+
+       ret = nm_supplicant_get_properties();
+       if (ret == NM_SUPPLICANT_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_supplicant_get_properties"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_supplicant_get_properties : %s ",
+                               print_supplicant_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_wfd_manager_init()
+{
+       int ret = 0;
+
+       ret = nm_wfd_manager_init();
+       if (ret == NM_WFD_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_wfd_manager_init"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_wfd_manager_init : %s ",
+                               print_wfd_manager_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_wfd_manager_deinit()
+{
+       int ret = 0;
+
+       ret = nm_wfd_manager_deinit();
+       if (ret == NM_WFD_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_wfd_manager_deinit"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_wfd_manager_deinit : %s ",
+                               print_wfd_manager_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_mobileap_init()
+{
+       int ret = 0;
+
+       ret = nm_mobileap_init();
+       if (ret == NM_MOBILEAP_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_mobileap_init"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_mobileap_init : %s ",
+                               print_mobileap_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_mobileap_deinit()
+{
+       int ret = 0;
+
+       ret = nm_mobileap_deinit();
+       if (ret == NM_MOBILEAP_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_mobileap_deinit"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_mobileap_deinit : %s ",
+                               print_mobileap_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void __nm_statistics_callback(nm_statistic_s *stats, gpointer user_data)
+{
+       printf("iface [%s] rx byte [%llu] rx packets [%llu] tx bytes [%llu] tx packets [%llu]\n",
+                       stats->ifname, stats->rx_bytes, stats->rx_packets, stats->tx_bytes, stats->tx_packets);
+
+}
+
+void test_nm_statistics_start_monitor()
+{
+       int ret = 0;
+
+
+       ret = nm_statistics_start_monitor(__nm_statistics_callback, NULL);
+       if (ret == NM_STATISTICS_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_statistics_start_monitor"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_statistics_start_monitor : %s ",
+                               print_statistics_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+       return;
+}
+
+void test_nm_statistics_stop_monitor()
+{
+       int ret = 0;
+
+       ret = nm_statistics_stop_monitor();
+       if (ret == NM_STATISTICS_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_statistics_stop_monitor"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_statistics_stop_monitor : %s ",
+                               print_statistics_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+       return;
+}
+
+void test_nm_statistics_is_enabled()
+{
+       gboolean is_enabled = FALSE;
+       int ret = 0;
+
+       ret = nm_statistics_is_enabled(&is_enabled);
+       if (ret == NM_STATISTICS_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_statistics_is_enabled"RESET_COLOR"\n");
+               printf("Enabled [%s]\n", is_enabled?"Yes":"No");
+       } else {
+               printf(MAKE_RED"nm_statistics_is_enabled : %s ",
+                               print_statistics_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+       return;
+}
+
+void test_nm_cong_mon_init()
+{
+       int ret = 0;
+
+       ret = nm_congestion_mon_init();
+       if (ret == NM_CONG_MON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_congestion_mon_init"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_congestion_mon_init: %s ",
+                               print_iface_mon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_cong_mon_deinit()
+{
+       int ret = 0;
+
+       ret = nm_congestion_mon_deinit();
+       if (ret == NM_CONG_MON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_congestion_mon_deinit"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_congestion_mon_deinit: %s ",
+                               print_iface_mon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_cong_mon_start_monitor()
+{
+       int ret = 0;
+
+       ret = nm_congestion_monitor_start(congestion_mon_callback, NULL);
+       if (ret == NM_CONG_MON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_congestion_monitor_start"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_congestion_monitor_start: %s ",
+                               print_iface_mon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void test_nm_cong_mon_stop_monitor()
+{
+       int ret = 0;
+
+       ret = nm_congestion_monitor_stop();
+       if (ret == NM_CONG_MON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_congestion_monitor_stop"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_congestion_monitor_stop: %s ",
+                               print_iface_mon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+
+       return;
+}
+
+void __nm_retry_tx_rate_callback(int retry_rate, gpointer user_data)
+{
+       printf("Retry Rate: %d\n", retry_rate);
+}
+
+void test_nm_retry_tx_rate_start_monitor()
+{
+       int ret = 0;
+
+       ret = nm_retry_tx_rate_monitor_start(__nm_retry_tx_rate_callback, NULL);
+       if (ret == NM_DAEMON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_retry_tx_rate_monitor_start"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_retry_tx_rate_monitor_start: %s ",
+                               print_nmdaemon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+       return;
+}
+
+void test_nm_retry_tx_rate_stop_monitor()
+{
+       int ret = 0;
+
+       ret = nm_retry_tx_rate_monitor_stop();
+       if (ret == NM_DAEMON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_retry_tx_rate_monitor_stop"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_retry_tx_rate_monitor_stop: %s ",
+                               print_nmdaemon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+       return;
+}
+
+void __nm_channel_interference_callback(int freq, double channel_intf, gpointer user_data)
+{
+       printf("Frequency: [%d] Channel Interference: [%lf]\n", freq, channel_intf);
+}
+
+void test_nm_channel_interference_start_monitor()
+{
+       int ret = 0;
+
+       ret = nm_channel_interference_monitor_start(__nm_channel_interference_callback, NULL);
+       if (ret == NM_DAEMON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_channel_interference_monitor_start"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_channel_interference_monitor_start: %s ",
+                               print_nmdaemon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+       return;
+}
+
+void test_nm_channel_interference_stop_monitor()
+{
+       int ret = 0;
+
+       ret = nm_channel_interference_monitor_stop();
+       if (ret == NM_DAEMON_ERROR_NONE) {
+               printf(MAKE_GREEN"nm_channel_interference_monitor_stop"RESET_COLOR"\n");
+       } else {
+               printf(MAKE_RED"nm_channel_interference_monitor_stop: %s ",
+                               print_nmdaemon_err(ret));
+               printf(RESET_COLOR"\n");
+       }
+       return;
+}
+
+typedef void (*test_func)(void);
+
+typedef struct {
+       int cmd;
+       test_func func;
+} menu_func_s;
+
+menu_func_s g_menu_func[] = {
+               {CMD_QUIT, test_quit },
+               {CMD_FULL_MENU, test_full_menu},
+               {CMD_IP_CONFLICT_INIT, test_ip_conflict_detection_init },
+               {CMD_IP_CONFLICT_DEINIT, test_ip_conflict_detection_deinit},
+               {CMD_IP_CONFLICT_GET_DETECTION_PERIOD, test_nm_ip_conflict_get_detection_period},
+               {CMD_IP_CONFLICT_SET_DETECTION_PERIOD, test_nm_ip_conflict_set_detection_period },
+               {CMD_IP_CONFLICT_GET_STATE, test_nm_ip_conflict_get_state},
+               {CMD_IP_CONFLICT_IS_DETECTION_ENABLED, test_nm_ip_conflict_is_detection_enabled},
+               {CMD_IP_CONFLICT_ENABLE_DETECTION, test_nm_ip_conflict_enable_detection},
+               {CMD_IP_CONFLICT_SET_CB, test_ip_conflict_set_callback},
+               {CMD_IP_CONFLICT_UNSET_CB, test_ip_conflict_unset_callback},
+
+               {CMD_DUMP_INIT, test_nm_dump_init},
+               {CMD_DUMP_DEINIT, test_nm_dump_deinit},
+               {CMD_DUMP_START_TCPDUMP, test_nm_dump_start_tcpdump},
+               {CMD_DUMP_STOP_TCPDUMP, test_nm_dump_stop_tcpdump},
+               {CMD_DUMP_GET_TCPDUMP_STATE, test_nm_dump_get_tcpdump_state},
+               {CMD_DUMP_LOG, test_nm_dump_log},
+               {CMD_DUMP_CHECK_STATE_AND_START, test_nm_dump_check_state_and_start},
+
+               {CMD_IFACE_MON_INIT, test_nm_iface_mon_init},
+               {CMD_IFACE_MON_DEINIT, test_nm_iface_mon_deinit},
+               {CMD_IFACE_MON_START, test_nm_iface_mon_start_monitor},
+               {CMD_IFACE_MON_STOP, test_nm_iface_mon_stop_monitor},
+               {CMD_IFACE_MON_GET_STATE, test_nm_iface_mon_get_iface_state},
+
+               {CMD_GDBUS_INIT, test_nm_gdbus_init},
+               {CMD_GDBUS_DEINIT, test_nm_gdbus_deinit},
+
+               {CMD_CONNMAN_INIT, test_nm_connman_init},
+               {CMD_CONNMAN_DEINIT, test_nm_connman_deinit},
+               {CMD_CONNMAN_MGR_GET_PROPERTIES, test_nm_connman_mgr_get_properties},
+               {CMD_CONNMAN_MGR_GET_SERVICES, test_nm_connman_mgr_get_services},
+               {CMD_CONNMAN_MGR_GET_TECHNOLOGIES, test_nm_connman_mgr_get_technologies},
+
+               {CMD_SUPPLICANT_INIT, test_nm_supplicant_init},
+               {CMD_SUPPLICANT_DEINIT, test_nm_supplicant_deinit},
+               {CMD_SUPPLICANT_GET_PROPERTIES, test_nm_supplicant_get_properties},
+
+               {CMD_WFD_MANAGER_INIT, test_nm_wfd_manager_init},
+               {CMD_WFD_MANAGER_DEINIT, test_nm_wfd_manager_deinit},
+
+               {CMD_MOBILEAP_INIT, test_nm_mobileap_init},
+               {CMD_MOBILEAP_DEINIT, test_nm_mobileap_deinit},
+
+               {CMD_STATISTICS_MON_START, test_nm_statistics_start_monitor},
+               {CMD_STATISTICS_MON_STOP, test_nm_statistics_stop_monitor},
+               {CMD_STATISTICS_IS_ENABLED, test_nm_statistics_is_enabled},
+
+               {CMD_CONG_MON_INIT, test_nm_cong_mon_init},
+               {CMD_CONG_MON_DEINIT, test_nm_cong_mon_deinit},
+               {CMD_CONG_MON_START, test_nm_cong_mon_start_monitor},
+               {CMD_CONG_MON_STOP, test_nm_cong_mon_stop_monitor},
+
+               {CMD_RETRY_TX_RATE_MON_START, test_nm_retry_tx_rate_start_monitor},
+               {CMD_RETRY_TX_RATE_MON_STOP, test_nm_retry_tx_rate_stop_monitor},
+
+               {CMD_CHANNEL_INTERFERENCE_MON_START, test_nm_channel_interference_start_monitor},
+               {CMD_CHANNEL_INTERFERENCE_MON_STOP, test_nm_channel_interference_stop_monitor},
+
+               { -1, NULL }, };
+
+void process_input(const char *input, gpointer user_data)
+{
+       int cmd = -1;
+
+       cmd = strtol(input, NULL, 0);
+       if (is_digit(input) < 0 || strlen(input) == 0 || errno == ERANGE || errno
+                       == EINVAL)
+               cmd = -1;
+
+       printf("cmd=[%d]\n", cmd);
+       if (cmd >= CMD_MAX || cmd < CMD_QUIT) {
+               printf("Invalid CMD\n");
+               return;
+       }
+       g_menu_func[cmd].func();
+}
+
+static gboolean test_terminal_read_std_input(GIOChannel * source,
+               GIOCondition condition, gpointer user_data)
+{
+       int fd = 0;
+
+       static char buf[1024];
+       int n;
+
+       errno = 0;
+       n = read(fd, buf, 1024);
+
+       buf[n - 1] = '\0'; /* remove new line... */
+       if (n == 0)
+               printf("Error: read() from stdin returns 0.\n");
+       else if (n < 0)
+               printf("input: read, err\n");
+       else
+               printf("\n\n");
+
+       process_input(buf, user_data);
+
+       return TRUE;
+}
+
+int main(int argc, char **argv)
+{
+
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+       g_type_init();
+#endif
+
+       g_event_loop = g_main_loop_new(NULL, FALSE);
+
+       int std_input_fd = 0;
+       GIOChannel *gio2 = g_io_channel_unix_new(std_input_fd);
+       g_io_add_watch(gio2, G_IO_IN, (GIOFunc) test_terminal_read_std_input, NULL);
+       g_io_channel_unref(gio2);
+
+       usage_full();
+
+       g_main_loop_run(g_event_loop);
+
+       return 0;
+}
diff --git a/test/nm-test.c b/test/nm-test.c
deleted file mode 100644 (file)
index 0d4b01c..0000000
+++ /dev/null
@@ -1,1402 +0,0 @@
-/*
- * Network Monitoring Module
- *
- * Copyright (c) 2018 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.
- *
- */
-
-/**
- * This file implements application for testing network monitoring functions.
- *
- * @file        nm-test.c
- * @author      Jiung Yu (jiung.yu@samsung.com)
- * @version     0.1
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <time.h>
-#include <assert.h>
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "nm-daemon-log.h"
-#include "nm-daemon.h"
-#include "nm-ip-conflict.h"
-#include "nm-iface-mon.h"
-#include "nm-statistics.h"
-#include "nm-dump.h"
-#include "nm-gdbus.h"
-#include "nm-connman.h"
-#include "nm-supplicant.h"
-#include "nm-wfd-manager.h"
-#include "nm-mobileap.h"
-
-#define RESET_COLOR "\e[m"
-#define MAKE_RED "\e[31m"
-#define MAKE_GREEN "\e[32m"
-
-enum {
-       CMD_QUIT,
-       CMD_FULL_MENU,
-       CMD_IP_CONFLICT_INIT,
-       CMD_IP_CONFLICT_DEINIT,
-       CMD_IP_CONFLICT_GET_DETECTION_PERIOD,
-       CMD_IP_CONFLICT_SET_DETECTION_PERIOD,
-       CMD_IP_CONFLICT_GET_STATE,
-       CMD_IP_CONFLICT_IS_DETECTION_ENABLED,
-       CMD_IP_CONFLICT_ENABLE_DETECTION,
-       CMD_IP_CONFLICT_SET_CB,
-       CMD_IP_CONFLICT_UNSET_CB,
-       CMD_DUMP_INIT,
-       CMD_DUMP_DEINIT,
-       CMD_DUMP_START_TCPDUMP,
-       CMD_DUMP_STOP_TCPDUMP,
-       CMD_DUMP_GET_TCPDUMP_STATE,
-       CMD_DUMP_LOG,
-       CMD_DUMP_CHECK_STATE_AND_START,
-       CMD_IFACE_MON_INIT,
-       CMD_IFACE_MON_DEINIT,
-       CMD_IFACE_MON_START,
-       CMD_IFACE_MON_STOP,
-       CMD_IFACE_MON_GET_STATE,
-
-       CMD_GDBUS_INIT,
-       CMD_GDBUS_DEINIT,
-
-       CMD_CONNMAN_INIT,
-       CMD_CONNMAN_DEINIT,
-       CMD_CONNMAN_MGR_GET_PROPERTIES,
-       CMD_CONNMAN_MGR_GET_SERVICES,
-       CMD_CONNMAN_MGR_GET_TECHNOLOGIES,
-
-       CMD_SUPPLICANT_INIT,
-       CMD_SUPPLICANT_DEINIT,
-       CMD_SUPPLICANT_GET_PROPERTIES,
-
-       CMD_WFD_MANAGER_INIT,
-       CMD_WFD_MANAGER_DEINIT,
-
-       CMD_MOBILEAP_INIT,
-       CMD_MOBILEAP_DEINIT,
-
-       CMD_STATISTICS_MON_START,
-       CMD_STATISTICS_MON_STOP,
-       CMD_STATISTICS_IS_ENABLED,
-
-       CMD_CONG_MON_INIT,
-       CMD_CONG_MON_DEINIT,
-       CMD_CONG_MON_START,
-       CMD_CONG_MON_STOP,
-
-       CMD_RETRY_TX_RATE_MON_START,
-       CMD_RETRY_TX_RATE_MON_STOP,
-
-       CMD_CHANNEL_INTERFERENCE_MON_START,
-       CMD_CHANNEL_INTERFERENCE_MON_STOP,
-
-       CMD_MAX,
-};
-
-typedef struct {
-       int cmd;
-       char* menu_str;
-} menu_str_t;
-
-
-menu_str_t g_menu_str[] = {
-               { CMD_QUIT, "CMD_QUIT" },
-               { CMD_FULL_MENU, "CMD_FULL_MENU" },
-               { CMD_IP_CONFLICT_INIT, "CMD_IP_CONFLICT_INIT" },
-               { CMD_IP_CONFLICT_DEINIT, "CMD_IP_CONFLICT_DEINIT" },
-               { CMD_IP_CONFLICT_GET_DETECTION_PERIOD, "CMD_IP_CONFLICT_GET_DETECTION_PERIOD" },
-               { CMD_IP_CONFLICT_SET_DETECTION_PERIOD, "CMD_IP_CONFLICT_SET_DETECTION_PERIOD" },
-               { CMD_IP_CONFLICT_GET_STATE, "CMD_IP_CONFLICT_GET_STATE" },
-               { CMD_IP_CONFLICT_IS_DETECTION_ENABLED, "CMD_IP_CONFLICT_IS_DETECTION_ENABLED" },
-               { CMD_IP_CONFLICT_ENABLE_DETECTION, "CMD_IP_CONFLICT_ENABLE_DETECTION" },
-               { CMD_IP_CONFLICT_SET_CB, "CMD_IP_CONFLICT_SET_CB" },
-               { CMD_IP_CONFLICT_UNSET_CB, "CMD_IP_CONFLICT_UNSET_CB" },
-               { CMD_DUMP_INIT, "CMD_DUMP_INIT" },
-               { CMD_DUMP_DEINIT, "CMD_DUMP_DEINIT" },
-               { CMD_DUMP_START_TCPDUMP, "CMD_DUMP_START_TCPDUMP" },
-               { CMD_DUMP_STOP_TCPDUMP, "CMD_DUMP_STOP_TCPDUMP" },
-               { CMD_DUMP_GET_TCPDUMP_STATE, "CMD_DUMP_GET_TCPDUMP_STATE" },
-               { CMD_DUMP_LOG, "CMD_DUMP_LOG" },
-               { CMD_IFACE_MON_INIT, "CMD_IFACE_MON_INIT" },
-               { CMD_IFACE_MON_DEINIT, "CMD_IFACE_MON_DEINIT" },
-               { CMD_IFACE_MON_START, "CMD_IFACE_MON_START" },
-               { CMD_IFACE_MON_STOP, "CMD_IFACE_MON_STOP" },
-               { CMD_IFACE_MON_GET_STATE, "CMD_IFACE_MON_GET_STATE" },
-
-               {CMD_GDBUS_INIT, "CMD_GDBUS_INIT"},
-               {CMD_GDBUS_DEINIT, "CMD_GDBUS_DEINIT"},
-
-               {CMD_CONNMAN_INIT, "CMD_CONNMAN_INIT"},
-               {CMD_CONNMAN_DEINIT, "CMD_CONNMAN_DEINIT"},
-               {CMD_CONNMAN_MGR_GET_PROPERTIES, "CMD_CONNMAN_MGR_GET_PROPERTIES"},
-               {CMD_CONNMAN_MGR_GET_SERVICES, "CMD_CONNMAN_MGR_GET_SERVICES"},
-               {CMD_CONNMAN_MGR_GET_TECHNOLOGIES, "CMD_CONNMAN_MGR_GET_TECHNOLOGIES"},
-
-               {CMD_SUPPLICANT_INIT, "CMD_SUPPLICANT_INIT"},
-               {CMD_SUPPLICANT_DEINIT, "CMD_SUPPLICANT_DEINIT"},
-               {CMD_SUPPLICANT_GET_PROPERTIES, "CMD_SUPPLICANT_GET_PROPERTIES"},
-
-
-               {CMD_WFD_MANAGER_INIT, "CMD_WFD_MANAGER_INIT"},
-               {CMD_WFD_MANAGER_DEINIT, "CMD_WFD_MANAGER_DEINIT"},
-
-               {CMD_MOBILEAP_INIT, "CMD_MOBILEAP_INIT"},
-               {CMD_MOBILEAP_DEINIT, "CMD_MOBILEAP_DEINIT"},
-
-               {CMD_STATISTICS_MON_START, "CMD_STATISTICS_MON_START"},
-               {CMD_STATISTICS_MON_STOP, "CMD_STATISTICS_MON_STOP"},
-               {CMD_STATISTICS_IS_ENABLED, "CMD_STATISTICS_IS_ENABLED"},
-
-               {CMD_CONG_MON_INIT, "CMD_CONG_MON_INIT" },
-               {CMD_CONG_MON_DEINIT, "CMD_CONG_MON_DEINIT" },
-               {CMD_CONG_MON_START, "CMD_CONG_MON_START" },
-               {CMD_CONG_MON_STOP, "CMD_CONG_MON_STOP" },
-
-               {CMD_RETRY_TX_RATE_MON_START, "CMD_RETRY_TX_RATE_MON_START"},
-               {CMD_RETRY_TX_RATE_MON_STOP, "CMD_RETRY_TX_RATE_MON_STOP"},
-
-               {CMD_CHANNEL_INTERFERENCE_MON_START, "CMD_CHANNEL_INTERFERENCE_MON_START"},
-               {CMD_CHANNEL_INTERFERENCE_MON_STOP, "CMD_CHANNEL_INTERFERENCE_MON_STOP"},
-
-               { -1, NULL }, };
-
-GMainLoop* g_event_loop;
-
-char* print_ip_conflict_err(nm_ip_conflict_error_e err)
-{
-       if (err == NM_IP_CONFLICT_ERROR_NONE)
-               return "ERROR_NONE";
-       if (err == NM_IP_CONFLICT_ERROR_NOT_INITIALIZED)
-               return "NOT_INITIALIZED";
-       if (err == NM_IP_CONFLICT_ERROR_INVALID_PARAM)
-               return "INVALID_PARAM";
-       if (err == NM_IP_CONFLICT_ERROR_ALREADY_EXIST)
-               return "ALREADY_EXIST";
-       if (err == NM_IP_CONFLICT_ERROR_OPERATION_FAILED)
-               return "OPERATION_FAILED";
-
-       return "Unknown err";
-}
-
-char* print_ip_conflict_state(nm_ip_conflict_state_e state)
-{
-       if (state == IP_CONFLICT_STATE_UNKNOWN)
-               return "UNKNOWN";
-       if (state == IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED)
-               return "NOT_DETECTED";
-       if (state == IP_CONFLICT_STATE_CONFLICT_DETECTED)
-               return "DETECTED";
-
-       return "Unknown state";
-}
-
-char* print_dump_err(nm_dump_error_e err)
-{
-       if (err == NM_DUMP_ERROR_NONE)
-               return "ERROR_NONE";
-       if (err == NM_DUMP_NOT_INITIALIZED)
-               return "NOT_INITIALIZED";
-       if (err == NM_DUMP_INVALID_PARAMETER)
-               return "INVALID_PARAM";
-       if (err == NM_DUMP_OPERATION_FAILED)
-               return "OPERATION_FAILED";
-
-       return "Unknown err";
-}
-
-char* print_iface_mon_err(nm_iface_mon_error_e err)
-{
-       if (err == NM_IFACE_MON_ERROR_NONE)
-               return "ERROR_NONE";
-       if (err == NM_IFACE_MON_NOT_INITIALIZED)
-               return "NOT_INITIALIZED";
-       if (err == NM_IFACE_MON_INVALID_PARAMETER)
-               return "INVALID_PARAM";
-       if (err == NM_IFACE_MON_OPERATION_FAILED)
-               return "OPERATION_FAILED";
-
-       return "Unknown err";
-}
-
-char* print_gdbus_err(nm_gdbus_error_e err)
-{
-       if (err == NM_GDBUS_ERROR_NONE)
-               return "ERROR_NONE";
-       if (err == NM_GDBUS_ERROR_NOT_INITIALIZED)
-               return "NOT_INITIALIZED";
-       if (err == NM_GDBUS_ERROR_INVALID_PARAM)
-               return "INVALID_PARAM";
-       if (err == NM_GDBUS_ERROR_OPERATION_FAILED)
-               return "OPERATION_FAILED";
-
-       return "Unknown err";
-}
-
-char* print_connman_err(nm_connman_error_e err)
-{
-       if (err == NM_CONNMAN_ERROR_NONE)
-               return "ERROR_NONE";
-       if (err == NM_CONNMAN_ERROR_NOT_INITIALIZED)
-               return "NOT_INITIALIZED";
-       if (err == NM_CONNMAN_ERROR_INVALID_PARAM)
-               return "INVALID_PARAM";
-       if (err == NM_CONNMAN_ERROR_OPERATION_FAILED)
-               return "OPERATION_FAILED";
-       if (err == NM_CONNMAN_ERROR_SIGNAL_SUBSCRIBE_FAILED)
-               return "SIGNAL_SUBSCRIBE_FAILED";
-       if (err == NM_CONNMAN_ERROR_METHOD_CALL_FAILED)
-               return "METHOD_CALL_FAILED";
-
-       return "Unknown err";
-}
-
-char* print_supplicant_err(nm_supplicant_error_e err)
-{
-       if (err == NM_SUPPLICANT_ERROR_NONE)
-               return "ERROR_NONE";
-       if (err == NM_SUPPLICANT_ERROR_NOT_INITIALIZED)
-               return "NOT_INITIALIZED";
-       if (err == NM_SUPPLICANT_ERROR_INVALID_PARAM)
-               return "INVALID_PARAM";
-       if (err == NM_SUPPLICANT_ERROR_OPERATION_FAILED)
-               return "OPERATION_FAILED";
-       if (err == NM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED)
-               return "SIGNAL_SUBSCRIBE_FAILED";
-       if (err == NM_SUPPLICANT_ERROR_METHOD_CALL_FAILED)
-               return "METHOD_CALL_FAILED";
-
-       return "Unknown err";
-}
-
-char* print_wfd_manager_err(nm_wfd_error_e err)
-{
-       if (err == NM_WFD_ERROR_NONE)
-               return "ERROR_NONE";
-       if (err == NM_WFD_ERROR_NOT_INITIALIZED)
-               return "NOT_INITIALIZED";
-       if (err == NM_WFD_ERROR_INVALID_PARAM)
-               return "INVALID_PARAM";
-       if (err == NM_WFD_ERROR_OPERATION_FAILED)
-               return "OPERATION_FAILED";
-       if (err == NM_WFD_ERROR_SIGNAL_SUBSCRIBE_FAILED)
-               return "SIGNAL_SUBSCRIBE_FAILED";
-       if (err == NM_WFD_ERROR_METHOD_CALL_FAILED)
-               return "METHOD_CALL_FAILED";
-
-       return "Unknown err";
-}
-
-char* print_mobileap_err(nm_mobileap_error_e err)
-{
-       if (err == NM_MOBILEAP_ERROR_NONE)
-               return "ERROR_NONE";
-       if (err == NM_MOBILEAP_ERROR_NOT_INITIALIZED)
-               return "NOT_INITIALIZED";
-       if (err == NM_MOBILEAP_ERROR_INVALID_PARAM)
-               return "INVALID_PARAM";
-       if (err == NM_MOBILEAP_ERROR_OPERATION_FAILED)
-               return "OPERATION_FAILED";
-       if (err == NM_MOBILEAP_ERROR_SIGNAL_SUBSCRIBE_FAILED)
-               return "SIGNAL_SUBSCRIBE_FAILED";
-       if (err == NM_MOBILEAP_ERROR_METHOD_CALL_FAILED)
-               return "METHOD_CALL_FAILED";
-
-       return "Unknown err";
-}
-
-char* print_statistics_err(nm_statistics_error_e err)
-{
-       if (err == NM_STATISTICS_ERROR_NONE)
-               return "ERROR_NONE";
-       if (err == NM_STATISTICS_ERROR_NOT_INITIALIZED)
-               return "NOT_INITIALIZED";
-       if (err == NM_STATISTICS_ERROR_INVALID_PARAM)
-               return "INVALID_PARAM";
-       if (err == NM_STATISTICS_ERROR_OPERATION_FAILED)
-               return "OPERATION_FAILED";
-
-       return "Unknown err";
-}
-
-const char *print_nmdaemon_err(nm_daemon_error_e err_type)
-{
-       switch (err_type) {
-       case NM_DAEMON_ERROR_NONE:
-               return "ERROR_NONE";
-       case NM_DAEMON_ERROR_NOT_INITIALIZED:
-               return "NOT_INITIALIZED";
-       case NM_DAEMON_ERROR_INVALID_PARAM:
-               return "INVALID_PARAM";
-       case NM_DAEMON_ERROR_OUT_OF_MEMORY:
-               return "OUT_OF_MEMORY";
-       case NM_DAEMON_ERROR_OPERATION_FAILED:
-               return "OPERATION_FAILED";
-       default:
-               return "ERROR_UNKNOWN";
-       }
-}
-
-void usage()
-{
-       printf("Call Test Program\n");
-       printf(" %d: quit\n", CMD_QUIT);
-       printf(" %d: Full menu\n", CMD_FULL_MENU);
-}
-
-char* cmd_transform(char*str)
-{
-       int i, j;
-       int len;
-       static char static_buffer[255];
-
-       if (str == NULL)
-               return "";
-
-       len = strlen(str);
-       if (len == 0)
-               return "";
-
-       /* remove "CMD_" */
-       /* lower char */
-       /* replance "_" to space */
-       for (i = 0, j = 4; i < len; i++, j++) {
-
-               if (str[j] >= 'A' && str[j] <= 'Z')
-                       static_buffer[i] = str[j] + 'a' - 'A';
-               else if (str[j] == '_')
-                       static_buffer[i] = ' ';
-               else
-                       static_buffer[i] = str[j];
-       }
-       static_buffer[j] = '\0';
-
-       return static_buffer;
-}
-
-void usage_full()
-{
-       int i;
-       printf("Call Test Program\n");
-
-       for (i = 0; g_menu_str[i].cmd != -1; i++) {
-               if (i%3 == 0)
-                       printf("\n");
-               if (i == 2 || i == 4 || i == 6 || i == 12 || i == 17 ||
-                               i == 20 || i == 24 || i == 26 || i == 28 || i == 36)
-                       printf(MAKE_GREEN);
-               printf(" %02d: %-32s ", g_menu_str[i].cmd,
-                               cmd_transform(g_menu_str[i].menu_str));
-               if (i == 2 || i == 4 || i == 6 || i == 12 || i == 17 ||
-                               i == 20 || i == 24 || i == 26 || i == 28 || i == 36)
-                       printf(RESET_COLOR);
-
-       }
-       printf("\n");
-}
-
-int is_digit(const char* str)
-{
-       int len;
-       int i;
-
-       if (str == NULL)
-               return -1;
-
-       if (strlen(str) == 0)
-               return -1;
-
-       len = strlen(str);
-       for (i = 0; i < len; i++)       {
-               if (str[i] < '0' || str[i] > '9')
-                       return -2;
-       }
-
-       return 0;
-}
-
-void ip_con_callback(int state, unsigned char *arp_sha, gpointer user_data)
-{
-       printf("User callback IP conflict state[%s] :", print_ip_conflict_state(state));
-       if (arp_sha)
-               printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
-                               arp_sha[0], arp_sha[1], arp_sha[2],
-                               arp_sha[3], arp_sha[4], arp_sha[5]);
-       return;
-}
-
-void iface_mon_callback(char *iface_name, int state, void *user_data)
-{
-       printf("%s changed [%s]\n", iface_name, (state == 1)?"ATTACHED":"DETACHED");
-
-       return;
-}
-
-void congestion_mon_callback(int cong_status, void *user_data)
-{
-       if (cong_status > 40)
-               printf("Alert very High Congestion(%d), Please take necessary action\n", cong_status);
-       else if (cong_status > 25)
-               printf("High Congestion(%d), Excessive re-transmissions\n", cong_status);
-       else if( cong_status > 15 )
-               printf("Warning, moderate congestion(%d)\n", cong_status);
-       else
-               printf("Low congestion: %d\n", cong_status);
-}
-
-void test_full_menu()
-{
-       usage_full();
-
-       return;
-}
-
-void test_quit()
-{
-       printf("Bye\n");
-       g_main_loop_quit(g_event_loop);
-
-       return;
-}
-
-void test_ip_conflict_detection_init()
-{
-       int ret = 0;
-
-       ret = ip_conflict_detection_init();
-       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
-               printf(MAKE_GREEN"ip_conflict_detection_init"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"ip_conflict_detection_init : %s ",
-                               print_ip_conflict_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_ip_conflict_detection_deinit()
-{
-       int ret = 0;
-       ret = ip_conflict_detection_deinit();
-       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
-               printf(MAKE_GREEN"ip_conflict_detection_deinit"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"ip_conflict_detection_deinit : %s ",
-                               print_ip_conflict_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_ip_conflict_get_detection_period()
-{
-       unsigned int period = 0;
-       int ret = 0;
-
-       ret = nm_ip_conflict_get_detection_period(&period);
-       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_ip_conflict_get_detection_period"RESET_COLOR"\n");
-               printf("period : %u secs\n", period);
-       } else {
-               printf(MAKE_RED"nm_ip_conflict_get_detection_period : %s ",
-                               print_ip_conflict_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_ip_conflict_set_detection_period()
-{
-       unsigned int period = 0;
-       int ret = 0;
-
-       printf("Enter IP conflict detection period : \n");
-       if (scanf("%u", &period) < 0)
-               return;
-
-       ret = nm_ip_conflict_set_detection_period(period);
-       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_ip_conflict_set_detection_period"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_ip_conflict_set_detection_period : %s ",
-                               print_ip_conflict_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_ip_conflict_get_state()
-{
-       unsigned int state = 0;
-       int ret = 0;
-
-       ret = nm_ip_conflict_get_state("wlan0", &state);
-       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_ip_conflict_get_state"RESET_COLOR"\n");
-               printf("state : [%s]\n", print_ip_conflict_state(state));
-       } else {
-               printf(MAKE_RED"nm_ip_conflict_get_state : %s ",
-                               print_ip_conflict_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_ip_conflict_is_detection_enabled()
-{
-       gboolean enabled = FALSE;
-       int ret = 0;
-
-       ret = nm_ip_conflict_is_detection_enabled("wlan0", &enabled);
-       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_ip_conflict_is_detection_enabled"RESET_COLOR"\n");
-               printf("enabled : [%s]\n", (enabled)?"YES":"NO");
-       } else {
-               printf(MAKE_RED"nm_ip_conflict_is_detection_enabled : %s ",
-                               print_ip_conflict_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_ip_conflict_enable_detection()
-{
-       unsigned char enable = 0;
-       int ret = 0;
-
-       printf("Enter Enabling detection : ");
-       printf("0 = Disable\n");
-       printf("1 = Enable\n");
-       if (scanf("%hhu", &enable) < 0)
-               return;
-
-       ret = nm_ip_conflict_enable_detection("wlan0", enable == 1);
-       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_ip_conflict_enable_detection"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_ip_conflict_enable_detection : %s ",
-                               print_ip_conflict_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_ip_conflict_set_callback()
-{
-       int ret = 0;
-
-       ret = ip_conflict_set_callback("wlan0", ip_con_callback, NULL);
-       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
-               printf(MAKE_GREEN"ip_conflict_set_callback"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"ip_conflict_set_callback : %s ",
-                               print_ip_conflict_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_ip_conflict_unset_callback()
-{
-       int ret = 0;
-
-       ret = ip_conflict_unset_callback("wlan0");
-       if (ret == NM_IP_CONFLICT_ERROR_NONE) {
-               printf(MAKE_GREEN"ip_conflict_unset_callback"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"ip_conflict_unset_callback : %s ",
-                               print_ip_conflict_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-       return;
-}
-
-void test_nm_dump_init()
-{
-       int ret = 0;
-
-       ret = nm_dump_init();
-       if (ret == NM_DUMP_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_dump_init"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_dump_init : %s ",
-                               print_dump_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_dump_deinit()
-{
-       int ret = 0;
-       ret = nm_dump_deinit();
-       if (ret == NM_DUMP_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_dump_deinit"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_dump_deinit : %s ",
-                               print_dump_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_dump_start_tcpdump()
-{
-       int ret = 0;
-       ret = nm_dump_start_tcpdump();
-       if (ret == NM_DUMP_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_dump_start_tcpdump"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_dump_start_tcpdump : %s ",
-                               print_dump_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_dump_stop_tcpdump()
-{
-       int ret = 0;
-       ret = nm_dump_stop_tcpdump();
-       if (ret == NM_DUMP_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_dump_stop_tcpdump"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_dump_stop_tcpdump : %s ",
-                               print_dump_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_dump_get_tcpdump_state()
-{
-       gboolean is_running = FALSE;
-       int ret = 0;
-
-       ret = nm_dump_get_tcpdump_state(&is_running);
-       if (ret == NM_DUMP_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_dump_get_tcpdump_state"RESET_COLOR"\n");
-               printf("is_running : [%s]\n", (is_running)?"YES":"NO");
-       } else {
-               printf(MAKE_RED"nm_dump_get_tcpdump_state : %s ",
-                               print_dump_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_dump_log()
-{
-       int ret = 0;
-       ret = nm_dump_log("/home/jiung/share/");
-       if (ret == NM_DUMP_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_dump_log"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_dump_log : %s ",
-                               print_dump_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_dump_check_state_and_start()
-{
-       int ret = 0;
-       ret = nm_dump_check_state_and_start();
-       if (ret == NM_DUMP_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_dump_check_state_and_start"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_dump_check_state_and_start : %s ",
-                               print_dump_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_iface_mon_init()
-{
-       int ret = 0;
-
-       ret = nm_iface_mon_init();
-       if (ret == NM_IFACE_MON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_iface_mon_init"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_iface_mon_init : %s ",
-                               print_iface_mon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_iface_mon_deinit()
-{
-       int ret = 0;
-
-       ret = nm_iface_mon_deinit();
-       if (ret == NM_IFACE_MON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_iface_mon_deinit"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_iface_mon_deinit : %s ",
-                               print_iface_mon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_iface_mon_start_monitor()
-{
-       char iface_name[17] = {0, };
-       int ret = 0;
-    printf("Input iface_name :\n");
-    if (scanf(" %17[^\n]s", iface_name) < 0)
-            return;
-
-    if (strlen(iface_name) <= 0) {
-            printf("invalid iface_name !!\n");
-            return;
-    }
-
-       ret = nm_iface_mon_start_monitor(iface_name, iface_mon_callback, NULL);
-       if (ret == NM_IFACE_MON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_iface_mon_start_monitor"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_iface_mon_start_monitor : %s ",
-                               print_iface_mon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_iface_mon_stop_monitor()
-{
-       char iface_name[17] = {0, };
-       int ret = 0;
-    printf("Input iface_name :\n");
-    if (scanf(" %17[^\n]s", iface_name) < 0)
-            return;
-
-    if (strlen(iface_name) <= 0) {
-            printf("invalid iface_name !!\n");
-            return;
-    }
-
-       ret = nm_iface_mon_stop_monitor(iface_name);
-       if (ret == NM_IFACE_MON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_iface_mon_stop_monitor"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_iface_mon_stop_monitor : %s ",
-                               print_iface_mon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_iface_mon_get_iface_state()
-{
-       char iface_name[17] = {0, };
-       int status = 0;
-       int ret = 0;
-    printf("Input iface_name :\n");
-    if (scanf(" %17[^\n]s", iface_name) < 0)
-            return;
-
-    if (strlen(iface_name) <= 0) {
-            printf("invalid iface_name !!\n");
-            return;
-    }
-
-       ret = nm_iface_mon_get_iface_state(iface_name, &status);
-       if (ret == NM_IFACE_MON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_iface_mon_get_iface_state [%d]"RESET_COLOR"\n", status);
-       } else {
-               printf(MAKE_RED"nm_iface_mon_get_iface_state : %s ",
-                               print_iface_mon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_gdbus_init()
-{
-       int ret = 0;
-
-       ret = nm_gdbus_init(NULL, NULL);
-       if (ret == NM_GDBUS_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_gdbus_init"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_gdbus_init : %s ",
-                               print_gdbus_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_gdbus_deinit()
-{
-       int ret = 0;
-
-       ret = nm_gdbus_deinit();
-       if (ret == NM_GDBUS_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_gdbus_deinit"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_gdbus_deinit : %s ",
-                               print_gdbus_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_connman_init()
-{
-       int ret = 0;
-
-       ret = nm_connman_init();
-       if (ret == NM_CONNMAN_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_connman_init"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_connman_init : %s ",
-                               print_connman_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_connman_deinit()
-{
-       int ret = 0;
-
-       ret = nm_connman_deinit();
-       if (ret == NM_CONNMAN_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_connman_deinit"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_connman_deinit : %s ",
-                               print_connman_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_connman_mgr_get_properties()
-{
-       int ret = 0;
-
-       ret = nm_connman_mgr_get_properties();
-       if (ret == NM_CONNMAN_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_connman_mgr_get_properties"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_connman_mgr_get_properties : %s ",
-                               print_connman_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_connman_mgr_get_services()
-{
-       int ret = 0;
-
-       ret = nm_connman_mgr_get_services();
-       if (ret == NM_CONNMAN_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_connman_mgr_get_services"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_connman_mgr_get_services : %s ",
-                               print_connman_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_connman_mgr_get_technologies()
-{
-       int ret = 0;
-
-       ret = nm_connman_mgr_get_technologies();
-       if (ret == NM_CONNMAN_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_connman_mgr_get_technologies"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_connman_mgr_get_technologies : %s ",
-                               print_connman_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_supplicant_init()
-{
-       int ret = 0;
-
-       ret = nm_supplicant_init();
-       if (ret == NM_SUPPLICANT_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_supplicant_init"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_supplicant_init : %s ",
-                               print_supplicant_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_supplicant_deinit()
-{
-       int ret = 0;
-
-       ret = nm_supplicant_deinit();
-       if (ret == NM_SUPPLICANT_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_supplicant_deinit"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_supplicant_deinit : %s ",
-                               print_supplicant_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_supplicant_get_properties()
-{
-       int ret = 0;
-
-       ret = nm_supplicant_get_properties();
-       if (ret == NM_SUPPLICANT_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_supplicant_get_properties"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_supplicant_get_properties : %s ",
-                               print_supplicant_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_wfd_manager_init()
-{
-       int ret = 0;
-
-       ret = nm_wfd_manager_init();
-       if (ret == NM_WFD_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_wfd_manager_init"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_wfd_manager_init : %s ",
-                               print_wfd_manager_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_wfd_manager_deinit()
-{
-       int ret = 0;
-
-       ret = nm_wfd_manager_deinit();
-       if (ret == NM_WFD_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_wfd_manager_deinit"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_wfd_manager_deinit : %s ",
-                               print_wfd_manager_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_mobileap_init()
-{
-       int ret = 0;
-
-       ret = nm_mobileap_init();
-       if (ret == NM_MOBILEAP_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_mobileap_init"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_mobileap_init : %s ",
-                               print_mobileap_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_mobileap_deinit()
-{
-       int ret = 0;
-
-       ret = nm_mobileap_deinit();
-       if (ret == NM_MOBILEAP_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_mobileap_deinit"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_mobileap_deinit : %s ",
-                               print_mobileap_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void __nm_statistics_callback(nm_statistic_s *stats, gpointer user_data)
-{
-       printf("iface [%s] rx byte [%llu] rx packets [%llu] tx bytes [%llu] tx packets [%llu]\n",
-                       stats->ifname, stats->rx_bytes, stats->rx_packets, stats->tx_bytes, stats->tx_packets);
-
-}
-
-void test_nm_statistics_start_monitor()
-{
-       int ret = 0;
-
-
-       ret = nm_statistics_start_monitor(__nm_statistics_callback, NULL);
-       if (ret == NM_STATISTICS_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_statistics_start_monitor"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_statistics_start_monitor : %s ",
-                               print_statistics_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-       return;
-}
-
-void test_nm_statistics_stop_monitor()
-{
-       int ret = 0;
-
-       ret = nm_statistics_stop_monitor();
-       if (ret == NM_STATISTICS_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_statistics_stop_monitor"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_statistics_stop_monitor : %s ",
-                               print_statistics_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-       return;
-}
-
-void test_nm_statistics_is_enabled()
-{
-       gboolean is_enabled = FALSE;
-       int ret = 0;
-
-       ret = nm_statistics_is_enabled(&is_enabled);
-       if (ret == NM_STATISTICS_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_statistics_is_enabled"RESET_COLOR"\n");
-               printf("Enabled [%s]\n", is_enabled?"Yes":"No");
-       } else {
-               printf(MAKE_RED"nm_statistics_is_enabled : %s ",
-                               print_statistics_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-       return;
-}
-
-void test_nm_cong_mon_init()
-{
-       int ret = 0;
-
-       ret = nm_congestion_mon_init();
-       if (ret == NM_CONG_MON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_congestion_mon_init"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_congestion_mon_init: %s ",
-                               print_iface_mon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_cong_mon_deinit()
-{
-       int ret = 0;
-
-       ret = nm_congestion_mon_deinit();
-       if (ret == NM_CONG_MON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_congestion_mon_deinit"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_congestion_mon_deinit: %s ",
-                               print_iface_mon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_cong_mon_start_monitor()
-{
-       int ret = 0;
-
-       ret = nm_congestion_monitor_start(congestion_mon_callback, NULL);
-       if (ret == NM_CONG_MON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_congestion_monitor_start"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_congestion_monitor_start: %s ",
-                               print_iface_mon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void test_nm_cong_mon_stop_monitor()
-{
-       int ret = 0;
-
-       ret = nm_congestion_monitor_stop();
-       if (ret == NM_CONG_MON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_congestion_monitor_stop"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_congestion_monitor_stop: %s ",
-                               print_iface_mon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-
-       return;
-}
-
-void __nm_retry_tx_rate_callback(int retry_rate, gpointer user_data)
-{
-       printf("Retry Rate: %d\n", retry_rate);
-}
-
-void test_nm_retry_tx_rate_start_monitor()
-{
-       int ret = 0;
-
-       ret = nm_retry_tx_rate_monitor_start(__nm_retry_tx_rate_callback, NULL);
-       if (ret == NM_DAEMON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_retry_tx_rate_monitor_start"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_retry_tx_rate_monitor_start: %s ",
-                               print_nmdaemon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-       return;
-}
-
-void test_nm_retry_tx_rate_stop_monitor()
-{
-       int ret = 0;
-
-       ret = nm_retry_tx_rate_monitor_stop();
-       if (ret == NM_DAEMON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_retry_tx_rate_monitor_stop"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_retry_tx_rate_monitor_stop: %s ",
-                               print_nmdaemon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-       return;
-}
-
-void __nm_channel_interference_callback(int freq, double channel_intf, gpointer user_data)
-{
-       printf("Frequency: [%d] Channel Interference: [%lf]\n", freq, channel_intf);
-}
-
-void test_nm_channel_interference_start_monitor()
-{
-       int ret = 0;
-
-       ret = nm_channel_interference_monitor_start(__nm_channel_interference_callback, NULL);
-       if (ret == NM_DAEMON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_channel_interference_monitor_start"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_channel_interference_monitor_start: %s ",
-                               print_nmdaemon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-       return;
-}
-
-void test_nm_channel_interference_stop_monitor()
-{
-       int ret = 0;
-
-       ret = nm_channel_interference_monitor_stop();
-       if (ret == NM_DAEMON_ERROR_NONE) {
-               printf(MAKE_GREEN"nm_channel_interference_monitor_stop"RESET_COLOR"\n");
-       } else {
-               printf(MAKE_RED"nm_channel_interference_monitor_stop: %s ",
-                               print_nmdaemon_err(ret));
-               printf(RESET_COLOR"\n");
-       }
-       return;
-}
-
-typedef void (*test_func)(void);
-
-typedef struct {
-       int cmd;
-       test_func func;
-} menu_func_s;
-
-menu_func_s g_menu_func[] = {
-               {CMD_QUIT, test_quit },
-               {CMD_FULL_MENU, test_full_menu},
-               {CMD_IP_CONFLICT_INIT, test_ip_conflict_detection_init },
-               {CMD_IP_CONFLICT_DEINIT, test_ip_conflict_detection_deinit},
-               {CMD_IP_CONFLICT_GET_DETECTION_PERIOD, test_nm_ip_conflict_get_detection_period},
-               {CMD_IP_CONFLICT_SET_DETECTION_PERIOD, test_nm_ip_conflict_set_detection_period },
-               {CMD_IP_CONFLICT_GET_STATE, test_nm_ip_conflict_get_state},
-               {CMD_IP_CONFLICT_IS_DETECTION_ENABLED, test_nm_ip_conflict_is_detection_enabled},
-               {CMD_IP_CONFLICT_ENABLE_DETECTION, test_nm_ip_conflict_enable_detection},
-               {CMD_IP_CONFLICT_SET_CB, test_ip_conflict_set_callback},
-               {CMD_IP_CONFLICT_UNSET_CB, test_ip_conflict_unset_callback},
-
-               {CMD_DUMP_INIT, test_nm_dump_init},
-               {CMD_DUMP_DEINIT, test_nm_dump_deinit},
-               {CMD_DUMP_START_TCPDUMP, test_nm_dump_start_tcpdump},
-               {CMD_DUMP_STOP_TCPDUMP, test_nm_dump_stop_tcpdump},
-               {CMD_DUMP_GET_TCPDUMP_STATE, test_nm_dump_get_tcpdump_state},
-               {CMD_DUMP_LOG, test_nm_dump_log},
-               {CMD_DUMP_CHECK_STATE_AND_START, test_nm_dump_check_state_and_start},
-
-               {CMD_IFACE_MON_INIT, test_nm_iface_mon_init},
-               {CMD_IFACE_MON_DEINIT, test_nm_iface_mon_deinit},
-               {CMD_IFACE_MON_START, test_nm_iface_mon_start_monitor},
-               {CMD_IFACE_MON_STOP, test_nm_iface_mon_stop_monitor},
-               {CMD_IFACE_MON_GET_STATE, test_nm_iface_mon_get_iface_state},
-
-               {CMD_GDBUS_INIT, test_nm_gdbus_init},
-               {CMD_GDBUS_DEINIT, test_nm_gdbus_deinit},
-
-               {CMD_CONNMAN_INIT, test_nm_connman_init},
-               {CMD_CONNMAN_DEINIT, test_nm_connman_deinit},
-               {CMD_CONNMAN_MGR_GET_PROPERTIES, test_nm_connman_mgr_get_properties},
-               {CMD_CONNMAN_MGR_GET_SERVICES, test_nm_connman_mgr_get_services},
-               {CMD_CONNMAN_MGR_GET_TECHNOLOGIES, test_nm_connman_mgr_get_technologies},
-
-               {CMD_SUPPLICANT_INIT, test_nm_supplicant_init},
-               {CMD_SUPPLICANT_DEINIT, test_nm_supplicant_deinit},
-               {CMD_SUPPLICANT_GET_PROPERTIES, test_nm_supplicant_get_properties},
-
-               {CMD_WFD_MANAGER_INIT, test_nm_wfd_manager_init},
-               {CMD_WFD_MANAGER_DEINIT, test_nm_wfd_manager_deinit},
-
-               {CMD_MOBILEAP_INIT, test_nm_mobileap_init},
-               {CMD_MOBILEAP_DEINIT, test_nm_mobileap_deinit},
-
-               {CMD_STATISTICS_MON_START, test_nm_statistics_start_monitor},
-               {CMD_STATISTICS_MON_STOP, test_nm_statistics_stop_monitor},
-               {CMD_STATISTICS_IS_ENABLED, test_nm_statistics_is_enabled},
-
-               {CMD_CONG_MON_INIT, test_nm_cong_mon_init},
-               {CMD_CONG_MON_DEINIT, test_nm_cong_mon_deinit},
-               {CMD_CONG_MON_START, test_nm_cong_mon_start_monitor},
-               {CMD_CONG_MON_STOP, test_nm_cong_mon_stop_monitor},
-
-               {CMD_RETRY_TX_RATE_MON_START, test_nm_retry_tx_rate_start_monitor},
-               {CMD_RETRY_TX_RATE_MON_STOP, test_nm_retry_tx_rate_stop_monitor},
-
-               {CMD_CHANNEL_INTERFERENCE_MON_START, test_nm_channel_interference_start_monitor},
-               {CMD_CHANNEL_INTERFERENCE_MON_STOP, test_nm_channel_interference_stop_monitor},
-
-               { -1, NULL }, };
-
-void process_input(const char *input, gpointer user_data)
-{
-       int cmd = -1;
-
-       cmd = strtol(input, NULL, 0);
-       if (is_digit(input) < 0 || strlen(input) == 0 || errno == ERANGE || errno
-                       == EINVAL)
-               cmd = -1;
-
-       printf("cmd=[%d]\n", cmd);
-       if (cmd >= CMD_MAX || cmd < CMD_QUIT) {
-               printf("Invalid CMD\n");
-               return;
-       }
-       g_menu_func[cmd].func();
-}
-
-static gboolean test_terminal_read_std_input(GIOChannel * source,
-               GIOCondition condition, gpointer user_data)
-{
-       int fd = 0;
-
-       static char buf[1024];
-       int n;
-
-       errno = 0;
-       n = read(fd, buf, 1024);
-
-       buf[n - 1] = '\0'; /* remove new line... */
-       if (n == 0)
-               printf("Error: read() from stdin returns 0.\n");
-       else if (n < 0)
-               printf("input: read, err\n");
-       else
-               printf("\n\n");
-
-       process_input(buf, user_data);
-
-       return TRUE;
-}
-
-int main(int argc, char **argv)
-{
-
-#if !GLIB_CHECK_VERSION(2, 36, 0)
-       g_type_init();
-#endif
-
-       g_event_loop = g_main_loop_new(NULL, FALSE);
-
-       int std_input_fd = 0;
-       GIOChannel *gio2 = g_io_channel_unix_new(std_input_fd);
-       g_io_add_watch(gio2, G_IO_IN, (GIOFunc) test_terminal_read_std_input, NULL);
-       g_io_channel_unref(gio2);
-
-       usage_full();
-
-       g_main_loop_run(g_event_loop);
-
-       return 0;
-}
index 0f1242882daaee58691d3c8c342a1f8029afd79a..cbc5471f6ef70b08a90a0e523d31be261164d01d 100644 (file)
@@ -25,7 +25,7 @@ IF(BUILD_GTESTS)
 ENDIF(BUILD_GTESTS)
 
 FILE(GLOB GTEST_TEST_SRCS *.cpp ${CMAKE_SOURCE_DIR}/src/*.c)
-LIST(REMOVE_ITEM GTEST_TEST_SRCS ${CMAKE_SOURCE_DIR}/src/nm-daemon-main.c)
+LIST(REMOVE_ITEM GTEST_TEST_SRCS ${CMAKE_SOURCE_DIR}/src/inm-daemon-main.c)
 
 SET(GTEST_TEST_SRCS ${GTEST_TEST_SRCS} unittest.cpp)