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
}
#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 */
<arg type="i" name="result" direction="out"/>\r
</method>\r
<method name="set_gate">\r
- <arg type="b" name="stp" direction="in"/>\r
- <arg type="b" name="gate_announce" direction="in"/>\r
+ <arg type="b" name="gate_announce" direction="in"/>\r
+ <arg type="q" name="hwmp_root_mode" direction="in"/>\r
+ <arg type="q" name="stp" direction="in"/>\r
<arg type="i" name="result" direction="out"/>\r
</method>\r
<method name="unset_gate">\r
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;
+}
+
#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)
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;
}
/* In error case, we call enable etheret again for OdroidU3 */
mesh_gdbus_enable_ethernet_interface(service, true);
}
-
#if 0
_get_mpath_info(service);
#endif
}
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);
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;