2 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "mesh-util.h"
19 #include "mesh-gdbus.h"
20 #include "mesh-request.h"
24 static GDBusProxy *_gproxy_connman = NULL;
25 static GDBusProxy *_gproxy_connman_mesh = NULL;
26 static GDBusProxy *_gproxy_connman_technology = NULL;
28 static int _meshd_close_gdbus_call(mesh_service *service);
30 static int __channel_to_frequency(int channel, enum nl80211_band band)
36 case NL80211_BAND_2GHZ:
39 else if (channel < 14)
40 return 2407 + channel * 5;
42 case NL80211_BAND_5GHZ:
43 if (channel >= 182 && channel <= 196)
44 return 4000 + channel * 5;
46 return 5000 + channel * 5;
56 static int __frequency_to_channel(int freq)
61 return (freq - 2407) / 5;
62 else if (freq >= 4910 && freq <= 4980)
63 return (freq - 4000) / 5;
64 else if (freq <= 45000)
65 return (freq - 5000) / 5;
66 else if (freq >= 58320 && freq <= 64800)
67 return (freq - 56160) / 2160;
72 static GDBusProxy *_proxy_get_connman(mesh_service *service)
74 GDBusProxy *proxy = NULL;
75 meshd_check_null_ret_error("service", service, NULL);
77 if (NULL == _gproxy_connman) {
78 proxy = g_dbus_proxy_new_sync(service->connection,
79 G_DBUS_PROXY_FLAGS_NONE, NULL,
82 CONNMAN_INTERFACE_MANAGER,
85 proxy = _gproxy_connman;
90 static GDBusProxy *_proxy_get_connman_mesh(mesh_service *service)
92 GDBusProxy *proxy = NULL;
93 meshd_check_null_ret_error("service", service, NULL);
95 if (NULL == _gproxy_connman_mesh) {
96 proxy = g_dbus_proxy_new_sync(service->connection,
97 G_DBUS_PROXY_FLAGS_NONE, NULL,
99 CONNMAN_OBJECT_PATH_MESH,
100 CONNMAN_INTERFACE_MESH,
103 proxy = _gproxy_connman_mesh;
108 static GDBusProxy *_proxy_get_connman_technology(mesh_service *service)
110 GDBusProxy *proxy = NULL;
111 meshd_check_null_ret_error("service", service, NULL);
113 if (NULL == _gproxy_connman_technology) {
114 proxy = g_dbus_proxy_new_sync(service->connection,
115 G_DBUS_PROXY_FLAGS_NONE, NULL,
117 CONNMAN_OBJECT_PATH_TECH_MESH,
118 CONNMAN_INTERFACE_TECH,
121 proxy = _gproxy_connman_technology;
126 static void _dbus_name_owner_notify(GObject *object, GParamSpec *pspec,
129 GDBusProxy *proxy = G_DBUS_PROXY(object);
130 gchar *name_owner = g_dbus_proxy_get_name_owner(proxy);
131 mesh_service *service = (mesh_service*)user_data;
135 if (NULL == name_owner) {
136 MESH_LOGE("name_owner is not exists !");
137 _meshd_close_gdbus_call(service);
143 static int _meshd_create_gdbus_call(mesh_service *service)
146 GError *error = NULL;
149 return MESHD_ERROR_INVALID_PARAMETER;
151 if (NULL != service->connection)
152 return MESHD_ERROR_ALREADY_REGISTERED;
154 service->connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
155 if (service->connection == NULL) {
157 MESH_LOGE("Failed to connect to the D-BUS daemon [%s]", error->message);
160 return MESHD_ERROR_IO_ERROR;
163 id = g_signal_connect(service->connection, "notify::g-name-owner",
164 G_CALLBACK(_dbus_name_owner_notify), service);
166 MESH_LOGE("g_signal_connect() Fail");
167 g_object_unref(service->connection);
168 service->connection = NULL;
169 return MESHD_ERROR_IO_ERROR;
172 return MESHD_ERROR_NONE;
175 static int _meshd_close_gdbus_call(mesh_service *service)
177 /* CHECK: is connection ref count required? */
178 g_object_unref(service->connection);
179 service->connection = NULL;
181 return MESHD_ERROR_NONE;
184 static void _meshd_signal_handler(GDBusConnection *connection,
185 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
186 const gchar *signal_name, GVariant *parameters, gpointer user_data)
188 mesh_service *service = (mesh_service*)user_data;
190 meshd_check_null_ret("user_data", user_data);
191 //meshd_check_null_ret("event_handler", service->event_handler);
193 NOTUSED(sender_name);
194 NOTUSED(object_path);
195 NOTUSED(interface_name);
196 NOTUSED(signal_name);
201 MESH_LOGD("signal received = %s", signal_name);
202 if (0 == g_strcmp0(signal_name, "ScanDone")) {
203 /* TODO: Handle event */
204 mesh_notify_scan_done();
208 static void _meshd_subscribe_event(mesh_service *service)
212 id = g_dbus_connection_signal_subscribe(
213 (GDBusConnection *)service->connection,
214 CONNMAN_SERVER_NAME, CONNMAN_INTERFACE_MANAGER,
215 "ScanDone", "/", NULL,
216 G_DBUS_CALL_FLAGS_NONE, _meshd_signal_handler, service, NULL);
218 MESH_LOGE("g_dbus_connection_signal_subscribe(ScanDone) Fail(%d)", errno);
221 service->dbus_sub_ids = g_list_append(service->dbus_sub_ids, GUINT_TO_POINTER(id));
222 MESH_LOGD("[Signal subscribe] : ScanDone (%d)", id);
224 /* End of subscription */
227 int meshd_dbus_start(mesh_service *service)
231 rv = _meshd_create_gdbus_call(service);
232 if (MESHD_ERROR_NONE != rv)
235 service->ca = g_cancellable_new();
237 /* Create all required proxies here */
238 _gproxy_connman = _proxy_get_connman(service);
239 meshd_check_null_ret_error("_gproxy_connman", _gproxy_connman,
240 MESHD_ERROR_IO_ERROR);
241 g_dbus_proxy_set_default_timeout(
242 G_DBUS_PROXY(_gproxy_connman), MESH_DBUS_PROXY_TIMEOUT);
244 _gproxy_connman_mesh = _proxy_get_connman_mesh(service);
245 meshd_check_null_ret_error("_gproxy_connman_mesh", _gproxy_connman_mesh,
246 MESHD_ERROR_IO_ERROR);
247 g_dbus_proxy_set_default_timeout(
248 G_DBUS_PROXY(_gproxy_connman_mesh), MESH_DBUS_PROXY_TIMEOUT);
250 _gproxy_connman_technology = _proxy_get_connman_technology(service);
251 meshd_check_null_ret_error("_gproxy_connman_technology", _gproxy_connman_technology,
252 MESHD_ERROR_IO_ERROR);
253 g_dbus_proxy_set_default_timeout(
254 G_DBUS_PROXY(_gproxy_connman_technology), MESH_DBUS_PROXY_TIMEOUT);
256 /* Subscribe events */
257 _meshd_subscribe_event(service);
259 return MESHD_ERROR_NONE;
262 int meshd_dbus_stop(mesh_service *service)
267 return MESHD_ERROR_INVALID_PARAMETER;
269 /* Unref all proxies here */
270 if (_gproxy_connman) {
271 g_object_unref(_gproxy_connman);
272 _gproxy_connman = NULL;
274 if (_gproxy_connman_mesh) {
275 g_object_unref(_gproxy_connman_mesh);
276 _gproxy_connman_mesh = NULL;
278 if (_gproxy_connman_technology) {
279 g_object_unref(_gproxy_connman_technology);
280 _gproxy_connman_technology = NULL;
283 g_cancellable_cancel(service->ca);
284 g_object_unref(service->ca);
287 rv = _meshd_close_gdbus_call(service);
291 int mesh_ipc_create_mesh_interface(mesh_service *service)
293 int ret = MESHD_ERROR_NONE;
294 GVariant *variant = NULL;
295 GError *error = NULL;
296 GVariant *var_dict = NULL;
298 mesh_interface_s *info = NULL;
300 meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
301 meshd_check_null_ret_error("connection", service->connection,
302 MESHD_ERROR_INVALID_PARAMETER);
303 meshd_check_null_ret_error("_gproxy_connman_technology",
304 _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
306 info = service->interface_info;
308 g_variant_dict_init(&dict, NULL);
309 g_variant_dict_insert(&dict, "Ifname", "s", info->mesh_interface);
310 g_variant_dict_insert(&dict, "ParentIfname", "s", info->base_interface);
311 g_variant_dict_insert(&dict, "BridgeIfname", "s", info->bridge_interface);
312 var_dict = g_variant_dict_end(&dict);
314 variant = g_dbus_proxy_call_sync(_gproxy_connman_technology, "MeshCommands",
315 g_variant_new("(sv)", "MeshInterfaceAdd", var_dict),
316 G_DBUS_CALL_FLAGS_NONE,
319 MESH_LOGD("Successfully requested. [MeshInterfaceAdd]");
321 ret = MESHD_ERROR_IO_ERROR;
322 MESH_LOGE("Failed DBus call [%s]", error->message);
324 /* Interface not exists */
325 if (g_strrstr(error->message, "No such device"))
326 ret = MESHD_ERROR_INVALID_PARAMETER;
333 int mesh_ipc_remove_mesh_interface(mesh_service *service)
335 GVariant *variant = NULL;
336 GError *error = NULL;
337 GVariant *var_dict = NULL;
339 mesh_interface_s *info = NULL;
341 meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
342 meshd_check_null_ret_error("connection", service->connection,
343 MESHD_ERROR_INVALID_PARAMETER);
344 meshd_check_null_ret_error("_gproxy_connman_technology",
345 _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
347 info = service->interface_info;
349 g_variant_dict_init(&dict, NULL);
350 g_variant_dict_insert(&dict, "Ifname", "s", info->mesh_interface);
351 var_dict = g_variant_dict_end(&dict);
353 variant = g_dbus_proxy_call_sync(_gproxy_connman_technology, "MeshCommands",
354 g_variant_new("(sv)", "MeshInterfaceRemove", var_dict),
355 G_DBUS_CALL_FLAGS_NONE,
358 MESH_LOGD("Successfully requested. [MeshInterfaceRemove]");
360 MESH_LOGE("Failed DBus call [%s]", error->message);
362 return MESHD_ERROR_IO_ERROR;
365 return MESHD_ERROR_NONE;
368 int mesh_ipc_mesh_scan(mesh_service *service)
370 meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
371 meshd_check_null_ret_error("connection", service->connection,
372 MESHD_ERROR_INVALID_PARAMETER);
373 meshd_check_null_ret_error("_gproxy_connman_technology",
374 _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
376 g_dbus_proxy_call(_gproxy_connman_technology, "Scan",
378 G_DBUS_CALL_FLAGS_NONE,
379 -1, NULL, NULL, NULL);
381 MESH_LOGD("Successfully requested. [Scan]");
383 return MESHD_ERROR_NONE;
386 int mesh_ipc_mesh_specific_scan(mesh_service *service, gchar *mesh_id,
389 GVariant *variant = NULL;
390 GError *error = NULL;
391 GVariant *var_dict = NULL;
394 enum nl80211_band band = (channel <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
395 gushort freq = __channel_to_frequency(channel, band);
397 meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
398 meshd_check_null_ret_error("connection", service->connection,
399 MESHD_ERROR_INVALID_PARAMETER);
400 meshd_check_null_ret_error("_gproxy_connman_technology",
401 _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
403 g_variant_dict_init(&dict, NULL);
404 g_variant_dict_insert(&dict, "Name", "s", mesh_id);
405 g_variant_dict_insert(&dict, "Frequency", "q", freq);
406 var_dict = g_variant_dict_end(&dict);
408 variant = g_dbus_proxy_call_sync(_gproxy_connman_technology, "MeshCommands",
409 g_variant_new("(sv)", "MeshSpecificScan", var_dict),
410 G_DBUS_CALL_FLAGS_NONE,
413 MESH_LOGD("Successfully requested. [MeshSpecificScan]");
415 MESH_LOGE("Failed DBus call [%s]", error->message);
417 return MESHD_ERROR_IO_ERROR;
420 return MESHD_ERROR_NONE;
423 int mesh_ipc_mesh_cancel_scan(mesh_service *service)
425 GVariant *variant = NULL;
426 GError *error = NULL;
427 GVariant *var_dict = NULL;
430 meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
431 meshd_check_null_ret_error("connection", service->connection,
432 MESHD_ERROR_INVALID_PARAMETER);
433 meshd_check_null_ret_error("_gproxy_connman_technology",
434 _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
436 g_variant_dict_init(&dict, NULL);
437 var_dict = g_variant_dict_end(&dict);
439 variant = g_dbus_proxy_call_sync(_gproxy_connman_technology, "MeshCommands",
440 g_variant_new("(sv)", "AbortScan", var_dict),
441 G_DBUS_CALL_FLAGS_NONE,
444 MESH_LOGD("Successfully requested. [AbortScan]");
446 MESH_LOGE("Failed DBus call [%s]", error->message);
448 return MESHD_ERROR_IO_ERROR;
451 return MESHD_ERROR_NONE;
454 static void _on_scan_result_destroy(gpointer data)
456 mesh_scan_result_s *scan_item = (mesh_scan_result_s *)data;
459 g_free(scan_item->mesh_id);
460 g_free(scan_item->bssid);
461 g_free(scan_item->object_path);
465 static void _get_joined_network(mesh_service *service, GVariant *variant)
467 GVariantIter *peer = NULL;
468 GVariantIter *property = NULL;
470 GVariant *val = NULL;
473 const gchar* obj_path = NULL;
474 const gchar* buf = NULL;
476 g_variant_get(variant, "(a(oa{sv}))", &peer);
477 while ((child = g_variant_iter_next_value(peer))) {
478 mesh_network_info_s *joined_info = NULL;
479 gboolean valid_state = TRUE;
481 g_variant_get(child, "(oa{sv})", &obj_path, &property);
482 MESH_LOGD(" Object: [%s]", obj_path);
483 if (NULL == obj_path) {
484 MESH_LOGE("Null object");
488 /* Create an information structure for joined network */
489 joined_info = g_try_new0(mesh_network_info_s, 1);
490 if (NULL == joined_info) {
491 MESH_LOGE("Failed to allocate !");
495 while (g_variant_iter_loop(property, "{sv}", &key, &val)) {
496 if (strcasecmp(key, "Name") == 0) {
497 buf = g_variant_get_string(val, &len);
498 joined_info->mesh_id = g_strdup(buf);
500 else if (strcasecmp(key, "Address") == 0) {
501 buf = g_variant_get_string(val, &len);
502 joined_info->bssid = g_strdup(buf);
504 else if (strcasecmp(key, "State") == 0) {
505 buf = g_variant_get_string(val, &len);
506 MESH_LOGD(" State : %s", buf);
508 /* Skip ignorable state */
509 if (g_strcmp0(buf, "idle") == 0
510 || g_strcmp0(buf, "disconnect") == 0
511 || g_strcmp0(buf, "failure") == 0) {
516 else if (strcasecmp(key, "Frequency") == 0) {
517 joined_info->channel = __frequency_to_channel(g_variant_get_uint16(val));
521 /* Skip ignorable state */
522 if (FALSE == valid_state) {
523 g_free(joined_info->mesh_id);
524 g_free(joined_info->bssid);
528 MESH_LOGD(" Mesh ID : %s", joined_info->mesh_id);
529 MESH_LOGD(" BSSID : %s", joined_info->bssid);
530 MESH_LOGD(" Channel : %d", joined_info->channel);
531 service->joined_network = joined_info;
533 g_variant_iter_free(property);
535 /* If found, stop loop iteration */
538 g_variant_iter_free(peer);
541 static void _get_mesh_peers(mesh_service *service, GVariant *variant)
543 GVariantIter *peer = NULL;
544 GVariantIter *property = NULL;
546 GVariant *val = NULL;
549 const gchar* obj_path = NULL;
551 g_variant_get(variant, "(a(oa{sv}))", &peer);
552 while ((child = g_variant_iter_next_value(peer))) {
553 mesh_scan_result_s *scan_info = NULL;
555 scan_info = g_try_new0(mesh_scan_result_s, 1);
556 if (NULL == scan_info) {
557 MESH_LOGE("Failed to allocate !");
561 g_variant_get(child, "(oa{sv})", &obj_path, &property);
562 if (NULL == obj_path) {
563 MESH_LOGE("Null object");
567 MESH_LOGD(" Obj path : [%s]", obj_path);
568 scan_info->object_path = g_strdup(obj_path);
570 while (g_variant_iter_loop(property, "{sv}", &key, &val)) {
571 if (strcasecmp(key, "Name") == 0) {
572 const char *buf = g_variant_get_string(val, &len);
573 scan_info->mesh_id = g_strdup(buf);
574 MESH_LOGD(" Mesh ID : %s", scan_info->mesh_id);
576 else if (strcasecmp(key, "Address") == 0) {
577 const char *buf = g_variant_get_string(val, &len);
578 scan_info->bssid = g_strdup(buf);
579 MESH_LOGD(" BSSID : %s", scan_info->bssid);
581 else if (strcasecmp(key, "State") == 0) {
582 const char *buf = g_variant_get_string(val, &len);
583 MESH_LOGD(" State : %s", buf);
585 else if (strcasecmp(key, "Security") == 0) {
586 const char *buf = g_variant_get_string(val, &len);
587 MESH_LOGD(" Security : %s", buf);
589 else if (strcasecmp(key, "Frequency") == 0) {
590 scan_info->channel = __frequency_to_channel(g_variant_get_uint16(val));
591 MESH_LOGD(" Channel : %d", scan_info->channel);
593 else if (strcasecmp(key, "Favorite") == 0) {
594 const char *buf = g_variant_get_string(val, &len);
595 MESH_LOGD(" Favorite : %s", buf);
597 else if (strcasecmp(key, "Strength") == 0) {
598 scan_info->rssi = (gint)g_variant_get_byte(val);
599 MESH_LOGD(" RSSI : %d", scan_info->rssi);
603 service->scanned_mesh_network =
604 g_list_prepend(service->scanned_mesh_network, scan_info);
606 g_variant_iter_free(property);
608 g_variant_iter_free(peer);
611 int mesh_ipc_get_mesh_peers(mesh_service *service)
613 GVariant *variant = NULL;
614 GError *error = NULL;
616 meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
617 meshd_check_null_ret_error("connection", service->connection,
618 MESHD_ERROR_INVALID_PARAMETER);
619 meshd_check_null_ret_error("_gproxy_connman",
620 _gproxy_connman, MESHD_ERROR_IO_ERROR);
622 variant = g_dbus_proxy_call_sync(_gproxy_connman, "GetMeshPeers",
624 G_DBUS_CALL_FLAGS_NONE,
627 MESH_LOGD("Successfully requested. [GetMeshPeers]");
629 if (service->scanned_mesh_network) {
630 g_list_free_full(service->scanned_mesh_network, _on_scan_result_destroy);
631 service->scanned_mesh_network = NULL;
634 _get_mesh_peers(service, variant);
636 /* List item is saved with reversed order for efficiency. */
637 service->scanned_mesh_network =
638 g_list_reverse(service->scanned_mesh_network);
640 MESH_LOGE("Failed DBus call [%s]", error->message);
642 return MESHD_ERROR_IO_ERROR;
645 return MESHD_ERROR_NONE;
648 int mesh_ipc_get_joined_mesh_network(mesh_service *service)
650 GVariant *variant = NULL;
651 GError *error = NULL;
653 meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
654 meshd_check_null_ret_error("connection", service->connection,
655 MESHD_ERROR_INVALID_PARAMETER);
656 meshd_check_null_ret_error("_gproxy_connman",
657 _gproxy_connman, MESHD_ERROR_IO_ERROR);
659 variant = g_dbus_proxy_call_sync(_gproxy_connman, "GetMeshPeers",
661 G_DBUS_CALL_FLAGS_NONE,
664 MESH_LOGD("Successfully requested. [GetMeshPeers]");
666 if (service->joined_network) {
667 g_free(service->joined_network->mesh_id);
668 g_free(service->joined_network->bssid);
669 g_free(service->joined_network);
670 service->joined_network = NULL;
673 _get_joined_network(service, variant);
675 MESH_LOGE("Failed DBus call [%s]", error->message);
677 return MESHD_ERROR_IO_ERROR;
680 return MESHD_ERROR_NONE;
683 int mesh_ipc_create_network(mesh_service *service, gchar *mesh_id, gint channel,
686 GVariant *variant = NULL;
687 GError *error = NULL;
688 GVariant *var_dict = NULL;
689 GVariantBuilder builder;
690 const gchar* secu = (security == 0) ? "none" : "SAE";
692 enum nl80211_band band = (channel <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
693 gushort freq = __channel_to_frequency(channel, band);
695 meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
696 meshd_check_null_ret_error("connection", service->connection,
697 MESHD_ERROR_INVALID_PARAMETER);
698 meshd_check_null_ret_error("_gproxy_connman_technology",
699 _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
701 g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
702 g_variant_builder_open(&builder, G_VARIANT_TYPE("a{sv}"));
704 g_variant_builder_open(&builder, G_VARIANT_TYPE("{sv}"));
705 g_variant_builder_add(&builder, "s", "Name");
706 g_variant_builder_add(&builder, "v", g_variant_new_string(mesh_id));
707 g_variant_builder_close(&builder); /* {sv} */
709 g_variant_builder_open(&builder, G_VARIANT_TYPE("{sv}"));
710 g_variant_builder_add(&builder, "s", "Frequency");
711 g_variant_builder_add(&builder, "v", g_variant_new_uint16(freq));
712 g_variant_builder_close(&builder); /* {sv} */
714 g_variant_builder_open(&builder, G_VARIANT_TYPE("{sv}"));
715 g_variant_builder_add(&builder, "s", "Security");
716 g_variant_builder_add(&builder, "v", g_variant_new_string(secu));
717 g_variant_builder_close(&builder); /* {sv} */
719 g_variant_builder_close(&builder); /* a{sv} */
721 var_dict = g_variant_builder_end(&builder);
723 variant = g_dbus_proxy_call_sync(_gproxy_connman_technology, "MeshCommands",
724 g_variant_new("(sv)", "MeshCreateNetwork", var_dict),
725 G_DBUS_CALL_FLAGS_NONE,
728 MESH_LOGD("Successfully requested. [MeshCreateNetwork]");
730 MESH_LOGE("Failed DBus call [%s]", error->message);
732 return MESHD_ERROR_IO_ERROR;
735 return MESHD_ERROR_NONE;
738 int mesh_ipc_connect_network(mesh_service *service, mesh_scan_result_s *info)
740 int ret = MESHD_ERROR_NONE;
741 GVariant *variant = NULL;
742 GError *error = NULL;
744 meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
745 meshd_check_null_ret_error("info", info, MESHD_ERROR_INVALID_PARAMETER);
747 variant = g_dbus_connection_call_sync(service->connection,
750 CONNMAN_INTERFACE_MESH,
753 G_DBUS_CALL_FLAGS_NONE,
756 MESH_LOGD("Successfully requested. [Connect]");
758 ret = MESHD_ERROR_IO_ERROR;
759 LOGE("Failed DBus call [%s]", error->message);
761 if (g_strrstr(error->message, "Already exists"))
762 ret = MESHD_ERROR_ALREADY_REGISTERED;
764 ret = MESHD_ERROR_IO_ERROR;
772 int mesh_ipc_disconnect_network(mesh_service *service, mesh_scan_result_s *info)
774 GVariant *variant = NULL;
775 GError *error = NULL;
777 meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
778 meshd_check_null_ret_error("info", info, MESHD_ERROR_INVALID_PARAMETER);
780 variant = g_dbus_connection_call_sync(service->connection,
783 CONNMAN_INTERFACE_MESH,
786 G_DBUS_CALL_FLAGS_NONE,
789 MESH_LOGD("Successfully requested. [Disconnect]");
791 LOGE("Failed DBus call [%s]", error->message);
793 return MESHD_ERROR_IO_ERROR;
796 return MESHD_ERROR_NONE;
799 int mesh_ipc_remove_network(mesh_service *service, mesh_scan_result_s *info)
801 GVariant *variant = NULL;
802 GError *error = NULL;
804 meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
805 meshd_check_null_ret_error("info", info, MESHD_ERROR_INVALID_PARAMETER);
807 variant = g_dbus_connection_call_sync(service->connection,
810 CONNMAN_INTERFACE_MESH,
813 G_DBUS_CALL_FLAGS_NONE,
816 MESH_LOGD("Successfully requested. [Remove]");
818 LOGE("Failed DBus call [%s]", error->message);
820 return MESHD_ERROR_IO_ERROR;
823 return MESHD_ERROR_NONE;