library/L1CTL_Types: add missing template restrictions

The template restrictions are quite useful, becaue they give hints
to the TTCN-3 compiler, so it can spot more bugs.  For example,
the lack of thereof would not prevent one from passing 'omit' to
a template, that assigns a value to a non-optional field, so that
might lead to a DTE at run-time in some cases.

Since adding 'template (restriction) ' to each template parameter
obviously makes templates look more cumbersome, let's move the
part with template name and arguments onto a separate line, just
like it's sometimes done for function definitions in C.

Change-Id: I7e6846381e0b3fb611059fcfbafb19bd6c15cfd8
This commit is contained in:
Vadim Yanitskiy 2020-11-14 04:05:34 +07:00 committed by laforge
parent d4e95e8cfc
commit be33f6b158
1 changed files with 92 additions and 60 deletions

View File

@ -105,13 +105,15 @@ module L1CTL_Types {
OCT2 padding
} with { variant "" };
template L1ctlHeader tr_L1ctlHeader(template L1ctlMsgType msg_type) := {
template L1ctlHeader
tr_L1ctlHeader(template (present) L1ctlMsgType msg_type) := {
msg_type := msg_type,
flags := ?,
padding := ?
};
template (value) L1ctlHeader ts_L1ctlHeader(L1ctlMsgType msg_type) := {
template (value) L1ctlHeader
ts_L1ctlHeader(template (value) L1ctlMsgType msg_type) := {
msg_type := msg_type,
flags := { padding := '0000000'B, f_done := false },
padding := '0000'O
@ -459,7 +461,8 @@ module L1CTL_Types {
/* for generating RESET_REQ */
template (value) L1ctlUlMessage t_L1ctlResetReq(L1ctlResetType rst_type) := {
template (value) L1ctlUlMessage
t_L1ctlResetReq(template (value) L1ctlResetType rst_type) := {
header := ts_L1ctlHeader(L1CTL_RESET_REQ),
ul_info := omit,
ul_info_tbf := omit,
@ -473,10 +476,12 @@ module L1CTL_Types {
};
/* for generating FBSB_REQ */
template (value) L1ctlUlMessage ts_L1CTL_FBSB_REQ(Arfcn arfcn, L1ctlFbsbFlags flags,
uint8_t sync_info_idx,
L1ctlCcchMode ccch_mode,
GsmRxLev rxlev_exp) := {
template (value) L1ctlUlMessage
ts_L1CTL_FBSB_REQ(template (value) Arfcn arfcn,
template (value) L1ctlFbsbFlags flags,
template (value) uint8_t sync_info_idx,
template (value) L1ctlCcchMode ccch_mode,
template (value) GsmRxLev rxlev_exp) := {
header := ts_L1ctlHeader(L1CTL_FBSB_REQ),
ul_info := omit,
ul_info_tbf := omit,
@ -497,7 +502,8 @@ module L1CTL_Types {
};
/* for matching against incoming FBSB_CONF */
template L1ctlDlMessage tr_L1CTL_FBSB_CONF(template uint8_t result) := {
template L1ctlDlMessage
tr_L1CTL_FBSB_CONF(template (present) uint8_t result) := {
header := tr_L1ctlHeader(L1CTL_FBSB_CONF),
dl_info := ?,
payload := {
@ -509,7 +515,8 @@ module L1CTL_Types {
}
};
template (value) L1ctlUlMessage ts_L1CTL_CCCH_MODE_REQ(L1ctlCcchMode ccch_mode) := {
template (value) L1ctlUlMessage
ts_L1CTL_CCCH_MODE_REQ(template (value) L1ctlCcchMode ccch_mode) := {
header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ),
ul_info := omit,
ul_info_tbf := omit,
@ -541,7 +548,8 @@ module L1CTL_Types {
};
template L1ctlDlMessage tr_L1CTL_MsgType(template L1ctlMsgType msg_type) := {
template L1ctlDlMessage
tr_L1CTL_MsgType(template (present) L1ctlMsgType msg_type) := {
header := tr_L1ctlHeader(msg_type),
dl_info := *,
payload := *
@ -549,9 +557,12 @@ module L1CTL_Types {
template L1ctlDlMessage tr_L1CTL_CCCH_MODE_CONF := tr_L1CTL_MsgType(L1CTL_CCCH_MODE_CONF);
template L1ctlUlMessage ts_L1CTL_RACH_REQ(uint8_t ra, uint8_t combined, uint16_t offset,
template (value) RslChannelNr chan_nr := ts_RslChanNr_RACH(0),
template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0)) := {
template (value) L1ctlUlMessage
ts_L1CTL_RACH_REQ(template (value) uint8_t ra,
template (value) uint8_t combined,
template (value) uint16_t offset,
template (value) RslChannelNr chan_nr := ts_RslChanNr_RACH(0),
template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0)) := {
header := ts_L1ctlHeader(L1CTL_RACH_REQ),
ul_info := {
chan_nr := chan_nr,
@ -569,10 +580,11 @@ module L1CTL_Types {
}
}
template L1ctlUlMessage ts_L1CTL_EXT_RACH_REQ(
uint16_t ra11, L1ctlRachSynchSeq seq,
uint8_t combined, uint16_t offset
) := {
template (value) L1ctlUlMessage
ts_L1CTL_EXT_RACH_REQ(template (value) uint16_t ra11,
template (value) L1ctlRachSynchSeq seq,
template (value) uint8_t combined,
template (value) uint16_t offset) := {
header := ts_L1ctlHeader(L1CTL_EXT_RACH_REQ),
ul_info := {
/* FIXME: both RSL chan_nr and link_id should be configurable */
@ -592,7 +604,9 @@ module L1CTL_Types {
}
}
template L1ctlUlMessage ts_L1CTL_PAR_REQ(uint8_t ta, uint8_t tx_power) := {
template (value) L1ctlUlMessage
ts_L1CTL_PAR_REQ(template (value) uint8_t ta,
template (value) uint8_t tx_power) := {
header := ts_L1ctlHeader(L1CTL_PARAM_REQ),
ul_info := {
chan_nr := t_RslChanNr_RACH(0),
@ -611,8 +625,9 @@ module L1CTL_Types {
}
/* Base template to be inherited by ts_L1CTL_DM_EST_REQ_H0 and ts_L1CTL_DM_EST_REQ_H1 */
private template (value) L1ctlUlMessage ts_L1CTL_DM_EST_REQ(template (value) RslChannelNr chan_nr,
template (value) GsmTsc tsc) := {
private template (value) L1ctlUlMessage
ts_L1CTL_DM_EST_REQ(template (value) RslChannelNr chan_nr,
template (value) GsmTsc tsc) := {
header := ts_L1ctlHeader(L1CTL_DM_EST_REQ),
ul_info := {
chan_nr := chan_nr,
@ -630,9 +645,10 @@ module L1CTL_Types {
}
}
template (value) L1ctlUlMessage ts_L1CTL_DM_EST_REQ_H0(template (value) RslChannelNr chan_nr,
template (value) GsmTsc tsc,
template (value) GsmArfcn arfcn)
template (value) L1ctlUlMessage
ts_L1CTL_DM_EST_REQ_H0(template (value) RslChannelNr chan_nr,
template (value) GsmTsc tsc,
template (value) GsmArfcn arfcn)
modifies ts_L1CTL_DM_EST_REQ := {
payload := {
dm_est_req := {
@ -647,11 +663,12 @@ module L1CTL_Types {
}
}
template (value) L1ctlUlMessage ts_L1CTL_DM_EST_REQ_H1(template (value) RslChannelNr chan_nr,
template (value) GsmTsc tsc,
template (value) uint6_t hsn,
template (value) uint6_t maio,
template (value) L1ctlMA ma)
template (value) L1ctlUlMessage
ts_L1CTL_DM_EST_REQ_H1(template (value) RslChannelNr chan_nr,
template (value) GsmTsc tsc,
template (value) uint6_t hsn,
template (value) uint6_t maio,
template (value) L1ctlMA ma)
modifies ts_L1CTL_DM_EST_REQ := {
payload := {
dm_est_req := {
@ -671,7 +688,8 @@ module L1CTL_Types {
}
}
template L1ctlUlMessage ts_L1CTL_DM_REL_REQ(RslChannelNr chan_nr) := {
template (value) L1ctlUlMessage
ts_L1CTL_DM_REL_REQ(template (value) RslChannelNr chan_nr) := {
header := ts_L1ctlHeader(L1CTL_DM_REL_REQ),
ul_info := {
chan_nr := chan_nr,
@ -685,9 +703,10 @@ module L1CTL_Types {
}
}
template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr,
template (value) RslLinkId link_id,
octetstring l2_data) := {
template (value) L1ctlUlMessage
ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr,
template (value) RslLinkId link_id,
octetstring l2_data) := {
header := ts_L1ctlHeader(L1CTL_DATA_REQ),
ul_info := {
chan_nr := chan_nr,
@ -704,10 +723,11 @@ module L1CTL_Types {
}
}
template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ_SACCH(template (value) RslChannelNr chan_nr,
template (value) RslLinkId link_id,
template (value) SacchL1Header l1h,
octetstring l2_data) := {
template (value) L1ctlUlMessage
ts_L1CTL_DATA_REQ_SACCH(template (value) RslChannelNr chan_nr,
template (value) RslLinkId link_id,
template (value) SacchL1Header l1h,
octetstring l2_data) := {
header := ts_L1ctlHeader(L1CTL_DATA_REQ),
ul_info := {
chan_nr := chan_nr,
@ -724,9 +744,10 @@ module L1CTL_Types {
}
}
template (value) L1ctlUlMessage ts_L1CTL_TRAFFIC_REQ(template (value) RslChannelNr chan_nr,
template (value) RslLinkId link_id,
octetstring frame) := {
template (value) L1ctlUlMessage
ts_L1CTL_TRAFFIC_REQ(template (value) RslChannelNr chan_nr,
template (value) RslLinkId link_id,
octetstring frame) := {
header := ts_L1ctlHeader(L1CTL_TRAFFIC_REQ),
ul_info := {
chan_nr := chan_nr,
@ -742,7 +763,9 @@ module L1CTL_Types {
}
};
template (value) L1ctlUlMessage ts_L1CTL_TBF_CFG_REQ(boolean is_uplink, TfiUsfArr tfi_usf) := {
template (value) L1ctlUlMessage
ts_L1CTL_TBF_CFG_REQ(template (value) boolean is_uplink,
template (value) TfiUsfArr tfi_usf) := {
header := ts_L1ctlHeader(L1CTL_TBF_CFG_REQ),
ul_info := omit,
ul_info_tbf := omit,
@ -757,7 +780,8 @@ module L1CTL_Types {
}
};
template L1ctlDlMessage tr_L1CTL_TBF_CFG_CONF(template boolean is_uplink) := {
template L1ctlDlMessage
tr_L1CTL_TBF_CFG_CONF(template (present) boolean is_uplink) := {
header := tr_L1ctlHeader(L1CTL_TBF_CFG_CONF),
dl_info := omit,
payload := {
@ -770,9 +794,10 @@ module L1CTL_Types {
}
};
template (value) L1ctlUlMessage ts_L1CTL_DATA_TBF_REQ(octetstring l2_data,
L1ctlGprsCs cs := L1CTL_CS1,
uint8_t tbf_nr := 0) := {
template (value) L1ctlUlMessage
ts_L1CTL_DATA_TBF_REQ(octetstring l2_data,
template (value) L1ctlGprsCs cs := L1CTL_CS1,
template (value) uint8_t tbf_nr := 0) := {
header := ts_L1ctlHeader(L1CTL_DATA_TBF_REQ),
ul_info := omit,
ul_info_tbf := {
@ -786,10 +811,13 @@ module L1CTL_Types {
}
}
template (value) L1ctlUlMessage ts_L1CTL_DATA_ABS_REQ(octetstring l2_data, Arfcn arfcn,
uint8_t ts, GsmFrameNumber fn,
L1ctlGprsCs cs := L1CTL_CS1,
uint8_t tbf_nr := 0) := {
template (value) L1ctlUlMessage
ts_L1CTL_DATA_ABS_REQ(octetstring l2_data,
template (value) Arfcn arfcn,
template (value) uint8_t ts,
template (value) GsmFrameNumber fn,
template (value) L1ctlGprsCs cs := L1CTL_CS1,
template (value) uint8_t tbf_nr := 0) := {
header := ts_L1ctlHeader(L1CTL_DATA_ABS_REQ),
ul_info := omit,
ul_info_tbf := omit,
@ -816,11 +844,12 @@ module L1CTL_Types {
};
/* for matching against incoming DATA_IND */
template L1ctlDlMessage tr_L1CTL_DATA_IND(template RslChannelNr chan_nr,
template RslLinkId link_id := ?,
template octetstring l2_data := ?,
template uint8_t num_biterr := 0,
template uint8_t fire_crc := 0) := {
template L1ctlDlMessage
tr_L1CTL_DATA_IND(template (present) RslChannelNr chan_nr,
template (present) RslLinkId link_id := ?,
template (present) octetstring l2_data := ?,
template (present) uint8_t num_biterr := 0,
template (present) uint8_t fire_crc := 0) := {
header := tr_L1ctlHeader(L1CTL_DATA_IND),
dl_info := {
chan_nr := chan_nr,
@ -840,11 +869,12 @@ module L1CTL_Types {
};
/* for matching against incoming TRAFFIC_IND */
template L1ctlDlMessage tr_L1CTL_TRAFFIC_IND(template RslChannelNr chan_nr,
template RslLinkId link_id := ?,
template octetstring frame := ?,
template uint8_t num_biterr := ?,
template uint8_t fire_crc := ?) := {
template L1ctlDlMessage
tr_L1CTL_TRAFFIC_IND(template (present) RslChannelNr chan_nr,
template (present) RslLinkId link_id := ?,
template (present) octetstring frame := ?,
template (present) uint8_t num_biterr := ?,
template (present) uint8_t fire_crc := ?) := {
header := tr_L1ctlHeader(L1CTL_TRAFFIC_IND),
dl_info := {
chan_nr := chan_nr,
@ -863,8 +893,10 @@ module L1CTL_Types {
}
};
template (value) L1ctlUlMessage ts_L1CTL_CRYPTO_REQ(RslChannelNr chan_nr, uint8_t algo,
octetstring key) := {
template (value) L1ctlUlMessage
ts_L1CTL_CRYPTO_REQ(template (value) RslChannelNr chan_nr,
template (value) uint8_t algo,
template (value) octetstring key) := {
header := ts_L1ctlHeader(L1CTL_CRYPTO_REQ),
ul_info := {
chan_nr := chan_nr,