GSUP: Fix build of IEs in f_gen_tr_ies(), add PdpInfo(Compl) IEs to it

The previous conditions "isvalue()" were wrong. Passing an array of
templates to isvalue() returns false, which is unexpected here.

Change-Id: Iaad47b1ec7e2a7477fa554df9caeb866ffa594eb
diff --git a/epdg/EPDG_Tests.ttcn b/epdg/EPDG_Tests.ttcn
index 554dd07..0e9cbed 100644
--- a/epdg/EPDG_Tests.ttcn
+++ b/epdg/EPDG_Tests.ttcn
@@ -506,8 +506,15 @@
 	GSUP.send(ts_GSUP_EPDGTunnel_REQ(g_pars.imsi));
 	f_GTP2C_CreateSession_success();
 	/* Expect a positive response back to the translator; */
+	var template (present) GSUP_IEs pdp_info := {
+			tr_GSUP_IE_PDP_CONTEXT_ID(?),
+			tr_GSUP_IE_PDP_ADDRESS(?),
+			tr_GSUP_IE_APN(?),
+			tr_GSUP_IE_PDP_QOS(?),
+			tr_GSUP_IE_Charging_Characteristics(?)
+			};
 	alt {
-	[] GSUP.receive(tr_GSUP_EPDGTunnel_RES(g_pars.imsi));
+	[] GSUP.receive(tr_GSUP_EPDGTunnel_RES(g_pars.imsi, pdp_info));
 	[] GSUP.receive(GSUP_PDU:?) -> value rx_gsup {
 		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected GSUP msg rx: ", rx_gsup));
 		}
diff --git a/library/GSUP_Templates.ttcn b/library/GSUP_Templates.ttcn
index ea2b489..68e4fd1 100644
--- a/library/GSUP_Templates.ttcn
+++ b/library/GSUP_Templates.ttcn
@@ -190,6 +190,34 @@
 		}
 	}
 }
+template (value) GSUP_IE ts_GSUP_IE_PdpInfo_ie(template (value) GSUP_IEs pdp_info) := {
+	tag := OSMO_GSUP_PDP_INFO_IE,
+	len := 0, /* overwritten */
+	val := {
+		pdp_info := pdp_info
+	}
+}
+
+template (present) GSUP_IE tr_GSUP_IE_PdpInfo(template (present) OCT1 ctx_id,
+					      template (present) octetstring apn,
+					      template (present) GSUP_PDP_Address pdp_address) := {
+	tag := OSMO_GSUP_PDP_INFO_IE,
+	len := ?,
+	val := {
+		pdp_info := {
+			tr_GSUP_IE_PDP_CONTEXT_ID(ctx_id),
+			tr_GSUP_IE_PDP_ADDRESS(pdp_address),
+			tr_GSUP_IE_APN(apn)
+		}
+	}
+}
+template (present) GSUP_IE tr_GSUP_IE_PdpInfo_ie(template (present) GSUP_IEs pdp_info := ?) := {
+	tag := OSMO_GSUP_PDP_INFO_IE,
+	len := ?,
+	val := {
+		pdp_info := pdp_info
+	}
+}
 
 template (value) GSUP_IE ts_GSUP_IE_PDP_CONTEXT_ID(template (value) OCT1 ctx_id) := {
 	tag := OSMO_GSUP_PDP_CONTEXT_ID_IE,
@@ -207,7 +235,6 @@
 	}
 }
 
-
 template (value) GSUP_IE ts_GSUP_IE_PDP_ADDRESS(template (value) GSUP_PDP_Address pdp_address) := {
 	tag := OSMO_GSUP_PDP_ADDRESS_IE,
 	len := 0,
@@ -216,6 +243,14 @@
 	}
 }
 
+template (present) GSUP_IE tr_GSUP_IE_PDP_ADDRESS(template (present) GSUP_PDP_Address pdp_address := ?) := {
+	tag := OSMO_GSUP_PDP_ADDRESS_IE,
+	len := ?,
+	val := {
+		pdp_address := pdp_address
+	}
+}
+
 template (value) GSUP_IE ts_GSUP_IE_PDP_QOS(template (value) octetstring pdp_qos) := {
 	tag := OSMO_GSUP_PDP_QOS_IE,
 	len := 0,
@@ -224,6 +259,29 @@
 	}
 }
 
+template (present) GSUP_IE tr_GSUP_IE_PDP_QOS(template (present) octetstring pdp_qos := ?) := {
+	tag := OSMO_GSUP_PDP_QOS_IE,
+	len := ?,
+	val := {
+		pdp_qos := pdp_qos
+	}
+}
+
+template (value) GSUP_IE ts_GSUP_IE_Charging_Characteristics(template (value) octetstring charg_char) := {
+	tag := OSMO_GSUP_CHARG_CHAR_IE,
+	len := 0,
+	val := {
+		charg_char := charg_char
+	}
+}
+
+template (present) GSUP_IE tr_GSUP_IE_Charging_Characteristics(template (present) octetstring charg_char := ?) := {
+	tag := OSMO_GSUP_CHARG_CHAR_IE,
+	len := ?,
+	val := {
+		charg_char := charg_char
+	}
+}
 
 template GSUP_PDU tr_GSUP(template GSUP_MessageType msgt := ?, template GSUP_IEs ies := *) := {
 	msg_type := msgt,
@@ -428,19 +486,25 @@
 
 
 template (value) GSUP_PDU ts_GSUP_EPDGTunnel_RES(hexstring imsi,
+						template (value) GSUP_IEs pdp_info,
 						GSUP_Message_Class message_class := OSMO_GSUP_MESSAGE_CLASS_IPSEC_EPDG,
 						octetstring destination_name := ''O) :=
 	ts_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_RESULT, {
 		valueof(ts_GSUP_IE_IMSI(imsi)),
+		valueof(ts_GSUP_IE_PdpInfoCompl),
+		valueof(ts_GSUP_IE_PdpInfo_ie(pdp_info)),
 		valueof(ts_GSUP_IE_Message_Class(message_class)),
 		valueof(ts_GSUP_IE_Destination_Name(destination_name))
 		});
 
 template (present) GSUP_PDU tr_GSUP_EPDGTunnel_RES(template (present) hexstring imsi,
+						   template (present) GSUP_IEs pdp_info,
 						   template (present) GSUP_Message_Class message_class := OSMO_GSUP_MESSAGE_CLASS_IPSEC_EPDG,
 						   template octetstring destination_name := omit) :=
 	tr_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_RESULT,
 		f_gen_tr_ies(imsi,
+			     pdp_info_compl := true,
+			     pdp_info := pdp_info,
 			     message_class := message_class,
 			     destination_name := destination_name));
 
@@ -1077,6 +1141,7 @@
 }
 
 private function f_gen_ts_ies(hexstring imsi,
+			   template (omit) boolean pdp_info_compl := omit,
 			   template (omit) GSUP_Message_Class message_class := omit,
 			   template (omit) hexstring imei := omit,
 			   template (omit) GSUP_CnDomain dom := omit,
@@ -1091,6 +1156,10 @@
 		ies := ies & { valueof(ts_GSUP_IE_CnDomain(dom)) };
 	}
 
+	if (isvalue(pdp_info_compl) and valueof(pdp_info_compl)) {
+		ies := ies & { valueof(ts_GSUP_IE_PdpInfoCompl) };
+	}
+
 	if (isvalue(imei)) {
 		ies := ies & { valueof(ts_GSUP_IE_IMEI(valueof(imei))) };
 	}
@@ -1111,6 +1180,8 @@
 }
 
 private function f_gen_tr_ies(template hexstring imsi,
+			      template boolean pdp_info_compl := omit,
+			      template GSUP_IEs pdp_info := omit,
 			      template GSUP_Message_Class message_class := omit,
 			      template integer cause := omit,
 			      template hexstring msisdn := omit,
@@ -1123,27 +1194,37 @@
 	};
 	var integer idx := 1;
 
-	if (isvalue(cause)) {
-		ies[idx] := tr_GSUP_IE_Cause(cause);
-		idx := idx + 1;
-	}
-
-	if (isvalue(msisdn)) {
+	if (not istemplatekind(msisdn, "omit")) {
 		ies[idx] := tr_GSUP_IE_MSISDN(msisdn);
 		idx := idx + 1;
 	}
 
-	if (isvalue(imei_result)) {
+	if (not istemplatekind(cause, "omit")) {
+		ies[idx] := tr_GSUP_IE_Cause(cause);
+		idx := idx + 1;
+	}
+
+	if (not istemplatekind(pdp_info_compl, "omit")) {
+		ies[idx] := tr_GSUP_IE_PdpInfoCompl;
+		idx := idx + 1;
+	}
+
+	if (not istemplatekind(pdp_info, "omit")) {
+		ies[idx] := tr_GSUP_IE_PdpInfo_ie(pdp_info);
+		idx := idx + 1;
+	}
+
+	if (not istemplatekind(imei_result, "omit")) {
 		ies[idx] := tr_GSUP_IE_IMEI_Result(imei_result);
 		idx := idx + 1;
 	}
 
-	if (isvalue(message_class)) {
+	if (not istemplatekind(message_class, "omit")) {
 		ies[idx] := tr_GSUP_IE_Message_Class(message_class);
 		idx := idx + 1;
 	}
 
-	if (isvalue(source_name)) {
+	if (not istemplatekind(source_name, "omit")) {
 		ies[idx] := tr_GSUP_IE_Source_Name(source_name);
 		idx := idx + 1;
 	}
@@ -1151,8 +1232,12 @@
 	ies[idx] := *;
 	idx := idx + 1;
 
-	if (isvalue(destination_name)) {
-		ies[idx] := tr_GSUP_IE_Destination_Name(destination_name);
+	if (not istemplatekind(destination_name, "omit")) {
+		if (istemplatekind(destination_name, "*")) {
+			ies[idx] := *;
+		} else {
+			ies[idx] := tr_GSUP_IE_Destination_Name(destination_name);
+		}
 		idx := idx + 1;
 	}