laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/21609 )


Change subject: tlv.h: Add msgb_tvlv_put_{16,32}be()
......................................................................

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
---
M include/osmocom/gsm/tlv.h
1 file changed, 15 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/09/21609/1

diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h
index d34b7da..fe057f4 100644
--- a/include/osmocom/gsm/tlv.h
+++ b/include/osmocom/gsm/tlv.h
@@ -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 @@
        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)

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21609
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I033f9a708c9d7ffad91336178231dc66233e1693
Gerrit-Change-Number: 21609
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <[email protected]>
Gerrit-MessageType: newchange

Reply via email to