Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9740999ybi; Wed, 10 Jul 2019 16:09:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbs4H8zEMoq5FJZlKTUaGmbpVPevOYblQjHXXmuCtA2A0ksE8EYLKUg9hDn1Pyylwrbk/S X-Received: by 2002:a17:90a:d996:: with SMTP id d22mr992128pjv.86.1562800143047; Wed, 10 Jul 2019 16:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562800143; cv=none; d=google.com; s=arc-20160816; b=de7NuOmfUYsiAhmMEfuXbaPQZudxYVHR29Qb1hkzx6UQPmBowyFa/9wcz7ZUP10kE/ xGyrrTXQh5pFi+U90YzPUZW88utvHEfZC6IojwQGveFBO1wjUADsle/5uWzajkCBbfSG 8QCzICPeTpHffNnnTNInzDvI/UIJCRn4xDKvhwxC2S7RbIcUZeZwq9uc4SNcQnCpmOzI UQf+GHSYpRCYc/QSmdz1Fzi4Ersu3ZOVN5EPAJeyIqZA2D2Z29Snp9Jwc4XOFJddAe/K soUcUNKfWbA+iM03oc8G/6Yb89/+8M2lPM4UfXO/+8jWkVREXRHEfEgEaUc0espycm3K wkdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=UmiKg5AP6sB9L3cruNREXIraU98Pc7fOQi2FLGLMBQQ=; b=QAq1z1CKJ9XYoms4m6/OlkKxCj1HjCVzHFnqoqxHg79kaKEMY86dylSH4eUh5oLcZQ HwGzPGZgs2JDkPHZcFdP7k6AZ2D4mmJ8yMzLeTJku4fMeOk7CPlNGgIjl51a2GdXmaux ehJU7NtXbKcUKEpjaW44QZ5QbKL+RLkRxwCTAQ6zZljZfXEHW/d5K4RjuCxAjneBMSc0 Q/MQ4f2MxrqHnf5Sr5xPK8lkPVAPMcITCCKHT8E/JQxUNN7UjdMQoN84sKV+9953JEgF diAmyxkuopoGoDTuBbsRIu4IQ8M9jQfnFvsOKpec8XDJ9IhuTd1JBMyMGP4vlID/X+4Z 4Axw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l62si3411774pgd.24.2019.07.10.16.08.48; Wed, 10 Jul 2019 16:09:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727458AbfGJXI2 (ORCPT + 99 others); Wed, 10 Jul 2019 19:08:28 -0400 Received: from mga14.intel.com ([192.55.52.115]:52368 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726708AbfGJXI1 (ORCPT ); Wed, 10 Jul 2019 19:08:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2019 16:08:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,476,1557212400"; d="scan'208";a="186250414" Received: from bgix-dell-lap.sea.intel.com ([10.255.80.129]) by fmsmga001.fm.intel.com with ESMTP; 10 Jul 2019 16:08:27 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, michal.lowas-rzechonek@silvair.com, brian.gix@intel.com Subject: [PATCH BlueZ 5/8] mesh: Expose resources needed by Management1 interface Date: Wed, 10 Jul 2019 16:07:54 -0700 Message-Id: <20190710230757.8425-6-brian.gix@intel.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190710230757.8425-1-brian.gix@intel.com> References: <20190710230757.8425-1-brian.gix@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- 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 1f781cfe9..27235ef34 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -80,7 +80,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; @@ -242,14 +243,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; } } @@ -441,6 +442,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)); @@ -1026,14 +1032,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; @@ -1509,6 +1515,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; @@ -1736,7 +1745,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}))"); @@ -2007,7 +2016,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 142527b30..d69887ed1 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.14.5