From: saerome.kim Date: Mon, 3 Jul 2017 04:58:56 +0000 (+0900) Subject: Modified sometings related to 'mesh_set_gate' X-Git-Tag: accepted/tizen/unified/20170829.053204~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b5ffe441157e9bc1b4e9fc7537e5021e8e7574a;p=platform%2Fcore%2Fconnectivity%2Fwifi-mesh-manager.git Modified sometings related to 'mesh_set_gate' - Changed 'mesh_set_gate / mesh_unset_gate API - Added the 'SetMeshGate' GDbus command Signed-off-by: saerome.kim --- diff --git a/include/mesh-gdbus.h b/include/mesh-gdbus.h index 10a7309..edc4d22 100644 --- a/include/mesh-gdbus.h +++ b/include/mesh-gdbus.h @@ -57,6 +57,7 @@ int mesh_gdbus_connect_network(mesh_service *service, mesh_scan_result_s *info); int mesh_gdbus_disconnect_network(mesh_service *service, mesh_scan_result_s *info); int mesh_gdbus_remove_network(mesh_service *service, mesh_scan_result_s *info); int mesh_gdbus_enable_ethernet_interface(mesh_service *service, bool state); +int mesh_gdbus_set_mesh_gate(mesh_service *service); #ifdef __cplusplus } diff --git a/include/mesh.h b/include/mesh.h index 8949e9d..5fc6cc9 100644 --- a/include/mesh.h +++ b/include/mesh.h @@ -66,6 +66,9 @@ typedef struct { #ifdef USE_UDEV_MONITOR GUdevClient *udev_client; /**< The udev event client */ #endif /* USE_UDEV_MONITOR */ + bool gate_announce; /**< Gate Announce Dnable/Disable */ + int hwmp_root_mode; /**< HWMP Root Mode (0, 2,3 or 4) */ + int stp; /**< Spanning Tree Protocol Enable/Disablel */ } mesh_interface_s; /**< Saved mesh network list structure */ diff --git a/introspection/mesh.xml b/introspection/mesh.xml index 519d46f..3cdb056 100644 --- a/introspection/mesh.xml +++ b/introspection/mesh.xml @@ -45,8 +45,9 @@ - - + + + diff --git a/src/mesh-gdbus.c b/src/mesh-gdbus.c index ecf4163..1ed034a 100644 --- a/src/mesh-gdbus.c +++ b/src/mesh-gdbus.c @@ -1223,3 +1223,45 @@ int mesh_gdbus_enable_ethernet_interface(mesh_service *service, bool state) return ret; } +int mesh_gdbus_set_mesh_gate(mesh_service *service) +{ + int ret = MESHD_ERROR_NONE; + GVariant *variant = NULL; + GError *error = NULL; + GVariant *var_dict = NULL; + GVariantDict dict; + mesh_interface_s *info = NULL; + + meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER); + meshd_check_null_ret_error("connection", service->connection, + MESHD_ERROR_INVALID_PARAMETER); + meshd_check_null_ret_error("_gproxy_connman_technology", + _gproxy_connman_technology, MESHD_ERROR_IO_ERROR); + + info = service->interface_info; + + g_variant_dict_init(&dict, NULL); + g_variant_dict_insert(&dict, "GateAnnounce", "b", info->gate_announce); + g_variant_dict_insert(&dict, "HWMPRootMode", "q", info->hwmp_root_mode); + g_variant_dict_insert(&dict, "STP", "q", info->stp); + var_dict = g_variant_dict_end(&dict); + + variant = g_dbus_proxy_call_sync(_gproxy_connman_technology, "MeshCommands", + g_variant_new("(sv)", "SetMeshGate", var_dict), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, &error); + if (variant) { + MESH_LOGD("Successfully requested. [SetMeshGate]"); + } else if (error) { + ret = MESHD_ERROR_IO_ERROR; + MESH_LOGE("Failed DBus call [%s]", error->message); + + /* Interface not exists */ + if (g_strrstr(error->message, "No such device")) + ret = MESHD_ERROR_INVALID_PARAMETER; + g_error_free(error); + } + + return ret; +} + diff --git a/src/mesh-peer-monitor.c b/src/mesh-peer-monitor.c index 079087e..8bfc044 100644 --- a/src/mesh-peer-monitor.c +++ b/src/mesh-peer-monitor.c @@ -208,10 +208,11 @@ static gboolean _on_mesh_monitor_cb(gpointer pdata) #else ret = mesh_interface_check_external_exists(info->external_interface, &state); #endif /* USE_IOCTL_MONITOR */ - MESH_LOGE("Status : %d %d %d", ret, info->can_be_gate, state); + MESH_LOGD("Status : %d %d %d", ret, info->can_be_gate, state); if (MESHD_ERROR_NONE == ret) { if (info->can_be_gate != state) { mesh_gdbus_enable_ethernet_interface(service, state); +#if 0 /* Detect external network state (i.e. Ethernet) and decide to make gate enabled */ if (state) @@ -220,7 +221,7 @@ static gboolean _on_mesh_monitor_cb(gpointer pdata) else mesh_request_unset_mesh_gate(info->bridge_interface, info->mesh_interface, info->external_interface); - +#endif MESH_LOGD("External interface state has been changed : [%d]", state); info->can_be_gate = state; } @@ -228,7 +229,6 @@ static gboolean _on_mesh_monitor_cb(gpointer pdata) /* In error case, we call enable etheret again for OdroidU3 */ mesh_gdbus_enable_ethernet_interface(service, true); } - #if 0 _get_mpath_info(service); #endif diff --git a/src/mesh-service-interface.c b/src/mesh-service-interface.c index 5e904c1..753a5eb 100644 --- a/src/mesh-service-interface.c +++ b/src/mesh-service-interface.c @@ -495,21 +495,31 @@ static gboolean _meshd_dbus_handle_get_connected_peers(NetMesh *object, } static gboolean _meshd_dbus_handle_set_gate(NetMesh *object, - GDBusMethodInvocation *invocation, gboolean stp, gboolean gate_announce, - gpointer user_data) + GDBusMethodInvocation *invocation, gint16 gate_announce, guint hwmp_root_mode, + gboolean stp, gpointer user_data) { int ret = MESHD_ERROR_NONE; mesh_service *service = (mesh_service *)user_data; mesh_interface_s *info = service->interface_info; - MESH_LOGD("STP = %d", stp); MESH_LOGD("gate_announce = %d", gate_announce); + MESH_LOGD("HWMP_Root_Mode = %d", hwmp_root_mode); + MESH_LOGD("STP = %d", stp); - /* Set STP and gate_announce */ + info->gate_announce = gate_announce; + info->hwmp_root_mode = hwmp_root_mode; + info->stp = stp; + + /* Set STP and gate_announce right now */ ret = mesh_request_set_mesh_gate(info->bridge_interface, info->mesh_interface, info->external_interface); if (MESHD_ERROR_NONE != ret) - MESH_LOGE("Failed to mesh_request_set_mesh_gate [%d]", ret); + MESH_LOGE("Failed to mesh_gdbus_set_mesh_gate [%d]", ret); + + /* Set STP and gate_announce for connmand */ + ret = mesh_gdbus_set_mesh_gate(service); + if (MESHD_ERROR_NONE != ret) + MESH_LOGE("Failed to mesh_gdbus_set_mesh_gate [%d]", ret); net_mesh_complete_set_gate(object, invocation, ret); @@ -524,11 +534,21 @@ static gboolean _meshd_dbus_handle_unset_gate(NetMesh *object, mesh_service *service = (mesh_service *)user_data; mesh_interface_s *info = service->interface_info; + info->gate_announce = 0; + info->hwmp_root_mode = 0; + info->stp = 0; + + /* Unset STP and Gate Annouce right now */ ret = mesh_request_unset_mesh_gate(info->bridge_interface, info->mesh_interface, info->external_interface); if (MESHD_ERROR_NONE != ret) MESH_LOGE("Failed to mesh_request_unset_mesh_gate [%d]", ret); + /* Set STP and gate_announce for connmand */ + ret = mesh_gdbus_set_mesh_gate(service); + if (MESHD_ERROR_NONE != ret) + MESH_LOGE("Failed to mesh_gdbus_set_mesh_gate [%d]", ret); + net_mesh_complete_unset_gate(object, invocation, ret); return TRUE;