This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Max gerrit-no-reply at lists.osmocom.orgMax has submitted this change and it was merged. ( https://gerrit.osmocom.org/12373 ) Change subject: TLV: add convenience function for 1-byte values ...................................................................... TLV: add convenience function for 1-byte values Similar to existing 16 and 32 bit value helpers but simpler because we don't have to worry about alingment and endianness. Change-Id: Ic0a148bd04b8860e321f509fdcd913f688c8e920 --- M include/osmocom/gsm/tlv.h 1 file changed, 16 insertions(+), 0 deletions(-) Approvals: Max: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h index 4c39264..d0c9552 100644 --- a/include/osmocom/gsm/tlv.h +++ b/include/osmocom/gsm/tlv.h @@ -495,6 +495,22 @@ (TLVP_PRES_LEN(_tp, tag, min_len)? (_tp)->lv[tag].val : NULL) +/*! Obtain 1-byte TLV element. + * \param[in] tp pointer to \ref tlv_parsed + * \param[in] tag the Tag to look for + * \param[in] default_val default value to use if tag not available + * \returns the 1st byte of value with a given tag or default_val if tag was not found + */ +static inline uint8_t tlvp_val8(const struct tlv_parsed *tp, uint8_t tag, uint8_t default_val) +{ + const uint8_t *res = TLVP_VAL_MINLEN(tp, tag, 1); + + if (res) + return res[0]; + + return default_val; +} + /*! Align given TLV element with 16 bit value to an even address * \param[in] tp pointer to \ref tlv_parsed * \param[in] pos element to return -- To view, visit https://gerrit.osmocom.org/12373 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: Ic0a148bd04b8860e321f509fdcd913f688c8e920 Gerrit-Change-Number: 12373 Gerrit-PatchSet: 4 Gerrit-Owner: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder (1000002) Gerrit-Reviewer: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181220/3a1fdcd6/attachment.htm>