Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2777020ybi; Sat, 13 Jul 2019 23:31:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7wdwvoT6Thp3ouwi1WX2tJDe7Q1PNWJ5SE0MU0sLQlwUfeu6DOqkmkzgL5U4t8wYj/24z X-Received: by 2002:a17:90a:ba94:: with SMTP id t20mr22124147pjr.8.1563085875728; Sat, 13 Jul 2019 23:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563085875; cv=none; d=google.com; s=arc-20160816; b=DjkI5vV//MyzxwSPyaTlQXZFumRsvOZboKYQWHFT13zk//z7/KluGukMlxkpVdoh7Q KdQtSpI5rr+7oegJWZlHRg97JzZliXcucPXdtiqtEIr0bXXIspyjknHaIdRV2FFMVB0H WV4ceemXWiAdZ3E0qX2NBEBXNcawTsgNSiLpQ9EpLK/QLfLFgKUVsIYHtveBOoCC7z2F mtjRopcmVsERYIez9ifWjBoWlVj8nrX9P6liQwJbbijXjN6jwuCFVoH7mbPNTZdUiyzJ CfAcUIYA+V2+QuGy2MnhNYWccmSMWrGDUw7K7YWfWTb6vlZLLuLP1tHVevJDiWBRQ7Y6 Xs+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=8lrUyjz1Zk1cSyZbWEk3rAXFHcSoeZifK47FfWaIcZU=; b=D9jM1W7sq9ODQe7GIiwKBSh0WGpn+YcCcmIFvSNslnu0T6mdWRvSQr/3PYAFIxd86N 6aU+Nx3QG+4qmc59EFbGSzQRx6+o/5D8JQ29wOJjNWtkxArW+Io0bKSbdVK6a6KyFyfx q6zDiS9Be8+Vc4xhJno3Ogs0559cCCyFB9qU+U5Ayv8H9Din7J9+07KjJcXBsQobKALX K3hIxEh9bKGHWMvjU180+OJBBvevJYpqpnTXL70DZy2pzCoIIa7kNitsZ849hJI4IEXj L206k1H7tRfsCDES4wL0kLdrQ9mJ+IvaYPO/ohPTzW7AYoNIDEGZN8wKaGh5vj9U8Ppv Bc0w== 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 p20si1909043pgm.192.2019.07.13.23.30.58; Sat, 13 Jul 2019 23:31:15 -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 S1726157AbfGNG2Q (ORCPT + 99 others); Sun, 14 Jul 2019 02:28:16 -0400 Received: from mga06.intel.com ([134.134.136.31]:30353 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbfGNG2Q (ORCPT ); Sun, 14 Jul 2019 02:28:16 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2019 23:28:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,489,1557212400"; d="scan'208";a="318387975" Received: from ingas-nuc1.sea.intel.com ([10.251.146.93]) by orsmga004.jf.intel.com with ESMTP; 13 Jul 2019 23:28:15 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com, jakub.witowski@silvair.com, Inga Stotland Subject: [PATCH BlueZ 01/10 v2] mesh: Move network config setup from storage.c to node.c Date: Sat, 13 Jul 2019 23:28:03 -0700 Message-Id: <20190714062812.31041-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190714062812.31041-1-inga.stotland@intel.com> References: <20190714062812.31041-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This commit moves initialization of configuration parameters for node->net when the local node state is restored from stored configuration. Old location: storage.c, new locaiton node.c. --- mesh/node.c | 28 ++++++++++++++++++++++++++++ mesh/storage.c | 39 --------------------------------------- 2 files changed, 28 insertions(+), 39 deletions(-) diff --git a/mesh/node.c b/mesh/node.c index 1f781cfe9..a2d95dacf 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -375,6 +375,7 @@ bool node_init_from_storage(struct mesh_node *node, void *data) { struct mesh_db_node *db_node = data; unsigned int num_ele; + uint8_t mode; node->comp = l_new(struct node_composition, 1); node->comp->cid = db_node->cid; @@ -407,6 +408,33 @@ bool node_init_from_storage(struct mesh_node *node, void *data) node->primary = db_node->unicast; + mesh_net_set_seq_num(node->net, node->seq_number); + mesh_net_set_default_ttl(node->net, node->ttl); + + mode = node->proxy; + if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) + mesh_net_set_proxy_mode(node->net, mode == MESH_MODE_ENABLED); + + mode = node->lpn; + if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) + mesh_net_set_friend_mode(node->net, mode == MESH_MODE_ENABLED); + + mode = node->relay.mode; + if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) + mesh_net_set_relay_mode(node->net, mode == MESH_MODE_ENABLED, + node->relay.cnt, node->relay.interval); + + mode = node->beacon; + if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) + mesh_net_set_beacon_mode(node->net, mode == MESH_MODE_ENABLED); + + if (!IS_UNASSIGNED(node->primary) && + !mesh_net_register_unicast(node->net, node->primary, num_ele)) + return false; + + if (node->uuid) + mesh_net_id_uuid_set(node->net, node->uuid); + /* Initialize configuration server model */ mesh_config_srv_init(node, PRIMARY_ELE_IDX); diff --git a/mesh/storage.c b/mesh/storage.c index 0f2b77fde..2b7804242 100644 --- a/mesh/storage.c +++ b/mesh/storage.c @@ -56,51 +56,12 @@ static const char *storage_dir; static bool read_node_cb(struct mesh_db_node *db_node, void *user_data) { struct mesh_node *node = user_data; - struct mesh_net *net; - uint32_t seq_number; - uint8_t ttl, mode, cnt, num_ele; - uint16_t unicast, interval; - uint8_t *uuid; if (!node_init_from_storage(node, db_node)) { node_remove(node); return false; } - net = node_get_net(node); - seq_number = node_get_sequence_number(node); - mesh_net_set_seq_num(net, seq_number); - ttl = node_default_ttl_get(node); - mesh_net_set_default_ttl(net, ttl); - - mode = node_proxy_mode_get(node); - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_proxy_mode(net, mode == MESH_MODE_ENABLED); - - mode = node_friend_mode_get(node); - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_friend_mode(net, mode == MESH_MODE_ENABLED); - - mode = node_relay_mode_get(node, &cnt, &interval); - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_relay_mode(net, mode == MESH_MODE_ENABLED, cnt, - interval); - - mode = node_beacon_mode_get(node); - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_beacon_mode(net, mode == MESH_MODE_ENABLED); - - unicast = db_node->unicast; - num_ele = node_get_num_elements(node); - - if (!IS_UNASSIGNED(unicast) && - !mesh_net_register_unicast(net, unicast, num_ele)) - return false; - - uuid = node_uuid_get(node); - if (uuid) - mesh_net_id_uuid_set(net, uuid); - return true; } -- 2.21.0