mesh: Fix friendship counter increasing order

For Bluetooth Mesh, counter shall be increasing by one when
every try to establishing friendship.

Counter to be used when create friendship security material.
So this value shall be consist between friend and lpn.

Due to zephyr bluetooth mesh send previous counter, after that
it will automatically increase one, which will result in the
incorrect generation of friend key when key rephase.

this is port of f8022fa01265deb72259f38dfcd8dfcf54c415ca
This commit is contained in:
Krzysztof Kopyściński
2021-01-12 14:05:19 +01:00
committed by Łukasz Rymanowski
parent 13a7c75cba
commit 5a5493d70f
2 changed files with 4 additions and 4 deletions
+1 -2
View File
@@ -173,6 +173,7 @@ static void friend_clear(struct bt_mesh_friend *frnd)
seg->seg_count = 0U;
}
frnd->counter++;
frnd->subnet = NULL;
frnd->established = 0;
frnd->pending_buf = 0;
@@ -884,8 +885,6 @@ static void enqueue_offer(struct bt_mesh_friend *frnd, int8_t rssi)
goto done;
}
frnd->counter++;
if (frnd->last) {
net_buf_unref(frnd->last);
}
+3 -2
View File
@@ -293,6 +293,9 @@ static int send_friend_req(struct bt_mesh_lpn *lpn)
.src = bt_mesh_primary_addr(),
.xmit = POLL_XMIT,
};
lpn->lpn_counter++;
struct bt_mesh_ctl_friend_req req = {
.criteria = LPN_CRITERIA,
.recv_delay = LPN_RECV_DELAY,
@@ -556,8 +559,6 @@ int bt_mesh_lpn_friend_offer(struct bt_mesh_net_rx *rx,
return err;
}
lpn->lpn_counter++;
return 0;
}