Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3527464ybi; Sun, 14 Jul 2019 16:24:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNppsZK4ba7JNIn/pYFUqiochZ+hoGNp4KH6j5But4ze+JnvoQy3KeYWZx6uT0Lb/lAn2s X-Received: by 2002:a17:902:ff05:: with SMTP id f5mr24254128plj.116.1563146640845; Sun, 14 Jul 2019 16:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563146640; cv=none; d=google.com; s=arc-20160816; b=ZRUZJvxogbjIcBQkWeHUr8gfw+x281XnDRNA4r3kecxfWcqCv62BCRAnkULO7CD2P5 7AEWYNPYoyf5kE6H6AEqGApi9sviH6gY+EtPVAaq6VQ93+UkyA0yFpbPGNcHMTaQ5erH +v1GHn/d1dk0TgciQfqS9wX4EIlkT7L3tsxRLuX0SznHJ17aW54oH6rBpgkuOTH0PWmx pwvSOkk+gR4NsJbNMF9MICgaZLDFomiO3b0U+WMJ3RFQ+ToA58G/R9jRYnNlN7eCemCt 7t1+BEvirnsQzgNHCTk0DQcDwblEitqm+7VkrARepaiVpuX6D95yQS7kHx/jeCWZuqqu BHEw== 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=bMWTOxvloFcq2a5OOo7ndpIbX4e3nmWUDwx65pZDYBs=; b=DeTom7R3MBH5i2HBjbet5HDjk2XOF2Kqs7LwUa199cW3ziThLm1A5JlT0NoLR2ZUpf 13aR/ew/0jlTuX9al4gQn2llM9WKmwxwDmsre4RiDyb0l13bmfloVoeqo71eP+4M+JB1 zfTTnOZkQuvqBOEz/2rIS1NS0BEONp3T8kkuZ8WD8edadpV4XU6yiMoYo5yI5Wr4+CPl 24donQk0ngYF0eQBH0kyeaPqJFEYQNq9a2OiwuPdoid78dPxI+UuUbhhGzo7UJbdRfqV SAMUWNTF2sAtgZehIhmFJwuCQ7L8W84Jm4GMwS7PYoxwJpWEqzoUiucbh7PDR0i9B/cE GDrA== 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 h6si13754239pll.313.2019.07.14.16.23.25; Sun, 14 Jul 2019 16:24:00 -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 S1728864AbfGNXXX (ORCPT + 99 others); Sun, 14 Jul 2019 19:23:23 -0400 Received: from mga02.intel.com ([134.134.136.20]:39738 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728803AbfGNXXX (ORCPT ); Sun, 14 Jul 2019 19:23:23 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jul 2019 16:23:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,492,1557212400"; d="scan'208";a="168805626" Received: from rreichel-mobl1.amr.corp.intel.com (HELO ingas-nuc1.sea.intel.com) ([10.254.24.81]) by fmsmga007.fm.intel.com with ESMTP; 14 Jul 2019 16:23:22 -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 v3] mesh: Move network config setup from storage.c to node.c Date: Sun, 14 Jul 2019 16:23:11 -0700 Message-Id: <20190714232320.20921-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190714232320.20921-1-inga.stotland@intel.com> References: <20190714232320.20921-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 27235ef34..dc9781482 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -376,6 +376,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; @@ -408,6 +409,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