summaryrefslogtreecommitdiffstats
path: root/library/BSSMAP_LE_Templates.ttcn
blob: 3619a3aa94119d6270d84efb869532c89c74bdc1 (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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
module BSSMAP_LE_Templates {

/* BSSMAP-LE Templates, building on top of BSSAP_LE_Types.
 *
 * (C) 2017-2020 by Harald Welte <laforge@gnumonks.org>
 * contributions by sysmocom - s.f.m.c. GmbH
 * 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
 */

import from General_Types all;
import from Osmocom_Types all;
import from GSM_Types all;
import from BSSAP_Types all;
import from BSSAP_LE_Types all;
import from BSSMAP_Templates all;
import from L3_Templates all;

function ts_BSSMAP_LE_LcsCause(template (omit) BSSMAP_LE_LcsCause cause)
return template (omit) BSSMAP_LE_IE_LcsCause {
	if (istemplatekind(cause, "omit")) {
		return omit;
	}
	var template (omit) BSSMAP_LE_IE_LcsCause ie := {
		iei := BSSMAP_LE_IEI_LCS_CAUSE,
		len := 1,
		cause := cause,
		diag_val := omit
	}
	return ie;
}
function tr_BSSMAP_LE_LcsCause(template BSSMAP_LE_LcsCause cause)
return template BSSMAP_LE_IE_LcsCause {
	if (istemplatekind(cause, "omit")) {
		return omit;
	}
	var template BSSMAP_LE_IE_LcsCause ie := {
		iei := BSSMAP_LE_IEI_LCS_CAUSE,
		len := ?,
		cause := cause,
		diag_val := *
	}
	return ie;
}


function ts_BSSMAP_LE_GeographicLoc(template (omit) octetstring loc)
return template (omit) BSSMAP_LE_IE_GeographicLoc {
	if (istemplatekind(loc, "omit")) {
		return omit;
	}
	var template (omit) BSSMAP_LE_IE_GeographicLoc ie := {
		iei := BSSMAP_LE_IEI_GEO_LOCATION,
		len := 0,
		location := loc
	}
	return ie;
}
function tr_BSSMAP_LE_GeographicLoc(template octetstring loc)
return template BSSMAP_LE_IE_GeographicLoc {
	if (istemplatekind(loc, "omit")) {
		return omit;
	}
	var template BSSMAP_LE_IE_GeographicLoc ie := {
		iei := BSSMAP_LE_IEI_GEO_LOCATION,
		len := ?,
		location := loc
	}
	return ie;
}




template (value) PDU_BSSAP_LE ts_BSSAP_LE_BSSMAP := {
	discriminator := '0'B,
	spare := '0000000'B,
	dlci := omit,
	lengthIndicator := 0,	/* overwritten by codec */
	pdu := {
		bssmap := -
	}
}

template (present) PDU_BSSAP_LE tr_BSSAP_LE_BSSMAP := {
	discriminator := '0'B,
	spare := '0000000'B,
	dlci := *,
	lengthIndicator := ?,
	pdu := {
		bssmap := ?
	}
}

template (value) PDU_BSSAP_LE ts_BSSAP_LE_DTAP(octetstring dtap, template (value) OCT1 dlci) := {
	discriminator := '1'B,
	spare := '0000000'B,
	dlci := dlci,
	lengthIndicator := 0,	/* overwritten by codec */
	pdu := {
		dtap := dtap
	}
}

template (present) PDU_BSSAP_LE tr_BSSAP_LE_DTAP := {
	discriminator := '1'B,
	spare := '0000000'B,
	dlci := *,
	lengthIndicator := ?,
	pdu := {
		dtap := ?
	}
}

function ts_BSSMAP_LE_IMSI(template (omit) hexstring imsi) return template (omit) BSSMAP_LE_IE_IMSI {
	if (istemplatekind(imsi, "omit")) {
		return omit;
	}
	template (value) BSSMAP_LE_IE_IMSI res := {
		iei := BSSMAP_LE_IEI_IMSI,
		len := 0,
		imsi := ts_MI_IMSI(valueof(imsi))
	};
	return res;
}
function tr_BSSMAP_LE_IMSI(template hexstring imsi) return template BSSMAP_LE_IE_IMSI {
	if (istemplatekind(imsi, "omit")) {
		return omit;
	}
	template BSSMAP_LE_IE_IMSI res := {
		iei := BSSMAP_LE_IEI_IMSI,
		len := ?,
		imsi := tr_MI_IMSI(imsi)
	};
	return res;
}

template (value) BSSMAP_LE_IE_LocationType ts_BSSMAP_LE_LocType(template (value) BSSMAP_LE_LocInfo li,
								template (omit) BSSMAP_LE_PosMethod pm := omit) := {
	iei := BSSMAP_LE_IEI_LOCATION_TYPE,
	len := 0,
	loc_info := li,
	pos_method := pm
}
template (present) BSSMAP_LE_IE_LocationType tr_BSSMAP_LE_LocType(template (present) BSSMAP_LE_LocInfo li,
								  template BSSMAP_LE_PosMethod pm := omit) := {
	iei := BSSMAP_LE_IEI_LOCATION_TYPE,
	len := ?,
	loc_info := li,
	pos_method := pm
}


/* Section 9.1 */
template (value) PDU_BSSAP_LE ts_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LocInfo loc_info := BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC,
						      template (value) BSSMAP_IE_CellIdentifier cell_id,
						      template (omit) hexstring imsi,
						      template (omit) octetstring bsslap_apdu := omit)

modifies ts_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			perf_loc_req := {
				msg_type := BSSMAP_LE_PERFORM_LOC_REQ,
				location_type := ts_BSSMAP_LE_LocType(loc_info),
				cell_id := cell_id,
				cm3 := omit,
				lcs_client_type := omit,
				chosen_channel := omit,
				lcs_priority := omit,
				lcs_qos := omit,
				req_gps_ass_d := omit,
				bsslap_apdu := ts_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, bsslap_apdu),
				lcs_capability := omit,
				packet_meas_rep := omit,
				meas_cell_id_list := omit,
				imsi := ts_BSSMAP_LE_IMSI(imsi),
				imei := omit
			}
		}
	}
}
template (present) PDU_BSSAP_LE tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LocInfo loc_info := BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC,
							template (present) BSSMAP_IE_CellIdentifier cell_id,
							template hexstring imsi)
modifies tr_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			perf_loc_req := {
				msg_type := BSSMAP_LE_PERFORM_LOC_REQ,
				location_type := tr_BSSMAP_LE_LocType(loc_info),
				cell_id := cell_id,
				cm3 := *,
				lcs_client_type := *,
				chosen_channel := *,
				lcs_priority := *,
				lcs_qos := *,
				req_gps_ass_d := *,
				bsslap_apdu := *,
				lcs_capability := *,
				packet_meas_rep := *,
				meas_cell_id_list := *,
				imsi := tr_BSSMAP_LE_IMSI(imsi),
				imei := *
			}
		}
	}
}


/* Section 9.2 */
template (value) PDU_BSSAP_LE ts_BSSMAP_LE_PerfLocResp(template (omit) octetstring geo_loc,
						       template (omit) BSSMAP_LE_LcsCause cause)

modifies ts_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			perf_loc_resp := {
				msg_type := BSSMAP_LE_PERFORM_LOC_RESP,
				geographic_loc := ts_BSSMAP_LE_GeographicLoc(geo_loc),
				pos_data := omit,
				deciph_keys := omit,
				lcs_cause := ts_BSSMAP_LE_LcsCause(cause),
				velocity_data := omit,
				ganss_pos_data := omit
			}
		}
	}
}
template (present) PDU_BSSAP_LE tr_BSSMAP_LE_PerfLocResp(template octetstring geo_loc,
							 template BSSMAP_LE_LcsCause cause)
modifies tr_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			perf_loc_resp := {
				msg_type := BSSMAP_LE_PERFORM_LOC_RESP,
				geographic_loc := tr_BSSMAP_LE_GeographicLoc(geo_loc),
				pos_data := *,
				deciph_keys := *,
				lcs_cause := tr_BSSMAP_LE_LcsCause(cause),
				velocity_data := *,
				ganss_pos_data := *
			}
		}
	}
}


/* Section 9.8 */
template (value) PDU_BSSAP_LE ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_ProtocolId prot_id, octetstring data,
						    template (omit) BSSMAP_LE_IE_Segmentation segm := omit)
modifies ts_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			co_info := {
				msg_type := BSSMAP_LE_CONN_ORIENTED_INFO,
				bsslap_apdu := {
					iei := BSSMAP_LE_IEI_APDU,
					len := 0,
					protocol_id := prot_id,
					spare := '0'B,
					data := data
				},
				segmentation := segm
			}
		}
	}
}
template (present) PDU_BSSAP_LE tr_BSSMAP_LE_ConnInfo(template (present) BSSMAP_LE_ProtocolId prot_id,
						      template (present) octetstring data,
						      template BSSMAP_LE_IE_Segmentation segm := omit)
modifies tr_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			co_info := {
				msg_type := BSSMAP_LE_CONN_ORIENTED_INFO,
				bsslap_apdu := {
					iei := BSSMAP_LE_IEI_APDU,
					len := ?,
					protocol_id := prot_id,
					spare := '0'B,
					data := data
				},
				segmentation := segm
			}
		}
	}
}

template (value) PDU_BSSAP_LE ts_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LcsCause cause)
modifies ts_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			perf_loc_abort := {
				msg_type := BSSMAP_LE_PERFORM_LOC_ABORT,
				lcs_cause := ts_BSSMAP_LE_LcsCause(cause)
			}
		}
	}
}

template (present) PDU_BSSAP_LE tr_BSSMAP_LE_PerfLocAbort(template BSSMAP_LE_LcsCause cause)
modifies tr_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			perf_loc_abort := {
				msg_type := BSSMAP_LE_PERFORM_LOC_ABORT,
				lcs_cause := tr_BSSMAP_LE_LcsCause(cause)
			}
		}
	}
}

/* Section 9.10 */
template (value) PDU_BSSAP_LE ts_BSSMAP_LE_Reset(myBSSMAP_Cause cause) modifies ts_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			reset := {
				msg_type := BSSMAP_LE_RESET,
				cause := ts_BSSMAP_IE_Cause(enum2int(cause))
			}
		}
	}
}
template (present) PDU_BSSAP_LE tr_BSSMAP_LE_Reset modifies tr_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			reset := {
				msg_type := BSSMAP_LE_RESET,
				cause := ?
			}
		}
	}
}

/* Section 9.11 */
template (value) PDU_BSSAP_LE ts_BSSMAP_LE_ResetAck modifies ts_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			reset_ack := {
				msg_type := BSSMAP_LE_RESET_ACK
			}
		}
	}
}
template (present) PDU_BSSAP_LE tr_BSSMAP_LE_ResetAck modifies tr_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			reset_ack := {
				msg_type := BSSMAP_LE_RESET_ACK
			}
		}
	}
}

function ts_BSSMAP_LE_APDU(BSSMAP_LE_ProtocolId prot_id, template (omit) octetstring data)
return template (omit) BSSMAP_LE_IE_APDU {
	var BSSMAP_LE_IE_APDU ie := {
		iei := BSSMAP_LE_IEI_APDU,
		len := 0, // overwritten
		protocol_id := prot_id,
		spare := '0'B
	}
	if (istemplatekind(data, "omit")) {
		return omit;
	}
	ie.data := valueof(data);
	return ie;
}

function tr_BSSMAP_LE_APDU(template BSSMAP_LE_ProtocolId prot_id, template octetstring data)
return template BSSMAP_LE_IE_APDU {
	var template BSSMAP_LE_IE_APDU ie := {
		iei := BSSMAP_LE_IEI_APDU,
		len := ?,
		protocol_id := prot_id,
		spare := '0'B
	}
	if (istemplatekind(data, "omit")) {
		return omit;
	} else if (istemplatekind(data, "*")) {
		return *;
	}
	ie.data := data;
	return ie;
}


/* Section 9.12 */
template (value) PDU_BSSAP_LE ts_BSSMAP_LE_PerformLocInfo(BSSMAP_IE_CellIdentifier cell_id,
							  BSSMAP_LE_ProtocolId prot_id,
							  template (omit) octetstring data)
modifies ts_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			perf_loc_info := {
				msg_type := BSSMAP_LE_PERFORM_LOC_INFO,
				cell_id := cell_id,
				bsslap_apdu := ts_BSSMAP_LE_APDU(prot_id, data)
			}
		}
	}
}
template (present) PDU_BSSAP_LE tr_BSSMAP_LE_PerformLocInfo(template (present) BSSMAP_IE_CellIdentifier cell_id,
							    template BSSMAP_LE_ProtocolId prot_id,
							    template octetstring data)
modifies tr_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			perf_loc_info := {
				msg_type := BSSMAP_LE_PERFORM_LOC_INFO,
				cell_id := cell_id,
				bsslap_apdu := tr_BSSMAP_LE_APDU(prot_id, data)
			}
		}
	}
}

/* return Layer3 octetstring inside BSSAP-LE PDU */
function f_bssap_le_extract_l3(PDU_BSSAP_LE bssap) return template octetstring {
	if (ischosen(bssap.pdu.bssmap)) {
		return omit;
	} else {
		return bssap.pdu.dtap;
	}
}


template PDU_BSSAP_LE tr_BSSMAP_LE_Paging(template hexstring imsi_digits := ?,
					template OCT4 tmsi := *,
					template BSSMAP_IE_ChannelNeeded chneed := *)
modifies tr_BSSAP_LE_BSSMAP := {
	pdu := {
		bssmap := {
			paging := {
				messageType := '52'O,
				iMSI := tr_BSSMAP_Imsi(imsi_digits),
				tMSI := tr_BSSMAP_IE_TMSI(tmsi) ifpresent,
				cellIdentifierList := ?,
				channelNeeded := chneed,
				eMLPP_Priority := omit,
				pagingInformation := omit /* only VGCS/VBS flag */
			}
		}
	}
}




} with { encode "RAW" };