DIAMETER: Split Gy and Gx messages to their own TS files

Those interfaces reuse messages from other Diameter RFCs, but changing
the contents of the messages, eg some Mandatory fields like
Service-Context-Id which are mandatory in RFC5006, doesn't even appear
in Gx CCR in TS 29.212.

Keeping them well separated helps in avoiding confusion on users fo the
messages.

Change-Id: Ibe0d5f263813d5083e020c942283f214983162b4
diff --git a/ggsn_tests/GGSN_Tests.ttcn b/ggsn_tests/GGSN_Tests.ttcn
index a1aab9b..d7de443 100644
--- a/ggsn_tests/GGSN_Tests.ttcn
+++ b/ggsn_tests/GGSN_Tests.ttcn
@@ -34,7 +34,9 @@
 
 	import from DIAMETER_Types all;
 	import from DIAMETER_Templates all;
+	import from DIAMETER_ts29_212_Templates all;
 	import from DIAMETER_ts29_272_Templates all;
+	import from DIAMETER_ts32_299_Templates all;
 	import from DIAMETER_Emulation all;
 
 	const integer GTP0_PORT := 3386;
diff --git a/ggsn_tests/gen_links.sh b/ggsn_tests/gen_links.sh
index b51620e..4981e64 100755
--- a/ggsn_tests/gen_links.sh
+++ b/ggsn_tests/gen_links.sh
@@ -61,7 +61,7 @@
 FILES="Misc_Helpers.ttcn General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn Native_Functions.ttcn Native_FunctionDefs.cc IPCP_Types.ttcn PAP_Types.ttcn "
 FILES+="GTP_CodecPort.ttcn GTP_CodecPort_CtrlFunct.ttcn GTP_CodecPort_CtrlFunctDef.cc GTP_Templates.ttcn Osmocom_Gb_Types.ttcn "
 FILES+="DIAMETER_Types.ttcn DIAMETER_CodecPort.ttcn DIAMETER_CodecPort_CtrlFunct.ttcn DIAMETER_CodecPort_CtrlFunctDef.cc DIAMETER_Emulation.ttcn "
-FILES+="DIAMETER_Templates.ttcn DIAMETER_ts29_272_Templates.ttcn "
+FILES+="DIAMETER_Templates.ttcn DIAMETER_ts29_212_Templates.ttcn DIAMETER_ts29_272_Templates.ttcn DIAMETER_ts32_299_Templates.ttcn "
 FILES+="Osmocom_VTY_Functions.ttcn "
 gen_links $DIR $FILES
 
diff --git a/library/DIAMETER_Templates.ttcn b/library/DIAMETER_Templates.ttcn
index 05b63d2..82a433c 100644
--- a/library/DIAMETER_Templates.ttcn
+++ b/library/DIAMETER_Templates.ttcn
@@ -102,10 +102,9 @@
 	DIAMETER_ERROR_EAP_CODE_UNKNOWN			(5048)
 };
 
-/* Gy : 3GPP TS 32.299 7.1.6, RFC4006 3.1 */
+/* RFC4006 3.1 */
 const uint32_t c_DIAMETER_CREDIT_CONTROL_AID := 4;
 
-const uint32_t c_DIAMETER_3GPP_Gx_AID := 16777238;
 const uint32_t c_DIAMETER_3GPP_S7_AID := 16777308;
 
 const octetstring c_def_sess_id := char2oct("ttcn3.session");
@@ -1215,142 +1214,6 @@
 	return diam_pdu;
 }
 
-/* RFC 4006 3.1.  Credit-Control-Request (CCR) Command */
-template (present) PDU_DIAMETER
-tr_DIA_Gx_CCR(template (present) DCC_NONE_CC_Request_Type req_type := INITIAL_REQUEST)
-:= tr_DIAMETER(flags:='11000000'B, cmd_code:=Credit_Control,
-	avps := superset(
-		tr_AVP_SessionId,
-		tr_AVP_OriginHost,
-		tr_AVP_OriginRealm,
-		tr_AVP_DestinationRealm,
-		tr_AVP_AuthAppId(int2oct(c_DIAMETER_3GPP_Gx_AID, 4)),
-		tr_AVP_CcReqType(req_type),
-		tr_AVP_CcReqNum(?)
-	));
-template (present) PDU_DIAMETER
-tr_DIA_Gy_CCR(template (present) DCC_NONE_CC_Request_Type req_type := INITIAL_REQUEST)
-:= tr_DIAMETER(flags:='11000000'B, cmd_code:=Credit_Control,
-	avps := superset(
-		tr_AVP_SessionId,
-		tr_AVP_OriginHost,
-		tr_AVP_OriginRealm,
-		tr_AVP_DestinationRealm,
-		tr_AVP_AuthAppId(int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4)),
-		tr_AVP_CcReqType(req_type),
-		tr_AVP_CcReqNum(?)
-	));
-
-
-
-/* RFC 4006 3.2.  Credit-Control-Answer (CCA) Command */
-template (value) PDU_DIAMETER
-ts_DIA_Gx_CCA(template (value) UINT32 hbh_id, template (value) UINT32 ete_id,
-	   template (value) octetstring sess_id,
-	   template (value) DCC_NONE_CC_Request_Type req_type,
-	   template (value) AVP_Unsigned32 req_num)
-:= ts_DIAMETER(flags:='01000000'B, cmd_code:=Credit_Control,
-		app_id:=int2oct(c_DIAMETER_3GPP_Gx_AID, 4), hbh_id:=hbh_id, ete_id:=ete_id,
-	avps := {
-		ts_AVP_SessionId(sess_id),
-		ts_AVP_ResultCode(DIAMETER_SUCCESS),
-		ts_AVP_OriginHost("pcrf.localdomain"),
-		ts_AVP_OriginRealm("localdomain"),
-		ts_AVP_AuthAppId(int2oct(c_DIAMETER_3GPP_Gx_AID, 4)),
-		ts_AVP_CcReqType(req_type),
-		ts_AVP_CcReqNum(req_num),
-		ts_AVP_PCC_3GPP_QoS_Information({
-			ts_AVP_PCC_3GPP_APN_Aggregate_Max_Bitrate_UL(33554432),
-			ts_AVP_PCC_3GPP_APN_Aggregate_Max_Bitrate_DL(52428800)
-			}),
-		ts_AVP_PCC_3GPP_Default_EPS_Bearer_QoS({
-			ts_AVP_PCC_3GPP_QoS_Class_Identifier(9),
-			ts_AVP_PCC_3GPP_AllocRetenPrio(2)
-			})
-		// supported features
-		// origin
-	});
-template (value) PDU_DIAMETER
-ts_DIA_Gy_CCA(template (value) UINT32 hbh_id, template (value) UINT32 ete_id,
-	   template (value) octetstring sess_id,
-	   template (value) DCC_NONE_CC_Request_Type req_type,
-	   template (value) AVP_Unsigned32 req_num)
-:= ts_DIAMETER(flags:='01000000'B, cmd_code:=Credit_Control,
-		app_id:=int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4), hbh_id:=hbh_id, ete_id:=ete_id,
-	avps := {
-		ts_AVP_SessionId(sess_id),
-		ts_AVP_ResultCode(DIAMETER_SUCCESS),
-		ts_AVP_OriginHost("ocs.localdomain"),
-		ts_AVP_OriginRealm("localdomain"),
-		ts_AVP_AuthAppId(int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4)),
-		ts_AVP_CcReqType(req_type),
-		ts_AVP_CcReqNum(req_num)//,
-		// qos
-		// default eps bearer qos
-		// supported features
-		// origin
-	});
-/* Same as ts_DIA_Gy_CCA, but with extra AVP to grant access for limited amount of seconds */
-template (value) PDU_DIAMETER
-ts_DIA_Gy_CCA_ValidityTime(template (value) UINT32 hbh_id, template (value) UINT32 ete_id,
-	   template (value) octetstring sess_id,
-	   template (value) DCC_NONE_CC_Request_Type req_type,
-	   template (value) AVP_Unsigned32 req_num,
-	   uint32_t validity_time)
-:= ts_DIAMETER(flags:='01000000'B, cmd_code:=Credit_Control,
-		app_id:=int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4), hbh_id:=hbh_id, ete_id:=ete_id,
-	avps := {
-		ts_AVP_SessionId(sess_id),
-		ts_AVP_ResultCode(DIAMETER_SUCCESS),
-		ts_AVP_OriginHost("ocs.localdomain"),
-		ts_AVP_OriginRealm("localdomain"),
-		ts_AVP_AuthAppId(int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4)),
-		ts_AVP_CcReqType(req_type),
-		ts_AVP_CcReqNum(req_num),
-		ts_AVP_Multiple_Services_Credit_Control({
-			ts_AVP_Validity_Time(validity_time),
-			ts_AVP_Granted_Service_Unit({
-				//ts_AVP_CC_Time(validity_time*2),
-				ts_AVP_CC_Total_Octets(1000)
-				})
-			})
-		//,
-		// qos
-		// default eps bearer qos
-		// supported features
-		// origin
-	});
-/* Same as ts_DIA_Gy_CCA_ValidityTime, but with extra AVP to grant access for limited amount of octets */
-template (value) PDU_DIAMETER
-ts_DIA_Gy_CCA_ValidityTimeVolumeThreshold(template (value) UINT32 hbh_id, template (value) UINT32 ete_id,
-	   template (value) octetstring sess_id,
-	   template (value) DCC_NONE_CC_Request_Type req_type,
-	   template (value) AVP_Unsigned32 req_num,
-	   uint32_t validity_time, uint32_t volume_threhsold)
-:= ts_DIAMETER(flags:='01000000'B, cmd_code:=Credit_Control,
-		app_id:=int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4), hbh_id:=hbh_id, ete_id:=ete_id,
-	avps := {
-		ts_AVP_SessionId(sess_id),
-		ts_AVP_ResultCode(DIAMETER_SUCCESS),
-		ts_AVP_OriginHost("ocs.localdomain"),
-		ts_AVP_OriginRealm("localdomain"),
-		ts_AVP_AuthAppId(int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4)),
-		ts_AVP_CcReqType(req_type),
-		ts_AVP_CcReqNum(req_num),
-		ts_AVP_Multiple_Services_Credit_Control({
-			ts_AVP_Validity_Time(validity_time),
-			ts_AVP_Granted_Service_Unit({
-				ts_AVP_CC_Total_Octets(volume_threhsold*100)
-				}),
-			ts_AVP_3GPP_VolumeQuotaThreshold(volume_threhsold)
-			})
-		//,
-		// qos
-		// default eps bearer qos
-		// supported features
-		// origin
-	});
-
 /* RFC 6733, section 5.5.1 "Device-Watchdog-Request" */
 template (value) PDU_DIAMETER
 ts_DIA_DWR(template (value) OCTET4 state_id := '00000000'O,
@@ -1477,53 +1340,6 @@
 	return valueof(avp);
 }
 
-function f_validate_gy_cc_report(PDU_DIAMETER rx_dia, template (present) DCA_3GPP_Reporting_Reason repreason_exp := ?,
-				 template (present) integer cc_time_exp := ?,
-				 template (present) integer cc_in_oct_exp := ?,
-				 template (present) integer cc_out_oct_exp := ?)
-{
-	var AVP multi_services_cc, used_service_unit;
-	var AVP_Grouped multi_services_cc_data, used_service_unit_data;
-	var template (omit) AVP repreason_tpl;
-	var AVP repreason, cc_time, cc_in_oct, cc_out_oct;
-
-	multi_services_cc := f_DIAMETER_get_avp_or_fail(rx_dia, c_AVP_Code_DCC_NONE_Multiple_Services_Credit_Control);
-	multi_services_cc_data := valueof(multi_services_cc.avp_data.avp_DCC_NONE_Multiple_Services_Credit_Control);
-
-	used_service_unit := f_AVP_Grouped_get_avp_or_fail(multi_services_cc_data, c_AVP_Code_DCC_NONE_Used_Service_Unit);
-	used_service_unit_data := valueof(used_service_unit.avp_data.avp_DCC_NONE_Used_Service_Unit);
-
-	/* Reporting-Reason can be either inside Multiple-Services-Credit-Control or inside Used-Service-Unit */
-	repreason_tpl := f_AVP_Grouped_get_avp(multi_services_cc_data, c_AVP_Code_DCA_3GPP_Reporting_Reason);
-	if (istemplatekind(repreason_tpl, "omit")) {
-		repreason := f_AVP_Grouped_get_avp_or_fail(used_service_unit_data, c_AVP_Code_DCA_3GPP_Reporting_Reason);
-	} else {
-		repreason := valueof(repreason_tpl);
-	}
-	if (not match(repreason.avp_data.avp_DCA_3GPP_Reporting_Reason, repreason_exp)) {
-		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-			log2str("3GPP-Reporting-Reason mismatch ", repreason, " vs exp ", repreason_exp));
-	}
-
-	cc_time := f_AVP_Grouped_get_avp_or_fail(used_service_unit_data, c_AVP_Code_DCC_NONE_CC_Time);
-	if (not match(oct2int(cc_time.avp_data.avp_DCC_NONE_CC_Time), cc_time_exp)) {
-		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-			log2str("3GPP-CC-Time mismatch ", cc_time, " vs exp ", cc_time_exp));
-	}
-
-	cc_in_oct := f_AVP_Grouped_get_avp_or_fail(used_service_unit_data, c_AVP_Code_DCC_NONE_CC_Input_Octets);
-	if (not match(oct2int(cc_in_oct.avp_data.avp_DCC_NONE_CC_Input_Octets), cc_in_oct_exp)) {
-		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-			log2str("3GPP-CC-Input-Octets mismatch ", cc_in_oct, " vs exp ", cc_in_oct_exp));
-	}
-
-	cc_out_oct := f_AVP_Grouped_get_avp_or_fail(used_service_unit_data, c_AVP_Code_DCC_NONE_CC_Output_Octets);
-	if (not match(oct2int(cc_out_oct.avp_data.avp_DCC_NONE_CC_Output_Octets), cc_out_oct_exp)) {
-		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-			log2str("3GPP-CC-Output-Octets mismatch ", cc_out_oct, " vs exp ", cc_out_oct_exp));
-	}
-}
-
 
 /*****************************
  * Cx, Dx, 3GPP TS 29.229
diff --git a/library/DIAMETER_ts29_212_Templates.ttcn b/library/DIAMETER_ts29_212_Templates.ttcn
new file mode 100644
index 0000000..209ac10
--- /dev/null
+++ b/library/DIAMETER_ts29_212_Templates.ttcn
@@ -0,0 +1,69 @@
+module DIAMETER_ts29_212_Templates {
+
+/* (C) 2023 by sysmocom s.f.m.c. GmbH <info@sysmocom.de
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Templates for AVPs and messages for TS 29.212
+ */
+
+import from General_Types all;
+import from DIAMETER_Types all;
+import from DIAMETER_Templates all;
+import from Osmocom_Types all;
+import from Misc_Helpers all;
+
+/*******************************
+ * S6a 3GPP TS 29.212 section 7
+ *******************************/
+
+/* 3GPP TS 29.212 Section 5.1 */
+const uint32_t c_DIAMETER_3GPP_Gx_AID := 16777238;
+
+/* 3GPP TS 29.212 5.6.2 Credit-Control-Request (CC-Request, CCR) Command */
+template (present) PDU_DIAMETER
+tr_DIA_Gx_CCR(template (present) DCC_NONE_CC_Request_Type req_type := INITIAL_REQUEST)
+:= tr_DIAMETER(flags:='11000000'B, cmd_code:=Credit_Control,
+	avps := superset(
+		tr_AVP_SessionId,
+		tr_AVP_OriginHost,
+		tr_AVP_OriginRealm,
+		tr_AVP_DestinationRealm,
+		tr_AVP_AuthAppId(int2oct(c_DIAMETER_3GPP_Gx_AID, 4)),
+		tr_AVP_CcReqType(req_type),
+		tr_AVP_CcReqNum(?)
+	));
+
+/* 3GPP TS 29.212 5.6.3 Credit-Control-Answer (CC-Answer, CCA) Command */
+template (value) PDU_DIAMETER
+ts_DIA_Gx_CCA(template (value) UINT32 hbh_id, template (value) UINT32 ete_id,
+	   template (value) octetstring sess_id,
+	   template (value) DCC_NONE_CC_Request_Type req_type,
+	   template (value) AVP_Unsigned32 req_num)
+:= ts_DIAMETER(flags:='01000000'B, cmd_code:=Credit_Control,
+		app_id:=int2oct(c_DIAMETER_3GPP_Gx_AID, 4), hbh_id:=hbh_id, ete_id:=ete_id,
+	avps := {
+		ts_AVP_SessionId(sess_id),
+		ts_AVP_ResultCode(DIAMETER_SUCCESS),
+		ts_AVP_OriginHost("pcrf.localdomain"),
+		ts_AVP_OriginRealm("localdomain"),
+		ts_AVP_AuthAppId(int2oct(c_DIAMETER_3GPP_Gx_AID, 4)),
+		ts_AVP_CcReqType(req_type),
+		ts_AVP_CcReqNum(req_num),
+		ts_AVP_PCC_3GPP_QoS_Information({
+			ts_AVP_PCC_3GPP_APN_Aggregate_Max_Bitrate_UL(33554432),
+			ts_AVP_PCC_3GPP_APN_Aggregate_Max_Bitrate_DL(52428800)
+			}),
+		ts_AVP_PCC_3GPP_Default_EPS_Bearer_QoS({
+			ts_AVP_PCC_3GPP_QoS_Class_Identifier(9),
+			ts_AVP_PCC_3GPP_AllocRetenPrio(2)
+			})
+		// supported features
+		// origin
+	});
+
+} /* module */
diff --git a/library/DIAMETER_ts32_299_Templates.ttcn b/library/DIAMETER_ts32_299_Templates.ttcn
new file mode 100644
index 0000000..af8f514
--- /dev/null
+++ b/library/DIAMETER_ts32_299_Templates.ttcn
@@ -0,0 +1,169 @@
+module DIAMETER_ts32_299_Templates {
+
+/* (C) 2023 by sysmocom s.f.m.c. GmbH <info@sysmocom.de
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Templates for AVPs and messages for TS 32.299
+ */
+
+import from General_Types all;
+import from DIAMETER_Types all;
+import from DIAMETER_Templates all;
+import from Osmocom_Types all;
+import from Misc_Helpers all;
+
+/*******************************
+ * S6a 3GPP TS 32.299 section 7
+ *******************************/
+
+/* Gy AID : 3GPP TS 32.299 7.1.6, RFC4006 3.1: c_DIAMETER_CREDIT_CONTROL_AID */
+
+/* 3GPP TS 32.299 6.4.2 Credit-Control-Request */
+template (present) PDU_DIAMETER
+tr_DIA_Gy_CCR(template (present) DCC_NONE_CC_Request_Type req_type := INITIAL_REQUEST)
+:= tr_DIAMETER(flags:='11000000'B, cmd_code:=Credit_Control,
+	avps := superset(
+		tr_AVP_SessionId,
+		tr_AVP_OriginHost,
+		tr_AVP_OriginRealm,
+		tr_AVP_DestinationRealm,
+		tr_AVP_AuthAppId(int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4)),
+		tr_AVP_CcReqType(req_type),
+		tr_AVP_CcReqNum(?)
+	));
+
+/* 3GPP TS 32.299 6.4.3 Credit-Control-Answer message */
+template (value) PDU_DIAMETER
+ts_DIA_Gy_CCA(template (value) UINT32 hbh_id, template (value) UINT32 ete_id,
+	   template (value) octetstring sess_id,
+	   template (value) DCC_NONE_CC_Request_Type req_type,
+	   template (value) AVP_Unsigned32 req_num)
+:= ts_DIAMETER(flags:='01000000'B, cmd_code:=Credit_Control,
+		app_id:=int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4), hbh_id:=hbh_id, ete_id:=ete_id,
+	avps := {
+		ts_AVP_SessionId(sess_id),
+		ts_AVP_ResultCode(DIAMETER_SUCCESS),
+		ts_AVP_OriginHost("ocs.localdomain"),
+		ts_AVP_OriginRealm("localdomain"),
+		ts_AVP_AuthAppId(int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4)),
+		ts_AVP_CcReqType(req_type),
+		ts_AVP_CcReqNum(req_num)//,
+		// qos
+		// default eps bearer qos
+		// supported features
+		// origin
+	});
+/* Same as ts_DIA_Gy_CCA, but with extra AVP to grant access for limited amount of seconds */
+template (value) PDU_DIAMETER
+ts_DIA_Gy_CCA_ValidityTime(template (value) UINT32 hbh_id, template (value) UINT32 ete_id,
+	   template (value) octetstring sess_id,
+	   template (value) DCC_NONE_CC_Request_Type req_type,
+	   template (value) AVP_Unsigned32 req_num,
+	   uint32_t validity_time)
+:= ts_DIAMETER(flags:='01000000'B, cmd_code:=Credit_Control,
+		app_id:=int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4), hbh_id:=hbh_id, ete_id:=ete_id,
+	avps := {
+		ts_AVP_SessionId(sess_id),
+		ts_AVP_ResultCode(DIAMETER_SUCCESS),
+		ts_AVP_OriginHost("ocs.localdomain"),
+		ts_AVP_OriginRealm("localdomain"),
+		ts_AVP_AuthAppId(int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4)),
+		ts_AVP_CcReqType(req_type),
+		ts_AVP_CcReqNum(req_num),
+		ts_AVP_Multiple_Services_Credit_Control({
+			ts_AVP_Validity_Time(validity_time),
+			ts_AVP_Granted_Service_Unit({
+				//ts_AVP_CC_Time(validity_time*2),
+				ts_AVP_CC_Total_Octets(1000)
+				})
+			})
+		//,
+		// qos
+		// default eps bearer qos
+		// supported features
+		// origin
+	});
+/* Same as ts_DIA_Gy_CCA_ValidityTime, but with extra AVP to grant access for limited amount of octets */
+template (value) PDU_DIAMETER
+ts_DIA_Gy_CCA_ValidityTimeVolumeThreshold(template (value) UINT32 hbh_id, template (value) UINT32 ete_id,
+	   template (value) octetstring sess_id,
+	   template (value) DCC_NONE_CC_Request_Type req_type,
+	   template (value) AVP_Unsigned32 req_num,
+	   uint32_t validity_time, uint32_t volume_threhsold)
+:= ts_DIAMETER(flags:='01000000'B, cmd_code:=Credit_Control,
+		app_id:=int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4), hbh_id:=hbh_id, ete_id:=ete_id,
+	avps := {
+		ts_AVP_SessionId(sess_id),
+		ts_AVP_ResultCode(DIAMETER_SUCCESS),
+		ts_AVP_OriginHost("ocs.localdomain"),
+		ts_AVP_OriginRealm("localdomain"),
+		ts_AVP_AuthAppId(int2oct(c_DIAMETER_CREDIT_CONTROL_AID, 4)),
+		ts_AVP_CcReqType(req_type),
+		ts_AVP_CcReqNum(req_num),
+		ts_AVP_Multiple_Services_Credit_Control({
+			ts_AVP_Validity_Time(validity_time),
+			ts_AVP_Granted_Service_Unit({
+				ts_AVP_CC_Total_Octets(volume_threhsold*100)
+				}),
+			ts_AVP_3GPP_VolumeQuotaThreshold(volume_threhsold)
+			})
+		//,
+		// qos
+		// default eps bearer qos
+		// supported features
+		// origin
+	});
+
+function f_validate_gy_cc_report(PDU_DIAMETER rx_dia, template (present) DCA_3GPP_Reporting_Reason repreason_exp := ?,
+				 template (present) integer cc_time_exp := ?,
+				 template (present) integer cc_in_oct_exp := ?,
+				 template (present) integer cc_out_oct_exp := ?)
+{
+	var AVP multi_services_cc, used_service_unit;
+	var AVP_Grouped multi_services_cc_data, used_service_unit_data;
+	var template (omit) AVP repreason_tpl;
+	var AVP repreason, cc_time, cc_in_oct, cc_out_oct;
+
+	multi_services_cc := f_DIAMETER_get_avp_or_fail(rx_dia, c_AVP_Code_DCC_NONE_Multiple_Services_Credit_Control);
+	multi_services_cc_data := valueof(multi_services_cc.avp_data.avp_DCC_NONE_Multiple_Services_Credit_Control);
+
+	used_service_unit := f_AVP_Grouped_get_avp_or_fail(multi_services_cc_data, c_AVP_Code_DCC_NONE_Used_Service_Unit);
+	used_service_unit_data := valueof(used_service_unit.avp_data.avp_DCC_NONE_Used_Service_Unit);
+
+	/* Reporting-Reason can be either inside Multiple-Services-Credit-Control or inside Used-Service-Unit */
+	repreason_tpl := f_AVP_Grouped_get_avp(multi_services_cc_data, c_AVP_Code_DCA_3GPP_Reporting_Reason);
+	if (istemplatekind(repreason_tpl, "omit")) {
+		repreason := f_AVP_Grouped_get_avp_or_fail(used_service_unit_data, c_AVP_Code_DCA_3GPP_Reporting_Reason);
+	} else {
+		repreason := valueof(repreason_tpl);
+	}
+	if (not match(repreason.avp_data.avp_DCA_3GPP_Reporting_Reason, repreason_exp)) {
+		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+			log2str("3GPP-Reporting-Reason mismatch ", repreason, " vs exp ", repreason_exp));
+	}
+
+	cc_time := f_AVP_Grouped_get_avp_or_fail(used_service_unit_data, c_AVP_Code_DCC_NONE_CC_Time);
+	if (not match(oct2int(cc_time.avp_data.avp_DCC_NONE_CC_Time), cc_time_exp)) {
+		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+			log2str("3GPP-CC-Time mismatch ", cc_time, " vs exp ", cc_time_exp));
+	}
+
+	cc_in_oct := f_AVP_Grouped_get_avp_or_fail(used_service_unit_data, c_AVP_Code_DCC_NONE_CC_Input_Octets);
+	if (not match(oct2int(cc_in_oct.avp_data.avp_DCC_NONE_CC_Input_Octets), cc_in_oct_exp)) {
+		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+			log2str("3GPP-CC-Input-Octets mismatch ", cc_in_oct, " vs exp ", cc_in_oct_exp));
+	}
+
+	cc_out_oct := f_AVP_Grouped_get_avp_or_fail(used_service_unit_data, c_AVP_Code_DCC_NONE_CC_Output_Octets);
+	if (not match(oct2int(cc_out_oct.avp_data.avp_DCC_NONE_CC_Output_Octets), cc_out_oct_exp)) {
+		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+			log2str("3GPP-CC-Output-Octets mismatch ", cc_out_oct, " vs exp ", cc_out_oct_exp));
+	}
+}
+
+} /* module */
diff --git a/pgw/PGW_Tests.ttcn b/pgw/PGW_Tests.ttcn
index fa7be47..81fea12 100644
--- a/pgw/PGW_Tests.ttcn
+++ b/pgw/PGW_Tests.ttcn
@@ -18,7 +18,9 @@
 
 import from DIAMETER_Types all;
 import from DIAMETER_Templates all;
+import from DIAMETER_ts29_212_Templates all;
 import from DIAMETER_ts29_272_Templates all;
+import from DIAMETER_ts32_299_Templates all;
 import from DIAMETER_Emulation all;
 
 
diff --git a/pgw/gen_links.sh b/pgw/gen_links.sh
index 0bf264a..9aebfc2 100755
--- a/pgw/gen_links.sh
+++ b/pgw/gen_links.sh
@@ -64,7 +64,7 @@
 FILES+="GTPv2_CodecPort.ttcn GTPv2_CodecPort_CtrlFunctDef.cc GTPv2_CodecPort_CtrlFunct.ttcn GTPv2_Emulation.ttcn "
 FILES+="DNS_Helpers.ttcn "
 FILES+="DIAMETER_Types.ttcn DIAMETER_CodecPort.ttcn DIAMETER_CodecPort_CtrlFunct.ttcn DIAMETER_CodecPort_CtrlFunctDef.cc DIAMETER_Emulation.ttcn "
-FILES+="DIAMETER_Templates.ttcn DIAMETER_ts29_272_Templates.ttcn "
+FILES+="DIAMETER_Templates.ttcn DIAMETER_ts29_212_Templates.ttcn DIAMETER_ts29_272_Templates.ttcn DIAMETER_ts32_299_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results