summaryrefslogtreecommitdiffstats
path: root/library/GSM_RestOctets.ttcn
blob: 531528cd1d7bd3cb5d59421e2c1b097dbf1187a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/**
 * 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)" }