Bluetooth: Mesh: Expose header parsing outside net

Provides utility function for parsing network headers outside of the
network layer. The primary intended use-case is friendship.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This commit is contained in:
Trond Einar Snekvik 2019-09-30 13:24:44 +02:00 committed by Johan Hedberg
commit ec5e43ba5f
2 changed files with 13 additions and 0 deletions

View file

@ -1218,6 +1218,17 @@ done:
net_buf_unref(buf);
}
void bt_mesh_net_header_parse(struct net_buf_simple *buf,
struct bt_mesh_net_rx *rx)
{
rx->old_iv = (IVI(buf->data) != (bt_mesh.iv_index & 0x01));
rx->ctl = CTL(buf->data);
rx->ctx.recv_ttl = TTL(buf->data);
rx->seq = SEQ(buf->data);
rx->ctx.addr = SRC(buf->data);
rx->ctx.recv_dst = DST(buf->data);
}
int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if,
struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
{

View file

@ -344,6 +344,8 @@ u32_t bt_mesh_next_seq(void);
void bt_mesh_net_start(void);
void bt_mesh_net_init(void);
void bt_mesh_net_header_parse(struct net_buf_simple *buf,
struct bt_mesh_net_rx *rx);
/* Friendship Credential Management */
struct friend_cred {