Implement Mesh CAPI according to DBus API guide documents
authorsaerome.kim <saerome.kim@samsung.com>
Mon, 6 Mar 2017 12:14:25 +0000 (21:14 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 17 Jul 2017 02:09:10 +0000 (11:09 +0900)
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
include/mesh.h [changed mode: 0755->0644]
include/mesh_dbus.h [changed mode: 0755->0644]
include/mesh_private.h [changed mode: 0755->0644]
src/mesh.c [changed mode: 0755->0644]
src/mesh_dbus.c [changed mode: 0755->0644]
test/mesh_device.c [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index c065f8e..8609375
@@ -239,9 +239,8 @@ int mesh_disable(mesh_h handle);
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_enable()
+ * @see mesh_specific_scan()
+ * @see mesh_cancel_scan()
  *
  */
 int mesh_scan(mesh_h handle);
@@ -262,8 +261,8 @@ int mesh_scan(mesh_h handle);
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_initialize()
- * @see mesh_deinitialize()
+ * @see mesh_scan()
+ * @see mesh_cancel_scan()
  *
  */
 int mesh_specific_scan(mesh_h handle, const char* ssid, int channel);
@@ -282,15 +281,15 @@ int mesh_specific_scan(mesh_h handle, const char* ssid, int channel);
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_initialize()
- * @see mesh_deinitialize()
+ * @see mesh_scan()
+ * @see mesh_specific_scan()
  * @see mesh_scan()
  *
  */
 int mesh_cancel_scan(mesh_h handle);
 
 /**
- * @brief
+ * @brief Called after mesh_foreach_found_mesh_netwrok()
  * @details This function can receive scan results from mesh network.
  *
  * @since_tizen 4.0
@@ -298,15 +297,15 @@ int mesh_cancel_scan(mesh_h handle);
  * @param[out] network mesh bss information handle
  * @param[out] user_data user data pointer
  *
- * @pre The callback must be registered with mesh_enable()
+ * @pre The callback must be registered with mesh_foreach_found_mesh_netwrok()
  *
  * @see mesh_foreach_found_mesh_netwrok()
  */
 typedef void (*mesh_found_mesh_netwrok_cb)(mesh_network_h network, void* user_data);
 
 /**
- * @brief
- * @details
+ * @brief Gets scanned mesh network bss informatoin
+ * @details This function returns network information scanned through mesh_found_mesh_netwrok_cb.
  *
  * @since_tizen 4.0
  *
@@ -324,16 +323,17 @@ typedef void (*mesh_found_mesh_netwrok_cb)(mesh_network_h network, void* user_da
  * @see mesh_found_mesh_netwrok_cb()
  *
  */
-int mesh_foreach_found_mesh_netwrok(mesh_h handle, mesh_found_mesh_netwrok_cb cb, void *user_data);
+int mesh_foreach_found_mesh_netwrok(mesh_h handle,
+       mesh_found_mesh_netwrok_cb cb, void *user_data);
 
 /**
- * @brief Get information of all connected stations.
- * @details Get information about all stations present in the currently connected mesh network.
+ * @brief Get the mesh connection state.
+ * @details Check if current device is joined mesh network.
  *
  * @since_tizen 4.0
  *
  * @param[in] handle The mesh handle
- * @param[out] station The mesh station information handle
+ * @param[out] is_joined The state of mesh network connection.
  *
  *
  * @return 0 on success, otherwise a negative error value.
@@ -341,20 +341,20 @@ int mesh_foreach_found_mesh_netwrok(mesh_h handle, mesh_found_mesh_netwrok_cb cb
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_initialize()
- * @see mesh_deinitialize()
+ * @see mesh_enable_mesh()
+ * @see mesh_found_mesh_netwrok_cb()
  *
  */
-int mesh_get_station_info(mesh_h handle, mesh_station_info_h station);
+int mesh_is_joined(mesh_h handle, int* is_joined);
 
 /**
- * @brief Get information of all mesh paths.
- * @details Get information about all mesh paths present in the currently connected mesh network.
+ * @brief Gets current joined mesh network information.
+ * @details Return current joined mesh network information..
  *
  * @since_tizen 4.0
  *
  * @param[in] handle The mesh handle
- * @param[out] path The mesh path information handle
+ * @param[in] is_joined The state of mesh network connection.
  *
  *
  * @return 0 on success, otherwise a negative error value.
@@ -362,20 +362,20 @@ int mesh_get_station_info(mesh_h handle, mesh_station_info_h station);
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_initialize()
- * @see mesh_deinitialize()
+ * @see mesh_enable_mesh()
  *
  */
-int mesh_get_path_info(mesh_h handle, mesh_path_info_h path);
+int mesh_get_joined_network(mesh_h handle, mesh_network_h network);
 
 /**
- * @brief Join into specific mesh network.
- * @details Join into specific mesh network with given SSID.
+ * @brief Adds new mesh network configuration
+ * @details This function adds new network configuration.
  *
  * @since_tizen 4.0
  *
  * @param[in] handle The mesh handle
- * @param[in] ssid Specific SSID to scan
+ * @param[in] network callback function pointer to know saved network information
+ * @param[in] user_data user data pointer
  *
  *
  * @return 0 on success, otherwise a negative error value.
@@ -383,22 +383,38 @@ int mesh_get_path_info(mesh_h handle, mesh_path_info_h path);
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_is_joined()
- * @see mesh_disjoin()
+ * @see mesh_foreach_saved_mesh_network()
+ * @see mesh_saved_mesh_netwrok_cb()
+ * @see mesh_select_mesh_network()
+ * @see mesh_remove_mesh_network()
  *
  */
-int mesh_join(mesh_h handle, const char* ssid);
+int mesh_add_mesh_network(mesh_h handle, mesh_network_h network);
 
 /**
- * @brief Get the mesh connection state.
- * @details Check if current device is joined mesh network.
+ * @brief Called after mesh_foreach_saved_mesh_network()
+ * @details This function can receive saved mesh network configuration.
+ *
+ * @since_tizen 4.0
+ *
+ * @param[out] network saved network configuration handle
+ * @param[out] user_data user data pointer
+ *
+ * @pre The callback must be registered with mesh_foreach_saved_mesh_netwrok()
+ *
+ * @see mesh_foreach_saved_mesh_netwrok()
+ */
+typedef void (*mesh_saved_mesh_netwrok_cb)(mesh_network_h network, void* user_data);
+
+/**
+ * @brief Gets saved mesh network informatoin
+ * @details This function returns saved network information through mesh_saved_mesh_netwrok_cb.
  *
  * @since_tizen 4.0
  *
  * @param[in] handle The mesh handle
- * @param[in] is_joined The state of mesh network connection.
+ * @param[in] cb callback function pointer to know saved network information
+ * @param[in] user_data user data pointer
  *
  *
  * @return 0 on success, otherwise a negative error value.
@@ -406,20 +422,21 @@ int mesh_join(mesh_h handle, const char* ssid);
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_join()
+ * @see mesh_saved_mesh_netwrok_cb()
  *
  */
-int mesh_is_joined(mesh_h handle, int is_joined);
+int mesh_foreach_saved_mesh_network(mesh_h handle,
+       mesh_saved_mesh_netwrok_cb cb, void *user_data);
 
 /**
- * @brief Disconnect from joined mesh network.
- * @details Disconnect mesh network connection from current mesh network.
+ * @brief Seletcs existing mesh network configuration
+ * @details This function seletcs existing network configuration to connect.
  *
  * @since_tizen 4.0
  *
  * @param[in] handle The mesh handle
+ * @param[in] network callback function pointer to know saved network information
+ * @param[in] user_data user data pointer
  *
  *
  * @return 0 on success, otherwise a negative error value.
@@ -427,28 +444,23 @@ int mesh_is_joined(mesh_h handle, int is_joined);
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_join()
- * @see mesh_is_joined()
+ * @see mesh_foreach_saved_mesh_network()
+ * @see mesh_saved_mesh_netwrok_cb()
+ * @see mesh_select_mesh_network()
+ * @see mesh_add_mesh_network()
  *
  */
-int mesh_disjoin(mesh_h handle);
+int mesh_select_mesh_network(mesh_h handle, mesh_network_h network);
 
 /**
- * @brief Set AP setting with given parameters.
- * @details Set SoftAP parameters to use configured AP settings.
+ * @brief Removes existing mesh network configuration
+ * @details This function removes new network configuration.
  *
  * @since_tizen 4.0
  *
  * @param[in] handle The mesh handle
- * @param[in] ssid SSID for SoftAP
- * @param[in] key The key for SoftAP
- * @param[in] mode SoftAP mode
- * @param[in] channel The channel number
- * @param[in] visibility The visibility of SoftAP
- * @param[in] max_stations Max acceptable station number.
- * @param[in] security Security type of SoftAP
+ * @param[in] network callback function pointer to know saved network information
+ * @param[in] user_data user data pointer
  *
  *
  * @return 0 on success, otherwise a negative error value.
@@ -456,24 +468,22 @@ int mesh_disjoin(mesh_h handle);
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_initialize()
- * @see mesh_deinitialize()
+ * @see mesh_foreach_saved_mesh_network()
+ * @see mesh_saved_mesh_netwrok_cb()
+ * @see mesh_select_mesh_network()
+ * @see mesh_add_mesh_network()
  *
  */
-int mesh_load_softap_settings(mesh_h handle, const char* ssid,
-               const char* key, const char* mode,
-               int channel, int visibility,
-               int max_stations, int security);
+int mesh_remove_mesh_network(mesh_h handle, mesh_network_h network);
 
 /**
- * @brief Start bridging for mesh network.
- * @details For mesh gate, network bridging is required to communicate with external network.
+ * @brief Get information of all connected stations.
+ * @details Get information about all stations present in the currently connected mesh network.
  *
  * @since_tizen 4.0
  *
  * @param[in] handle The mesh handle
- * @param[in] interface The interface name of bridge.
- * @param[in] mode Mode
+ * @param[out] station The mesh station information handle
  *
  *
  * @return 0 on success, otherwise a negative error value.
@@ -481,20 +491,19 @@ int mesh_load_softap_settings(mesh_h handle, const char* ssid,
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_stop_bridge()
+ * @see mesh_get_path_info()
  *
  */
-int mesh_start_bridge(mesh_h handle, const char* interface, int mode);
+int mesh_get_station_info(mesh_h handle, mesh_station_info_h station);
 
 /**
- * @brief Stop bridging for mesh network.
- * @details For mesh gate, network bridging is required to communicate with external network.
+ * @brief Get information of all mesh paths.
+ * @details Get information about all mesh paths present in the currently connected mesh network.
  *
  * @since_tizen 4.0
  *
  * @param[in] handle The mesh handle
+ * @param[out] path The mesh path information handle
  *
  *
  * @return 0 on success, otherwise a negative error value.
@@ -502,14 +511,32 @@ int mesh_start_bridge(mesh_h handle, const char* interface, int mode);
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
  *
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_start_bridge()
+ * @see mesh_get_station_info()
  *
  */
-int mesh_stop_bridge(mesh_h handle);
+int mesh_get_path_info(mesh_h handle, mesh_path_info_h path);
 
 /**
+ * @brief Sets network device interface name.
+ * @details This function provides the ability to manually select interfaces for advanced users.
+ *
+ * @since_tizen 4.0
+ *
+ * @param[in] handle The mesh handle
+ * @param[in] mesh An interface name for mesh network
+ * @param[in] gate An interface name for external network
+ * @param[in] softap An interface name for internal softap
+ *
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MESH_ERROR_NONE Successful
+ * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
+ *
+ */
+int mesh_set_interface(mesh_h handle,
+       const char *mesh, const char* gate, const char *softap);
+/**
  * @}
  */
 
old mode 100755 (executable)
new mode 100644 (file)
index 61e06df..7007bae
@@ -38,20 +38,33 @@ int _mesh_disable(mesh_h handle);
 int _mesh_scan(mesh_h handle);
 int _mesh_specific_scan(mesh_h handle, const char* ssid, int channel);
 int _mesh_cancel_scan(mesh_h handle);
-int _mesh_get_station_info(mesh_h handle, void *station);
-int _mesh_get_path_info(mesh_h handle, void *mpath_data);
+int _mesh_foreach_found_mesh_network(mesh_h handle,
+       mesh_found_mesh_netwrok_cb cb, void *user_data);
 int _mesh_enable_mesh(mesh_h handle);
 int _mesh_disable_mesh(mesh_h handle);
+int _mesh_is_joined(mesh_h handle, int* is_joined);
+int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h _network);
 int _mesh_set_gate(mesh_h handle, bool stp, bool gate_announce);
 int _mesh_unset_gate(mesh_h handle);
-int _mesh_set_softap(mesh_h handle, const char* ssid,
-               const char* key, const char* mode,
-               int channel, int visibility,
-               int max_stations, int security);
+int _mesh_set_softap(mesh_h handle, const char* ssid, const char* key, const char* mode,
+               int channel, int visibility, int max_stations, int security);
 int _mesh_enable_softap(mesh_h handle);
 int _mesh_disable_softap(mesh_h handle);
+int _mesh_add_network(mesh_h handle, mesh_network_h _network);
+int _mesh_foreach_saved_mesh_netwrok(mesh_h handle,
+       mesh_saved_mesh_netwrok_cb cb, void *user_data);
+int _mesh_select_network(mesh_h handle, mesh_network_h _network);
+int _mesh_remove_network(mesh_h handle, mesh_network_h _network);
+int _mesh_set_interface(mesh_h handle, const char *mesh, const char *gate, const char *softap);
+int _mesh_get_station_info(mesh_h handle, void *station);
+int _mesh_get_path_info(mesh_h handle, void *mpath_data);
+int _mesh_join(mesh_h handle, const char* ssid);
 int _mesh_is_joined(mesh_h handle, int is_joined);
 int _mesh_disjoin(mesh_h handle);
+int _mesh_load_softap_settings(mesh_h handle, const char* ssid,
+               const char* key, const char* mode,
+               int channel, int visibility,
+               int max_stations, int security);
 int _mesh_start_bridge(mesh_h handle, const char* interface, int mode);
 int _mesh_stop_bridge(mesh_h handle);
 
old mode 100755 (executable)
new mode 100644 (file)
index 695fa7a..e540475
@@ -82,12 +82,13 @@ struct mesh_handle {
 #endif
 } mesh_handle_s;
 
-struct mesh_found_network_s {
-       char *meshid; /**< meshid */
-       char *bssid; /**< bssid */
+struct mesh_network_s {
+       char meshid[32]; /**< meshid */
+       char bssid[32]; /**< bssid */
        int channel; /**< channel */
        int rssi; /**< rssi */
        int data_rate; /**< data rate */
+       int security; /**< security type */
 };
 
 struct mesh_station_info_s {
@@ -136,6 +137,8 @@ struct mesh_mpath_dump_s {
        int flags; /**< flags */
 };
 
+#define NOTUSED(var) (var = var)
+
 const char* _mesh_internal_error_to_string(mesh_internal_err_e err);
 
 #endif /* __CAPI_MESH_PRIVATE_H__ */
old mode 100755 (executable)
new mode 100644 (file)
index 718acf9..72c920d
@@ -117,6 +117,21 @@ EXPORT_API int mesh_scan(mesh_h handle)
        return MESH_ERROR_NONE;
 }
 
+EXPORT_API int mesh_cancel_scan(mesh_h handle)
+{
+       int rv = 0;
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+       rv = _mesh_cancel_scan(handle);
+       if (rv == MESH_ITNL_ERR_IO_ERROR) {
+               return MESH_ERROR_IO_ERROR;
+       }
+
+       return MESH_ERROR_NONE;
+}
+
 EXPORT_API int mesh_specific_scan(mesh_h handle, const char* ssid, int channel)
 {
        int rv = 0;
@@ -133,14 +148,16 @@ EXPORT_API int mesh_specific_scan(mesh_h handle, const char* ssid, int channel)
        return MESH_ERROR_NONE;
 }
 
-EXPORT_API int mesh_cancel_scan(mesh_h handle)
+EXPORT_API int mesh_foreach_round_mesh_network(mesh_h handle,
+       mesh_found_mesh_netwrok_cb cb, void *user_data)
 {
        int rv = 0;
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
+       RETV_IF(NULL == cb, MESH_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
 
-       rv = _mesh_cancel_scan(handle);
+       rv = _mesh_foreach_found_mesh_network(handle, cb, user_data);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
                return MESH_ERROR_IO_ERROR;
        }
@@ -148,14 +165,14 @@ EXPORT_API int mesh_cancel_scan(mesh_h handle)
        return MESH_ERROR_NONE;
 }
 
-EXPORT_API int mesh_get_station_info(mesh_h handle, mesh_station_info_h station)
+EXPORT_API int mesh_enable_mesh(mesh_h handle)
 {
        int rv = 0;
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
 
-       rv = _mesh_get_station_info(handle, station);
+       rv = _mesh_enable_mesh(handle);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
                return MESH_ERROR_IO_ERROR;
        }
@@ -163,14 +180,14 @@ EXPORT_API int mesh_get_station_info(mesh_h handle, mesh_station_info_h station)
        return MESH_ERROR_NONE;
 }
 
-EXPORT_API int mesh_get_path_info(mesh_h handle, mesh_path_info_h path)
+EXPORT_API int mesh_disable_mesh(mesh_h handle)
 {
        int rv = 0;
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
 
-       rv = _mesh_get_path_info(handle, path);
+       rv = _mesh_disable_mesh(handle);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
                return MESH_ERROR_IO_ERROR;
        }
@@ -178,15 +195,14 @@ EXPORT_API int mesh_get_path_info(mesh_h handle, mesh_path_info_h path)
        return MESH_ERROR_NONE;
 }
 
-EXPORT_API int mesh_enable_mesh(mesh_h handle, const char* ssid)
+EXPORT_API int mesh_is_joined(mesh_h handle, int* is_joined)
 {
        int rv = 0;
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
-       RETV_IF(NULL == ssid, MESH_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
 
-       rv = _mesh_enable_mesh(handle);
+       rv = _mesh_is_joined(handle, is_joined);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
                return MESH_ERROR_IO_ERROR;
        }
@@ -194,14 +210,29 @@ EXPORT_API int mesh_enable_mesh(mesh_h handle, const char* ssid)
        return MESH_ERROR_NONE;
 }
 
-EXPORT_API int mesh_is_joined(mesh_h handle, int is_joined)
+EXPORT_API int mesh_get_joined_network(mesh_h handle, mesh_network_h network)
 {
        int rv = 0;
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
 
-       rv = _mesh_is_joined(handle, is_joined);
+       rv = _mesh_get_joined_mesh_network(handle, network);
+       if (rv == MESH_ITNL_ERR_IO_ERROR) {
+               return MESH_ERROR_IO_ERROR;
+       }
+
+       return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_set_gate(mesh_h handle, bool stp, bool gate_announce)
+{
+       int rv = 0;
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+       rv = _mesh_set_gate(handle, stp, gate_announce);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
                return MESH_ERROR_IO_ERROR;
        }
@@ -209,14 +240,14 @@ EXPORT_API int mesh_is_joined(mesh_h handle, int is_joined)
        return MESH_ERROR_NONE;
 }
 
-EXPORT_API int mesh_disjoin(mesh_h handle)
+EXPORT_API int mesh_unset_gate(mesh_h handle)
 {
        int rv = 0;
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
 
-       rv = _mesh_disjoin(handle);
+       rv = _mesh_unset_gate(handle);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
                return MESH_ERROR_IO_ERROR;
        }
@@ -224,7 +255,7 @@ EXPORT_API int mesh_disjoin(mesh_h handle)
        return MESH_ERROR_NONE;
 }
 
-EXPORT_API int mesh_load_softap_settings(mesh_h handle, const char* ssid,
+EXPORT_API int mesh_set_softap(mesh_h handle, const char* ssid,
                const char* key, const char* mode,
                int channel, int visibility,
                int max_stations, int security)
@@ -246,15 +277,29 @@ EXPORT_API int mesh_load_softap_settings(mesh_h handle, const char* ssid,
        return MESH_ERROR_NONE;
 }
 
-EXPORT_API int mesh_start_bridge(mesh_h handle, const char* interface, int mode)
+EXPORT_API int mesh_enable_softap(mesh_h handle)
+{
+       int rv = 0;
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+       rv = _mesh_enable_softap(handle);
+       if (rv == MESH_ITNL_ERR_IO_ERROR) {
+               return MESH_ERROR_IO_ERROR;
+       }
+
+       return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_disable_softap(mesh_h handle)
 {
        int rv = 0;
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
-       RETV_IF(NULL == interface, MESH_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
 
-       rv = _mesh_start_bridge(handle, interface, mode);
+       rv = _mesh_disable_softap(handle);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
                return MESH_ERROR_IO_ERROR;
        }
@@ -262,17 +307,112 @@ EXPORT_API int mesh_start_bridge(mesh_h handle, const char* interface, int mode)
        return MESH_ERROR_NONE;
 }
 
-EXPORT_API int mesh_stop_bridge(mesh_h handle)
+EXPORT_API int mesh_add_mesh_network(mesh_h handle, mesh_network_h network)
 {
        int rv = 0;
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
        RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
 
-       rv = _mesh_stop_bridge(handle);
+       rv = _mesh_add_network(handle, network);
        if (rv == MESH_ITNL_ERR_IO_ERROR) {
                return MESH_ERROR_IO_ERROR;
        }
 
        return MESH_ERROR_NONE;
 }
+
+EXPORT_API int mesh_foreach_saved_mesh_network(mesh_h handle,
+       mesh_found_mesh_netwrok_cb cb, void *user_data)
+{
+       int rv = 0;
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       RETV_IF(NULL == cb, MESH_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+       rv = _mesh_foreach_saved_mesh_netwrok(handle, cb, user_data);
+       if (rv == MESH_ITNL_ERR_IO_ERROR) {
+               return MESH_ERROR_IO_ERROR;
+       }
+
+       return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_select_mesh_network(mesh_h handle, mesh_network_h network)
+{
+       int rv = 0;
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+       rv = _mesh_select_network(handle, network);
+       if (rv == MESH_ITNL_ERR_IO_ERROR) {
+               return MESH_ERROR_IO_ERROR;
+       }
+
+       return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_remove_mesh_network(mesh_h handle, mesh_network_h network)
+{
+       int rv = 0;
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+       rv = _mesh_remove_network(handle, network);
+       if (rv == MESH_ITNL_ERR_IO_ERROR) {
+               return MESH_ERROR_IO_ERROR;
+       }
+
+       return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_get_station_info(mesh_h handle, mesh_station_info_h station)
+{
+       int rv = 0;
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+       rv = _mesh_get_station_info(handle, station);
+       if (rv == MESH_ITNL_ERR_IO_ERROR) {
+               return MESH_ERROR_IO_ERROR;
+       }
+
+       return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_get_path_info(mesh_h handle, mesh_path_info_h path)
+{
+       int rv = 0;
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+       rv = _mesh_get_path_info(handle, path);
+       if (rv == MESH_ITNL_ERR_IO_ERROR) {
+               return MESH_ERROR_IO_ERROR;
+       }
+
+       return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_set_interface(mesh_h handle,
+       const char *mesh, const char* gate, const char *softap)
+{
+       int rv = 0;
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       RETV_IF(NULL == mesh, MESH_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+       rv = _mesh_set_interface(handle, mesh, gate, softap);
+       if (rv == MESH_ITNL_ERR_IO_ERROR) {
+               return MESH_ERROR_IO_ERROR;
+       }
+
+       return MESH_ERROR_NONE;
+}
+
old mode 100755 (executable)
new mode 100644 (file)
index dfca6e2..c5f52be
@@ -150,7 +150,7 @@ struct mesh_network_list_s g_networks;
 
 static void _mesh_free_network(gpointer data)
 {
-       struct mesh_found_network_s *network = data;
+       struct mesh_network_s *network = data;
        g_free(network->meshid);
        g_free(network->bssid);
        g_free(network);
@@ -337,7 +337,7 @@ int _mesh_cancel_scan(mesh_h handle)
        return MESH_ITNL_ERR_NONE;
 }
 
-int _mesh_foreach_found_mesh_netwrok(mesh_h handle,
+int _mesh_foreach_found_mesh_network(mesh_h handle,
        mesh_found_mesh_netwrok_cb cb, void *user_data)
 {
        GVariant *variant = NULL;
@@ -370,17 +370,21 @@ int _mesh_foreach_found_mesh_netwrok(mesh_h handle,
                g_variant_iter_init(&iter, params);
                while (g_variant_iter_loop(&iter, "(a{sv})", &inner_params)) {
 
-                       struct mesh_found_network_s *network_info =
-                               g_malloc0(sizeof(struct mesh_found_network_s));
+                       struct mesh_network_s *network_info =
+                               g_malloc0(sizeof(struct mesh_network_s));
 
                        g_variant_iter_init(&inner_iter, inner_params);
                        while (g_variant_iter_loop(&inner_iter, "{sv}", &key, &val)) {
                                if (strcasecmp(key, "meshid") == 0)  {
-                                       network_info->meshid = g_variant_dup_string(val, &len);
+                                       const char *buf = g_variant_get_string(val, &len);
+                                       memcpy(network_info->meshid, buf, len);
+                                       //network_info->meshid = g_variant_get_string(val, &len);
                                        LOGE("meshid=%s", network_info->meshid);
                                }
                                else if (strcasecmp(key, "bssid") == 0)  {
-                                       network_info->bssid = g_variant_dup_string(val, &len);
+                                       const char *buf = g_variant_get_string(val, &len);
+                                       memcpy(network_info->bssid, buf, len);
+                                       //network_info->bssid = g_variant_dup_string(val, &len);
                                        LOGE("bssid = %s", network_info->bssid);
                                }
                                else if (strcasecmp(key, "channel") == 0)  {
@@ -467,7 +471,35 @@ int _mesh_disable_mesh(mesh_h handle)
        return MESH_ITNL_ERR_NONE;
 }
 
-int _mesh_get_joined_mesh_network(mesh_h handle)
+/* TODO: Parameter verification required */
+int _mesh_is_joined(mesh_h handle, int* is_joined)
+{
+       GVariant *variant = NULL;
+       unsigned int result;
+       GError *error = NULL;
+       struct mesh_handle *h = handle;
+
+       RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
+       RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
+
+       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "is_joined",
+                               g_variant_new("(b)", (is_joined==0) ? FALSE : TRUE),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL, &error);
+       if (variant) {
+               g_variant_get(variant, "(u)", &result);
+               LOGD("Mesh is_joined status 0x%x", result);
+       } else if (error) {
+               LOGE("Failed DBus call [%s]", error->message);
+               g_error_free(error);
+               return MESH_ITNL_ERR_IO_ERROR;
+       }
+
+       return MESH_ITNL_ERR_NONE;
+}
+
+int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h _network)
 {
        GVariant *variant = NULL;
        GError *error = NULL;
@@ -475,6 +507,7 @@ int _mesh_get_joined_mesh_network(mesh_h handle)
 
        RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
+       RETV_IF(NULL == _network, MESH_ITNL_ERR_INVALID_PARAM);
 
        variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_joined_mesh_network",
                                NULL,
@@ -482,13 +515,24 @@ int _mesh_get_joined_mesh_network(mesh_h handle)
                                -1,
                                NULL, &error);
        if (variant) {
-               gchar *meshid = NULL;
-               gchar *bssid = NULL;
+               struct mesh_network_s *n = _network;
+               int len;
+               char *meshid = NULL;
+               char *bssid = NULL;
                int channel, max_speed;
                unsigned int result;
 
                g_variant_get(variant, "(ssiiu)", meshid, bssid, &channel, &max_speed, &result);
                LOGD("get_joined_mesh_network status 0x%x", result);
+
+               len = strlen(meshid);
+               memcpy(n->meshid, meshid, len > 32 ? 32 : len);
+               len = strlen(bssid);
+               memcpy(n->bssid, bssid, len > 32 ? 32 : len);
+               n->channel = channel;
+               n->data_rate = max_speed;
+               n->rssi = -1;
+
        } else if (error) {
                LOGE("Failed DBus call [%s]", error->message);
                g_error_free(error);
@@ -583,62 +627,79 @@ int _mesh_set_softap(mesh_h handle, const char* ssid,
        return MESH_ITNL_ERR_NONE;
 }
 
-struct mesh_station_info_s g_station;
-
-int _mesh_get_station_info(mesh_h handle, void *station)
+int _mesh_enable_softap(mesh_h handle)
 {
        GVariant *variant = NULL;
        unsigned int result;
        GError *error = NULL;
        struct mesh_handle *h = handle;
 
-       GVariant *params = NULL;
-       GVariant *inner_params = NULL;
-       GVariantIter iter, inner_iter;
-
-       gchar *key;
-       GVariant *val;
-       gsize len = 0;
+       RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
+       RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
 
-       if (g_station.station) {
-               g_free(g_station.station);
+       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "enable_softap",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL, &error);
+       if (variant) {
+               g_variant_get(variant, "(u)", &result);
+               LOGD("enable_softap status 0x%x", result);
+       } else if (error) {
+               LOGE("Failed DBus call [%s]", error->message);
+               g_error_free(error);
+               return MESH_ITNL_ERR_IO_ERROR;
        }
-       memset(&g_station, 0, sizeof(g_station));
+
+       return MESH_ITNL_ERR_NONE;
+}
+
+int _mesh_disable_softap(mesh_h handle)
+{
+       GVariant *variant = NULL;
+       unsigned int result;
+       GError *error = NULL;
+       struct mesh_handle *h = handle;
 
        RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
 
-       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_station_info",
+       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "disable_softap",
                                NULL,
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL, &error);
        if (variant) {
-               g_variant_get(variant, "(a(a{sv})u)", &params, &result);
+               g_variant_get(variant, "(u)", &result);
+               LOGD("disable_softap status 0x%x", result);
+       } else if (error) {
+               LOGE("Failed DBus call [%s]", error->message);
+               g_error_free(error);
+               return MESH_ITNL_ERR_IO_ERROR;
+       }
 
-               /* TODO: handle station list here */
-               g_variant_iter_init(&iter, params);
-               while (g_variant_iter_loop(&iter, "(a{sv})", &inner_params)) {
+       return MESH_ITNL_ERR_NONE;
+}
 
-                       g_variant_iter_init(&inner_iter, inner_params);
-                       while (g_variant_iter_loop(&inner_iter, "{sv}", &key, &val)) {
-                               if (strcasecmp(key, "station") == 0)  {
-                                       g_station.station = g_variant_dup_string(val, &len);
-                                       LOGE("station= %s", g_station.station);
-                               }
-                               else if (strcasecmp(key, "inactive_time") == 0)  {
-                                       g_station.inactive_time = g_variant_get_uint32(val);
-                                       LOGE("inactive_time= %s", g_station.inactive_time);
-                               }
-                               else if (strcasecmp(key, "rx_bytes") == 0)  {
-                                       g_station.rx_bytes = g_variant_get_uint32(val);
-                                       LOGE("rx_bytes= %s", g_station.rx_bytes);
-                               }
-                       }
-                       g_variant_unref(inner_params);
-               }
-               g_variant_unref(params);
+int _mesh_add_network(mesh_h handle, mesh_network_h _network)
+{
+       GVariant *variant = NULL;
+       unsigned int result;
+       GError *error = NULL;
+       struct mesh_handle *h = handle;
+       struct mesh_network_s *n = _network;
+
+       RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
+       RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
 
+       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "add_network",
+                               g_variant_new("(sii)", n->meshid, n->channel, n->security),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL, &error);
+       if (variant) {
+               g_variant_get(variant, "(u)", &result);
+               LOGD("add_network status 0x%x", result);
        } else if (error) {
                LOGE("Failed DBus call [%s]", error->message);
                g_error_free(error);
@@ -646,10 +707,10 @@ int _mesh_get_station_info(mesh_h handle, void *station)
        }
 
        return MESH_ITNL_ERR_NONE;
-
 }
 
-int _mesh_get_path_info(mesh_h handle, void* mpath_data)
+int _mesh_foreach_saved_mesh_netwrok(mesh_h handle,
+       mesh_saved_mesh_netwrok_cb cb, void *user_data)
 {
        GVariant *variant = NULL;
        unsigned int result;
@@ -664,44 +725,52 @@ int _mesh_get_path_info(mesh_h handle, void* mpath_data)
        GVariant *val;
        gsize len = 0;
 
+       _mesh_remove_networks();
+
        RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
 
-       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_mpath_info",
+       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_found_mesh_networks",
                                NULL,
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL, &error);
        if (variant) {
-               g_variant_get(variant, "(a(a{sv})u)", &params, &result);
-
                /* handle station list here */
-               _mesh_remove_mpath();
+               g_variant_get(variant, "(a(a{sv})u)", &params, &result);
 
                g_variant_iter_init(&iter, params);
                while (g_variant_iter_loop(&iter, "(a{sv})", &inner_params)) {
-                       struct mesh_mpath_dump_s *mpath = g_malloc0(sizeof(struct mesh_mpath_dump_s));
+
+                       struct mesh_network_s *network_info =
+                               g_malloc0(sizeof(struct mesh_network_s));
+
                        g_variant_iter_init(&inner_iter, inner_params);
                        while (g_variant_iter_loop(&inner_iter, "{sv}", &key, &val)) {
-                               if (strcasecmp(key, "dest_addr") == 0)  {
-                                       mpath->dest_addr = g_variant_dup_string(val, &len);
-                                       LOGE("dest_addr= %s", mpath->dest_addr);
-                               }
-                               else if (strcasecmp(key, "next_hop") == 0)  {
-                                       mpath->next_hop = g_variant_dup_string(val, &len);
-                                       LOGE("next_hop= %s", mpath->next_hop);
+                               if (strcasecmp(key, "meshid") == 0)  {
+                                       const char *buf = g_variant_get_string(val, &len);
+                                       memcpy(network_info->meshid, buf, len);
+                                       //network_info->meshid = g_variant_dup_string(val, &len);
+                                       LOGE("meshid=%s", network_info->meshid);
                                }
-                               else if (strcasecmp(key, "iface") == 0)  {
-                                       mpath->iface = g_variant_dup_string(val, &len);
-                                       LOGE("iface= %s", mpath->iface);
+                               else if (strcasecmp(key, "bssid") == 0)  {
+                                       const char *buf = g_variant_get_string(val, &len);
+                                       memcpy(network_info->bssid, buf, len);
+                                       //network_info->bssid = g_variant_dup_string(val, &len);
+                                       LOGE("bssid = %s", network_info->bssid);
                                }
+                               else if (strcasecmp(key, "channel") == 0)  {
+                                       network_info->channel = g_variant_get_int32(val);
+                                       LOGE("channel = %d", network_info->channel);
 
-                               _mesh_add_mpath((gpointer)mpath);
+                                       _mesh_append_network(network_info);
+                                       if (cb) cb(network_info, user_data);
+                               }
                        }
                        g_variant_unref(inner_params);
                }
-
                g_variant_unref(params);
+               LOGD("get_saved_mesh_networks status 0x%x", result);
 
        } else if (error) {
                LOGE("Failed DBus call [%s]", error->message);
@@ -711,25 +780,26 @@ int _mesh_get_path_info(mesh_h handle, void* mpath_data)
 
        return MESH_ITNL_ERR_NONE;
 }
-#if 1
-int _mesh_join(mesh_h handle, const char* ssid)
+
+int _mesh_select_network(mesh_h handle, mesh_network_h _network)
 {
        GVariant *variant = NULL;
        unsigned int result;
        GError *error = NULL;
        struct mesh_handle *h = handle;
+       struct mesh_network_s *n = _network;
 
        RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
 
-       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "join",
-                               g_variant_new("(s)", ssid),
+       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "select_network",
+                               g_variant_new("(sii)", n->meshid, n->channel, n->security),
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL, &error);
        if (variant) {
                g_variant_get(variant, "(u)", &result);
-               LOGD("Mesh join status 0x%x", result);
+               LOGD("select_network status 0x%x", result);
        } else if (error) {
                LOGE("Failed DBus call [%s]", error->message);
                g_error_free(error);
@@ -739,25 +809,25 @@ int _mesh_join(mesh_h handle, const char* ssid)
        return MESH_ITNL_ERR_NONE;
 }
 
-/* TODO: Parameter verification required */
-int _mesh_is_joined(mesh_h handle, int is_joined)
+int _mesh_remove_network(mesh_h handle, mesh_network_h _network)
 {
        GVariant *variant = NULL;
        unsigned int result;
        GError *error = NULL;
        struct mesh_handle *h = handle;
+       struct mesh_network_s *n = _network;
 
        RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
 
-       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "is_joined",
-                               g_variant_new("(b)", (is_joined==0) ? FALSE : TRUE),
+       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "remove_network",
+                               g_variant_new("(sii)", n->meshid, n->channel, n->security),
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL, &error);
        if (variant) {
                g_variant_get(variant, "(u)", &result);
-               LOGD("Mesh is_joined status 0x%x", result);
+               LOGD("remove_network status 0x%x", result);
        } else if (error) {
                LOGE("Failed DBus call [%s]", error->message);
                g_error_free(error);
@@ -767,24 +837,63 @@ int _mesh_is_joined(mesh_h handle, int is_joined)
        return MESH_ITNL_ERR_NONE;
 }
 
-int _mesh_disjoin(mesh_h handle)
+
+struct mesh_station_info_s g_station;
+
+int _mesh_get_station_info(mesh_h handle, void *station)
 {
        GVariant *variant = NULL;
        unsigned int result;
        GError *error = NULL;
        struct mesh_handle *h = handle;
 
+       GVariant *params = NULL;
+       GVariant *inner_params = NULL;
+       GVariantIter iter, inner_iter;
+
+       gchar *key;
+       GVariant *val;
+       gsize len = 0;
+
+       if (g_station.station) {
+               g_free(g_station.station);
+       }
+       memset(&g_station, 0, sizeof(g_station));
+
        RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
 
-       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "disjoin",
+       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_station_info",
                                NULL,
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL, &error);
        if (variant) {
-               g_variant_get(variant, "(u)", &result);
-               LOGD("Mesh disjoin status 0x%x", result);
+               g_variant_get(variant, "(a(a{sv})u)", &params, &result);
+
+               /* TODO: handle station list here */
+               g_variant_iter_init(&iter, params);
+               while (g_variant_iter_loop(&iter, "(a{sv})", &inner_params)) {
+
+                       g_variant_iter_init(&inner_iter, inner_params);
+                       while (g_variant_iter_loop(&inner_iter, "{sv}", &key, &val)) {
+                               if (strcasecmp(key, "station") == 0)  {
+                                       g_station.station = g_variant_dup_string(val, &len);
+                                       LOGE("station= %s", g_station.station);
+                               }
+                               else if (strcasecmp(key, "inactive_time") == 0)  {
+                                       g_station.inactive_time = g_variant_get_uint32(val);
+                                       LOGE("inactive_time= %s", g_station.inactive_time);
+                               }
+                               else if (strcasecmp(key, "rx_bytes") == 0)  {
+                                       g_station.rx_bytes = g_variant_get_uint32(val);
+                                       LOGE("rx_bytes= %s", g_station.rx_bytes);
+                               }
+                       }
+                       g_variant_unref(inner_params);
+               }
+               g_variant_unref(params);
+
        } else if (error) {
                LOGE("Failed DBus call [%s]", error->message);
                g_error_free(error);
@@ -792,26 +901,63 @@ int _mesh_disjoin(mesh_h handle)
        }
 
        return MESH_ITNL_ERR_NONE;
+
 }
 
-int _mesh_start_bridge(mesh_h handle, const char* interface, int mode)
+int _mesh_get_path_info(mesh_h handle, void* mpath_data)
 {
        GVariant *variant = NULL;
        unsigned int result;
        GError *error = NULL;
        struct mesh_handle *h = handle;
 
+       GVariant *params = NULL;
+       GVariant *inner_params = NULL;
+       GVariantIter iter, inner_iter;
+
+       gchar *key;
+       GVariant *val;
+       gsize len = 0;
+
        RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
 
-       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "start_bridge",
-                               g_variant_new("(is)", mode, interface),
+       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_mpath_info",
+                               NULL,
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL, &error);
        if (variant) {
-               g_variant_get(variant, "(u)", &result);
-               LOGD("Mesh bridge start status 0x%x", result);
+               g_variant_get(variant, "(a(a{sv})u)", &params, &result);
+
+               /* handle station list here */
+               _mesh_remove_mpath();
+
+               g_variant_iter_init(&iter, params);
+               while (g_variant_iter_loop(&iter, "(a{sv})", &inner_params)) {
+                       struct mesh_mpath_dump_s *mpath = g_malloc0(sizeof(struct mesh_mpath_dump_s));
+                       g_variant_iter_init(&inner_iter, inner_params);
+                       while (g_variant_iter_loop(&inner_iter, "{sv}", &key, &val)) {
+                               if (strcasecmp(key, "dest_addr") == 0)  {
+                                       mpath->dest_addr = g_variant_dup_string(val, &len);
+                                       LOGE("dest_addr= %s", mpath->dest_addr);
+                               }
+                               else if (strcasecmp(key, "next_hop") == 0)  {
+                                       mpath->next_hop = g_variant_dup_string(val, &len);
+                                       LOGE("next_hop= %s", mpath->next_hop);
+                               }
+                               else if (strcasecmp(key, "iface") == 0)  {
+                                       mpath->iface = g_variant_dup_string(val, &len);
+                                       LOGE("iface= %s", mpath->iface);
+                               }
+
+                               _mesh_add_mpath((gpointer)mpath);
+                       }
+                       g_variant_unref(inner_params);
+               }
+
+               g_variant_unref(params);
+
        } else if (error) {
                LOGE("Failed DBus call [%s]", error->message);
                g_error_free(error);
@@ -821,30 +967,18 @@ int _mesh_start_bridge(mesh_h handle, const char* interface, int mode)
        return MESH_ITNL_ERR_NONE;
 }
 
-int _mesh_stop_bridge(mesh_h handle)
+int _mesh_set_interface(mesh_h handle, const char *mesh, const char *gate, const char *softap)
 {
-       GVariant *variant = NULL;
-       unsigned int result;
-       GError *error = NULL;
        struct mesh_handle *h = handle;
 
        RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
 
-       variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "stop_bridge",
-                               NULL,
-                               G_DBUS_CALL_FLAGS_NONE,
-                               -1,
-                               NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(u)", &result);
-               LOGD("Mesh bridge stop status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               return MESH_ITNL_ERR_IO_ERROR;
-       }
+       LOGE("Not implemented yet!!");
 
+       NOTUSED(mesh);
+       NOTUSED(gate);
+       NOTUSED(softap);
        return MESH_ITNL_ERR_NONE;
 }
-#endif
+
old mode 100755 (executable)
new mode 100644 (file)