summaryrefslogtreecommitdiff
path: root/mesh/node.c
diff options
context:
space:
mode:
authorMichaƂ Lowas-Rzechonek <michal.lowas-rzechonek@silvair.com>2019-12-17 15:54:42 +0100
committerBrian Gix <brian.gix@intel.com>2019-12-18 07:46:16 -0800
commitb9a4d9410b0ea2b7c571820baa90743cbe92b78d (patch)
tree776e1d5390908d3aef8583deed18921738f49abe /mesh/node.c
parent4a1bea28b15b4ab9b9c962597162cb4070587763 (diff)
downloadbluez-b9a4d9410b0ea2b7c571820baa90743cbe92b78d.tar.gz
mesh: Fix getting managed objects from ObjectManager
D-Bus spec mandates that GetManagedObjects method of org.freedesktop.DBus.ObjectManager interface returns *children* only: https://dbus.freedesktop.org/doc/dbus-specification.html > All returned object paths are children of the object path implementing > this interface, i.e. their object paths start with the ObjectManager's > object path plus '/' Both test scripts and ELL abuse this by returning application interfaces via ObjectManager attached to the same path, but other D-Bus implementations do not, making Attach() fail because mandatory interfaces cannot be found. This patch fixes the issue by scanning hierarchy returned by GetManagedObjects for object implementing org.bluez.mesh.Application1 interface and keeping that as node's app_path.
Diffstat (limited to 'mesh/node.c')
-rw-r--r--mesh/node.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/mesh/node.c b/mesh/node.c
index be8da8f07..16deced32 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -1529,6 +1529,11 @@ static void get_managed_objects_cb(struct l_dbus_message *msg, void *user_data)
goto fail;
} else if (!strcmp(MESH_APPLICATION_INTERFACE,
interface)) {
+ if (have_app)
+ goto fail;
+
+ req->node->app_path = l_strdup(path);
+
res = get_app_properties(node, path,
&properties);
if (!res)
@@ -1672,7 +1677,7 @@ fail:
}
/* Establish relationship between application and mesh node */
-int node_attach(const char *app_path, const char *sender, uint64_t token,
+int node_attach(const char *app_root, const char *sender, uint64_t token,
node_ready_func_t cb, void *user_data)
{
struct managed_obj_request *req;
@@ -1695,14 +1700,13 @@ int node_attach(const char *app_path, const char *sender, uint64_t token,
* application. Existing node is passed in req->attach.
*/
req->node = node_new(node->uuid);
- req->node->app_path = l_strdup(app_path);
req->node->owner = l_strdup(sender);
req->ready_cb = cb;
req->pending_msg = user_data;
req->attach = node;
req->type = REQUEST_TYPE_ATTACH;
- l_dbus_method_call(dbus_get_bus(), sender, app_path,
+ l_dbus_method_call(dbus_get_bus(), sender, app_root,
L_DBUS_INTERFACE_OBJECT_MANAGER,
"GetManagedObjects", NULL,
get_managed_objects_cb,
@@ -1713,7 +1717,7 @@ int node_attach(const char *app_path, const char *sender, uint64_t token,
/* Create a temporary pre-provisioned node */
-void node_join(const char *app_path, const char *sender, const uint8_t *uuid,
+void node_join(const char *app_root, const char *sender, const uint8_t *uuid,
node_join_ready_func_t cb)
{
struct managed_obj_request *req;
@@ -1725,14 +1729,14 @@ void node_join(const char *app_path, const char *sender, const uint8_t *uuid,
req->join_ready_cb = cb;
req->type = REQUEST_TYPE_JOIN;
- l_dbus_method_call(dbus_get_bus(), sender, app_path,
+ l_dbus_method_call(dbus_get_bus(), sender, app_root,
L_DBUS_INTERFACE_OBJECT_MANAGER,
"GetManagedObjects", NULL,
get_managed_objects_cb,
req, l_free);
}
-bool node_import(const char *app_path, const char *sender, const uint8_t *uuid,
+bool node_import(const char *app_root, const char *sender, const uint8_t *uuid,
const uint8_t dev_key[16], const uint8_t net_key[16],
uint16_t net_idx, bool kr, bool ivu,
uint32_t iv_index, uint16_t unicast,
@@ -1759,7 +1763,7 @@ bool node_import(const char *app_path, const char *sender, const uint8_t *uuid,
req->type = REQUEST_TYPE_IMPORT;
- l_dbus_method_call(dbus_get_bus(), sender, app_path,
+ l_dbus_method_call(dbus_get_bus(), sender, app_root,
L_DBUS_INTERFACE_OBJECT_MANAGER,
"GetManagedObjects", NULL,
get_managed_objects_cb,
@@ -1767,7 +1771,7 @@ bool node_import(const char *app_path, const char *sender, const uint8_t *uuid,
return true;
}
-void node_create(const char *app_path, const char *sender, const uint8_t *uuid,
+void node_create(const char *app_root, const char *sender, const uint8_t *uuid,
node_ready_func_t cb, void *user_data)
{
struct managed_obj_request *req;
@@ -1780,7 +1784,7 @@ void node_create(const char *app_path, const char *sender, const uint8_t *uuid,
req->pending_msg = user_data;
req->type = REQUEST_TYPE_CREATE;
- l_dbus_method_call(dbus_get_bus(), sender, app_path,
+ l_dbus_method_call(dbus_get_bus(), sender, app_root,
L_DBUS_INTERFACE_OBJECT_MANAGER,
"GetManagedObjects", NULL,
get_managed_objects_cb,