linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Gix <brian.gix@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: brian.gix@intel.com, inga.stotland@intel.com
Subject: [PATCH BlueZ 1/2] mesh: Deliver newly composed SNBs to local nodes
Date: Fri, 20 Dec 2019 12:13:39 -0800	[thread overview]
Message-ID: <20191220201340.8039-2-brian.gix@intel.com> (raw)
In-Reply-To: <20191220201340.8039-1-brian.gix@intel.com>

---
 mesh/net-keys.c |  3 +++
 mesh/net.c      | 13 +++++++++++++
 mesh/net.h      |  1 +
 3 files changed, 17 insertions(+)

diff --git a/mesh/net-keys.c b/mesh/net-keys.c
index 65f0808dd..6f1758fe3 100644
--- a/mesh/net-keys.c
+++ b/mesh/net-keys.c
@@ -480,6 +480,9 @@ bool net_key_beacon_refresh(uint32_t id, uint32_t iv_index, bool kr, bool ivu)
 	l_debug("Setting SNB: IVI: %8.8x, IVU: %d, KR: %d", iv_index, ivu, kr);
 	print_packet("Set SNB Beacon to", beacon, sizeof(beacon));
 
+	/* Propagate changes to all local nodes */
+	net_local_beacon(id, beacon);
+
 	/* Send one new SNB soon, after all nodes have seen it */
 	l_getrandom(&rand_ms, sizeof(rand_ms));
 	rand_ms %= 1000;
diff --git a/mesh/net.c b/mesh/net.c
index 0485086bc..5aeeab188 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -2739,6 +2739,19 @@ static void beacon_recv(void *user_data, struct mesh_io_recv_info *info,
 		net_key_beacon_seen(beacon_data.key_id);
 }
 
+void net_local_beacon(uint32_t key_id, uint8_t *beacon)
+{
+	struct net_beacon_data beacon_data = {
+		.key_id = key_id,
+		.ivu = !!(beacon[2] & 0x02),
+		.kr = !!(beacon[2] & 0x01),
+		.ivi = l_get_be32(beacon + 11),
+	};
+
+	/* Deliver locally generated beacons to all nodes */
+	l_queue_foreach(nets, process_beacon, &beacon_data);
+}
+
 bool mesh_net_set_beacon_mode(struct mesh_net *net, bool enable)
 {
 	if (!net)
diff --git a/mesh/net.h b/mesh/net.h
index 07b87830d..023b61e71 100644
--- a/mesh/net.h
+++ b/mesh/net.h
@@ -280,6 +280,7 @@ uint16_t mesh_net_get_address(struct mesh_net *net);
 bool mesh_net_register_unicast(struct mesh_net *net,
 					uint16_t unicast, uint8_t num_ele);
 uint8_t mesh_net_get_num_ele(struct mesh_net *net);
+void net_local_beacon(uint32_t key_id, uint8_t *beacon);
 bool mesh_net_set_beacon_mode(struct mesh_net *net, bool enable);
 bool mesh_net_set_proxy_mode(struct mesh_net *net, bool enable);
 bool mesh_net_set_relay_mode(struct mesh_net *net, bool enable, uint8_t cnt,
-- 
2.21.0


  reply	other threads:[~2019-12-20 20:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20 20:13 [PATCH BlueZ 0/2] mesh: Fix some SNB details Brian Gix
2019-12-20 20:13 ` Brian Gix [this message]
2019-12-20 20:13 ` [PATCH BlueZ 2/2] mesh: Recognize SNBs in SecondsSinceLastHeard Brian Gix
2019-12-24 19:03 ` [PATCH BlueZ 0/2] mesh: Fix some SNB details Gix, Brian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191220201340.8039-2-brian.gix@intel.com \
    --to=brian.gix@intel.com \
    --cc=inga.stotland@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).