Bluetooth: Mesh: Use net_buf_simple_clone

Uses net_buf_simple_clone to access the sdu of an unsegmented app packet
for re-encryption.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This commit is contained in:
Trond Einar Snekvik 2019-10-01 13:50:24 +02:00 committed by Johan Hedberg
commit 6911287899

View file

@ -361,12 +361,11 @@ static int unseg_app_sdu_decrypt(struct bt_mesh_friend *frnd,
struct net_buf *buf,
const struct unseg_app_sdu_meta *meta)
{
struct net_buf_simple sdu = {
.len = buf->len - 14,
.data = &buf->data[10],
.__buf = &buf->data[10],
.size = buf->len - 10,
};
struct net_buf_simple sdu;
net_buf_simple_clone(&buf->b, &sdu);
net_buf_simple_pull(&sdu, 10);
sdu.len -= 4;
return bt_mesh_app_decrypt(meta->key, meta->is_dev_key, 0, &sdu, &sdu,
meta->ad, meta->net.ctx.addr,
@ -378,12 +377,11 @@ static int unseg_app_sdu_encrypt(struct bt_mesh_friend *frnd,
struct net_buf *buf,
const struct unseg_app_sdu_meta *meta)
{
struct net_buf_simple sdu = {
.len = buf->len - 14,
.data = &buf->data[10],
.__buf = &buf->data[10],
.size = buf->len - 10,
};
struct net_buf_simple sdu;
net_buf_simple_clone(&buf->b, &sdu);
net_buf_simple_pull(&sdu, 10);
sdu.len -= 4;
return bt_mesh_app_encrypt(meta->key, meta->is_dev_key, 0, &sdu,
meta->ad, meta->net.ctx.addr,