/* S1AP Templates in TTCN-3
 * (C) 2019 Harald Welte <laforge@gnumonks.org>
 * 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
 */

module S1AP_Templates {

import from S1AP_IEs all;
import from S1AP_CommonDataTypes all;
import from S1AP_Constants all;
import from S1AP_Containers all;
import from S1AP_PDU_Contents all;
import from S1AP_PDU_Descriptions all;

/*********************************************************************************
 * non-UE related
 *********************************************************************************/

/*********************************************************************************
 * 9.1.8 Management Messages 
 *********************************************************************************/

/* 9.1.8.4 S1 SETUP REQUEST */
template (value) S1AP_PDU
ts_S1AP_SetupReq(template (value) Global_ENB_ID p_global_ENB_ID,
		 template (value) SupportedTAs p_supportedTAs,
		 template (value) PagingDRX p_pagingDRXs) := {
	initiatingMessage := {
		procedureCode := id_S1Setup,
		criticality := reject,
		value_ := {
			S1SetupRequest := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_Global_ENB_ID,
						criticality := ignore,
						value_ := { Global_ENB_ID := p_global_ENB_ID }
					}, {
						id := S1AP_Constants.id_SupportedTAs,
						criticality := reject,
						value_ := {SupportedTAs := p_supportedTAs}
            				} /* HACK: work around nextepc bug
					  , {
						id := S1AP_Constants.id_pagingDRX,
						criticality := ignore,
						value_ := {PagingDRX := p_pagingDRXs}
            				} */
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_SetupReq(template (present) Global_ENB_ID p_global_ENB_ID := ?,
		 template (present) SupportedTAs p_supportedTAs := ?,
		 template (present) PagingDRX p_pagingDRXs := ?) := {
	initiatingMessage := {
		procedureCode := id_S1Setup,
		criticality := reject,
		value_ := {
			S1SetupRequest := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_Global_ENB_ID,
						criticality := ignore,
						value_ := { Global_ENB_ID := p_global_ENB_ID }
					}, {
						id := S1AP_Constants.id_SupportedTAs,
						criticality := reject,
						value_ := {SupportedTAs := p_supportedTAs}
            				}, *
				}
			}
		}
	}
}

/* 9.1.8.5 S1 SETUP RESPONSE */
template (value) S1AP_PDU
ts_S1AP_SetupResp(template (value) ServedGUMMEIs served_gummeis,
		  template (value) RelativeMMECapacity rel_mme_capacity) := {
	successfulOutcome := {
		procedureCode := id_S1Setup,
		criticality := reject,
		value_ := {
			S1SetupResponse := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_ServedGUMMEIs,
						criticality := reject,
						value_ := { ServedGUMMEIs := served_gummeis }
					}, {
						id := S1AP_Constants.id_RelativeMMECapacity,
						criticality := ignore,
						value_ := { RelativeMMECapacity := rel_mme_capacity }
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_SetupResp(template (present) ServedGUMMEIs served_gummeis := ?,
		  template (present) RelativeMMECapacity rel_mme_capacity := ?) := {
	successfulOutcome := {
		procedureCode := id_S1Setup,
		criticality := reject,
		value_ := {
			S1SetupResponse := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_ServedGUMMEIs,
						criticality := reject,
						value_ := { ServedGUMMEIs := served_gummeis }
					}, {
						id := S1AP_Constants.id_RelativeMMECapacity,
						criticality := ignore,
						value_ := { RelativeMMECapacity := rel_mme_capacity }
					}, *
				}
			}
		}
	}
}

/* 9.1.8.6 S1 SETUP FAILURE */
template (value) S1AP_PDU
ts_S1AP_SetupFail(template (value) Cause cause) := {
	unsuccessfulOutcome := {
		procedureCode := id_S1Setup,
		criticality := reject,
		value_ := {
			S1SetupFailure := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_Cause,
						criticality := ignore,
						value_ := { Cause := cause }
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_SetupFail(template (present) Cause cause := ?) := {
	unsuccessfulOutcome := {
		procedureCode := id_S1Setup,
		criticality := reject,
		value_ := {
			S1SetupFailure := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_Cause,
						criticality := ignore,
						value_ := { Cause := cause }
					}, *
				}
			}
		}
	}
}

/* 9.1.8.1 RESET */
template (value) S1AP_PDU
ts_S1AP_Reset(template (value) Cause cause,
	      template (value) ResetType reset_type) := {
	initiatingMessage := {
		procedureCode := id_Reset,
		criticality := reject,
		value_ := {
			Reset := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_Cause,
						criticality := ignore,
						value_ := { Cause := cause }
					} , {
						id := S1AP_Constants.id_ResetType,
						criticality := reject,
						value_ := { resetType := reset_type }
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_Reset(template (present) Cause cause := ?,
	      template (present) ResetType reset_type := ?) := {
	initiatingMessage := {
		procedureCode := id_Reset,
		criticality := reject,
		value_ := {
			Reset := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_Cause,
						criticality := ignore,
						value_ := { Cause := cause }
					} , {
						id := S1AP_Constants.id_ResetType,
						criticality := reject,
						value_ := { resetType := reset_type }
					}, *
				}
			}
		}
	}
}

/* 9.1.8.2 RESET ACKNOWLEDGE */
template (value) S1AP_PDU
ts_S1AP_ResetAck(template (value) UE_associatedLogicalS1_ConnectionListResAck val) := {
	successfulOutcome := {
		procedureCode := id_Reset,
		criticality := reject,
		value_ := {
			ResetAcknowledge := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_UE_associatedLogicalS1_ConnectionListResAck,
						criticality := ignore,
						value_ := { UE_associatedLogicalS1_ConnectionListResAck := val }
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_ResetAck(template (present) UE_associatedLogicalS1_ConnectionListResAck val := ?) := {
	successfulOutcome := {
		procedureCode := id_Reset,
		criticality := reject,
		value_ := {
			ResetAcknowledge := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_UE_associatedLogicalS1_ConnectionListResAck,
						criticality := ignore,
						value_ := { UE_associatedLogicalS1_ConnectionListResAck := val }
					}, *
				}
			}
		}
	}
}




/*********************************************************************************
 * 9.1.7 NAS Transport
 *********************************************************************************/

/* 9.1.7.1 INITIAL UE MESSAGE */
template (value) S1AP_PDU
ts_S1AP_InitialUE(template (value) ENB_UE_S1AP_ID p_eNB_value,
		  template (value) NAS_PDU p_nasPdu,
		  template (value) TAI p_tAI,
		  template (value) EUTRAN_CGI  p_eUTRAN_CGI,
		  template (value) RRC_Establishment_Cause p_rrcCause) := {
	initiatingMessage := {
		procedureCode := id_initialUEMessage,
		criticality := ignore,
		value_ := {
			InitialUEMessage := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := reject,
						value_ := {ENB_UE_S1AP_ID := p_eNB_value}
					}, {
						id := S1AP_Constants.id_NAS_PDU,
						criticality := reject,
						value_ := {nAS_PDU := p_nasPdu}
					}, {
						id := S1AP_Constants.id_TAI,
						criticality := ignore,
						value_ := {TAI := p_tAI}
					}, {
						id := S1AP_Constants.id_EUTRAN_CGI,
						criticality := ignore,
						value_ := {EUTRAN_CGI := p_eUTRAN_CGI}
					}, {
						id := S1AP_Constants.id_RRC_Establishment_Cause,
						criticality := ignore,
						value_ := {RRC_Establishment_Cause := p_rrcCause}
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_InitialUE(template (present) ENB_UE_S1AP_ID p_eNB_value := ?,
		  template (present) NAS_PDU p_nasPdu := ?,
		  template (present) TAI p_tAI := ?,
		  template (present) EUTRAN_CGI p_eUTRAN_CGI := ?,
		  template (present) RRC_Establishment_Cause p_rrcCause := ?) := {
	initiatingMessage := {
		procedureCode := id_initialUEMessage,
		criticality := ignore,
		value_ := {
			InitialUEMessage := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := reject,
						value_ := {ENB_UE_S1AP_ID := p_eNB_value}
					}, {
						id := S1AP_Constants.id_NAS_PDU,
						criticality := reject,
						value_ := {nAS_PDU := p_nasPdu}
					}, {
						id := S1AP_Constants.id_TAI,
						criticality := ignore,
						value_ := {TAI := p_tAI}
					}, {
						id := S1AP_Constants.id_EUTRAN_CGI,
						criticality := ignore,
						value_ := {EUTRAN_CGI := p_eUTRAN_CGI}
					}, {
						id := S1AP_Constants.id_RRC_Establishment_Cause,
						criticality := ignore,
						value_ := {RRC_Establishment_Cause := p_rrcCause}
					}, *
				}
			}
		}
	}
}


/* 9.1.7.2 DOWNLINK NAS TRANSPORT */
template (value) S1AP_PDU
ts_S1AP_DlNasTransport(template (value) MME_UE_S1AP_ID mme_id,
		       template (value) ENB_UE_S1AP_ID enb_id,
		       template (value) octetstring p_nasPdu) := {
	initiatingMessage := {
		procedureCode := id_downlinkNASTransport,
		criticality := ignore,
		value_ := {
			DownlinkNASTransport := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := reject,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := reject,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_NAS_PDU,
						criticality := reject,
						value_ := {nAS_PDU := p_nasPdu}
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_DlNasTransport(template (present) MME_UE_S1AP_ID mme_id := ?,
		       template (present) ENB_UE_S1AP_ID enb_id := ?,
		       template (present) octetstring p_nasPdu := ?) := {
	initiatingMessage := {
		procedureCode := id_downlinkNASTransport,
		criticality := ignore,
		value_ := {
			DownlinkNASTransport := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := reject,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := reject,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_NAS_PDU,
						criticality := reject,
						value_ := {nAS_PDU := p_nasPdu}
					}, *
				}
			}
		}
	}
}


/* 9.1.7.3 UPNLINK NAS TRANSPORT */
template (value) S1AP_PDU
ts_S1AP_UlNasTransport(template (value) MME_UE_S1AP_ID mme_id,
		       template (value) ENB_UE_S1AP_ID enb_id,
		       template (value) octetstring p_nasPdu,
		       template (value) EUTRAN_CGI p_eUTRAN_CGI,
		       template (value) TAI p_tAI) := {
	initiatingMessage := {
		procedureCode := id_uplinkNASTransport,
		criticality := ignore,
		value_ := {
			UplinkNASTransport := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := reject,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := reject,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_NAS_PDU,
						criticality := reject,
						value_ := {nAS_PDU := p_nasPdu}
					}, {
						id := S1AP_Constants.id_EUTRAN_CGI,
						criticality := ignore,
						value_ := {EUTRAN_CGI := p_eUTRAN_CGI}
					}, {
						id := S1AP_Constants.id_TAI,
						criticality := ignore,
						value_ := {TAI := p_tAI}
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_UlNasTransport(template (present) MME_UE_S1AP_ID mme_id := ?,
		       template (present) ENB_UE_S1AP_ID enb_id := ?,
		       template (present) octetstring p_nasPdu := ?,
		       template (present) EUTRAN_CGI p_eUTRAN_CGI := ?,
		       template (present) TAI p_tAI := ?) := {
	initiatingMessage := {
		procedureCode := id_uplinkNASTransport,
		criticality := ignore,
		value_ := {
			UplinkNASTransport := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := reject,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := reject,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_NAS_PDU,
						criticality := reject,
						value_ := {nAS_PDU := p_nasPdu}
					}, {
						id := S1AP_Constants.id_EUTRAN_CGI,
						criticality := ignore,
						value_ := {EUTRAN_CGI := p_eUTRAN_CGI}
					}, {
						id := S1AP_Constants.id_TAI,
						criticality := ignore,
						value_ := {TAI := p_tAI}
					}, *
				}
			}
		}
	}
}

/*********************************************************************************
 * 9.1.4 Context Management
 *********************************************************************************/

/* 9.1.4.1 INITIAL CONTEXT SETUP REQ */
template (value) S1AP_PDU
ts_S1AP_IntialCtxSetupReq(template (value) MME_UE_S1AP_ID mme_id,
			  template (value) ENB_UE_S1AP_ID enb_id,
			  template (value) UEAggregateMaximumBitrate max_br,
			  template (value) E_RABToBeSetupListCtxtSUReq rab_setup_items,
			  template (value) UESecurityCapabilities ue_sec_par,
			  template (value) SecurityKey sec_key) := {
	initiatingMessage := {
		procedureCode := id_InitialContextSetup,
		criticality := reject,
		value_ := {
			initialContextSetupRequest := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := reject,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := reject,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_uEaggregateMaximumBitrate,
						criticality := reject,
						value_ := {UEAggregateMaximumBitrate := max_br}
					}, {
						id := S1AP_Constants.id_E_RABToBeSetupListCtxtSUReq,
						criticality := reject,
						value_ := {E_RABToBeSetupListCtxtSUReq := rab_setup_items}
					}, {
						id := S1AP_Constants.id_UESecurityCapabilities,
						criticality := reject,
						value_ := {UESecurityCapabilities := ue_sec_par}
					}, {
						id := S1AP_Constants.id_SecurityKey,
						criticality := reject,
						value_ := {SecurityKey := sec_key}
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_IntialCtxSetupReq(template (present) MME_UE_S1AP_ID mme_id := ?,
			  template (present) ENB_UE_S1AP_ID enb_id := ?,
			  template (present) UEAggregateMaximumBitrate max_br := ?,
			  template (present) E_RABToBeSetupListCtxtSUReq rab_setup_items := ?,
			  template (present) UESecurityCapabilities ue_sec_par := ?,
			  template (present) SecurityKey sec_key := ?) := {
	initiatingMessage := {
		procedureCode := id_InitialContextSetup,
		criticality := reject,
		value_ := {
			initialContextSetupRequest := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := reject,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := reject,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_uEaggregateMaximumBitrate,
						criticality := reject,
						value_ := {UEAggregateMaximumBitrate := max_br}
					}, {
						id := S1AP_Constants.id_E_RABToBeSetupListCtxtSUReq,
						criticality := reject,
						value_ := {E_RABToBeSetupListCtxtSUReq := rab_setup_items}
					}, {
						id := S1AP_Constants.id_UESecurityCapabilities,
						criticality := reject,
						value_ := {UESecurityCapabilities := ue_sec_par}
					}, {
						id := S1AP_Constants.id_SecurityKey,
						criticality := reject,
						value_ := {SecurityKey := sec_key}
					}, *
				}
			}
		}
	}
}

/* 9.1.4.3 INITIAL CONTEXT SETUP RESPONSE */
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) := {
	successfulOutcome := {
		procedureCode := id_InitialContextSetup,
		criticality := reject,
		value_ := {
			InitialContextSetupResponse := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := reject,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := reject,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_E_RABSetupListBearerSURes,
						criticality := ignore,
						value_ := {E_RABSetupListCtxtSURes := rab_setup_items}
					}, {
						id := S1AP_Constants.id_E_RABFailedToSetupListBearerSURes,
						criticality := ignore,
						value_ := {E_RABList := rab_items}
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_InitialCtxSetupResp(template (present) MME_UE_S1AP_ID mme_id := ?,
			    template (present) ENB_UE_S1AP_ID enb_id := ?,
			    template (present) E_RABSetupListCtxtSURes rab_setup_items := ?,
			    template (present) E_RABList rab_items := ?) := {
	successfulOutcome := {
		procedureCode := id_InitialContextSetup,
		criticality := reject,
		value_ := {
			InitialContextSetupResponse := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := reject,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := reject,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_E_RABSetupListBearerSURes,
						criticality := ignore,
						value_ := {E_RABSetupListCtxtSURes := rab_setup_items}
					}, {
						id := S1AP_Constants.id_E_RABFailedToSetupListBearerSURes,
						criticality := ignore,
						value_ := {E_RABList := rab_items}
					}
				}
			}
		}
	}
}

/* 9.1.4.4 INITIAL CONTEXT SETUP FAILURE */
template (value) S1AP_PDU
ts_S1AP_InitialCtxSetupFail(template (value) MME_UE_S1AP_ID mme_id,
			    template (value) ENB_UE_S1AP_ID enb_id,
			    template (value) Cause cause) := {
	unsuccessfulOutcome := {
		procedureCode := id_InitialContextSetup,
		criticality := reject,
		value_ := {
			InitialContextSetupFailure := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := ignore,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := ignore,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_Cause,
						criticality := ignore,
						value_ := {Cause := cause}
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_InitialCtxSetupFail(template (present) MME_UE_S1AP_ID mme_id := ?,
			    template (present) ENB_UE_S1AP_ID enb_id := ?,
			    template (present) Cause cause := ?) := {
	unsuccessfulOutcome := {
		procedureCode := id_InitialContextSetup,
		criticality := reject,
		value_ := {
			InitialContextSetupFailure := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := ignore,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := ignore,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_Cause,
						criticality := ignore,
						value_ := {Cause := cause}
					}, *
				}
			}
		}
	}
}

/* 9.1.4.5 UE CONTEXT RELEASE REQUEST */
template (value) S1AP_PDU
ts_S1AP_UeContextReleaseReq(template (value) MME_UE_S1AP_ID mme_id,
			    template (value) ENB_UE_S1AP_ID enb_id,
			    template (value) Cause cause) := {
	initiatingMessage := {
		procedureCode := id_UEContextReleaseRequest,
		criticality := reject,
		value_ := {
			UEContextReleaseRequest := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := ignore,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := ignore,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_Cause,
						criticality := ignore,
						value_ := {Cause := cause}
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_UeContextReleaseReq(template (present) MME_UE_S1AP_ID mme_id := ?,
			    template (present) ENB_UE_S1AP_ID enb_id := ?,
			    template (present) Cause cause := ?) := {
	initiatingMessage := {
		procedureCode := id_UEContextReleaseRequest,
		criticality := reject,
		value_ := {
			UEContextReleaseRequest := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := ignore,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := ignore,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, {
						id := S1AP_Constants.id_Cause,
						criticality := ignore,
						value_ := {Cause := cause}
					}, *
				}
			}
		}
	}
}

/* 9.1.4.6 UE CONTEXT RELEASE COMMAND */
template (value) S1AP_PDU
ts_S1AP_UeContextReleaseCmd(template (value) UE_S1AP_IDs mme_ids,
			    template (value) Cause cause) := {
	initiatingMessage := {
		procedureCode := id_UEContextRelease,
		criticality := reject,
		value_ := {
			UEContextReleaseCommand := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_UE_S1AP_IDs,
						criticality := ignore,
						value_ := {UE_S1AP_IDs := mme_ids}
					}, {
						id := S1AP_Constants.id_Cause,
						criticality := ignore,
						value_ := {Cause := cause}
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_UeContextReleaseCmd(template (present) UE_S1AP_IDs ue_ids := ?,
			    template (present) Cause cause := ?) := {
	initiatingMessage := {
		procedureCode := id_UEContextRelease,
		criticality := reject,
		value_ := {
			UEContextReleaseCommand := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_UE_S1AP_IDs,
						criticality := reject,
						value_ := {UE_S1AP_IDs := ue_ids}
					}, {
						id := S1AP_Constants.id_Cause,
						criticality := ignore,
						value_ := {Cause := cause}
					}, *
				}
			}
		}
	}
}

/* 9.1.4.7 UE CONTEXT RELEASE COMPLETE */
template (value) S1AP_PDU
ts_S1AP_UeContextReleaseCompl(template (value) MME_UE_S1AP_ID mme_id,
			      template (value) ENB_UE_S1AP_ID enb_id) := {
	successfulOutcome := {
		procedureCode := id_UEContextRelease,
		criticality := reject,
		value_ := {
			UEContextReleaseComplete := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := reject,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := ignore,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_UeContextReleaseCompl(template (present) MME_UE_S1AP_ID mme_id := ?,
			      template (present) ENB_UE_S1AP_ID enb_id := ?) := {
	successfulOutcome := {
		procedureCode := id_UEContextRelease,
		criticality := reject,
		value_ := {
			UEContextReleaseComplete := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := ignore,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := ignore,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, *
				}
			}
		}
	}
}

/* 9.1.4.20 CONNECTION ESTABLISHMENT INDICATION */
template (value) S1AP_PDU
ts_S1AP_ConnEstInd(template (value) MME_UE_S1AP_ID mme_id,
		   template (value) ENB_UE_S1AP_ID enb_id) := {
	initiatingMessage := {
		procedureCode := id_ConnectionEstablishmentIndication,
		criticality := reject,
		value_ := {
			ConnectionEstablishmentIndication := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := ignore,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := ignore,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}
				}
			}
		}
	}
}
template (present) S1AP_PDU
tr_S1AP_ConnEstInd(template (present) MME_UE_S1AP_ID mme_id := ?,
		   template (present) ENB_UE_S1AP_ID enb_id := ?) := {
	initiatingMessage := {
		procedureCode := id_ConnectionEstablishmentIndication,
		criticality := reject,
		value_ := {
			ConnectionEstablishmentIndication := {
				protocolIEs := {
					{
						id := S1AP_Constants.id_MME_UE_S1AP_ID,
						criticality := ignore,
						value_ := {MME_UE_S1AP_ID := mme_id}
					}, {
						id := S1AP_Constants.id_eNB_UE_S1AP_ID,
						criticality := ignore,
						value_ := {ENB_UE_S1AP_ID := enb_id}
					}, *
				}
			}
		}
	}
}



/* all non-UE-related S1AP messages */
template (present) S1AP_PDU
tr_S1AP_nonUErelated := (tr_S1AP_SetupReq, tr_S1AP_SetupResp, tr_S1AP_SetupFail,
			 tr_S1AP_Reset, tr_S1AP_ResetAck
			);


}
