cbc: Initial set of CBC tess for osmo-cbc

osmo-cbc is the Osmocom cell broadcast centre.  So far, there was no
TTCN-3 test suite.  Let's change that.

Change-Id: I38286e8a3dd0f39bd25f631dcbb3ff4f8d4c221f
diff --git a/library/CBSP_Templates.ttcn b/library/CBSP_Templates.ttcn
index 5ee1f33..5da2958 100644
--- a/library/CBSP_Templates.ttcn
+++ b/library/CBSP_Templates.ttcn
@@ -54,7 +54,7 @@
 	if (istemplatekind(val, "omit")) {
 		ie := omit;
 	} else if (istemplatekind(val, "*")) {
-		ie := tr_CBSP_IE({channel_ind := ?}) ifpresent;
+		ie := tr_CBSP_IE({channel_ind := ?}); //ifpresent;
 	} else {
 		ie := tr_CBSP_IE({channel_ind := val});
 	}
@@ -542,14 +542,20 @@
 			ts_OldSerNo(old_ser_nr),
 			ts_CbspCellList(cell_list),
 			ts_CbspChannelInd(channel_ind)});
-template CBSP_PDU tr_CBSP_KILL(template uint16_t msg_id := ?, template uint16_t old_ser_nr := ?,
-				template BSSMAP_FIELD_CellIdentificationList cell_list := ?,
-				template uint8_t channel_ind := ?) :=
-	tr_CBSP(CBSP_MSGT_KILL, {
-			tr_CbspMsgId(msg_id),
-			tr_OldSerNo(old_ser_nr),
-			tr_CbspCellList(cell_list),
-			tr_CbspChannelInd(channel_ind) });
+function tr_CBSP_KILL(template uint16_t msg_id := ?, template uint16_t old_ser_nr := ?,
+			template BSSMAP_FIELD_CellIdentificationList cell_list := ?,
+			template uint8_t channel_ind := ?)
+return template (present) CBSP_PDU {
+	var template CBSP_IEs ies := {
+		tr_CbspMsgId(msg_id),
+		tr_OldSerNo(old_ser_nr),
+		tr_CbspCellList(cell_list)
+	};
+	if (not istemplatekind(channel_ind, "omit")) {
+		ies[lengthof(ies)] := tr_CbspChannelInd(channel_ind);
+	}
+	return tr_CBSP(CBSP_MSGT_KILL, ies);
+}
 
 /* 8.1.3.5 KILL COMPLETE */
 function ts_CBSP_KILL_COMPL(template (value) uint16_t msg_id, template (value) uint16_t old_ser_nr,
diff --git a/library/CBSP_Types.ttcn b/library/CBSP_Types.ttcn
index c4c6cf2..5ab3c98 100644
--- a/library/CBSP_Types.ttcn
+++ b/library/CBSP_Types.ttcn
@@ -378,5 +378,24 @@
 external function dec_CBSP_PDU(in octetstring msg) return CBSP_PDU
 	with { extension "prototype(convert) decode(RAW)" };
 
+/* convert from warning period encoding to seconds */
+function f_cbsp_period2s(uint8_t period) return integer
+{
+	if (period == 0) {
+		return -1; /* infinite */
+	} else if (period <= 10) {
+		return period;
+	} else if (period <= 20) {
+		return 10 + (period - 10)*2;
+	} else if (period <= 38) {
+		return 30 + (period - 20)*5;
+	} else if (period <= 86) {
+		return 120 + (period - 38)*10;
+	} else if (period <= 186) {
+		return 600 + (period - 86)*30;
+	} else {
+		return 0;
+	}
+}
 
 } with { encode "RAW"; variant "FIELDORDER(msb)" }
diff --git a/library/SABP_Adapter.ttcn b/library/SABP_Adapter.ttcn
index e94e91c..046f597 100644
--- a/library/SABP_Adapter.ttcn
+++ b/library/SABP_Adapter.ttcn
@@ -20,7 +20,7 @@
 import from SABP_CodecPort_CtrlFunct all;
 import from IPL4asp_Types all;
 import from IPL4asp_PortType all;
-//import from Socket_API_Definitions all;
+import from Socket_API_Definitions all;
 
 const integer SABP_HDR_LEN := 3;
 
@@ -72,7 +72,7 @@
  * If the callback function detects that the it will be impossible to determine the length of the message,
  * even receiving more octets, should return "-2". In this case the connection will be closed and the
  * length calculation error will be reported. */
-private function f_APER_getMsgLen(in octetstring stream, inout ro_integer args) return integer {
+private function f_APER_getMsgLen(in octetstring stream, inout Socket_API_Definitions.ro_integer args) return integer {
 	var integer stream_len := lengthof(stream);
 	var integer hdr_len := args[0];
 	var octetstring stream_nohdr;