Support for SBc-AP protocol as used on the MME-CBC interface

This requires a recent libfftranscode (>=0.5) with SBC-AP support.

The asn files are obtained from 3GPP TS 29.168.

Related: osmo-cbc.git Ib278bc1d1a74459814016fef7a8fe21cc29d46c9
Related: docker-playground.git 5f3c78105836d1f2c229655df3f537a73ab6e12a
Change-Id: Ia6743e0a3e7974a5f2dd3ecf74ec331f646f6bc2
Related: OS#4945
diff --git a/library/sbcap/SBC_AP_Templates.ttcn b/library/sbcap/SBC_AP_Templates.ttcn
new file mode 100644
index 0000000..c0c0837
--- /dev/null
+++ b/library/sbcap/SBC_AP_Templates.ttcn
@@ -0,0 +1,276 @@
+module SBC_AP_Templates {
+
+import from General_Types all;
+import from Osmocom_Types all;
+
+import from SBC_AP_IEs all;
+import from SBC_AP_Constants all;
+import from SBC_AP_Containers all;
+import from SBC_AP_PDU_Contents all;
+import from SBC_AP_PDU_Descriptions all;
+
+import from SBC_AP_Types all;
+
+template (value) SBC_AP_PDU
+ts_SBCAP_PWS_RESTART(
+			template (value) Restarted_Cell_List restart_cl,
+			template (value) Global_ENB_ID global_enb_id) := {
+	initiatingMessage := {
+		procedureCode := id_PWS_Restart_Indication,
+		criticality := reject,
+		value_ := {
+			PWS_Restart_Indication := {
+				protocolIEs := {
+					{
+						id := SBC_AP_Constants.id_Restarted_Cell_List,
+						criticality := reject,
+						value_ := { Restarted_Cell_List := restart_cl }
+					}, {
+						id := SBC_AP_Constants.id_Global_ENB_ID,
+						criticality := reject,
+						value_ := { Global_ENB_ID := global_enb_id }
+					}
+					/* List of TAIs (mandatory) */
+					/* List of EAIs (optional) */
+				},
+				protocolExtensions := omit
+			}
+		}
+	}
+}
+
+template (value) SBC_AP_PDU
+ts_SBCAP_PWS_FAILURE(
+			template (value) Failed_Cell_List fail_cl,
+			template (value) Global_ENB_ID global_enb_id) := {
+	initiatingMessage := {
+		procedureCode := id_PWS_Failure_Indication,
+		criticality := reject,
+		value_ := {
+			PWS_Failure_Indication := {
+				protocolIEs := {
+					{
+						id := SBC_AP_Constants.id_Failed_Cell_List,
+						criticality := reject,
+						value_ := { Failed_Cell_List := fail_cl }
+					}, {
+						id := SBC_AP_Constants.id_Global_ENB_ID,
+						criticality := reject,
+						value_ := { Global_ENB_ID := global_enb_id }
+					}
+				},
+				protocolExtensions := omit
+			}
+		}
+	}
+}
+
+/* 4.3.4.2.1 WRITE-REPLACE WARNING REQUEST */
+template (value) SBC_AP_PDU
+ts_SBCAP_WRITE_WARNING(template (value) BIT16 p_msg_id, template (value) BIT16 p_ser_nr,
+		       template (value) uint12_t p_rep_per, template (value) uint16_t p_num_bcast,
+		       template (value) OCT2 p_w_type, OCT1 p_dcs,
+		       template (value) octetstring p_msg_content) := {
+	initiatingMessage := {
+		procedureCode := id_Write_Replace_Warning,
+		criticality := reject,
+		value_ := {
+			write_Replace_Warning_Request := {
+				protocolIEs := {
+					{
+						id := SBC_AP_Constants.id_Message_Identifier,
+						criticality := reject,
+						value_ := { Message_Identifier := p_msg_id }
+					}, {
+						id := SBC_AP_Constants.id_Serial_Number,
+						criticality := reject,
+						value_ := { Serial_Number := p_ser_nr }
+						/* List of TAIs */
+						/* Warning Area List */
+					}, {
+						id := SBC_AP_Constants.id_Repetition_Period,
+						criticality := reject,
+						value_ := { Repetition_Period := p_rep_per }
+						/* Extended Repetition Period */
+					}, {
+						id := SBC_AP_Constants.id_Number_of_Broadcasts_Requested,
+						criticality := reject,
+						value_ := { Number_of_Broadcasts_Requested := p_num_bcast }
+					}, {
+						id := SBC_AP_Constants.id_Warning_Type,
+						criticality := ignore,
+						value_ := { Warning_Type := p_w_type }
+					}, {
+						/* Warning Security Info */
+						/* Data Coding Scheme */
+						id := SBC_AP_Constants.id_Data_Coding_Scheme,
+						criticality := ignore,
+						value_ := { Data_Coding_Scheme := oct2bit(p_dcs) }
+					}, {
+						/* Warning Message Content */
+						id := SBC_AP_Constants.id_Warning_Message_Content,
+						criticality := ignore,
+						value_ := { Warning_Message_Content := p_msg_content }
+					}
+						/* OMC ID */
+						/* Concurrent Warning Message Indicator */
+						/* Send Write Replace Warning Indication */
+						/* Global eNB ID */
+						/* Warning Area Coordinates */
+				},
+				protocolExtensions := omit
+			}
+		}
+	}
+}
+
+template (present) SBC_AP_PDU
+tr_SBCAP_WRITE_WARNING(template (present) BIT16 p_msg_id, template (present) BIT16 p_ser_nr,
+		       template (present) uint12_t p_rep_per,
+		       template (present) uint16_t p_num_bcast,
+		       template (present) BIT8 dcs := ?,
+		       template (present) octetstring p_msg_content := ?
+		       ) := {
+	initiatingMessage := {
+		procedureCode := id_Write_Replace_Warning,
+		criticality := reject,
+		value_ := {
+			write_Replace_Warning_Request := {
+				protocolIEs := {
+					{
+						id := SBC_AP_Constants.id_Message_Identifier,
+						criticality := reject,
+						value_ := { Message_Identifier := p_msg_id }
+					}, {
+						id := SBC_AP_Constants.id_Serial_Number,
+						criticality := reject,
+						value_ := { Serial_Number := p_ser_nr }
+						/* List of TAIs */
+						/* Warning Area List */
+					}, {
+						id := SBC_AP_Constants.id_Repetition_Period,
+						criticality := reject,
+						value_ := { Repetition_Period := p_rep_per }
+						/* Extended Repetition Period */
+					}, {
+						id := SBC_AP_Constants.id_Number_of_Broadcasts_Requested,
+						criticality := reject,
+						value_ := { Number_of_Broadcasts_Requested := p_num_bcast }
+					}/*, {
+						id := SBC_AP_Constants.id_Warning_Type,
+						criticality := ignore,
+						value_ := { Warning_Type := warn_type }
+					}, {
+						id := SBC_AP_Constants.id_Warning_Security_Information,
+						criticality := reject,
+						value_ := { Warning_Security_Information := ? }
+					}*/, {
+						id := SBC_AP_Constants.id_Data_Coding_Scheme,
+						criticality := ignore,
+						value_ := { Data_Coding_Scheme := dcs }
+					}, {
+						/* Warning Message Content */
+						id := SBC_AP_Constants.id_Warning_Message_Content,
+						criticality := ignore,
+						value_ := { Warning_Message_Content := p_msg_content }
+					}
+						/* Warning Message Content */
+						/* OMC ID */
+						/* Concurrent Warning Message Indicator */
+						/* Send Write Replace Warning Indication */
+						/* Global eNB ID */
+						/* Warning Area Coordinates */
+				},
+				protocolExtensions := omit
+			}
+		}
+	}
+}
+
+/* 4.3.4.2.3 STOP WARNING REQUEST */
+template (value) SBC_AP_PDU
+ts_SBCAP_WRITE_WARNING_RESP(template (value) BIT16 p_msg_id, template (value) BIT16 p_ser_nr,
+		       template (value) SBC_AP_Cause cause := SBC_AP_Cause_message_accepted) := {
+	successfulOutcome := {
+		procedureCode := id_Write_Replace_Warning,
+		criticality := reject,
+		value_ := {
+			write_Replace_Warning_Response := {
+				protocolIEs := {
+					{
+						id := SBC_AP_Constants.id_Message_Identifier,
+						criticality := reject,
+						value_ := { Message_Identifier := p_msg_id }
+					}, {
+						id := SBC_AP_Constants.id_Serial_Number,
+						criticality := reject,
+						value_ := { Serial_Number := p_ser_nr }
+					}, {
+						id := SBC_AP_Constants.id_Cause,
+						criticality := reject,
+						value_ := { Cause := enum2int(valueof(cause)) }
+					}
+				},
+				protocolExtensions := omit
+			}
+		}
+	}
+}
+
+template (present) SBC_AP_PDU
+tr_SBCAP_STOP_WARNING(template (present) BIT16 p_msg_id, template (present) BIT16 p_ser_nr) := {
+	initiatingMessage := {
+		procedureCode := id_Stop_Warning,
+		criticality := reject,
+		value_ := {
+			stop_Warning_Request := {
+				protocolIEs := {
+					{
+						id := SBC_AP_Constants.id_Message_Identifier,
+						criticality := reject,
+						value_ := { Message_Identifier := p_msg_id }
+					}, {
+						id := SBC_AP_Constants.id_Serial_Number,
+						criticality := reject,
+						value_ := { Serial_Number := p_ser_nr }
+						/* List of TAIs */
+						/* Warning Area List */
+					}
+				},
+				protocolExtensions := omit
+			}
+		}
+	}
+}
+
+/* 4.3.4.2.4 STOP WARNING RESPONSE */
+template (value) SBC_AP_PDU
+ts_SBCAP_STOP_WARNING_RESP(template (value) BIT16 p_msg_id, template (value) BIT16 p_ser_nr,
+		       template (value) SBC_AP_Cause cause := SBC_AP_Cause_message_accepted) := {
+	successfulOutcome := {
+		procedureCode := id_Stop_Warning,
+		criticality := reject,
+		value_ := {
+			stop_Warning_Response := {
+				protocolIEs := {
+					{
+						id := SBC_AP_Constants.id_Message_Identifier,
+						criticality := reject,
+						value_ := { Message_Identifier := p_msg_id }
+					}, {
+						id := SBC_AP_Constants.id_Serial_Number,
+						criticality := reject,
+						value_ := { Serial_Number := p_ser_nr }
+					}, {
+						id := SBC_AP_Constants.id_Cause,
+						criticality := reject,
+						value_ := { Cause := enum2int(valueof(cause)) }
+					}
+				},
+				protocolExtensions := omit
+			}
+		}
+	}
+}
+
+}