mirror of https://gerrit.osmocom.org/libosmocore
tlv.h: Add msgb_tvlv_put_{16,32}be()
Those routines are very useful when puzzling together BSSGP messages with 16-bit and 32bit sized IEs. Change-Id: I033f9a708c9d7ffad91336178231dc66233e1693
This commit is contained in:
parent
a6f896232e
commit
dec201a606
|
@ -4,6 +4,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <osmocom/core/msgb.h>
|
||||
#include <osmocom/core/byteswap.h>
|
||||
#include <osmocom/core/bit16gen.h>
|
||||
#include <osmocom/core/bit32gen.h>
|
||||
|
||||
|
@ -278,6 +279,20 @@ static inline uint8_t *msgb_tvlv_put(struct msgb *msg, uint8_t tag, uint16_t len
|
|||
return tvlv_put(buf, tag, len, val);
|
||||
}
|
||||
|
||||
/*! put (append) a TvLV field containing a big-endian 16bit value to msgb. */
|
||||
static inline uint8_t *msgb_tvlv_put_16be(struct msgb *msg, uint8_t tag, uint16_t val)
|
||||
{
|
||||
uint16_t val_be = osmo_htons(val);
|
||||
return msgb_tvlv_put(msg, tag, 2, (const uint8_t *)&val_be);
|
||||
}
|
||||
|
||||
/*! put (append) a TvLV field containing a big-endian 16bit value to msgb. */
|
||||
static inline uint8_t *msgb_tvlv_put_32be(struct msgb *msg, uint8_t tag, uint32_t val)
|
||||
{
|
||||
uint32_t val_be = osmo_htonl(val);
|
||||
return msgb_tvlv_put(msg, tag, 4, (const uint8_t *)&val_be);
|
||||
}
|
||||
|
||||
/*! put (append) a vTvLV field to \ref msgb */
|
||||
static inline uint8_t *msgb_vtvlv_gan_put(struct msgb *msg, uint16_t tag,
|
||||
uint16_t len, const uint8_t *val)
|
||||
|
|
Loading…
Reference in New Issue