hnbgw: add CN pool tests

docker-playground.git needs a config file change to be committed at the
same time as this patch, see 'Related'.

Depends: osmo-ttcn3-hacks I94aa0b2adfc48b98cb4b1efe595c2432fc603d6c
Change-Id: I027a059faed3f140f8801f84338956cd004043b5
diff --git a/library/L3_Templates.ttcn b/library/L3_Templates.ttcn
index c31ce1f..710b0ea 100644
--- a/library/L3_Templates.ttcn
+++ b/library/L3_Templates.ttcn
@@ -177,6 +177,9 @@
 	}
 }
 
+template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
+	ts_MI_TMSI_LV(tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v, nri_bitlen := nri_bitlen));
+
 template MobileIdentityTLV ts_MI_IMEISV_TLV(hexstring imeisv) := {
 	elementIdentifier := '0100011'B,
 	spare1 := '0'B,
@@ -2425,11 +2428,23 @@
 	}
 }
 
+template (value) NetworkResourceIdentifierContainerTLV ts_GMM_NRI(integer nri) := {
+	elementIdentifier := '10'O,
+	networkResourceIdentifierContainerLV := {
+		lengthIndicator := 2,
+		networkResourceIdentifierContainerV := {
+			nRIContainerValue := f_bits_reversed(int2bit(nri, 10)),
+			spare := '000000'B
+		}
+	}
+}
+
 template (value) PDU_L3_MS_SGSN
 	ts_GMM_ATTACH_REQ(MobileIdentityLV mi_lv, RoutingAreaIdentificationV old_ra,
 			  boolean combined := false, boolean follow_on_pending := false,
-			  template (omit) MobileStationClassmark2_TLV cm2_tlv,
-			  template (omit) MobileStationClassmark3_TLV cm3_tlv
+			  template (omit) MobileStationClassmark2_TLV cm2_tlv := omit,
+			  template (omit) MobileStationClassmark3_TLV cm3_tlv := omit,
+			  template (omit) NetworkResourceIdentifierContainerTLV nri := omit
 		) := {
 	discriminator := '0000'B, /* overwritten */
 	tiOrSkip := {
@@ -2462,7 +2477,7 @@
 				mS_NetworkFeatureSupport := omit,
 				oldLocationAreaIdentification := omit,
 				additionalUpdateType := omit,
-				tMSIBasedNRIcontainer := omit,
+				tMSIBasedNRIcontainer := nri,
 				t3324 := omit,
 				t3312_ExtendedValue := omit,
 				extendedDRXParameters := omit
@@ -2577,9 +2592,10 @@
 	ts_GMM_RAU_REQ(MobileIdentityLV mi_lv, GprsUpdateType upd_type,
 			  RoutingAreaIdentificationV old_ra,
 			  boolean follow_on_pending := false,
-			  template (omit) MobileStationClassmark2_TLV cm2_tlv,
-			  template (omit) MobileStationClassmark3_TLV cm3_tlv,
-			  template (omit) OCT4 p_tmsi := omit
+			  template (omit) MobileStationClassmark2_TLV cm2_tlv := omit,
+			  template (omit) MobileStationClassmark3_TLV cm3_tlv := omit,
+			  template (omit) OCT4 p_tmsi := omit,
+			  template (omit) NetworkResourceIdentifierContainerTLV nri := omit
 		) := {
 	discriminator := '0000'B, /* overwritten */
 	tiOrSkip := {
@@ -2614,7 +2630,7 @@
 				mS_NetworkFeatureSupport := omit,
 				oldLocationAreaIdentification := omit,
 				additionalUpdateType := omit,
-				tMSIBasedNRIcontainer := omit,
+				tMSIBasedNRIcontainer := nri,
 				t3324 := omit,
 				t3312_ExtendedValue := omit,
 				extendedDRXParameters := omit
@@ -2898,6 +2914,27 @@
 	}
 }
 
+template (value) PDU_L3_MS_SGSN ts_GMM_DET_REQ_MO_mi(BIT3 dtt := c_GMM_DTT_MO_GPRS,
+						     boolean power_off := false,
+						     template (value) MobileIdentityTLV p_tmsi,
+						     template (omit) OCT3 p_tmsi_sig := omit) := {
+	discriminator := '0000'B, /* overwritten */
+	tiOrSkip := {
+		skipIndicator := '0000'B
+	},
+	msgs := {
+		gprs_mm := {
+			detachRequest_MS_SGSN := {
+				messageType := '00000000'B, /* overwritten */
+				detachType := valueof(ts_GMM_DetType(dtt, power_off)),
+				spare := '0000'B,
+				ptmsi := p_tmsi,
+				ptmsiSignature := ts_PtmsiSigTLV(p_tmsi_sig)
+			}
+		}
+	}
+}
+
 template PDU_L3_SGSN_MS tr_GMM_DET_ACCEPT_MT := {
 	discriminator := '1000'B,
 	tiOrSkip := {