diff --git a/nimble/host/mesh/include/mesh/glue.h b/nimble/host/mesh/include/mesh/glue.h index 8edb6c3ba..e4297b6c2 100644 --- a/nimble/host/mesh/include/mesh/glue.h +++ b/nimble/host/mesh/include/mesh/glue.h @@ -231,6 +231,7 @@ void net_buf_simple_push_le16(struct os_mbuf *om, uint16_t val); void net_buf_simple_push_be16(struct os_mbuf *om, uint16_t val); void net_buf_simple_push_u8(struct os_mbuf *om, uint8_t val); void *net_buf_simple_pull(struct os_mbuf *om, uint8_t len); +void *net_buf_simple_pull_mem(struct os_mbuf *om, uint8_t len); void *net_buf_simple_add(struct os_mbuf *om, uint8_t len); bool k_fifo_is_empty(struct ble_npl_eventq *q); void *net_buf_get(struct ble_npl_eventq *fifo,s32_t t); diff --git a/nimble/host/mesh/src/beacon.c b/nimble/host/mesh/src/beacon.c index 5ec0823a4..da909852f 100644 --- a/nimble/host/mesh/src/beacon.c +++ b/nimble/host/mesh/src/beacon.c @@ -279,8 +279,7 @@ static void secure_beacon_recv(struct os_mbuf *buf) data = buf->om_data; flags = net_buf_simple_pull_u8(buf); - net_id = buf->om_data; - net_buf_simple_pull(buf, 8); + net_id = net_buf_simple_pull_mem(buf, 8); iv_index = net_buf_simple_pull_be32(buf); auth = buf->om_data; diff --git a/nimble/host/mesh/src/cfg_srv.c b/nimble/host/mesh/src/cfg_srv.c index faad75d8b..4ee9e8cfd 100644 --- a/nimble/host/mesh/src/cfg_srv.c +++ b/nimble/host/mesh/src/cfg_srv.c @@ -1286,9 +1286,7 @@ static void mod_pub_va_set(struct bt_mesh_model *model, return; } - label_uuid = buf->om_data; - net_buf_simple_pull(buf, 16); - + label_uuid = net_buf_simple_pull_mem(buf, 16); pub_app_idx = net_buf_simple_pull_le16(buf); cred_flag = ((pub_app_idx >> 12) & BIT_MASK(1)); pub_app_idx &= BIT_MASK(12); @@ -1830,8 +1828,7 @@ static void mod_sub_va_add(struct bt_mesh_model *model, return; } - label_uuid = buf->om_data; - net_buf_simple_pull(buf, 16); + label_uuid = net_buf_simple_pull_mem(buf, 16); BT_DBG("elem_addr 0x%04x", elem_addr); @@ -1908,8 +1905,7 @@ static void mod_sub_va_del(struct bt_mesh_model *model, return; } - label_uuid = buf->om_data; - net_buf_simple_pull(buf, 16); + label_uuid = net_buf_simple_pull_mem(buf, 16); BT_DBG("elem_addr 0x%04x", elem_addr); @@ -1976,12 +1972,11 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model, return; } - label_uuid = buf->om_data; - net_buf_simple_pull(buf, 16); - mod_id = buf->om_data; + label_uuid = net_buf_simple_pull_mem(buf, 16); - BT_DBG("elem_addr 0x%04x, addr %s, mod_id %s", elem_addr, - bt_hex(label_uuid, 16), bt_hex(mod_id, buf->om_len)); + BT_DBG("elem_addr 0x%04x", elem_addr); + + mod_id = buf->om_data; elem = bt_mesh_elem_find(elem_addr); if (!elem) { diff --git a/nimble/host/mesh/src/glue.c b/nimble/host/mesh/src/glue.c index 01dbdf431..96df0f8f0 100644 --- a/nimble/host/mesh/src/glue.c +++ b/nimble/host/mesh/src/glue.c @@ -320,6 +320,15 @@ net_buf_simple_pull(struct os_mbuf *om, uint8_t len) return om->om_data; } +void * +net_buf_simple_pull_mem(struct os_mbuf *om, uint8_t len) +{ + void *data = om->om_data; + + net_buf_simple_pull(om, len); + return data; +} + void* net_buf_simple_add(struct os_mbuf *om, uint8_t len) {