mme: Implement missing UE attach steps

Related: OS#6294
Change-Id: Ib4a69aef40bf9dd17d640f650e459668f8415aaa
diff --git a/library/GTPv2_Templates.ttcn b/library/GTPv2_Templates.ttcn
index 1ccbcb8..c09bca8 100644
--- a/library/GTPv2_Templates.ttcn
+++ b/library/GTPv2_Templates.ttcn
@@ -1040,6 +1040,65 @@
 		privateExtension := omit
 	}});
 
+template (present) PDU_GTPCv2
+tr_GTP2C_ModifyBearerReq(template (present) OCT4 d_teid := ?,
+			  template (present) OCT3 seq := ?) :=
+tr_PDU_GTP2C(d_teid, seq, {
+	modifyBearerRequest := {
+		mEI := *,
+		userLocationInfo := *,
+		servingNetwork := *,
+		rAT_Type := *,
+		indicationFlags := *,
+		fullyQualifiedTEID := *,
+		ambr := *,
+		delayDownlinkPacketNotificationReq := *,
+		bearerContextGrouped := *,
+		recovery := *,
+		uE_TimeZone := *,
+		csid := *,
+		user_CSG_Information := *,
+		iP_Addr := *,
+		portNumber := *,
+		lDN := *,
+		//maxMBR_APN_AMBR := *,
+		cNOperatorSelectionEntity := *,
+		presenceReportingAreaInformation := *,
+		overloadControlInformationGrouped := *,
+		servingPLMNRateControl := *,
+		counter := *,
+		privateExtension := *
+	}});
+
+template (value) PDU_GTPCv2
+ts_GTP2C_ModifyBearerResp(template (value) OCT4 d_teid,
+			  template (value) OCT3 seq,
+			  template (value) GTP2C_Cause cause,
+			  template (value) uint4_t bearer_id,
+			  template (omit) BearerContextGrouped_List bearerContextGrouped := omit) :=
+ts_PDU_GTP2C(d_teid, seq, '23'O, {
+	modifyBearerResponse := {
+		cause := ts_GTP2C_Cause(cause, '0'B),
+		mSISDN := omit,
+		linkedEPS_Bearer_ID := ts_GTP2C_EpsBearerId(bearer_id),
+		aPN_Restriction := omit,
+		protocolConfigOptions := omit,
+		bearerContextGrouped := bearerContextGrouped,
+		changeReportingAction := omit,
+		cSG_InformationReportingAction := omit,
+		heNBInformationReporting := omit,
+		chargingGatewayName := omit,
+		chargingGatewayAddress := omit,
+		csid := omit,
+		recovery := omit,
+		lDN := omit,
+		indicationFlags := omit,
+		presenceReportingAreaAction := omit,
+		loadControlInformationGrouped := omit,
+		overloadControlInformationGrouped := omit,
+		pDNConnectionChargingID := omit,
+		privateExtension := omit
+	}});
 
 template (value) PDU_GTPCv2
 ts_GTP2C_DeleteBearerReq(template (value) OCT4 d_teid,
diff --git a/library/NAS_Templates.ttcn b/library/NAS_Templates.ttcn
index 45f5f8d..70561b3 100644
--- a/library/NAS_Templates.ttcn
+++ b/library/NAS_Templates.ttcn
@@ -1025,6 +1025,55 @@
 		}
 	}
 }
+template (present) PDU_NAS_EPS
+tr_NAS_ActDefEpsBearCtxReq(template (present) BIT4 bearer_id := ?,
+			   template (present) BIT8 proc_tid := ?,
+			   template (present) EPS_QualityOfServiceV qos := ?,
+			   template (present) octetstring apn := ?,
+			   template (present) BIT3 addr_type := ?,
+			   template (present) octetstring addr_info := ?) := {
+	protocolDiscriminator := c_EPS_NAS_PD_ESM,
+	ePS_messages := {
+		ePS_SessionManagement := {
+			pDU_NAS_EPS_ActDefEPSBearerContextRequest := {
+				ePSBearerIdentity := bearer_id,
+				procedureTransactionIdentifier := proc_tid,
+				messageType := '11000001'B,
+				ePS_QoS := {
+					lengthIndicator := ?,
+					ePS_QualityOfServiceV := qos
+				},
+				accessPointName := {
+					lengthIndicator := 0,
+					accessPointNameValue := apn
+				},
+				pDN_Address := {
+					lengthIndicator := 0,
+					typeValue := addr_type,
+					spare := '00000'B,
+					addressInformation := addr_info
+				},
+				transactionIdentifier := *,
+				negotiatedQoS := *,
+				negotiated_LLC_SAPI := *,
+				radioPriority := *,
+				packetFlowID := *,
+				aPN_AMBR := *,
+				esmCause := *,
+				protocolConfigOptions := *,
+				connectivityType := *,
+				wLANOffloadIndication := *,
+				nBIFOMContainer := *,
+				headerCompressinConfiguration := *,
+				controlPlaneOnlyIndication := *,
+				extendedProtocolConfigurationOptions := *,
+				servingPLMNRateControl := *,
+				extended_APN_AMBR := *,
+				extendedQoS := *
+			}
+		}
+	}
+}
 
 /* 8.3.4 Activate Default EPS Bearer Context Accept */
 template (value) PDU_NAS_EPS
diff --git a/library/s1ap/S1AP_Templates.ttcn b/library/s1ap/S1AP_Templates.ttcn
index 9e75cec..26e1ae1 100644
--- a/library/s1ap/S1AP_Templates.ttcn
+++ b/library/s1ap/S1AP_Templates.ttcn
@@ -22,7 +22,7 @@
  *********************************************************************************/
 
 /*********************************************************************************
- * 9.1.8 Management Messages 
+ * 9.1.8 Management Messages
  *********************************************************************************/
 
 /* 9.1.8.4 S1 SETUP REQUEST */
@@ -578,11 +578,30 @@
 }
 
 /* 9.1.4.3 INITIAL CONTEXT SETUP RESPONSE */
+template (value) E_RABSetupItemCtxtSURes
+ts_S1AP_RABSetupItemCtxtSURes(template (value) E_RAB_ID rab_id := 5,
+			      template (value) TransportLayerAddress tla := '00001010000101110001100000000100'B,
+			      template (value) GTP_TEID gtp_teid := '00000002'O) := {
+					e_RAB_ID := rab_id,
+					transportLayerAddress := tla,
+					gTP_TEID := gtp_teid,
+					iE_Extensions := omit
+}
+template (value) E_RABSetupListCtxtSURes
+ts_S1AP_RABSetupListCtxtSURes(template (value) E_RABSetupItemCtxtSURes it := ts_S1AP_RABSetupItemCtxtSURes()) := {
+	{
+		id := S1AP_Constants.id_E_RABSetupItemCtxtSURes,
+		criticality := ignore,
+		value_ := { E_RABSetupItemCtxtSURes := it }
+	}
+}
+
 template (value) S1AP_PDU
 ts_S1AP_InitialCtxSetupResp(template (value) MME_UE_S1AP_ID mme_id,
 			    template (value) ENB_UE_S1AP_ID enb_id,
-			    template (value) E_RABSetupListCtxtSURes rab_setup_items,
-			    template (value) E_RABList rab_items) := {
+			    template (value) E_RABSetupListCtxtSURes rab_setup_items
+			    /*OPTIONAL: template (value) E_RABList rab_items */
+			    ) := {
 	successfulOutcome := {
 		procedureCode := id_InitialContextSetup,
 		criticality := reject,
@@ -598,14 +617,15 @@
 						criticality := reject,
 						value_ := {ENB_UE_S1AP_ID := enb_id}
 					}, {
-						id := S1AP_Constants.id_E_RABSetupListBearerSURes,
+						id := S1AP_Constants.id_E_RABSetupListCtxtSURes,
 						criticality := ignore,
 						value_ := {E_RABSetupListCtxtSURes := rab_setup_items}
-					}, {
+					}
+					/*, {
 						id := S1AP_Constants.id_E_RABFailedToSetupListBearerSURes,
 						criticality := ignore,
 						value_ := {E_RABList := rab_items}
-					}
+					}*/
 				}
 			}
 		}