diff options
author | Ingo Albrecht <prom@berlin.ccc.de> | 2010-02-28 08:35:48 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-03-07 11:47:10 +0100 |
commit | d73784344053d8e12d302de53fee92c095de39e7 (patch) | |
tree | 157b8a5cecd9f24243495f8d9247a293436c4055 /src/target/firmware/include/comm | |
parent | 2fc7d9d001f470022c86edfa069c31c189c6d5c4 (diff) |
Buffer formatting and scanning functions.
Diffstat (limited to 'src/target/firmware/include/comm')
-rw-r--r-- | src/target/firmware/include/comm/msgb.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/target/firmware/include/comm/msgb.h b/src/target/firmware/include/comm/msgb.h index c89364a3..3aaeed43 100644 --- a/src/target/firmware/include/comm/msgb.h +++ b/src/target/firmware/include/comm/msgb.h @@ -85,6 +85,17 @@ static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len) msgb->len += len; return tmp; } +static inline void msgb_put_u8(struct msgb *msgb, uint8_t word) +{ + uint8_t *space = msgb_put(msgb, 1); + space[0] = word & 0xFF; +} +static inline void msgb_put_u16(struct msgb *msgb, uint16_t word) +{ + uint8_t *space = msgb_put(msgb, 2); + space[0] = word >> 8 & 0xFF; + space[1] = word & 0xFF; +} static inline void msgb_put_u32(struct msgb *msgb, uint32_t word) { uint8_t *space = msgb_put(msgb, 4); @@ -100,6 +111,16 @@ static inline unsigned char *msgb_get(struct msgb *msgb, unsigned int len) msgb->len -= len; return tmp; } +static inline uint8_t msgb_get_u8(struct msgb *msgb) +{ + uint8_t *space = msgb_get(msgb, 1); + return space[0]; +} +static inline uint16_t msgb_get_u16(struct msgb *msgb) +{ + uint8_t *space = msgb_get(msgb, 2); + return space[0] << 8 | space[1]; +} static inline uint32_t msgb_get_u32(struct msgb *msgb) { uint8_t *space = msgb_get(msgb, 4); |