Implement SystemInformation13 Rest Octets types

Related: SYS#5358
Change-Id: Id8845ebe28a9a6ed79d2d408dc7c1ad8a275b809
diff --git a/library/GSM_RestOctets.ttcn b/library/GSM_RestOctets.ttcn
index d47e510..9aa1217 100644
--- a/library/GSM_RestOctets.ttcn
+++ b/library/GSM_RestOctets.ttcn
@@ -15,6 +15,7 @@
 
 import from General_Types all;
 import from Osmocom_Types all;
+import from RLCMAC_CSN1_Types all;
 
 /* 10.5.2.33b SI 2quater Rest Octets */
 type record SI2quaterRestOctets {
@@ -692,6 +693,34 @@
 	variant "PADDING(yes), PADDING_PATTERN('00101011'B)"
 };
 
+/* 10.5.2.37b SI 13 Rest Octets (O & S) */
+type record SI13RestOctets {
+	BIT1			presence, // L/H
+	uint3_t			bcch_change_mark,
+	BIT4			si_change_field,
+	BIT1			presence2,
+	BIT2			si13_change_mark optional,
+	GprsMobileAllocation	gprs_ma optional,
+	BIT1			zero ('0'B), /* PBCCH not present in cell */
+	uint8_t			rac,
+	BIT1			spgc_ccch_sup,
+	BIT3			priority_access_thr,
+	BIT2			network_control_order,
+	GprsCellOptions		gprs_cell_opts,
+	GprsPowerControlParameters gprs_pwr_ctrl_params
+	/* TODO: Additions in release 99 */
+} with {
+
+	variant (presence) "CSN.1 L/H"
+	/* TODO: for all fields after presencte: variant (<field>) "PRESENCE(presence = '1'B)" */
+	variant (si13_change_mark) "PRESENCE(presence2 = '1'B)"
+	variant (gprs_ma) "PRESENCE(presence2 = '1'B)"
+
+	/* The TITAN's RAW encoder generates an octet-aligned octetstring,
+	 * so we should make sure that unused bits contain proper padding. */
+	variant "PADDING(yes), PADDING_PATTERN('00101011'B)"
+};
+
 /* Selection Parameters */
 type record SelectionParams {
 	boolean			cbq,
@@ -777,6 +806,11 @@
 external function dec_SI4RestOctets(in octetstring stream) return SI4RestOctets
 	with { extension "prototype(convert) decode(RAW)" };
 
+external function enc_SI13RestOctets(in SI13RestOctets ro) return octetstring
+	with { extension "prototype(convert) encode(RAW)" };
+external function dec_SI13RestOctets(in octetstring stream) return SI13RestOctets
+	with { extension "prototype(convert) decode(RAW)" };
+
 
 /* Basic templates to be extended in place */
 template (value) SI3RestOctets ts_SI3RestOctets := {
diff --git a/library/GSM_SystemInformation.ttcn b/library/GSM_SystemInformation.ttcn
index 85abb7f..0356e7d 100644
--- a/library/GSM_SystemInformation.ttcn
+++ b/library/GSM_SystemInformation.ttcn
@@ -196,6 +196,11 @@
 		RestOctets			rest_octets length(0..7)
 	} with { variant "" };
 
+	/* 44.018 9.1.43a */
+	type record SystemInformationType13 {
+		SI13RestOctets			rest_octets
+	} with { variant "" };
+
 	type union SystemInformationUnion {
 		SystemInformationType1		si1,
 		SystemInformationType2		si2,
@@ -208,6 +213,7 @@
 		SystemInformationType5bis	si5bis,
 		SystemInformationType5ter	si5ter,
 		SystemInformationType6		si6,
+		SystemInformationType13		si13,
 		octetstring			other
 	} with { variant "" };
 
@@ -225,6 +231,7 @@
 			      si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
 			      si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
 			      si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
+			      si13, header.message_type = SYSTEM_INFORMATION_TYPE_13;
 			      other, OTHERWISE;
 			)" };
 
diff --git a/library/RLCMAC_CSN1_Types.ttcn b/library/RLCMAC_CSN1_Types.ttcn
index af8b8d6..0dd8a8b 100644
--- a/library/RLCMAC_CSN1_Types.ttcn
+++ b/library/RLCMAC_CSN1_Types.ttcn
@@ -929,7 +929,7 @@
 	};
 	type record FreqDirect1 {
 		uint6_t			maio,
-		GprsMobileAllication	mobile_allocation
+		GprsMobileAllocation	mobile_allocation
 	}
 	type record FreqDirect2 {
 		uint6_t			maio,
@@ -953,6 +953,15 @@
 		variant (direct2) "PRESENCE(presence = '11'B)"
 	};
 
+	/* 12.9a GPRS Power Control Parameters */
+	type record GprsPowerControlParameters {
+		uint4_t			alpha,
+		BIT5			t_avg_w,
+		BIT5			t_avg_t,
+		BIT1			pc_meas_chan,
+		BIT4			n_avg_i
+	};
+
 	/* 12.10 Global TFI */
 	type record GlobalTfi {
 		boolean			is_dl_tfi,
@@ -967,7 +976,7 @@
 	} with {
 		variant (rfl_number_list) "PRESENCE(presence = '1'B)"
 	};
-	type record GprsMobileAllication {
+	type record GprsMobileAllocation {
 		uint6_t			hsn,
 		BIT1			rfl_number_list_present,
 		RflNumberList		rfl_number_list optional,
@@ -1036,6 +1045,48 @@
 		variant (relative_k) "PRESENCE(presence = '1'B)"
 	};
 
+	/* 12.24 GPRS Cell Options */
+	type record ExtensionInformation {
+		BIT1		egprs_supported,
+		BIT1		egprs_pkt_channel_req optional,
+		BIT4		bep_period optional,
+		BIT1		pfc_feature_mode,
+		BIT1		dtm_support,
+		BIT1		bss_paging_coordination,
+		/* REL-4 extension */
+		BIT1		ccn_active optional,
+		BIT1		nw_ext_utbf optional
+		/* TODO: REL-6 extension */
+		/* TODO: REL-7 extension */
+		/* TODO: REL-10 extension */
+	} with {
+		variant (egprs_pkt_channel_req) "PRESENCE(egprs_supported = '1'B)"
+		variant (bep_period) "PRESENCE(egprs_supported = '1'B)"
+	};
+	type record GprsCellOptions {
+		BIT2		nmo,
+		BIT3		t3168,
+		BIT3		t3192,
+		BIT3		drx_timer_max,
+		BIT1		access_burst_type,
+		BIT1		control_ack_type,
+		uint4_t		bs_cv_max,
+		BIT1		pan_presence,
+		uint3_t		pan_dec optional,
+		uint3_t		pan_inc optional,
+		BIT3		pan_max optional,
+		BIT1		ext_info_presence,
+		BIT6		ext_info_length optional,
+		ExtensionInformation ext_info optional
+	} with {
+		variant (pan_dec) "PRESENCE(pan_presence = '1'B)"
+		variant (pan_inc) "PRESENCE(pan_presence = '1'B)"
+		variant (pan_max) "PRESENCE(pan_presence = '1'B)"
+		variant (ext_info_length) "PRESENCE(ext_info_presence = '1'B)"
+		variant (ext_info) "PRESENCE(ext_info_presence = '1'B)"
+		/* TODO: mark REL-4 and upwards in ext_info as omit based on ext_info_length ? */
+	};
+
 	/* 3GPP TS 44.060, table 11.2.5a.2 "EGPRS PACKET CHANNEL REQUEST" */
 	type union EGPRSPktChRequest {
 		EGPRSPktChRequest_MC5P2RB3		one_phase,