summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-06-02 13:34:06 +0200
committerHarald Welte <laforge@gnumonks.org>2018-06-02 12:53:29 +0000
commit1fbe3eba757a6ce2f4ea81c7c6548f61f96f9de4 (patch)
tree08ca344dc69944212efc85e5b7fc98fff5db1e65 /include
parentebd362dbd2ef817f00f6713b5c4c5580dedd2b50 (diff)
tlv: Add TLVP_VAL_MINLEN() to obtain value _if_ length is >= minimum
This is a combination of TLVP_VAP() and TLVP_GET_MINLEN() Change-Id: Ic5a177941219ebc3a3bceb3f68bdb3b2cacb934b
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/gsm/tlv.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h
index a130dc8c..84fd511e 100644
--- a/include/osmocom/gsm/tlv.h
+++ b/include/osmocom/gsm/tlv.h
@@ -467,6 +467,16 @@ void tlv_def_patch(struct tlv_definition *dst, const struct tlv_definition *src)
#define TLVP_GET_MINLEN(_tp, tag, min_len) \
(TLVP_PRES_LEN(_tp, tag, min_len)? &(_tp)->lv[tag] : NULL)
+/*! Like TLVP_VAL(), but enforcing a minimum val length.
+ * \param[in] _tp pointer to \ref tlv_parsed.
+ * \param[in] tag IE tag to return.
+ * \param[in] min_len Minimum value length in bytes.
+ * \returns struct tlv_p_entry pointer, or NULL if not present or too short.
+ */
+#define TLVP_VAL_MINLEN(_tp, tag, min_len) \
+ (TLVP_PRES_LEN(_tp, tag, min_len)? (_tp)->lv[tag].val : NULL)
+
+
/*! 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