net: buf: Add support for 48 bit data type
This enables pulling and pushing values in 48 bit format. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
a0f5db952e
commit
e0a55796b2
2 changed files with 138 additions and 0 deletions
|
@ -291,6 +291,30 @@ void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val);
|
|||
*/
|
||||
void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 48-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 48-bit value in little endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_le48(struct net_buf_simple *buf, u64_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 48-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 48-bit value in big endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_be48(struct net_buf_simple *buf, u64_t val);
|
||||
|
||||
/**
|
||||
* @brief Push data to the beginning of the buffer.
|
||||
*
|
||||
|
@ -446,6 +470,30 @@ u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf);
|
|||
*/
|
||||
u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 48 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_simple_pull(), but a helper for operating
|
||||
* on 48-bit little endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 48-bit value converted from little endian to host endian.
|
||||
*/
|
||||
u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 48 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_simple_pull(), but a helper for operating
|
||||
* on 48-bit big endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 48-bit value converted from big endian to host endian.
|
||||
*/
|
||||
u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Get the tail pointer for a buffer.
|
||||
*
|
||||
|
@ -1212,6 +1260,32 @@ static inline void *net_buf_user_data(const struct net_buf *buf)
|
|||
*/
|
||||
#define net_buf_add_be32(buf, val) net_buf_simple_add_be32(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_add_le48
|
||||
* @brief Add 48-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 48-bit value in little endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be added.
|
||||
*/
|
||||
#define net_buf_add_le48(buf, val) net_buf_simple_add_le48(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_add_be48
|
||||
* @brief Add 48-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 48-bit value in big endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be added.
|
||||
*/
|
||||
#define net_buf_add_be48(buf, val) net_buf_simple_add_be48(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_push
|
||||
* @brief Push data to the beginning of the buffer.
|
||||
|
@ -1380,6 +1454,32 @@ static inline void *net_buf_user_data(const struct net_buf *buf)
|
|||
*/
|
||||
#define net_buf_pull_be32(buf) net_buf_simple_pull_be32(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull_le48
|
||||
* @brief Remove and convert 48 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_pull(), but a helper for operating on
|
||||
* 48-bit little endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 48-bit value converted from little endian to host endian.
|
||||
*/
|
||||
#define net_buf_pull_le48(buf) net_buf_simple_pull_le48(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull_be48
|
||||
* @brief Remove and convert 48 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_pull(), but a helper for operating on
|
||||
* 48-bit big endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer
|
||||
*
|
||||
* @return 48-bit value converted from big endian to host endian.
|
||||
*/
|
||||
#define net_buf_pull_be48(buf) net_buf_simple_pull_be48(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_tailroom
|
||||
* @brief Check buffer tailroom.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue