blob: c97b78b65960cabc15917d4f043e3956065f70f7 [file] [log] [blame]
Harald Welte3a194402017-07-22 17:07:51 +02001module BSSGP_Types {
2
3 import from General_Types all;
4 import from Osmocom_Types all;
5 import from GSM_Types all;
Harald Welte039f6952017-07-23 16:18:16 +02006 import from BSSGP_Helper_Functions all;
Harald Welte3a194402017-07-22 17:07:51 +02007
8 type enumerated BssgpPduType {
9 DL_UNITDATA ('00'H),
10 UL_UNITDATA ('01'H),
11 RA_CAPABILITY ('02'H),
12 DL_MBMS_UNITDATA ('04'H),
13 UL_MBMS_UNITDATA ('05'H),
14 /* between GMM SAPs */
15 PAGING_PS ('06'H),
16 PAGING_CS ('07'H),
17 RA_CAPABILITY_UPDATE ('08'H),
18 RA_CAPABILITY_UPDATE_ACK ('09'H),
19 RADIO_STATUS ('0A'H),
20 SUSPEND ('0B'H),
21 SUSPEND_ACK ('0C'H),
22 SUSPEND_NACK ('0D'H),
23 RESUME ('0E'H),
24 RESUME_ACK ('0F'H),
25 RESUME_NACK ('10'H),
26 /* between NM SAPs */
27 BVC_BLOCK ('20'H),
28 BVC_BLOCK_ACK ('21'H),
29 BVC_RESET ('22'H),
30 BVC_RESET_ACK ('23'H),
31 BVC_UNBLOCK ('24'H),
32 BVC_UNBLOCK_ACK ('25'H),
33 FLOW_CONTROL_BVC ('26'H),
34 FLOW_CONTROL_BVC_ACK ('27'H),
35 FLOW_CONTROL_MS ('28'H),
36 FLOW_CONTROL_MS_ACK ('29'H),
37 FLUSH_LL ('2A'H),
38 FLUSH_LL_ACK ('2B'H),
39 LLC_DISCARDED ('2C'H),
40 FLOW_CONTROL_PFC ('2D'H),
41 FLOW_CONTROL_PFC_ACK ('2E'H),
42 SGSN_INVOKE_TRACE ('40'H),
43 STATUS ('41'H)
44 /* between PFM SAPs : TODO */
45 /* between LCS SAPs : TODO */
46 /* between RIM SAPs : TODO */
47 /* between MBMS SAPs : TODO */
48 } with { variant "FIELDLENGTH(8)" };
49
50 type enumerated BssgpIEI {
51 ALIGNMENT_OCTETS ('00'H),
52 BMAX_DEFAULT_MS ('01'H),
53 BSS_AREA_INDICATION ('02'H),
54 BUCKET_LEAK_RATE ('03'H),
55 BVCI ('04'H),
56 BVC_BUCKET_SIZE ('05'H),
57 BVC_MEASUREMENT ('06'H),
58 CAUSE ('07'H),
59 CELL_ID ('08'H),
60 CHENNEL_NEEDED ('09'H),
61 DRX_PARAMETERS ('0A'H),
62 EMLPP_PRIORITY ('0B'H),
63 FLUSH_ACTION ('0C'H),
64 IMSI ('0D'H),
65 LLC_PDU ('0E'H),
66 LLC_FRAMES_DISCARDED ('0F'H),
67 LOCATION_AREA ('10'H),
68 MOBILE_IDENTITY ('11'H),
69 MS_BUCKET_SIZE ('12'H),
70 MS_RADIO_ACCESS_CAPABILITY ('13'H),
71 OMC_ID ('14'H),
72 PDU_IN_ERROR ('15'H),
73 PDU_LIFETIME ('16'H),
74 PRIORITY ('17'H),
75 QOS_PROFILE ('18'H),
76 RADIO_CAUSE ('19'H),
77 RA_CAP_UPD_CAUSE ('1A'H),
78 ROUTEING_AREA ('1B'H),
79 R_DEFAULT_MS ('1C'H),
80 SUSPE_DN_REFERENCE_NR ('1D'H),
81 TAG ('1E'H),
82 TLLI ('1F'H),
83 TMSI ('20'H),
84 TRACE_REFERENCE ('21'H),
85 TRACE_TYPE ('22'H),
86 TRANSACTION_ID ('23'H),
87 TRIGGER_ID ('24'H),
88 NUMBER_OF_OCTETS_AFFECTED ('25'H),
89 LSA_IDENTIFIER_LIST ('26'H),
90 LSA_INFORMATION ('27'H),
91 PACKET_FLOW_IDENTIFIER ('28'H),
92 PACKET_FLOW_TIMER ('29'H),
93 AGGREGATE_BSS_QOS_PROFILE ('3a'H),
94 FEATURE_BITMAP ('3b'H),
95 BUCKET_FILL_RATIO ('3c'H),
96 SERVICE_UTRAN_CCO ('3d'H),
97 NSEI ('3e'H),
98 RRLP_APDU ('3f'H),
99 LCS_QOS ('40'H),
100 LCS_CLIENT_TYPE ('41'H),
101 REQUESTED_GPS_ASSIST_DATA ('42'H),
102 LOCATION_TYPE ('43'H),
103 LOCATION_ESTIMATE ('44'H),
104 POSITIONING_DATA ('45'H),
105 DECIPHERING_KEYS ('46'H),
106 LCS_PRIORITY ('47'H),
107 LCS_CAUSE ('48'H),
108 LCS_CAPABILITY ('49'H),
109 RRLP_FLAGS ('4a'H),
110 RIM_APPLICATION_IDENTITY ('4b'H),
111 RIM_SEQUENCE_NUMBER ('4c'H),
112 RAN_INFO_REUEST_AC ('4d'H),
113 RAN_INFO_AC ('4e'H),
114 RIM_PDU_INDICATIONS ('4f'H),
115 PFC_FLOC_CONTROL_PARAMETERS ('52'H),
116 GLOBAL_CN_ID ('53'H),
117 RIM_ROUTING_INFORMATION ('54'H),
118 RIM_PROTOCOL_VERSION_NUMBER ('55'H),
119 APP_ERROR_CONTAINER ('56'H),
120 /* FIXME */
121 EXTENDED_FEATURE_BITMAP ('69'H)
122 } with { variant "FIELDLENGTH(8)" };
123
Harald Welte039f6952017-07-23 16:18:16 +0200124 type enumerated BssgpCause {
125 BSSGP_CAUSE_PROC_OVERLOAD ('00'H),
126 BSSGP_CAUSE_EQUIMENT_FAILURE ('01'H),
127 BSSGP_CAUSE_TRANSIT_NETWORK_FAILURE ('02'H),
128 BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS ('03'H),
129 BSSGP_CAUSE_UNKNOWN_MS ('04'H),
130 BSSGP_CAUSE_BVCI_UNKNOWN ('05'H),
131 BSSGP_CAUSE_CELL_TRAFFIC_CONGESTION ('06'H),
132 BSSGP_CAUSE_SGSN_CONGESTION ('07'H),
133 BSSGP_CAUSE_OM_INTERVENTION ('08'H),
134 BSSGP_CAUSE_BVCI_BLOCKED ('09'H),
135 BSSGP_CAUSE_PFC_CREATE_FAILURE ('0a'H),
136 BSSGP_CAUSE_PFC_PREEMPTED ('0b'H),
137 BSSGP_CAUSE_ABQP_NO_MORE_SUPPORTED ('0c'H),
138 BSSGP_CAUSE_SEMANTICALLY_INCORRECT_PDU ('20'H),
139 BSSGP_CAUSE_INVALID_MANDATORY_IE ('21'H),
140 BSSGP_CAUSE_MISSING_MANDATORY_IE ('22'H),
141 BSSGP_CAUSE_MISSING_CONDITIONAL_IE ('23'H),
142 BSSGP_CAUSE_UNEXPECTED_CONDITIONAL_IE ('24'H),
143 BSSGP_CAUSE_CONDITIONAL_IE_ERROR ('25'H),
144 BSSGP_CAUSE_PDU_NOT_COMPATIBLE_WITH_PROTOCOL_STATE ('26'H),
145 BSSGP_CAUSE_PROTOCOL_ERROR_UNSPECIFIED ('27'H),
146 BSSGP_CAUSE_PDU_NOT_COMPATIBLE_WITH_FEATURE_SET ('28'H),
147 BSSGP_CAUSE_REQUESTED_INFO_NOT_AVAILABLE ('29'H),
148 BSSGP_CAUSE_UNKNOWN_DESTINATION_ADDRESS ('2a'H),
149 BSSGP_CAUSE_UNKNOWN_RIM_APP_IDENTITY ('2b'H),
150 BSSGP_CAUSE_INVALID_CONTAINER_UNIT_INFO ('2c'H),
151 BSSGP_CAUSE_PFC_QUEUING ('2d'H),
152 BSSGP_CAUSE_PFC_CREATED_SUCCESSFULLY ('2e'H),
153 BSSGP_CAUSE_T12_EXPIRY ('2f'H),
154 BSSGP_CAUSE_MS_UNDER_PS_HANDOVER_TREATMENT ('30'H),
155 BSSGP_CAUSE_UPLINK_QUALITY ('31'H),
156 BSSGP_CAUSE_UPLINK_STRENGTH ('32'H),
157 BSSGP_CAUSE_DOWNLINK_QUALITY ('33'H),
158 BSSGP_CAUSE_DOWNLINK_STRENGTH ('34'H),
159 BSSGP_CAUSE_DISTANCE ('35'H),
160 BSSGP_CAUSE_BETTER_CELL ('36'H),
161 BSSGP_CAUSE_TRAFFIC ('37'H),
162 BSSGP_CAUSE_OM_INTERVENTION2 ('38'H),
163 BSSGP_CAUSE_MS_BACK_ON_OLD_CHANNEL ('39'H),
164 BSSGP_CAUSE_T13_EXPIRY ('3a'H),
165 BSSGP_CAUSE_T14_EXPIRY ('3b'H),
166 BSSGP_CAUSE_NOT_ALL_REQUESTED_PFC_CREATED ('3c'H)
167 } with { variant "FIELDLENGTH(8)" };
168
Harald Welte3a194402017-07-22 17:07:51 +0200169 /* 11.3.28 */
170 type record BssgpQosProfile {
171 uint16_t r,
172 BIT2 spare,
173 boolean c_r,
174 boolean t,
175 boolean a,
176 uint3_t precedence
177 } with { variant (c_r) "FIELDLENGTH(1)"
178 variant (t) "FIELDLENGTH(1)"
179 variant (a) "FIELDLENGTH(1)"
180 };
181
182 /* 11.3.84 */
183 type record BssgpFeatureBitmap {
184 boolean mbms,
185 boolean enh_radio_status,
186 boolean pfc_fc,
187 boolean rim,
188 boolean lcs,
189 boolean inr,
190 boolean cbl,
191 boolean pfc
192 } with { variant "" };
193
194 /* 11.3.47 */
195 type record BssgpServiceUtranCco {
196 uint5_t spare,
197 uint3_t value_part
198 } with { variant "" };
199
200 /* 11.3.84 */
201 type record BssgpExtendedFeatureBitmap {
202 BIT7 spare,
203 BIT1 ps_handover
204 } with { variant "" };
205
206 type uint16_t BssgpPduLifetime;
207
208 /* TS 48.008 3.2.2.18 */
209 type record BssmapPriority {
210 BIT1 spare,
211 boolean pci,
212 uint4_t level,
213 boolean qa,
214 boolean pvi
215 } with { variant "" };
216
217 type BssmapPriority BssgpPriority;
218
219 type uint32_t BssgpTlli;
220
221 type uint16_t BssgpBvci;
Harald Welte3a194402017-07-22 17:07:51 +0200222
223 type record BssgpCellId {
224 RoutingAreaIdentification ra_id,
225 CellIdentity cell_id
226 } with { variant "" };
227
228 type union BssgpIeUnion {
229 uint16_t bmax_default_ms, /* 11.3.2 */
230 uint16_t bucket_leak_rate, /* 11.3.4 */
231 uint16_t bvc_bucket_size, /* 11.3.5 */
232 BssgpBvci bvci, /* 11.3.6 */
233 uint16_t bvc_measurement, /* 11.3.7 */
234 BssgpCause cause, /* 11.3.8 */
235 BssgpCellId cell_id, /* 11.3.9 */
236 DrxParameter drx_parameter, /* 11.3.11 */
Harald Welte958700a2017-07-30 00:52:39 +0200237 MobileIdentity imsi, /* 11.3.14 */
Harald Welte3a194402017-07-22 17:07:51 +0200238 LocationAreaIdentification lai, /* 11.3.17 */
239 MobileIdentity mobile_id, /* 11.3.20 */
240 BssgpPduLifetime pdu_lifetime, /* 11.3.25 */
241 BssgpPriority priority, /* 11.3.27 */
242 BssgpQosProfile qos_profile, /* 11.3.28 */
243 BssgpTlli tlli, /* 11.3.25 */
244 uint16_t r_default_ms, /* 11.3.32 */
Harald Welte958700a2017-07-30 00:52:39 +0200245 GsmTmsi tmsi, /* 11.3.36 */
Harald Welte3a194402017-07-22 17:07:51 +0200246 BssgpServiceUtranCco svc_utran_cco, /* 11.3.47 */
247 BssgpFeatureBitmap feature_bitmap, /* 11.3.40 */
248 BssgpExtendedFeatureBitmap ext_feature_bitmap, /* 11.3.84 */
249 octetstring other
250 };
251
252 type record BssgpTLV {
253 BssgpIEI iei,
254 /* we cannot express a variable-length "length" field with extension octets in the TTCN-3
255 * syntax, so we simply assume a plain 16 bit length value here and have a 'pseudl-BSSGP'
256 * translator in front which explands all variable-length "length" fields to 16bits */
257 uint16_t len,
258 BssgpIeUnion u
259 } with {
260 variant (u) "CROSSTAG(
261 bmax_default_ms, iei = BMAX_DEFAULT_MS;
262 bucket_leak_rate, iei = BUCKET_LEAK_RATE;
263 bvc_bucket_size, iei = BVC_BUCKET_SIZE;
264 bvci, iei = BVCI;
265 bvc_measurement, iei = BVC_MEASUREMENT;
266 cause, iei = CAUSE;
267 cell_id, iei = CELL_ID;
268 drx_parameter, iei = DRX_PARAMETERS;
Harald Welte958700a2017-07-30 00:52:39 +0200269 imsi, iei = IMSI;
Harald Welte3a194402017-07-22 17:07:51 +0200270 lai, iei = LOCATION_AREA;
271 priority, iei = PRIORITY;
272 mobile_id, iei = MOBILE_IDENTITY;
273 pdu_lifetime, iei = PDU_LIFETIME;
274 qos_profile, iei = QOS_PROFILE;
275 tlli, iei = TLLI;
276 r_default_ms, iei = R_DEFAULT_MS;
Harald Welte958700a2017-07-30 00:52:39 +0200277 tmsi, iei = TMSI;
Harald Welte3a194402017-07-22 17:07:51 +0200278 svc_utran_cco, iei = SERVICE_UTRAN_CCO;
279 feature_bitmap, iei = FEATURE_BITMAP;
280 ext_feature_bitmap, iei = EXTENDED_FEATURE_BITMAP;
281 other, OTHERWISE)"
282 variant (len) "LENGTHTO(u)"
283 };
284
Harald Welte13d391e2017-07-23 19:52:33 +0200285 external function enc_BssgpTLV(in BssgpTLV pdu) return octetstring
286 with { extension "prototype(convert) encode(RAW)" };
287 external function dec_BssgpTLV(in octetstring stream) return BssgpTLV
288 with { extension "prototype(convert) decode(RAW)" };
289
290
Harald Welte3a194402017-07-22 17:07:51 +0200291 type record of BssgpTLV BssgpTLVs;
292
293 /* 10.2.1 */
294 type record BssgpDlUnitdata {
295 BssgpTlli tlli,
296 BssgpQosProfile qos_profile,
297 BssgpTLV pdu_lifetime,
298 /* optional parts */
299 BssgpTLVs tlvs
300 } with { variant "" };
301
302 /* 10.2.2 */
303 type record BssgpUlUnitdata {
304 BssgpTlli tlli,
305 BssgpQosProfile qos_profile,
306 BssgpTLV cell_id,
307 /* optional parts */
308 BssgpTLVs tlvs
309 } with { variant "" };
310
311 type record BssgpNormalPdu {
312 BssgpTLVs tlvs optional
313 } with { variant "" };
314
315 type union BssgpPduUnion {
316 BssgpDlUnitdata dl_unitdata,
317 BssgpUlUnitdata ul_unitdata,
318 BssgpNormalPdu other
319 };
320
321 type record BssgpPdu {
322 BssgpPduType pdu_type,
323 BssgpPduUnion u
324 } with {
325 variant (u) "CROSSTAG(
326 dl_unitdata, pdu_type = DL_UNITDATA;
327 ul_unitdata, pdu_type = UL_UNITDATA;
328 other, OTHERWISE)"
329 }
330
Harald Welte1067fbd2017-07-23 16:18:46 +0200331 external function enc_BssgpPdu(in BssgpPdu pdu) return octetstring
332 with { extension "prototype(convert) encode(RAW)" };
Harald Welte3a194402017-07-22 17:07:51 +0200333 external function dec_BssgpPdu(in octetstring stream) return BssgpPdu
334 with { extension "prototype(convert) decode(RAW)" };
335
Harald Welte1067fbd2017-07-23 16:18:46 +0200336 template BssgpPdu t_BSSGP_other(template BssgpPduType pdu_type, template BssgpTLVs tlvs) := {
337 pdu_type := pdu_type,
338 u := {
339 other := {
340 tlvs := tlvs
341 }
342 }
343 }
344
345 template BssgpTLV t_BSSGP_IE_Cause(template BssgpCause cause) := {
346 iei := CAUSE,
347 len := 1,
348 u := { cause := cause }
349 }
350
351 template BssgpTLV t_BSSGP_IE_Bvci(template BssgpBvci bvci) := {
352 iei := BVCI,
353 len := 2,
354 u := { bvci := bvci }
355 }
356
Harald Welte13d391e2017-07-23 19:52:33 +0200357 template BssgpTLV t_BSSGP_IE_CellId(template BssgpCellId cid) := {
358 iei := CELL_ID,
359 len := 8,
360 u := { cell_id := cid }
361 }
362
Harald Welte958700a2017-07-30 00:52:39 +0200363 template BssgpTLV t_BSSGP_IE_Lifetime(uint16_t time) := {
364 iei := PDU_LIFETIME,
365 len := 2,
366 u := { pdu_lifetime := time }
367 }
368
369 template BssgpTLV t_BSSGP_IE_Tmsi(template GsmTmsi tmsi) := {
370 iei := TMSI,
371 len := 4,
372 u := { tmsi := tmsi }
373 }
374
375 template BssgpTLV t_BSSGP_IE_Imsi(template hexstring imsi) := {
376 iei := IMSI,
377 len := 4,
378 u := {
379 imsi := {
380 imsi := {
381 mi_type := MI_TYPE_IMSI,
382 odd := true, /* IMSI has 15 digits */
383 digits := imsi
384 }
385 }
386 }
387 }
388
389 template BssgpTLV t_BSSGP_IE_Qos(BssgpQosProfile qos) := {
390 iei := QOS_PROFILE,
391 len := 0,
392 u := {
393 qos_profile := qos
394 }
395 }
Harald Welte13d391e2017-07-23 19:52:33 +0200396
Harald Welte1067fbd2017-07-23 16:18:46 +0200397 template BssgpTLV t_BssgpIE(template BssgpIEI iei, template BssgpIeUnion u) := {
398 iei := iei,
Harald Welte77bab252017-07-30 00:53:08 +0200399 len := 0,
Harald Welte1067fbd2017-07-23 16:18:46 +0200400 u := u
401 }
402
403 template BssgpTLV t_BSSGP_IE_PDU(BssgpPdu pdu) :=
404 t_BssgpIE(PDU_IN_ERROR, { other := f_BSSGP_compact_len(enc_BssgpPdu(pdu)) });
Harald Welte1067fbd2017-07-23 16:18:46 +0200405
406 template BssgpPdu t_BVC_RESET(template BssgpCause cause, template BssgpBvci bvci, template BssgpCellId cell_id) :=
Harald Welte0667eb12017-07-23 17:25:38 +0200407 t_BSSGP_other(BVC_RESET, { t_BSSGP_IE_Bvci(bvci), t_BSSGP_IE_Cause(cause), t_BSSGP_IE_CellId(cell_id) });
Harald Welte1067fbd2017-07-23 16:18:46 +0200408 template BssgpPdu t_BVC_RESET_ACK(template BssgpBvci bvci, template BssgpCellId cell_id) :=
409 t_BSSGP_other(BVC_RESET_ACK, { t_BSSGP_IE_Bvci(bvci), t_BSSGP_IE_CellId(cell_id) });
410
411 template BssgpPdu t_BVC_UNBLOCK(template BssgpBvci bvci) := t_BSSGP_other(BVC_UNBLOCK, { t_BSSGP_IE_Bvci(bvci) });
412 template BssgpPdu t_BVC_UNBLOCK_ACK(template BssgpBvci bvci) := t_BSSGP_other(BVC_UNBLOCK_ACK, { t_BSSGP_IE_Bvci(bvci) });
413
414 template BssgpPdu t_BVC_BLOCK(template BssgpBvci bvci, template BssgpCause cause) :=
415 t_BSSGP_other(BVC_BLOCK, { t_BSSGP_IE_Bvci(bvci), t_BSSGP_IE_Cause(cause) });
416 template BssgpPdu t_BVC_BLOCK_ACK(template BssgpBvci bvci) := t_BSSGP_other(BVC_BLOCK_ACK, { t_BSSGP_IE_Bvci(bvci) });
417
Harald Welte13d391e2017-07-23 19:52:33 +0200418
419 template BssgpPdu tr_BSSGP_type(template BssgpPduType pdu_type, template BssgpPduUnion u := ?) := {
Harald Welte1067fbd2017-07-23 16:18:46 +0200420 pdu_type := pdu_type,
Harald Welte13d391e2017-07-23 19:52:33 +0200421 u := u
Harald Welte1067fbd2017-07-23 16:18:46 +0200422 }
423
Harald Welte13d391e2017-07-23 19:52:33 +0200424 template BssgpPdu t_BVC_FC_BVC := t_BSSGP_other(FLOW_CONTROL_BVC, ?);
425 template BssgpPdu t_BVC_FC_BVC_ACK := t_BSSGP_other(FLOW_CONTROL_BVC_ACK, {});
426 template BssgpPdu t_BVC_FC_MS := t_BSSGP_other(FLOW_CONTROL_MS, ?);
427 template BssgpPdu t_BVC_FC_MS_ACK := t_BSSGP_other(FLOW_CONTROL_MS_ACK, {});
Harald Welte1067fbd2017-07-23 16:18:46 +0200428
429 template BssgpPdu t_BSSGP_STATUS(template BssgpTLVs tlvs) := t_BSSGP_other(STATUS, tlvs);
430
Harald Welte3a194402017-07-22 17:07:51 +0200431} with { encode "RAW" };