diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h index 701fe6885..8caddae86 100644 --- a/include/osmocom/gsm/tlv.h +++ b/include/osmocom/gsm/tlv.h @@ -4,6 +4,8 @@ #include #include +#include +#include /*! \defgroup tlv GSM L3 compatible TLV parser * @{ @@ -436,6 +438,27 @@ static inline uint32_t tlvp_val32_unal(const struct tlv_parsed *tp, int pos) return res; } +/*! \brief Retrieve (possibly unaligned) TLV element and convert to host byte order + * \param[in] tp pointer to \ref tlv_parsed + * \param[in] pos element to return + * \returns aligned 16 bit value in host byte order + */ +static inline uint16_t tlvp_val16be(const struct tlv_parsed *tp, int pos) +{ + return osmo_load16be(TLVP_VAL(tp, pos)); +} + +/*! \brief Retrieve (possibly unaligned) TLV element and convert to host byte order + * \param[in] tp pointer to \ref tlv_parsed + * \param[in] pos element to return + * \returns aligned 32 bit value in host byte order + */ +static inline uint32_t tlvp_val32be(const struct tlv_parsed *tp, int pos) +{ + return osmo_load32be(TLVP_VAL(tp, pos)); +} + + struct tlv_parsed *osmo_tlvp_copy(const struct tlv_parsed *tp_orig, void *ctx); int osmo_tlvp_merge(struct tlv_parsed *dst, const struct tlv_parsed *src); int osmo_shift_v_fixed(uint8_t **data, size_t *data_len,