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/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