osmo-ttcn3-hacks/library/GSM_RestOctets.ttcn

196 lines
5.0 KiB
Plaintext

/**
* GSM Rest Octets definitions as per 3GPP TS 44.018.
*
* (C) 2020 Vadim Yanitskiy <axilirator@gmail.com>
* 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 GSM_RestOctets {
import from General_Types all;
import from Osmocom_Types all;
/* 10.5.2.34 SI 3 Rest Octets */
type record SI3RestOctets {
SelectionParamsOpt sel_params,
PowerOffsetOpt pwr_offset,
BIT1 si_2ter_ind,
BIT1 early_cm_ind,
SchedIfAndWhere sched_where,
GPRSIndicatorOpt gprs_ind,
BIT1 umts_early_cm_ind,
SI2quaterIndicatorOpt si2_quater_ind,
BIT1 iu_mode_ind ('1'B) optional,
SI21IndicatorOpt si21_ind optional
/* ... spare padding ... */
} with {
variant (si_2ter_ind) "CSN.1 L/H"
variant (early_cm_ind) "CSN.1 L/H"
variant (umts_early_cm_ind) "CSN.1 L/H"
/* If Iu mode is not supported in the cell, the Iu Indicator is not sent
* within this cell. Iu Indicator is included if and only if GPRS is
* not supported, and Iu mode is supported in the cell. */
variant (iu_mode_ind) "PRESENCE(gprs_ind.presence = '0'B)"
/* SI21 field is only present if 'WHERE' information is not present. */
variant (si21_ind) "PRESENCE(sched_where.presence = '0'B)"
/* The TITAN's RAW encoder generates an octet-aligned octetstring,
* so we should make sure that unused bits contain proper padding. */
variant "PADDING(yes), PADDING_PATTERN('00101011'B)"
};
/* 10.5.2.35 SI 4 Rest Octets (O & S) */
type record SI4RestOctets {
SelectionParamsOpt sel_params,
PowerOffsetOpt pwr_offset,
GPRSIndicatorOpt gprs_ind,
BIT1 s_presence, // L/H
/* TODO: optional "Rest Octets S" part */
bitstring s optional
} with {
variant (s_presence) "CSN.1 L/H"
variant (s) "PRESENCE(s_presence = '1'B)"
/* The TITAN's RAW encoder generates an octet-aligned octetstring,
* so we should make sure that unused bits contain proper padding. */
variant "PADDING(yes), PADDING_PATTERN('00101011'B)"
};
/* Selection Parameters */
type record SelectionParams {
boolean cbq,
uint6_t cr_offset,
uint3_t temp_offset,
uint5_t penalty_time
} with {
variant (cbq) "FIELDLENGTH(1)"
};
/* Optional Selection Parameters: L | H < Selection Parameters > */
type record SelectionParamsOpt {
BIT1 presence, // L/H
SelectionParams params optional
} with {
variant (presence) "CSN.1 L/H"
variant (params) "PRESENCE(presence = '1'B)"
};
/* Optional Power Offset: L | H < Power Offset bit(2) > */
type record PowerOffsetOpt {
BIT1 presence, // L/H
uint2_t offset optional
} with {
variant (presence) "CSN.1 L/H"
variant (offset) "PRESENCE(presence = '1'B)"
};
/* Scheduling if and where: L | H < WHERE bit(3) > */
type record SchedIfAndWhere {
BIT1 presence, // L/H
uint3_t where optional
} with {
variant (presence) "CSN.1 L/H"
variant (where) "PRESENCE(presence = '1'B)"
};
type record GPRSIndicator {
uint3_t ra_colour,
BIT1 si13_pos
} with { variant "" };
/* Optional GPRS Indicator: L | H < GPRS Indicator > */
type record GPRSIndicatorOpt {
BIT1 presence, // L/H
GPRSIndicator ind optional
} with {
variant (presence) "CSN.1 L/H"
variant (ind) "PRESENCE(presence = '1'B)"
};
/* Optional SI2quater Indicator: L | H < SI2quater Indicator > */
type record SI2quaterIndicatorOpt {
BIT1 presence, // L/H
BIT1 ind optional
} with {
variant (presence) "CSN.1 L/H"
variant (ind) "PRESENCE(presence = '1'B)"
};
/* Optional SI21 Indicator: L | H < SI21 Position > */
type record SI21IndicatorOpt {
BIT1 presence, // L/H
BIT1 pos optional
} with {
variant (presence) "CSN.1 L/H"
variant (pos) "PRESENCE(presence = '1'B)"
};
external function enc_SI3RestOctets(in SI3RestOctets ro) return octetstring
with { extension "prototype(convert) encode(RAW)" };
external function dec_SI3RestOctets(in octetstring stream) return SI3RestOctets
with { extension "prototype(convert) decode(RAW)" };
external function enc_SI4RestOctets(in SI4RestOctets ro) return octetstring
with { extension "prototype(convert) encode(RAW)" };
external function dec_SI4RestOctets(in octetstring stream) return SI4RestOctets
with { extension "prototype(convert) decode(RAW)" };
/* Basic templates to be extended in place */
template (value) SI3RestOctets ts_SI3RestOctets := {
sel_params := {
presence := CSN1_L,
params := omit
},
pwr_offset := {
presence := CSN1_L,
offset := omit
},
si_2ter_ind := CSN1_L,
early_cm_ind := CSN1_L,
sched_where := {
presence := CSN1_L,
where := omit
},
gprs_ind := {
presence := CSN1_L,
ind := omit
},
umts_early_cm_ind := CSN1_L,
si2_quater_ind := {
presence := CSN1_L,
ind := omit
},
iu_mode_ind := omit,
si21_ind := {
presence := CSN1_L,
pos := omit
}
}
template (value) SI4RestOctets ts_SI4RestOctets := {
sel_params := {
presence := CSN1_L,
params := omit
},
pwr_offset := {
presence := CSN1_L,
offset := omit
},
gprs_ind := {
presence := CSN1_L,
ind := omit
},
s_presence := CSN1_L,
s := omit
}
} with { encode "RAW"; variant "FIELDORDER(msb)" }