summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2014-08-18 15:31:04 +0200
committerHarald Welte <laforge@gnumonks.org>2014-08-18 15:31:04 +0200
commitcc27fa6479efd446065d691d888d1729bc1be2c8 (patch)
treecc3637f46dad2ee66a83c24a4ba3d8c4beca3df9 /include
parent900e180f919d788adf55202a9d56e6ef7458de82 (diff)
TLV: add TLVP_PRES_LEN() definition to check for existance + minimum length
This is an import from osmo-bts where it was introduced in 6b561bb7ba5f10c5fd96542a7e42de2822352a67
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/gsm/tlv.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h
index fda1810e..d54ef1af 100644
--- a/include/osmocom/gsm/tlv.h
+++ b/include/osmocom/gsm/tlv.h
@@ -409,6 +409,9 @@ void tlv_def_patch(struct tlv_definition *dst, const struct tlv_definition *src)
#define TLVP_LEN(x, y) (x)->lv[y].len
#define TLVP_VAL(x, y) (x)->lv[y].val
+#define TLVP_PRES_LEN(tp, tag, min_len) \
+ (TLVP_PRESENT(tp, tag) && TLVP_LEN(tp, tag) >= min_len)
+
/*! \brief 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