michal-narajowski closed pull request #150: mesh: glue: Add utility net_buf
functions for later use
URL: https://github.com/apache/mynewt-nimble/pull/150
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/nimble/host/mesh/include/mesh/glue.h
b/nimble/host/mesh/include/mesh/glue.h
index 7237a82a..b458ffeb 100644
--- a/nimble/host/mesh/include/mesh/glue.h
+++ b/nimble/host/mesh/include/mesh/glue.h
@@ -215,11 +215,13 @@ void net_buf_unref(struct os_mbuf *om);
uint16_t net_buf_simple_pull_le16(struct os_mbuf *om);
uint16_t net_buf_simple_pull_be16(struct os_mbuf *om);
uint32_t net_buf_simple_pull_be32(struct os_mbuf *om);
+uint32_t net_buf_simple_pull_le32(struct os_mbuf *om);
uint8_t net_buf_simple_pull_u8(struct os_mbuf *om);
void net_buf_simple_add_le16(struct os_mbuf *om, uint16_t val);
void net_buf_simple_add_be16(struct os_mbuf *om, uint16_t val);
void net_buf_simple_add_u8(struct os_mbuf *om, uint8_t val);
void net_buf_simple_add_be32(struct os_mbuf *om, uint32_t val);
+void net_buf_simple_add_le32(struct os_mbuf *om, uint32_t val);
void net_buf_add_zeros(struct os_mbuf *om, uint8_t len);
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);
diff --git a/nimble/host/mesh/src/glue.c b/nimble/host/mesh/src/glue.c
index 5933bb5c..01dbdf43 100644
--- a/nimble/host/mesh/src/glue.c
+++ b/nimble/host/mesh/src/glue.c
@@ -183,6 +183,20 @@ net_buf_simple_pull_be32(struct os_mbuf *om)
return val;
}
+uint32_t
+net_buf_simple_pull_le32(struct os_mbuf *om)
+{
+ uint32_t val;
+ struct os_mbuf *old = om;
+
+ om = os_mbuf_pullup(om, sizeof(val));
+ assert(om == old);
+ val = get_le32(om->om_data);
+ os_mbuf_adj(om, sizeof(val));
+
+ return val;
+}
+
uint8_t
net_buf_simple_pull_u8(struct os_mbuf *om)
{
@@ -221,6 +235,14 @@ net_buf_simple_add_be32(struct os_mbuf *om, uint32_t val)
ASSERT_NOT_CHAIN(om);
}
+void
+net_buf_simple_add_le32(struct os_mbuf *om, uint32_t val)
+{
+ val = htole32(val);
+ os_mbuf_append(om, &val, sizeof(val));
+ ASSERT_NOT_CHAIN(om);
+}
+
void
net_buf_simple_add_u8(struct os_mbuf *om, uint8_t val)
{
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services