net: buf: Add net_buf_simple_init_with_data
This adds net_bug_simple_init_with_data which can be used to initialize a net_buf_simple pointer with an external data pointer. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
432c93bb55
commit
53784479b3
2 changed files with 22 additions and 4 deletions
|
@ -140,6 +140,18 @@ static inline void net_buf_simple_init(struct net_buf_simple *buf,
|
|||
buf->len = 0U;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize a net_buf_simple object with data.
|
||||
*
|
||||
* Initialized buffer object with external data.
|
||||
*
|
||||
* @param buf Buffer to initialize.
|
||||
* @param data External data pointer
|
||||
* @param size Amount of data the pointed data buffer if able to fit.
|
||||
*/
|
||||
void net_buf_simple_init_with_data(struct net_buf_simple *buf,
|
||||
void *data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Reset buffer
|
||||
*
|
||||
|
|
|
@ -385,10 +385,7 @@ struct net_buf *net_buf_alloc_with_data(struct net_buf_pool *pool,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
buf->__buf = data;
|
||||
buf->data = data;
|
||||
buf->size = size;
|
||||
buf->len = size;
|
||||
net_buf_simple_init_with_data(&buf->b, data, size);
|
||||
buf->flags = NET_BUF_EXTERNAL_DATA;
|
||||
|
||||
return buf;
|
||||
|
@ -427,6 +424,15 @@ struct net_buf *net_buf_get(struct k_fifo *fifo, s32_t timeout)
|
|||
return buf;
|
||||
}
|
||||
|
||||
void net_buf_simple_init_with_data(struct net_buf_simple *buf,
|
||||
void *data, size_t size)
|
||||
{
|
||||
buf->__buf = data;
|
||||
buf->data = data;
|
||||
buf->size = size;
|
||||
buf->len = size;
|
||||
}
|
||||
|
||||
void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve)
|
||||
{
|
||||
NET_BUF_ASSERT(buf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue