summaryrefslogtreecommitdiffstats
path: root/src/target
diff options
context:
space:
mode:
authorIngo Albrecht <prom@berlin.ccc.de>2010-02-24 02:28:11 +0100
committerHarald Welte <laforge@gnumonks.org>2010-03-07 11:47:09 +0100
commit0a8d443e82630e9f063c446f7028a7f8f076b31a (patch)
treea8332be2251f21ce11843d7e16b1e6e7a0fa93f5 /src/target
parent41abd7e50055e69993d5e9c8acd9852aee51da1f (diff)
Some msgb formatting functions.
Diffstat (limited to 'src/target')
-rw-r--r--src/target/firmware/include/comm/msgb.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/target/firmware/include/comm/msgb.h b/src/target/firmware/include/comm/msgb.h
index 6114d4b2..c89364a3 100644
--- a/src/target/firmware/include/comm/msgb.h
+++ b/src/target/firmware/include/comm/msgb.h
@@ -85,6 +85,26 @@ static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len)
msgb->len += len;
return tmp;
}
+static inline void msgb_put_u32(struct msgb *msgb, uint32_t word)
+{
+ uint8_t *space = msgb_put(msgb, 4);
+ space[0] = word >> 24 & 0xFF;
+ space[1] = word >> 16 & 0xFF;
+ space[2] = word >> 8 & 0xFF;
+ space[3] = word & 0xFF;
+}
+static inline unsigned char *msgb_get(struct msgb *msgb, unsigned int len)
+{
+ unsigned char *tmp = msgb->data;
+ msgb->data += len;
+ msgb->len -= len;
+ return tmp;
+}
+static inline uint32_t msgb_get_u32(struct msgb *msgb)
+{
+ uint8_t *space = msgb_get(msgb, 4);
+ return space[0] << 24 | space[1] << 16 | space[2] << 8 | space[3];
+}
static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len)
{
msgb->data -= len;