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:
parent
3d201b45f9
commit
6911287899
1 changed files with 10 additions and 12 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue