gint channel);
int mesh_ipc_mesh_cancel_scan(mesh_service *service);
int mesh_ipc_get_mesh_peers(mesh_service *service);
+int mesh_ipc_get_joined_mesh_network(mesh_service *service);
+int mesh_ipc_create_network(mesh_service *service, gchar *mesh_id, gint channel,
+ gint security);
int mesh_ipc_connect_network(mesh_service *service, mesh_scan_result_s *info);
int mesh_ipc_disconnect_network(mesh_service *service, mesh_scan_result_s *info);
int mesh_ipc_remove_network(mesh_service *service, mesh_scan_result_s *info);
gint channel);
int mesh_request_ipc_mesh_cancel_scan(mesh_service *service);
int mesh_request_ipc_mesh_get_peers(mesh_service *service);
+int mesh_request_ipc_get_joined_network(mesh_service *service);
+
+int mesh_request_ipc_create_mesh_network(mesh_service *service, gchar *mesh_id,
+ gint channel, gint security);
int mesh_request_ipc_connect_mesh_network(mesh_service *service, gchar *mesh_id,
gint channel, gint security);
int mesh_request_ipc_disconnect_mesh_network(mesh_service *service,
<method name="disable_softap">\r
<arg type="u" name="result" direction="out"/>\r
</method>\r
- <method name="add_mesh_network">\r
+ <method name="create_mesh_network">\r
<arg type="s" name="mesh_id" direction="in"/>\r
<arg type="i" name="channel" direction="in"/>\r
<arg type="i" name="security" direction="in"/>\r
<arg type="u" name="result" direction="out"/>\r
</method>\r
- <method name="get_saved_mesh_network">\r
- <arg type="aa{sv}" name="list" direction="out"/>\r
- <arg type="u" name="result" direction="out"/>\r
- </method>\r
- <method name="select_saved_mesh_network">\r
+ <method name="connect_mesh_network">\r
<arg type="s" name="mesh_id" direction="in"/>\r
<arg type="i" name="channel" direction="in"/>\r
<arg type="i" name="security" direction="in"/>\r
<arg type="u" name="result" direction="out"/>\r
</method>\r
- <method name="forget_saved_mesh_network">\r
+ <method name="forget_mesh_network">\r
<arg type="s" name="mesh_id" direction="in"/>\r
<arg type="i" name="channel" direction="in"/>\r
<arg type="i" name="security" direction="in"/>\r
return MESHD_ERROR_NONE;
}
+int mesh_ipc_mesh_cancel_scan(mesh_service *service)
+{
+ GVariant *variant = NULL;
+ GError *error = NULL;
+ GVariant *var_dict = NULL;
+ GVariantDict dict;
+
+ 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);
+
+ g_variant_dict_init(&dict, NULL);
+ var_dict = g_variant_dict_end(&dict);
+
+ variant = g_dbus_proxy_call_sync(_gproxy_connman_technology, "MeshCommands",
+ g_variant_new("(sv)", "AbortScan", var_dict),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, &error);
+ if (variant) {
+ MESH_LOGD("Successfully requested. [AbortScan]");
+ } else if (error) {
+ MESH_LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return MESHD_ERROR_IO_ERROR;
+ }
+
+ return MESHD_ERROR_NONE;
+}
+
static void _on_scan_result_destroy(gpointer data)
{
mesh_scan_result_s *scan_item = (mesh_scan_result_s *)data;
}
}
+static void _get_joined_network(mesh_service *service, GVariant *variant)
+{
+ GVariantIter *peer = NULL;
+ GVariantIter *property = NULL;
+ GVariant *val = NULL;
+ gsize len = 0;
+ GVariant *child;
+ gchar *var_string = NULL;
+ const gchar* obj_path = NULL;
+ const gchar* buf = NULL;
+
+ g_variant_get(variant, "(a(oa{sv}))", &peer);
+ while ((child = g_variant_iter_next_value(peer))) {
+ GVariantDict *dict = NULL;
+ GVariant *tmp = NULL;
+ mesh_network_info_s *joined_info = NULL;
+
+ MESH_LOGD(" Child : [%s]", g_variant_get_type_string(child));
+ var_string = g_variant_print(child, FALSE);
+ MESH_LOGD(" %s", var_string);
+ g_free(var_string);
+
+ g_variant_get(child, "(oa{sv})", &obj_path, &dict);
+ if (NULL == obj_path) {
+ MESH_LOGE("Null object");
+ continue;
+ }
+
+ tmp = g_variant_dict_lookup_value(dict, "State", G_VARIANT_TYPE_STRING);
+ if (NULL == tmp) continue;
+ buf = g_variant_get_string(tmp, &len);
+ if (g_strcmp0(buf, "association") != 0 && g_strcmp0(buf, "connected") != 0)
+ continue;
+
+ /* Create an information structure for joined network */
+ joined_info = g_try_new0(mesh_network_info_s, 1);
+ if (NULL == joined_info) {
+ MESH_LOGE("Failed to allocate !");
+ return;
+ }
+
+ tmp = g_variant_dict_lookup_value(dict, "Name", G_VARIANT_TYPE_STRING);
+ if (NULL == tmp) continue;
+ buf = g_variant_get_string(tmp, &len);
+ joined_info->mesh_id = g_strdup(buf);
+ MESH_LOGD(" Mesh ID : %s", joined_info->mesh_id);
+
+ tmp = g_variant_dict_lookup_value(dict, "Address", G_VARIANT_TYPE_STRING);
+ if (NULL == tmp) continue;
+ buf = g_variant_get_string(tmp, &len);
+ joined_info->bssid = g_strdup(buf);
+ MESH_LOGD(" BSSID : %s", joined_info->bssid);
+
+ tmp = g_variant_dict_lookup_value(dict, "Frequency", G_VARIANT_TYPE_UINT16);
+ joined_info->channel = __frequency_to_channel(g_variant_get_uint16(val));
+ MESH_LOGD(" Channel : %d", joined_info->channel);
+
+ service->joined_network = joined_info;
+
+ g_variant_iter_free(property);
+ }
+ g_variant_iter_free(peer);
+}
+
static void _get_mesh_peers(mesh_service *service, GVariant *variant)
{
GVariantIter *peer = NULL;
return MESHD_ERROR_NONE;
}
+int mesh_ipc_get_joined_mesh_network(mesh_service *service)
+{
+ GVariant *variant = NULL;
+ GError *error = 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",
+ _gproxy_connman, MESHD_ERROR_IO_ERROR);
+
+ variant = g_dbus_proxy_call_sync(_gproxy_connman, "GetMeshPeers",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, &error);
+ if (variant) {
+ MESH_LOGD("Successfully requested. [GetMeshPeers]");
+
+ if (service->joined_network) {
+ g_free(service->joined_network->mesh_id);
+ g_free(service->joined_network->bssid);
+ g_free(service->joined_network);
+ service->joined_network = NULL;
+ }
+
+ _get_joined_network(service, variant);
+ } else if (error) {
+ MESH_LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return MESHD_ERROR_IO_ERROR;
+ }
+
+ return MESHD_ERROR_NONE;
+}
+
+int mesh_ipc_create_network(mesh_service *service, gchar *mesh_id, gint channel,
+ gint security)
+{
+ GVariant *variant = NULL;
+ GError *error = NULL;
+ GVariant *var_dict = NULL;
+ GVariantDict dict;
+ const gchar* secu = (security == 0) ? "none" : "SAE";
+
+ enum nl80211_band band = (channel <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
+ gushort freq = __channel_to_frequency(channel, band);
+
+ 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);
+
+ g_variant_dict_init(&dict, NULL);
+ g_variant_dict_insert(&dict, "Name", "s", mesh_id);
+ g_variant_dict_insert(&dict, "Frequency", "q", freq);
+ g_variant_dict_insert(&dict, "Security", "s", secu);
+ var_dict = g_variant_dict_end(&dict);
+
+ variant = g_dbus_proxy_call_sync(_gproxy_connman_technology, "MeshCommands",
+ g_variant_new("(sv)", "MeshCreateNetwork", var_dict),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, &error);
+ if (variant) {
+ MESH_LOGD("Successfully requested. [MeshCreateNetwork]");
+ } else if (error) {
+ MESH_LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return MESHD_ERROR_IO_ERROR;
+ }
+
+ return MESHD_ERROR_NONE;
+}
+
int mesh_ipc_connect_network(mesh_service *service, mesh_scan_result_s *info)
{
GVariant *variant = NULL;
MESH_LOGD("[IPC] Cancel scan for mesh network");
- ret = mesh_ipc_mesh_scan(service);
+ ret = mesh_ipc_mesh_cancel_scan(service);
if(MESHD_ERROR_NONE != ret) {
MESH_LOGE("Failed to cancel scan for mesh network");
return ret;
return ret;
}
+int mesh_request_ipc_get_joined_network(mesh_service *service)
+{
+ int ret;
+
+ if (NULL == service) {
+ MESH_LOGE("Invalid parameter");
+ return MESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ MESH_LOGD("[IPC] Get joined mesh network");
+
+ ret = mesh_ipc_get_joined_mesh_network(service);
+ if(MESHD_ERROR_NONE != ret) {
+ MESH_LOGE("Failed to get joined mesh network");
+ return ret;
+ }
+
+ return MESHD_ERROR_NONE;
+}
+
+int mesh_request_ipc_create_mesh_network(mesh_service *service, gchar *mesh_id,
+ gint channel, gint security)
+{
+ int ret;
+
+ if (NULL == service) {
+ MESH_LOGE("Invalid parameter");
+ return MESHD_ERROR_INVALID_PARAMETER;
+ }
+
+ MESH_LOGD("[IPC] Create a new mesh network");
+
+ ret = mesh_ipc_create_network(service, mesh_id, channel, security);
+ if(MESHD_ERROR_NONE != ret) {
+ MESH_LOGE("Failed to create mesh network");
+ return ret;
+ }
+
+ return MESHD_ERROR_NONE;
+}
+
int mesh_request_ipc_connect_mesh_network(mesh_service *service, gchar *mesh_id,
gint channel, gint security)
{
{
int ret = MESHD_ERROR_NONE;
mesh_service *service = (mesh_service *)user_data;
- mesh_interface_s *info = service->interface_info;
- ret = mesh_request_cancel_scan(info->mesh_interface);
+ ret = mesh_request_ipc_mesh_cancel_scan(service);
if (MESHD_ERROR_NONE != ret) {
- MESH_LOGE("Failed to mesh_request_cancel_scan");
+ MESH_LOGE("Failed to mesh_request_ipc_mesh_cancel_scan");
}
net_mesh_complete_cancel_scan(object, invocation, ret);
{
int ret = MESHD_ERROR_NONE;
mesh_service *service = (mesh_service *)user_data;
- mesh_network_info_s *joined = service->joined_network;
+ mesh_network_info_s *joined = NULL;
//gchar *meshid = strdup("meshnet");
//gchar *bssid = strdup("7c:dd:90:d8:2a:64");
//gint channel = 161;
//gint max_speed = 866;
-
- if (joined) {
- net_mesh_complete_get_joined_mesh_network(object, invocation,
- joined->mesh_id, joined->bssid, joined->channel, ret);
+ ret = mesh_request_ipc_get_joined_network(service);
+ if (MESHD_ERROR_NONE == ret) {
+ joined = service->joined_network;
+ if (joined) {
+ net_mesh_complete_get_joined_mesh_network(object, invocation,
+ joined->mesh_id, joined->bssid, joined->channel, ret);
+ } else {
+ net_mesh_complete_get_joined_mesh_network(object, invocation,
+ "", "", 0, MESHD_ERROR_NO_DATA);
+ }
} else {
net_mesh_complete_get_joined_mesh_network(object, invocation,
- "", "", 0, MESHD_ERROR_NO_DATA);
+ "", "", 0, ret);
}
return TRUE;
return TRUE;
}
-static gboolean _meshd_dbus_handle_add_mesh_network(NetMesh *object,
+static gboolean _meshd_dbus_handle_create_mesh_network(NetMesh *object,
GDBusMethodInvocation *invocation,
gchar *mesh_id, gint channel, gint security,
gpointer user_data)
int ret = MESHD_ERROR_NONE;
mesh_service *service = (mesh_service *)user_data;
- ret = mesh_request_add_mesh_network(&service->saved_mesh_network,
- mesh_id, channel, security);
+ //ret = mesh_request_add_mesh_network(&service->saved_mesh_network,
+ // mesh_id, channel, security);
+ ret = mesh_request_ipc_create_mesh_network(service, mesh_id, channel, security);
- net_mesh_complete_add_mesh_network(object, invocation, ret);
+ net_mesh_complete_create_mesh_network(object, invocation, ret);
return TRUE;
}
-
+#if 0
static gboolean _meshd_dbus_handle_get_saved_mesh_network(NetMesh *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
return TRUE;
}
-
-static gboolean _meshd_dbus_handle_select_saved_mesh_network(NetMesh *object,
+#endif
+static gboolean _meshd_dbus_handle_connect_mesh_network(NetMesh *object,
GDBusMethodInvocation *invocation,
gchar *mesh_id, gint channel, gint security,
gpointer user_data)
ret = mesh_request_ipc_connect_mesh_network(service, mesh_id, channel, security);
/* ADDED */
- net_mesh_complete_select_saved_mesh_network(object, invocation, ret);
+ net_mesh_complete_connect_mesh_network(object, invocation, ret);
return TRUE;
}
-static gboolean _meshd_dbus_handle_forget_saved_mesh_network(NetMesh *object,
+static gboolean _meshd_dbus_handle_forget_mesh_network(NetMesh *object,
GDBusMethodInvocation *invocation,
gchar *mesh_id, gint channel, gint security,
gpointer user_data)
ret = mesh_request_ipc_disconnect_mesh_network(service,
mesh_id, channel, security);
- net_mesh_complete_forget_saved_mesh_network(object, invocation, ret);
+ net_mesh_complete_forget_mesh_network(object, invocation, ret);
return TRUE;
}
G_CALLBACK(_meshd_dbus_handle_enable_softap), service);
g_signal_connect(meshd_dbus_object, "handle-disable-softap",
G_CALLBACK(_meshd_dbus_handle_disable_softap), service);
- g_signal_connect(meshd_dbus_object, "handle-add-mesh-network",
- G_CALLBACK(_meshd_dbus_handle_add_mesh_network), service);
- g_signal_connect(meshd_dbus_object, "handle-get-saved-mesh-network",
- G_CALLBACK(_meshd_dbus_handle_get_saved_mesh_network), service);
- g_signal_connect(meshd_dbus_object, "handle-select-saved-mesh-network",
- G_CALLBACK(_meshd_dbus_handle_select_saved_mesh_network), service);
- g_signal_connect(meshd_dbus_object, "handle-forget-saved-mesh-network",
- G_CALLBACK(_meshd_dbus_handle_forget_saved_mesh_network), service);
+ g_signal_connect(meshd_dbus_object, "handle-create-mesh-network",
+ G_CALLBACK(_meshd_dbus_handle_create_mesh_network), service);
+ g_signal_connect(meshd_dbus_object, "handle-connect-mesh-network",
+ G_CALLBACK(_meshd_dbus_handle_connect_mesh_network), service);
+ g_signal_connect(meshd_dbus_object, "handle-forget-mesh-network",
+ G_CALLBACK(_meshd_dbus_handle_forget_mesh_network), service);
g_signal_connect(meshd_dbus_object, "handle-set-interfaces",
G_CALLBACK(_meshd_dbus_handle_set_interfaces), service);
g_signal_connect(meshd_dbus_object, "handle-get-station-info",