You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by na...@apache.org on 2021/05/27 08:19:44 UTC

[mynewt-nimble] 06/31: mesh: Initialize msg_ctx when re-encrypting friend msg

This is an automated email from the ASF dual-hosted git repository.

naraj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 8256009f6d90e6b81b9839e7ec32de87b34df87b
Author: Krzysztof Kopyściński <kr...@codecoup.pl>
AuthorDate: Mon Mar 29 12:46:00 2021 +0200

    mesh: Initialize msg_ctx when re-encrypting friend msg
    
    Set app_idx and net_idx in the msg_ctx before calling
    bt_mesh_keys_resolve when re-encrypting friend messages, as they'll be
    referenced inside the function.
    
    this is port of 48526b6925a11bb979b657912dda012303e9050e
---
 nimble/host/mesh/src/friend.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/nimble/host/mesh/src/friend.c b/nimble/host/mesh/src/friend.c
index 9a83c87..8dc55c1 100644
--- a/nimble/host/mesh/src/friend.c
+++ b/nimble/host/mesh/src/friend.c
@@ -345,7 +345,12 @@ static int unseg_app_sdu_unpack(struct bt_mesh_friend *frnd,
 				struct unseg_app_sdu_meta *meta)
 {
 	uint16_t app_idx = FRIEND_ADV(buf)->app_idx;
-	struct bt_mesh_net_rx net;
+	struct bt_mesh_net_rx net = {
+		.ctx = {
+			.app_idx = app_idx,
+			.net_idx = frnd->subnet->net_idx,
+		},
+	};
 	int err;
 
 	meta->subnet = frnd->subnet;
@@ -437,6 +442,8 @@ static int unseg_app_sdu_prepare(struct bt_mesh_friend *frnd,
 		return 0;
 	}
 
+	BT_DBG("Re-encrypting friend pdu");
+
 	err = unseg_app_sdu_decrypt(frnd, buf, &meta);
 	if (err) {
 		BT_WARN("Decryption failed! %d", err);