mesh: Take advantage of net_buf_simple_pull_mem()

Use net_buf_simple_pull_mem() instead of net_buf_simple_pull() where
it makes sense.
This commit is contained in:
Michał Narajowski
2019-01-31 17:50:26 +01:00
parent 7cf84d52b9
commit 58ed664b99
4 changed files with 18 additions and 14 deletions
+1
View File
@@ -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);
+1 -2
View File
@@ -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;
+7 -12
View File
@@ -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) {
+9
View File
@@ -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)
{