library/DIAMETER: Allow passing template as imsi param to tr_AVP_UserNameImsi()

Change-Id: Ia525b2a1850bc80cee13717b114fec215fa84f9f
diff --git a/library/DIAMETER_Templates.ttcn b/library/DIAMETER_Templates.ttcn
index 4dd686a..b6723e7 100644
--- a/library/DIAMETER_Templates.ttcn
+++ b/library/DIAMETER_Templates.ttcn
@@ -625,7 +625,7 @@
 	}
 }
 template (value) GenericAVP ts_AVP_UserNameImsi(hexstring imsi) := ts_AVP_UserName(char2oct(hex2str(imsi)));
-template (present) GenericAVP tr_AVP_UserNameImsi(hexstring imsi) := tr_AVP_UserName(char2oct(hex2str(imsi)));
+template (present) GenericAVP tr_AVP_UserNameImsi(template (present) hexstring imsi := ?) := tr_AVP_UserName(char2oct_tmpl(hex2str_tmpl(imsi)));
 
 
 
diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index ce22c1e..ef55583 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -179,6 +179,19 @@
 	}
 }
 
+function hex2str_tmpl(template hexstring inp) return template charstring
+{
+	if (istemplatekind(inp, "omit")) {
+		return omit;
+	} else if (istemplatekind(inp, "*")) {
+		return *;
+	} else if (istemplatekind(inp, "?")) {
+		return ?;
+	} else {
+		return hex2str(valueof(inp));
+	}
+}
+
 function f_array_contains(IntegerRecord arr, integer key) return boolean {
 	for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
 		if (arr[i] == key) {