From 3c873bd631a01315f64869719a25546ba25e91ed Mon Sep 17 00:00:00 2001 From: Brian Gix Date: Thu, 11 Jul 2019 15:59:48 -0700 Subject: [PATCH] mesh: Expose resources needed by Management1 interface Change-Id: I34c48666cad7fd717536582bedd44503a9b738e6 Signed-off-by: Anupam Roy --- mesh/node.c | 42 ++++++++++++++++++++++++++++++++---------- mesh/node.h | 3 +++ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/mesh/node.c b/mesh/node.c index 2a46e4f..c673cb7 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -82,7 +82,8 @@ struct mesh_node { struct l_queue *elements; char *app_path; char *owner; - char *path; + char *obj_path; + struct mesh_agent *agent; void *jconfig; char *node_path; uint32_t disc_watch; @@ -244,14 +245,14 @@ static void free_node_dbus_resources(struct mesh_node *node) l_free(node->app_path); node->app_path = NULL; - if (node->path) { - l_dbus_object_remove_interface(dbus_get_bus(), node->path, + if (node->obj_path) { + l_dbus_object_remove_interface(dbus_get_bus(), node->obj_path, MESH_NODE_INTERFACE); - l_dbus_object_remove_interface(dbus_get_bus(), node->path, + l_dbus_object_remove_interface(dbus_get_bus(), node->obj_path, MESH_MANAGEMENT_INTERFACE); - l_free(node->path); - node->path = NULL; + l_free(node->obj_path); + node->obj_path = NULL; } } @@ -443,6 +444,11 @@ void node_cleanup_all(void) l_dbus_unregister_interface(dbus_get_bus(), MESH_MANAGEMENT_INTERFACE); } +bool node_is_provisioner(struct mesh_node *node) +{ + return node->provisioner; +} + bool node_is_provisioned(struct mesh_node *node) { return (!IS_UNASSIGNED(node->primary)); @@ -1028,14 +1034,14 @@ static bool register_node_object(struct mesh_node *node) if (!hex2str(node->uuid, sizeof(node->uuid), uuid, sizeof(uuid))) return false; - node->path = l_strdup_printf(BLUEZ_MESH_PATH MESH_NODE_PATH_PREFIX + node->obj_path = l_strdup_printf(BLUEZ_MESH_PATH MESH_NODE_PATH_PREFIX "%s", uuid); - if (!l_dbus_object_add_interface(dbus_get_bus(), node->path, + if (!l_dbus_object_add_interface(dbus_get_bus(), node->obj_path, MESH_NODE_INTERFACE, node)) return false; - if (!l_dbus_object_add_interface(dbus_get_bus(), node->path, + if (!l_dbus_object_add_interface(dbus_get_bus(), node->obj_path, MESH_MANAGEMENT_INTERFACE, node)) return false; @@ -1511,6 +1517,9 @@ static void get_managed_objects_cb(struct l_dbus_message *msg, void *user_data) &properties); if (!agent) goto fail; + + node->agent = agent; + } else if (!strcmp(MESH_PROVISIONER_INTERFACE, interface)) { node->provisioner = true; @@ -1738,7 +1747,7 @@ void node_build_attach_reply(struct mesh_node *node, builder = l_dbus_message_builder_new(reply); /* Node object path */ - l_dbus_message_builder_append_basic(builder, 'o', node->path); + l_dbus_message_builder_append_basic(builder, 'o', node->obj_path); /* Array of element configurations "a*/ l_dbus_message_builder_enter_array(builder, "(ya(qa{sv}))"); @@ -2009,7 +2018,20 @@ char *node_path_get(struct mesh_node *node) return node->node_path; } +const char *node_get_app_path(struct mesh_node *node) +{ + if (!node) + return NULL; + + return node->app_path; +} + struct mesh_net *node_get_net(struct mesh_node *node) { return node->net; } + +struct mesh_agent *node_get_agent(struct mesh_node *node) +{ + return node->agent; +} diff --git a/mesh/node.h b/mesh/node.h index 142527b..d69887e 100644 --- a/mesh/node.h +++ b/mesh/node.h @@ -42,6 +42,7 @@ struct mesh_net *node_get_net(struct mesh_node *node); struct mesh_node *node_find_by_addr(uint16_t addr); struct mesh_node *node_find_by_uuid(uint8_t uuid[16]); struct mesh_node *node_find_by_token(uint64_t token); +bool node_is_provisioner(struct mesh_node *node); bool node_is_provisioned(struct mesh_node *node); bool node_app_key_delete(struct mesh_net *net, uint16_t addr, uint16_t net_idx, uint16_t idx); @@ -82,6 +83,7 @@ uint8_t node_friend_mode_get(struct mesh_node *node); uint32_t node_seq_cache(struct mesh_node *node); const char *node_get_element_path(struct mesh_node *node, uint8_t ele_idx); const char *node_get_owner(struct mesh_node *node); +const char *node_get_app_path(struct mesh_node *node); bool node_add_pending_local(struct mesh_node *node, void *info); void node_attach_io_all(struct mesh_io *io); void node_attach_io(struct mesh_node *node, struct mesh_io *io); @@ -99,3 +101,4 @@ void node_jconfig_set(struct mesh_node *node, void *jconfig); void *node_jconfig_get(struct mesh_node *node); void node_path_set(struct mesh_node *node, char *path); char *node_path_get(struct mesh_node *node); +struct mesh_agent *node_get_agent(struct mesh_node *node); -- 2.7.4