jenkins: Validate gsm 08.58 IEs are added to tlv_definition

It was recently found that several IEs which were added in the header
file were not actually added to the tlv_definition, and hence the tlv
parser failed to decode them. Let's make sure we don't foget to add new
IEs in the future.

Related: SYS#5915

Change-Id: Id8a679ca43eb0fcc4882780e9a95ec21c7f51972
diff --git a/contrib/jenkins_common.sh b/contrib/jenkins_common.sh
index c39b356..82dd471 100644
--- a/contrib/jenkins_common.sh
+++ b/contrib/jenkins_common.sh
@@ -28,6 +28,21 @@
 }
 verify_gsm0808_tlv_definition
 
+verify_gsm_08_05_tlv_definition() {
+    set +x;
+    enums=$(grep "RSL_IE_" include/osmocom/gsm/protocol/gsm_08_58.h | grep -e "=" -e ",$" | awk '{ print $1 }' | tr -d ',')
+    counted_enums=$(for f in $enums; do printf "%-60s %s\n" "$f" "$(grep -c "\[$f\]" src/gsm/rsl.c)"; done)
+    # TODO: Add RSL_IE_SIEMENS_* to the tlv struct definitions.
+    missing_enums=$(echo "$counted_enums" | grep -v RSL_IE_SIEMENS |grep "0$" || true)
+    if [ "x$missing_enums" != "x" ]; then
+        echo "Missing IEs in src/gsm/rsl.c!"
+        echo "$missing_enums"
+        exit 1
+    fi
+    set -x;
+}
+verify_gsm_08_05_tlv_definition
+
 prep_build() {
     _src_dir="$1"
     _build_dir="$2"