blob: 049614adf47d522690210be257b552be851bcb14 [file] [log] [blame]
Harald Welte34b5a952019-05-27 11:54:11 +02001/* GTP Templates in TTCN-3
2 * (C) 2018 Harald Welte <laforge@gnumonks.org>
3 * contributions by sysmocom - s.f.m.c. GmbH
4 * All rights reserved.
5 *
6 * Released under the terms of GNU General Public License, Version 2 or
7 * (at your option) any later version.
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
Harald Weltec69cf4e2018-02-17 20:57:02 +010012module GTP_Templates {
13
14 import from General_Types all;
15 import from Osmocom_Types all;
16 import from GTPC_Types all;
17 import from GTPU_Types all;
18 import from GTP_CodecPort all;
19 import from IPCP_Types all;
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +010020 import from GSM_Types all; // RoutingAreaIdentification, CellIdentity
21
22 type record GTP_CellId {
23 RoutingAreaIdentification ra_id,
24 CellIdentity cell_id
25 } with { encode "RAW" };
26
27 template (value) GTP_CellId ts_GTP_CellId(template (value) RoutingAreaIdentification rai, CellIdentity cell_id) := {
28 ra_id := rai,
29 cell_id := cell_id
30 };
Harald Weltec69cf4e2018-02-17 20:57:02 +010031
Harald Welte3b4c3562018-03-01 10:01:58 +010032 /* Table 38 of 3GPP TS 29.060 */
33 type enumerated GTP_Cause {
34 GTP_CAUSE_REQUEST_IMEI (1),
35 GTP_CAUSE_REQUEST_IMSI_AND_IMEI (2),
36 GTP_CAUSE_NO_IDENTITY_NEDED (3),
37 GTP_CAUSE_MS_REFUSES (4),
38 GTP_CAUSE_MS_IS_NOT_GPRS_RESPONDING (5),
39 /* reserved */
40 GTP_CAUSE_REQUEST_ACCEPTED (128)
41 /* FIXME */
42 };
43
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +020044 private function f_oct_or_wc(template integer inp, integer len) return template octetstring {
45 if (istemplatekind(inp, "omit")) {
46 return omit;
47 } else if (istemplatekind(inp, "*")) {
48 return *;
49 } else if (istemplatekind(inp, "?")) {
50 return ?;
51 }
52 return int2oct(valueof(inp), len);
53 }
54
55 private function f_hex_or_wc(template integer inp, integer len) return template hexstring {
56 if (istemplatekind(inp, "omit")) {
57 return omit;
58 } else if (istemplatekind(inp, "*")) {
59 return *;
60 } else if (istemplatekind(inp, "?")) {
61 return ?;
62 }
63 return int2hex(valueof(inp), len);
64 }
65
Harald Weltec69cf4e2018-02-17 20:57:02 +010066 /* generalized GTP-C receive template */
67 template PDU_GTPC tr_GTP1C_PDU(template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdu := ?) := {
68 /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
69 * error if this flag is set to '1'. */
70 pn_bit := '0'B,
71 /* Sequence number flag (S) shall be set to '1'. */
72 s_bit := '1'B,
73 e_bit := ?,
74 spare := ?,
75 /* Protocol Type flag (PT) shall be set to '1'.*/
76 pt := '1'B,
77 /* Version shall be set to decimal 1 ('001'). */
78 version := '001'B,
79 messageType := msg_type,
80 lengthf := ?,
81 teid := teid,
82 opt_part := *,
83 gtpc_pdu := pdu
84 }
85
86 /* generalized GTP-C send template */
87 template PDU_GTPC ts_GTP1C_PDU(OCT1 msg_type, OCT4 teid, GTPC_PDUs pdu, uint16_t seq_nr) := {
88 /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
89 * error if this flag is set to '1'. */
90 pn_bit := '0'B,
91 /* Sequence number flag (S) shall be set to '1'. */
92 s_bit := '1'B,
93 e_bit := '0'B,
94 spare := '0'B,
95 /* Protocol Type flag (PT) shall be set to '1'.*/
96 pt := '1'B,
97 /* Version shall be set to decimal 1 ('001'). */
98 version := '001'B,
99 messageType := msg_type,
100 lengthf := 0, /* we assume encoder overwrites this */
101 teid := teid,
102 opt_part := {
103 sequenceNumber := int2oct(seq_nr, 2),
104 npduNumber := '00'O,
105 nextExtHeader := '00'O,
106 gTPC_extensionHeader_List := omit
107 },
108 gtpc_pdu := pdu
109 }
110
111 /* recovery IE */
112 template Recovery_gtpc ts_Recovery(OCT1 restart_counter) := {
113 type_gtpc := '0E'O,
114 restartCounter := restart_counter
115 }
116
117 template Recovery_gtpc tr_Recovery(template OCT1 restart_counter) := {
118 type_gtpc := '0E'O,
119 restartCounter := restart_counter
120 }
121
122 /* template matching reception of GTP-C echo-request */
123 template Gtp1cUnitdata tr_GTPC_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdus := ?) := {
124 peer := peer,
125 gtpc := tr_GTP1C_PDU(msg_type, teid, pdus)
126 }
127
128 /* template matching reception of GTP-C echo-request */
129 template Gtp1cUnitdata tr_GTPC_PING(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoRequest, '00000000'O);
130
131 template GTPC_PDUs tr_EchoRespPDU(template OCT1 restart_counter) := {
132 echoResponse := {
133 recovery := tr_Recovery(restart_counter),
134 private_extension_gtpc := *
135 }
136 }
137
138 /* template matching reception of GTP-C echo-response */
139 template Gtp1cUnitdata tr_GTPC_PONG(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoResponse, '00000000'O, tr_EchoRespPDU(?));
140
141 template GTPC_PDUs ts_EchoRespPDU(OCT1 restart_counter) := {
142 echoResponse := {
143 recovery := ts_Recovery(restart_counter),
144 private_extension_gtpc := omit
145 }
146 }
147
148 /* master template for senidng a GTP-C echo response */
149 template Gtp1cUnitdata ts_GTPC_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
150 peer := peer,
151 gtpc := ts_GTP1C_PDU(echoResponse, '00000000'O, valueof(ts_EchoRespPDU(rest_ctr)), seq)
152 }
153
154 template GTPC_PDUs ts_EchoReqPDU := {
155 echoRequest := {
156 private_extension_gtpc := omit
157 }
158 }
159
160 /* master template for sending a GTP-C echo request */
161 template Gtp1cUnitdata ts_GTPC_PING(GtpPeer peer, uint16_t seq) := {
162 peer := peer,
163 gtpc := ts_GTP1C_PDU(echoRequest, '00000000'O, valueof(ts_EchoReqPDU), seq)
164 }
165
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100166 private function f_eua_ipv4_len(template OCT4 ip_addr) return template integer {
167 if (istemplatekind(ip_addr, "omit")) {
168 return 2;
169 } else if (istemplatekind(ip_addr, "*")) {
170 return ?;
171 } else if (istemplatekind(ip_addr, "?")) {
172 return 6;
173 }
174 return 6;
175 }
176
177 private function f_eua_ipv6_len(template OCT16 ip_addr) return template integer {
178 if (istemplatekind(ip_addr, "omit")) {
179 return 2;
180 } else if (istemplatekind(ip_addr, "*")) {
181 return ?;
182 } else if (istemplatekind(ip_addr, "?")) {
183 return 18;
184 }
185 return 18;
186 }
187
188 private function f_eua_ipv4v6_len(template OCT4 ip_addr4, template OCT16 ip_addr6) return template integer {
189 var integer len := 2;
190 if (istemplatekind(ip_addr4, "*") or
191 istemplatekind(ip_addr6, "*")) {
192 return ?;
193 }
194 if (not istemplatekind(ip_addr4, "omit")) {
195 len := len + 4;
196 }
197 if (not istemplatekind(ip_addr6, "omit")) {
198 len := len + 16;
199 }
200 return len;
201 }
202
Harald Weltec69cf4e2018-02-17 20:57:02 +0100203 template EndUserAddress t_EuaIPv4(template OCT4 ip_addr) := {
204 type_gtpc := '80'O,
205 endUserAddress := {
206 endUserAddressIPv4 := {
207 lengthf := 2,
208 pdp_typeorg := '0001'B,
209 spare := '1111'B,
210 pdp_typenum := '21'O,
211 ipv4_address := ip_addr
212 }
213 }
214 }
215 template EndUserAddress t_EuaIPv4Dyn := t_EuaIPv4(omit);
216 template EndUserAddress tr_EuaIPv4(template OCT4 ip_addr) modifies t_EuaIPv4 := {
217 endUserAddress := {
218 endUserAddressIPv4 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100219 lengthf := f_eua_ipv4_len(ip_addr)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100220 }
221 }
222 }
223
224 template EndUserAddress t_EuaIPv6(template OCT16 ip_addr) := {
225 type_gtpc := '80'O,
226 endUserAddress := {
227 endUserAddressIPv6 := {
228 lengthf := 2,
229 pdp_typeorg := '0001'B,
230 spare := '1111'B,
231 pdp_typenum := '57'O,
232 ipv6_address := ip_addr
233 }
234 }
235 }
236 template EndUserAddress t_EuaIPv6Dyn := t_EuaIPv6(omit);
237 template EndUserAddress tr_EuaIPv6(template OCT16 ip_addr) modifies t_EuaIPv6 := {
238 endUserAddress := {
239 endUserAddressIPv6 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100240 lengthf := f_eua_ipv6_len(ip_addr)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100241 }
242 }
243 }
244
Oliver Smithee6a0882019-03-08 11:05:46 +0100245 /* 3GPP TS 29.060 Figure 37A: End User Address Information Element for IPv4v6 (both static) */
246 template EndUserAddress t_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) := {
247 type_gtpc := '80'O,
248 endUserAddress := {
249 endUserAddressIPv4andIPv6 := {
250 lengthf := 2,
251 pdp_typeorg := '0001'B,
252 spare := '1111'B,
253 pdp_typenum := '8D'O,
254 ipv4_address := ip_addr4,
255 ipv6_address := ip_addr6
256 }
257 }
258 }
259 template EndUserAddress t_EuaIPv4Dynv6Dyn := t_EuaIPv4v6(omit, omit);
260 template EndUserAddress tr_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) modifies t_EuaIPv4v6 := {
261 endUserAddress := {
262 endUserAddressIPv4andIPv6 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100263 lengthf := f_eua_ipv4v6_len(ip_addr4, ip_addr6)
Oliver Smithee6a0882019-03-08 11:05:46 +0100264 }
265 }
266 }
267
Harald Weltec69cf4e2018-02-17 20:57:02 +0100268 template AccessPointName ts_APN(octetstring apn) := {
269 type_gtpc := '83'O,
270 lengthf := lengthof(apn),
271 apn_value := apn
272 }
273
274 template GSN_Address_GTPC ts_GsnAddr(octetstring ip_addr) := {
275 type_gtpc := '85'O,
276 lengthf := lengthof(ip_addr),
277 addressf := ip_addr
278 }
279
280 template MSISDN ts_Msisdn(octetstring msisdn) := {
281 type_gtpc := '86'O,
282 lengthf := lengthof(msisdn),
283 msisdn := msisdn
284 }
285
286 template QualityOfServiceProfile ts_QosDefault := {
287 type_gtpc := '87'O,
288 lengthf := 4,
289 allocRetensionPrio := '00'O,
290 qos_ProfileValue := {
291 reliabilityClass := '011'B,
292 delayClass := '001'B,
293 spare1 := '00'B,
294 precedenceClass := '010'B,
295 spare2 := '0'B,
296 peakThroughput := '1001'B,
297 meanThroughput := '11111'B,
298 spare3 := '000'B,
299 deliverErroneusSDU := omit,
300 deliveryOrder := omit,
301 trafficClass := omit,
302 maxSDUSize := omit,
303 maxBitrateUplink := omit,
304 maxBitrateDownlink := omit,
305 sduErrorRatio := omit,
306 residualBER := omit,
307 trafficHandlingPriority := omit,
308 transferDelay := omit,
309 guaranteedBitRateUplink := omit,
310 guaranteedBitRateDownlink := omit,
311 sourceStatisticsDescriptor := omit,
312 signallingIndication := omit,
313 spare4 := omit,
314 maxBitrateDownlinkExt := omit,
315 guaranteedBitRateDownlinkExt := omit,
316 maxBitrateUplinkExt := omit,
317 guaranteedBitRateUplinkExt := omit
318 }
319 }
320
321 template IMSI_gtpc ts_Imsi(hexstring digits) := {
322 type_gtpc := '02'O,
323 digits := digits,
324 padding := 'F'H
325 }
326
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100327 function f_ts_RATType(template (omit) OCT1 ratType := omit) return template (omit) RATType {
328 var template (omit) RATType rt;
329 if (istemplatekind(ratType, "omit")) {
330 rt := omit;
331 } else {
332 rt := {
333 type_gtpc := '97'O,
334 lengthf := 1,
335 ratTypeValue := ratType
336 };
337 }
338 return rt;
339 }
340
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100341 template (value) GeographicLocationCGI
342 ts_GeographicLocationCGI(template (value) hexstring mcc,
343 template (value) hexstring mnc,
344 template (value) OCT2 lac,
345 template (value) OCT2 cI_value) :=
346 {
347 mccDigit1 := mcc[0],
348 mccDigit2 := mcc[1],
349 mccDigit3 := mcc[2],
350 mncDigit3 := mnc[2], /* 'F'H for 2 digit MNC */
351 mncDigit1 := mnc[0],
352 mncDigit2 := mnc[1],
353 lac := lac,
354 cI_value := cI_value
355 }
356
Harald Weltec69cf4e2018-02-17 20:57:02 +0100357 template GTPC_PDUs ts_CreatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
358 BIT4 nsapi, EndUserAddress eua, octetstring apn,
359 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100360 octetstring msisdn, template ProtConfigOptions pco := omit,
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100361 template (omit) OCT1 ratType := omit,
362 template (omit) UserLocationInformation uli := omit) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100363 createPDPContextRequest := {
364 imsi := ts_Imsi(imsi),
365 rai := omit,
366 recovery := ts_Recovery(restart_ctr),
367 selectionMode := {
368 type_gtpc := '0F'O,
369 selectModeValue := '00'B,
370 spare := '111111'B
371 },
372 teidDataI := {
373 type_gtpc := '00'O,
374 teidDataI := teid_data
375 },
376 teidControlPlane := {
377 type_gtpc := '00'O,
378 teidControlPlane := teid_ctrl
379 },
380 nsapi := {
381 type_gtpc := '00'O,
382 nsapi := nsapi,
383 unused := '0000'B
384 },
385 linked_nsapi := omit,
386 charging_char := omit,
387 trace_ref := omit,
388 trace_type := omit,
389 endUserAddress := eua,
390 accessPointName := ts_APN(apn),
391 protConfigOptions := pco,
392 sgsn_addr_signalling := ts_GsnAddr(sgsn_ip_sign),
393 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
394 msisdn := ts_Msisdn(msisdn),
395 qualityOfServiceProfile := ts_QosDefault,
396 tft := omit,
397 triggerId := omit,
398 omcId := omit,
399 commonFlags := omit,
400 aPN_Restriction := omit,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100401 ratType := f_ts_RATType(ratType),
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100402 userLocationInformation := uli,
Harald Weltec69cf4e2018-02-17 20:57:02 +0100403 mS_TimeZone := omit,
404 imeisv := omit,
405 camelChargingInformationContainer := omit,
406 additionalTraceInfo := omit,
407 correlationID := omit,
408 evolvedAllocationRetentionPriorityI := omit,
409 extendedCommonFlags := omit,
410 userCSGInformation := omit,
411 aPN_AMBR := omit,
412 signallingPriorityIndication := omit,
413 cN_OperatorSelectionEntity := omit,
414 private_extension_gtpc := omit
415 }
416 }
417
418 template Gtp1cUnitdata ts_GTPC_CreatePDP(GtpPeer peer, uint16_t seq, hexstring imsi,
419 OCT1 restart_ctr, OCT4 teid_data,
420 OCT4 teid_ctrl, BIT4 nsapi, EndUserAddress eua,
421 octetstring apn, octetstring sgsn_ip_sign,
422 octetstring sgsn_ip_data, octetstring msisdn,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100423 template ProtConfigOptions pco := omit,
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100424 template (omit) OCT1 ratType := omit,
425 template (omit) UserLocationInformation uli := omit) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100426 peer := peer,
427 gtpc := ts_GTP1C_PDU(createPDPContextRequest, '00000000'O,
428 valueof(ts_CreatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
429 nsapi, eua, apn, sgsn_ip_sign,
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100430 sgsn_ip_data, msisdn, pco, ratType, uli)), seq)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100431 }
432
Harald Welteeded9ad2018-02-17 20:57:34 +0100433
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +0100434 template GTPC_PDUs ts_UpdatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
435 BIT4 nsapi,
436 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
437 template ProtConfigOptions pco := omit,
438 template (omit) OCT1 ratType := omit,
439 template (omit) UserLocationInformation uli := omit) := {
440 updatePDPContextRequest := {
441 updatePDPContextRequestSGSN := {
442 imsi := ts_Imsi(imsi),
443 rai := omit,
444 recovery := ts_Recovery(restart_ctr),
445 teidDataI := {
446 type_gtpc := '00'O,
447 teidDataI := teid_data
448 },
449 teidControlPlane := {
450 type_gtpc := '00'O,
451 teidControlPlane := teid_ctrl
452 },
453 nsapi := {
454 type_gtpc := '00'O,
455 nsapi := nsapi,
456 unused := '0000'B
457 },
458 trace_ref := omit,
459 trace_type := omit,
460 protConfigOptions := pco,
461 sgsn_addr_controlPlane := ts_GsnAddr(sgsn_ip_sign),
462 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
463 alt_ggsn_addr_controlPane := omit,
464 alt_ggsn_addr_traffic := omit,
465 qualityOfServiceProfile := ts_QosDefault,
466 tft := omit,
467 triggerId := omit,
468 omcId := omit,
469 commonFlags := omit,
470 ratType := f_ts_RATType(ratType),
471 userLocationInformation := uli,
472 mS_TimeZone := omit,
473 additionalTraceInfo := omit,
474 directTunnelFlags := omit,
475 evolvedAllocationRetentionPriorityI := omit,
476 extendedCommonFlags := omit,
477 userCSGInformation := omit,
478 aPN_AMBR := omit,
479 signallingPriorityIndication := omit,
480 cN_OperatorSelectionEntity := omit,
481 private_extension_gtpc := omit
482 }
483 }
484 }
485
486 template Gtp1cUnitdata ts_GTPC_UpdatePDP(GtpPeer peer, OCT4 teid, uint16_t seq, hexstring imsi,
487 OCT1 restart_ctr, OCT4 teid_data,
488 OCT4 teid_ctrl, BIT4 nsapi, octetstring sgsn_ip_sign,
489 octetstring sgsn_ip_data,
490 template ProtConfigOptions pco := omit,
491 template (omit) OCT1 ratType := omit,
492 template (omit) UserLocationInformation uli := omit) := {
493 peer := peer,
494 gtpc := ts_GTP1C_PDU(updatePDPContextRequest, teid,
495 valueof(ts_UpdatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
496 nsapi, sgsn_ip_sign,
497 sgsn_ip_data, pco, ratType, uli)), seq)
498 }
499
500
Harald Welteeded9ad2018-02-17 20:57:34 +0100501 template NSAPI_GTPC ts_NSAPI(BIT4 nsapi) := {
502 type_gtpc := '14'O,
503 nsapi := nsapi,
504 unused := '0000'B
505 }
506
507 template ReorderingRequired ts_ReorderReq(boolean req := false) := {
508 type_gtpc := '08'O,
509 reordreq := bool2bit(req),
510 spare := '0000000'B
511 }
512
513 template GTPC_PDUs ts_CreatePdpRespPDU(OCT1 cause, OCT4 teid_data, OCT4 teid_ctrl, BIT4 nsapi,
514 octetstring ggsn_ip_sign, octetstring ggsn_ip_data,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100515 OCT4 chg_id, template EndUserAddress eua := omit,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200516 template Recovery_gtpc recovery := omit,
Harald Welteeded9ad2018-02-17 20:57:34 +0100517 template ProtConfigOptions pco := omit) := {
518 createPDPContextResponse := {
519 cause := { '00'O, cause },
520 reorderingRequired := ts_ReorderReq(false),
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200521 recovery := recovery,
Harald Welteeded9ad2018-02-17 20:57:34 +0100522 teidDataI := {
523 type_gtpc := '00'O,
524 teidDataI := teid_data
525 },
526 teidControlPlane := {
527 type_gtpc := '00'O,
528 teidControlPlane := teid_ctrl
529 },
530 nsapi := ts_NSAPI(nsapi),
Harald Welte7aff2ca2018-02-18 15:34:50 +0100531 chargingID := {
532 type_gtpc := '7F'O,
533 chargingID := chg_id
534 },
Harald Welteeded9ad2018-02-17 20:57:34 +0100535 endUserAddress := eua,
536 protConfigOptions := pco,
537 ggsn_addr_controlPlane := ts_GsnAddr(ggsn_ip_sign),
538 ggsn_addr_traffic := ts_GsnAddr(ggsn_ip_data),
539 alt_ggsn_addr_controlPane := omit,
540 alt_ggsn_addr_traffic := omit,
541 qualityOfServiceProfile := ts_QosDefault,
542 commonFlags := omit,
543 aPN_Restriction := omit,
544 mS_InfoChangeReportingAction := omit,
545 bearerControlMode := omit,
546 evolvedAllocationRetentionPriorityI := omit,
547 extendedCommonFlag := omit,
548 csg_information_reporting_action := omit,
549 aPN_AMBR := omit,
550 gGSN_BackOffTime := omit,
551 private_extension_gtpc := omit
552 }
553 }
554
555 template Gtp1cUnitdata ts_GTPC_CreatePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
556 OCT1 cause,
557 OCT4 teid_ctrl, OCT4 teid_data,
558 BIT4 nsapi, octetstring ggsn_ip_sign,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100559 octetstring ggsn_ip_data, OCT4 chg_id,
Harald Welteeded9ad2018-02-17 20:57:34 +0100560 template EndUserAddress eua := omit,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200561 template Recovery_gtpc recovery := omit,
Harald Welteeded9ad2018-02-17 20:57:34 +0100562 template ProtConfigOptions pco := omit) := {
563 peer := peer,
564 gtpc := ts_GTP1C_PDU(createPDPContextResponse, teid,
565 valueof(ts_CreatePdpRespPDU(cause, teid_data, teid_ctrl, nsapi,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100566 ggsn_ip_sign, ggsn_ip_data, chg_id,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200567 eua, recovery, pco)), seq)
Harald Welteeded9ad2018-02-17 20:57:34 +0100568 }
569
Harald Weltec69cf4e2018-02-17 20:57:02 +0100570 /* PCO send base template */
571 template ProtConfigOptions ts_PCO := {
572 type_gtpc := '84'O,
573 lengthf := 0,
574 configProtocol := '000'B,
575 spare := '0000'B,
576 extension0 := '1'B,
577 protocols := {}
578 }
579 /* PCO receive base template */
580 template ProtConfigOptions tr_PCO := {
581 type_gtpc := '84'O,
582 lengthf := ?,
583 configProtocol := '000'B,
584 spare := ?,
585 extension0 := '1'B,
586 protocols := {}
587 }
588
589 template ProtConfigOptions ts_PCO_IPv6_DNS modifies ts_PCO := {
590 protocols := {
591 { protocolID := '0003'O, lengthProtoID := 0, protoIDContents := ''O }
592 }
593 }
594 template ProtConfigOptions tr_PCO_IPv6_DNS_resp(template OCT16 contents) modifies tr_PCO := {
595 protocols := {
596 *, { protocolID := '0003'O, lengthProtoID := 16, protoIDContents := contents }, *
597 }
598 }
599
600 template ProtConfigOptions ts_PCO_IPv4_DNS_IPCP modifies ts_PCO := {
601 protocols := {
602 /* dummy PAP entry to check if our parser in the GGSN can properly iterate over
603 * the list of protocols, see Change-Id Icc2e6716c33d78d3c3e000f529806228d8aa155e */
604 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
605 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
606 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
607 }
608 }
609
Philipp Maier33e52612018-05-30 17:22:02 +0200610 template ProtConfigOptions ts_PCO_IPv4_PRI_DNS_IPCP modifies ts_PCO := {
611 protocols := {
612 /* dummy PAP entry to check if our parser can cope with a single primary DNS entry
613 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
614 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
615 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
616 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) }
617 }
618 }
619 template ProtConfigOptions ts_PCO_IPv4_SEC_DNS_IPCP modifies ts_PCO := {
620 protocols := {
621 /* dummy PAP entry to check if our parser can cope with a single secondary DNS entry
622 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
623 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
624 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
625 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
626 }
627 }
628 template ProtConfigOptions ts_PCO_IPv4_SEPARATE_DNS_IPCP modifies ts_PCO := {
629 protocols := {
630 /* dummy PAP entry to check if our parser can cope with a primary and secondary DNS
631 * in separate IPCP containers OS#3381 */
632 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
633 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
634 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) },
635 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
636 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
637 }
638 }
639
Harald Weltec69cf4e2018-02-17 20:57:02 +0100640 template ProtocolElement tr_PCO_Proto(OCT2 prot_id) := {
641 protocolID := prot_id,
642 lengthProtoID := ?,
643 protoIDContents := ?
644 }
Harald Weltef8298542019-04-10 10:15:28 +0200645 template ProtocolElement ts_PCOelem_PAP_broken := {
646 protocolID := 'C023'O,
647 lengthProtoID := 60,
648 /* PPP Password Authentication Protocol containing incorrect Peer-Id-Length set to 4 (6-7 should be the valid one), see OS#3914. */
649 protoIDContents := '0100003c'O & '0444435338323700bc1c08087c1508083e00790000150808fd06000001000000000000000000000000000000000000000000000000000000'O
650 }
651 template ProtConfigOptions ts_PCO_PAP_IPv4_DNS modifies ts_PCO := {
652 protocols := {
653 ts_PCOelem_PAP_broken,
654 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
655 }
656 }
Harald Weltec69cf4e2018-02-17 20:57:02 +0100657 template ProtConfigOptions tr_PCO_Contains(OCT2 prot_id) modifies tr_PCO := {
658 protocols := { *, tr_PCO_Proto(prot_id), * }
659 }
660
661 template ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := {
662 protocols := {
663 { protocolID := '000d'O, lengthProtoID := 0, protoIDContents := ''O }
664 }
665 }
666 template ProtConfigOptions tr_PCO_IPv4_DNS_CONT_resp(template OCT4 contents) modifies tr_PCO := {
667 protocols := {
668 *, { protocolID := '000d'O, lengthProtoID := 4, protoIDContents := contents }, *
669 }
670 }
671
672 /* extract a given protocol payload from PCO */
673 function f_PCO_extract_proto(ProtConfigOptions pco, OCT2 protocol, integer nth_match := 1) return octetstring {
674 var integer i;
675 var integer num_matches := 0;
676 for (i := 0; i < lengthof(pco.protocols); i := i + 1) {
677 if (pco.protocols[i].protocolID == protocol) {
678 num_matches := num_matches + 1;
679 if (num_matches == nth_match) {
680 return pco.protocols[i].protoIDContents;
681 }
682 }
683 }
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200684 setverdict(fail, "Could not extract protocol payload from protocol ", protocol);
685 mtc.stop;
Harald Weltec69cf4e2018-02-17 20:57:02 +0100686 return ''O;
687 }
688
689 template IpcpPacket tr_IPCP(template LcpCode code, template uint8_t identifier,
690 template IpcpOptionList opts) := {
691 code := code,
692 identifier := identifier,
693 len := ?,
694 options := opts
695 }
696 template IpcpOption tr_IPCP_PrimaryDns(template OCT4 addr) := {
697 code := IPCP_OPT_PrimaryDNS,
698 len := 6,
699 data := addr
700 }
701 template IpcpOption tr_IPCP_SecondaryDns(template OCT4 addr) := {
702 code := IPCP_OPT_SecondaryDNS,
703 len := 6,
704 data := addr
705 }
706 template IpcpPacket tr_IPCP_Ack_DNS(template uint8_t identifier := ?, template OCT4 dns1 := ?,
707 template OCT4 dns2 := ?) :=
708 tr_IPCP(LCP_Configure_Ack, identifier,
709 { *, tr_IPCP_PrimaryDns(dns1), *, tr_IPCP_SecondaryDns(dns2), * });
710
711 template IpcpPacket ts_IPCP(LcpCode code, uint8_t identifier, template IpcpOptionList opts) := {
712 code := code,
713 identifier := identifier,
714 len := 0, /* overwritten */
715 options := opts
716 }
717 template IpcpPacket ts_IPCP_ReqDNS(uint8_t identifier := 0) :=
718 ts_IPCP(LCP_Configure_Request, identifier,
719 { tr_IPCP_PrimaryDns('00000000'O), tr_IPCP_SecondaryDns('00000000'O) });
720
Philipp Maier33e52612018-05-30 17:22:02 +0200721 template IpcpPacket ts_IPCP_ReqDNS_Primary(uint8_t identifier := 0) :=
722 ts_IPCP(LCP_Configure_Request, identifier,
723 { tr_IPCP_PrimaryDns('00000000'O) });
724 template IpcpPacket ts_IPCP_ReqDNS_Secondary(uint8_t identifier := 0) :=
725 ts_IPCP(LCP_Configure_Request, identifier,
726 { tr_IPCP_SecondaryDns('00000000'O) });
727
Harald Welte57b9b7f2018-02-18 22:28:13 +0100728 function f_teardown_ind_IE(in template (omit) BIT1 ind) return template (omit) TearDownInd {
729 if (istemplatekind(ind, "omit")) {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100730 return omit;
731 }
Harald Weltec69cf4e2018-02-17 20:57:02 +0100732 var TearDownInd ret := {
733 type_gtpc := '13'O,
734 tdInd := valueof(ind),
735 spare:= '0000000'B
736 }
737 return ret;
738 }
739
Harald Welte57b9b7f2018-02-18 22:28:13 +0100740 template GTPC_PDUs ts_DeletePdpPDU(BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100741 deletePDPContextRequest := {
742 cause := omit,
743 tearDownIndicator := f_teardown_ind_IE(teardown_ind),
744 nsapi := {
745 type_gtpc := '14'O,
746 nsapi := nsapi,
747 unused := '0000'B
748 },
749 protConfigOptions := omit,
750 userLocationInformation := omit,
751 mS_TimeZone := omit,
752 extendedCommonFlags := omit,
753 uLI_Timestamp := omit,
754 private_extension_gtpc := omit
755 }
756 }
757
758 template Gtp1cUnitdata ts_GTPC_DeletePDP(GtpPeer peer, uint16_t seq, OCT4 teid,
Harald Welte57b9b7f2018-02-18 22:28:13 +0100759 BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100760 peer := peer,
761 gtpc := ts_GTP1C_PDU(deletePDPContextRequest, teid,
762 valueof(ts_DeletePdpPDU(nsapi, teardown_ind)), seq)
763 }
764
Harald Welte6f203162018-02-18 22:04:55 +0100765 template GTPC_PDUs ts_DeletePdpRespPDU(OCT1 cause,
766 template ProtConfigOptions pco := omit) := {
767 deletePDPContextResponse := {
768 cause := { '00'O, cause },
769 protConfigOptions := pco,
770 userLocationInformation := omit,
771 mS_TimeZone := omit,
772 uLI_Timestamp := omit,
773 private_extension_gtpc := omit
774 }
775 }
776
777 template Gtp1cUnitdata ts_GTPC_DeletePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
778 OCT1 cause,
779 template ProtConfigOptions pco := omit) := {
780 peer := peer,
781 gtpc := ts_GTP1C_PDU(deletePDPContextResponse, teid,
782 valueof(ts_DeletePdpRespPDU(cause, pco)), seq)
783 }
784
785
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200786 /* GTP-C RIM */
787
788 template (value) RIM_Application_Identity_GTPC ts_GTPC_RIM_Application_Identity(OCT1 app_id) := {
789 iEI := '4B'O,
790 ext := '1'B,
791 lengthIndicator := {
792 length1 := 1
793 },
794 rIMApplicationIdentity := app_id
795 }
796 /* 3GPP TS 48.018 11.3.62 */
797 template (value) RIM_Sequence_Number_GTPC ts_GTPC_RIM_Sequence_Number(integer seq) := {
798 iEI := '4C'O,
799 ext := '1'B,
800 lengthIndicator := {
801 length1 := 4
802 },
803 rIMSequenceNumber := int2oct(seq, 4)
804 }
805 template (value) RIM_PDU_Indications_GTPC ts_GTPC_RIM_PDU_Indications(boolean ack, BIT3 type_ext) := {
806 iEI := '4F'O,
807 ext := '1'B,
808 lengthIndicator := {
809 length1 := 1
810 },
811 ack := bool2bit(ack),
812 pDU_Type_Extension := type_ext,
813 reserved := '0000'B
814 }
815 /* 3GPP TS 48.018 11.3.67 */
816 template (value) RIM_Protocol_Version_Number_GTPC ts_GTPC_RIM_Protocol_Version_Number(integer ver) := {
817 iEI := '55'O,
818 ext := '1'B,
819 lengthIndicator := {
820 length1 := 1
821 },
822 rIMProtocolVersionNumber := int2oct(ver, 1)
823 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100824 function tr_GTPC_Cell_Identifier_V(template GTP_CellId cid) return template Cell_Identifier_V_GTPC {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200825 var template Cell_Identifier_V_GTPC ret := {
826 mccDigit1 := ?,
827 mccDigit2 := ?,
828 mccDigit3 := ?,
829 mncDigit3 := ?,
830 mncDigit1 := ?,
831 mncDigit2 := ?,
832 lac := ?,
833 rac := ?,
834 cI_value := ?
835 }
836 if (istemplatekind(cid, "omit")) {
837 return omit;
838 } else if (istemplatekind(cid, "*")) {
839 return *;
840 } else if (istemplatekind(cid, "?")) {
841 return ?;
842 }
843 if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) {
844 if (isvalue(cid.ra_id.lai.mcc_mnc)) {
845 ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0];
846 ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1];
847 ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2];
848 ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3];
849 ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4];
850 ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5];
851 }
852 if (isvalue(cid.ra_id.lai.lac)) {
853 ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2);
854 }
855 }
856 if (isvalue(cid) and isvalue(cid.ra_id)) {
857 ret.rac := f_oct_or_wc(cid.ra_id.rac, 1);
858 }
859 if (isvalue(cid)) {
860 ret.cI_value := f_oct_or_wc(cid.cell_id, 2);
861 }
862 return ret;
863 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100864 template (value) Cell_Identifier_V_GTPC ts_GTPC_Cell_Identifier_V(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200865 mccDigit1 := cid.ra_id.lai.mcc_mnc[0],
866 mccDigit2 := cid.ra_id.lai.mcc_mnc[1],
867 mccDigit3 := cid.ra_id.lai.mcc_mnc[2],
868 mncDigit3 := cid.ra_id.lai.mcc_mnc[3],
869 mncDigit1 := cid.ra_id.lai.mcc_mnc[4],
870 mncDigit2 := cid.ra_id.lai.mcc_mnc[5],
871 lac := int2oct(cid.ra_id.lai.lac, 2),
872 rac := int2oct(cid.ra_id.rac, 1),
873 cI_value := int2oct(cid.cell_id, 2)
874 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100875 template RIM_Routing_Address_GTPC t_GTPC_RIM_Routing_Address_cid(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200876 cell_Identifier := ts_GTPC_Cell_Identifier_V(cid)
877 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100878 function tr_GTPC_ENB_Identifier(template GTP_CellId cid, template integer tac, template octetstring gnbid) return template ENB_Identifier {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200879 var template ENB_Identifier ret := {
880 mccDigit1 := ?,
881 mccDigit2 := ?,
882 mccDigit3 := ?,
883 mncDigit3 := ?,
884 mncDigit1 := ?,
885 mncDigit2 := ?,
886 tAC := ?,
887 globalENB_ID := ?
888 }
889 if (istemplatekind(cid, "omit") and istemplatekind(tac, "omit") and istemplatekind(gnbid, "omit")) {
890 return omit;
891 } else if (istemplatekind(cid, "*") and istemplatekind(tac, "*") and istemplatekind(gnbid, "*")) {
892 return *;
893 } else if (istemplatekind(cid, "?") and istemplatekind(tac, "?") and istemplatekind(gnbid, "?")) {
894 return ?;
895 }
896 if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) {
897 if (isvalue(cid.ra_id.lai.mcc_mnc)) {
898 ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0];
899 ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1];
900 ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2];
901 ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3];
902 ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4];
903 ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5];
904 }
905 }
906 if (isvalue(tac)) {
907 ret.tAC := int2oct(valueof(tac), 2);
908 }
909 if (isvalue(gnbid)) {
910 ret.globalENB_ID := gnbid;
911 }
912
913 return ret;
914 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100915 template (value) ENB_Identifier ts_GTPC_ENB_Identifier(GTP_CellId cid, integer tac, octetstring gnbid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200916 mccDigit1 := cid.ra_id.lai.mcc_mnc[0],
917 mccDigit2 := cid.ra_id.lai.mcc_mnc[1],
918 mccDigit3 := cid.ra_id.lai.mcc_mnc[2],
919 mncDigit3 := cid.ra_id.lai.mcc_mnc[3],
920 mncDigit1 := cid.ra_id.lai.mcc_mnc[4],
921 mncDigit2 := cid.ra_id.lai.mcc_mnc[5],
922 tAC := int2oct(tac, 2),
923 globalENB_ID := gnbid
924 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100925 template RIM_Routing_Address_GTPC t_GTPC_RIM_Routing_Address_enbid(GTP_CellId cid, integer tac, octetstring gnbid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200926 eNB_Identifier := ts_GTPC_ENB_Identifier(cid, tac, gnbid)
927 }
928 template RIM_Routing_Information_GTPC
929 tr_GTPC_RIM_Routing_Information(HEX1 addr_discr, template RIM_Routing_Address_GTPC addr) := {
930 iEI := '54'O,
931 ext := '1'B,
932 lengthIndicator := {
933 length1 := ?
934 },
935 rIMRoutingAddressDiscriminator := addr_discr,
936 spare := '0'H,
937 rIM_Routing_Address := addr
938 }
939 template (value) RIM_Routing_Information_GTPC
940 ts_GTPC_RIM_Routing_Information(HEX1 addr_discr, template (value) RIM_Routing_Address_GTPC addr) := {
941 iEI := '54'O,
942 ext := '1'B,
943 lengthIndicator := {
944 length1 := 0 /* overwritten */
945 },
946 rIMRoutingAddressDiscriminator := addr_discr,
947 spare := '0'H,
948 rIM_Routing_Address := addr
949 }
950 /* 3GPP TS 48.018 11.3.63.1.1 */
951 template RAN_Information_Request_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100952 tr_GTPC_RAN_Information_Request_Application_Container_NACC(template GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200953 iEI := '4D'O,
954 ext := '1'B,
955 lengthIndicator := {
956 length1 := ?
957 },
958 reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid)
959 }
960 template (value) RAN_Information_Request_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100961 ts_GTPC_RAN_Information_Request_Application_Container_NACC(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200962 iEI := '4D'O,
963 ext := '1'B,
964 lengthIndicator := {
965 length1 := 0 /* overwritten */
966 },
967 reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid)
968 }
969 /* 3GPP TS 48.018 11.3.63.1 */
970 template RAN_Information_Request_Application_Container_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100971 tru_GTPC_RAN_Information_Request_Application_Container_NACC(template GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200972 nacc := tr_GTPC_RAN_Information_Request_Application_Container_NACC(cid)
973 }
974 template (value) RAN_Information_Request_Application_Container_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100975 tsu_GTPC_RAN_Information_Request_Application_Container_NACC(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200976 nacc := ts_GTPC_RAN_Information_Request_Application_Container_NACC(cid)
977 }
978 /* 3GPP TS 48.018 11.3.63.2.1 */
979 template RAN_Information_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100980 tr_GTPC_RAN_Information_Application_Container_NACC(template GTP_CellId cid, boolean psi_type, integer si_psi_num, octetstring si_psi) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200981 iEI := '4E'O,
982 ext := '1'B,
983 lengthIndicator := {
984 length1 := ?
985 },
986 reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid),
987 typeBit := bool2bit(psi_type),
988 number_of_SI_PSI := int2bit(si_psi_num, 7),
989 sI_PSI := si_psi
990 }
991 template (value) RAN_Information_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100992 ts_GTPC_RAN_Information_Application_Container_NACC(GTP_CellId cid, boolean psi_type, integer si_psi_num, octetstring si_psi) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200993 iEI := '4E'O,
994 ext := '1'B,
995 lengthIndicator := {
996 length1 := 0 /* overwritten */
997 },
998 reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid),
999 typeBit := bool2bit(psi_type),
1000 number_of_SI_PSI := int2bit(si_psi_num, 7),
1001 sI_PSI := si_psi
1002 }
1003
1004 /* RAN_Information_Request */
1005 template (value) RAN_Information_Request_RIM_Container_GTPC
1006 ts_GTPC_RAN_Information_Request_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id,
1007 template (value) RIM_Sequence_Number_GTPC seq,
1008 template (value) RIM_PDU_Indications_GTPC ind,
1009 template (omit) RIM_Protocol_Version_Number_GTPC ver := omit,
1010 template (omit) RAN_Information_Request_Application_Container_GTPC app_cont := omit,
1011 template (omit) SON_TransferApplicationIdentity son_app_id := omit) := {
1012 iEI := '57'O,
1013 ext := '1'B,
1014 lengthIndicator := {
1015 length1 := 0 /* overwritten */
1016 },
1017 rIM_Application_Identity := app_id,
1018 rIM_Sequence_Number := seq,
1019 rIM_PDU_Indications := ind,
1020 rIM_Protocol_Version_Number := ver,
1021 application_Container := app_cont,
1022 sON_TransferApplicationIdentity := son_app_id
1023 }
1024 template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC
1025 ts_GTPC_RAN_Information_Request(template (value) RIM_Routing_Information_GTPC dest,
1026 template (value) RIM_Routing_Information_GTPC src,
1027 template (value) RAN_Information_Request_RIM_Container_GTPC cont) := {
1028 bssgpPduType := '71'O,
1029 destination_Cell_Identifier := dest,
1030 source_Cell_Identifier := src,
1031 rIM_Container := cont
1032 }
1033 template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO_REQ(template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC pdu) := {
1034 type_gtpc := '90'O,
1035 lengthf := 0, /* FIXME */
1036 rANTransparentContainerField := {
1037 pDU_BSSGP_RAN_INFORMATION_REQUEST := pdu
1038 }
1039 }
1040
1041 /* RAN_Information */
1042 template ApplContainer_or_ApplErrContainer_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001043 tru_GTPC_ApplContainer_NACC(GTP_CellId cid, boolean psi_type, integer si_psi_num, octetstring si_psi) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001044 application_Container := tr_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi)
1045 }
1046 template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001047 tsu_GTPC_ApplContainer_NACC(GTP_CellId cid, boolean psi_type, integer si_psi_num, octetstring si_psi) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001048 application_Container := ts_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi)
1049 }
1050 template ApplContainer_or_ApplErrContainer_GTPC
1051 tru_GTPC_ApplContainer_or_ApplErrContainer_NACC(template ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := {
1052 nacc := cont
1053 }
1054 template (value) ApplContainer_or_ApplErrContainer_GTPC
1055 tsu_GTPC_ApplContainer_or_ApplErrContainer_NACC(template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := {
1056 nacc := cont
1057 }
1058 template RAN_Information_RIM_Container_GTPC
1059 tr_GTPC_RAN_Information_RIM_Container(template RIM_Application_Identity_GTPC app_id,
1060 template RIM_Sequence_Number_GTPC seq,
1061 template RIM_PDU_Indications_GTPC ind,
1062 template RIM_Protocol_Version_Number_GTPC ver := omit,
1063 template ApplContainer_or_ApplErrContainer_GTPC app_cont := omit,
1064 template SON_TransferApplicationIdentity son_app_id := omit) := {
1065 iEI := '58'O,
1066 ext := '1'B,
1067 lengthIndicator := {
1068 length1 := ?
1069 },
1070 rIM_Application_Identity := app_id,
1071 rIM_Sequence_Number := seq,
1072 rIM_PDU_Indications := ind,
1073 rIM_Protocol_Version_Number := ver,
1074 applContainer_or_ApplErrContainer := app_cont,
1075 sON_TransferApplicationIdentity := son_app_id
1076 }
1077 template (value) RAN_Information_RIM_Container_GTPC
1078 ts_GTPC_RAN_Information_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id,
1079 template (value) RIM_Sequence_Number_GTPC seq,
1080 template (value) RIM_PDU_Indications_GTPC ind,
1081 template (omit) RIM_Protocol_Version_Number_GTPC ver := omit,
1082 template (omit) ApplContainer_or_ApplErrContainer_GTPC app_cont := omit,
1083 template (omit) SON_TransferApplicationIdentity son_app_id := omit) := {
1084 iEI := '58'O,
1085 ext := '1'B,
1086 lengthIndicator := {
1087 length1 := 0 /* overwritten */
1088 },
1089 rIM_Application_Identity := app_id,
1090 rIM_Sequence_Number := seq,
1091 rIM_PDU_Indications := ind,
1092 rIM_Protocol_Version_Number := ver,
1093 applContainer_or_ApplErrContainer := app_cont,
1094 sON_TransferApplicationIdentity := son_app_id
1095 }
1096 template PDU_BSSGP_RAN_INFORMATION_GTPC
1097 tr_GTPC_RAN_Information(template RIM_Routing_Information_GTPC dest,
1098 template RIM_Routing_Information_GTPC src,
1099 template RAN_Information_RIM_Container_GTPC cont) := {
1100 bssgpPduType := '70'O,
1101 destination_Cell_Identifier := dest,
1102 source_Cell_Identifier := src,
1103 rIM_Container := cont
1104 }
1105 template (value) PDU_BSSGP_RAN_INFORMATION_GTPC
1106 ts_GTPC_RAN_Information(template (value) RIM_Routing_Information_GTPC dest,
1107 template (value) RIM_Routing_Information_GTPC src,
1108 template (value) RAN_Information_RIM_Container_GTPC cont) := {
1109 bssgpPduType := '70'O,
1110 destination_Cell_Identifier := dest,
1111 source_Cell_Identifier := src,
1112 rIM_Container := cont
1113 }
1114 template RANTransparentContainer tr_RANTransparentContainer_RAN_INFO(template PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := {
1115 type_gtpc := '90'O,
1116 lengthf := ?,
1117 rANTransparentContainerField := {
1118 pDU_BSSGP_RAN_INFORMATION := pdu
1119 }
1120 }
1121 template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO(template (value) PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := {
1122 type_gtpc := '90'O,
1123 lengthf := 0, /* overwritten */
1124 rANTransparentContainerField := {
1125 pDU_BSSGP_RAN_INFORMATION := pdu
1126 }
1127 }
1128
1129 template RANTransparentContainer tr_RANTransparentContainer(template RANTransparentContainerField rANTransparentContainerField) := {
1130 type_gtpc := '90'O,
1131 lengthf := ?,
1132 rANTransparentContainerField := rANTransparentContainerField
1133 }
1134 template (value) RANTransparentContainer ts_RANTransparentContainer(template (value) RANTransparentContainerField rANTransparentContainerField) := {
1135 type_gtpc := '90'O,
1136 lengthf := 0, /* overwritten */
1137 rANTransparentContainerField := rANTransparentContainerField
1138 }
1139 template GTPC_PDUs tr_RANInfoRelay(template RANTransparentContainer transparentContainer) := {
1140 ranInformationRelay := {
1141 transparentContainer := transparentContainer,
1142 rIM_RoutingAddress := *,
1143 rIM_RoutingAddress_Discriminator := *,
1144 private_extension_gtpc := *
1145 }
1146 }
1147 template (value) GTPC_PDUs ts_RANInfoRelay(template (value) RANTransparentContainer transparentContainer) := {
1148 ranInformationRelay := {
1149 transparentContainer := transparentContainer,
1150 rIM_RoutingAddress := omit,
1151 rIM_RoutingAddress_Discriminator := omit,
1152 private_extension_gtpc := omit
1153 }
1154 }
1155 template Gtp1cUnitdata
1156 tr_GTPC_RANInfoRelay(template GtpPeer peer,
1157 template RANTransparentContainer transparentContainer) := {
1158 peer := peer,
1159 gtpc := tr_GTP1C_PDU(rANInformationRelay, '00000000'O, tr_RANInfoRelay(transparentContainer))
1160 }
1161 template (value) Gtp1cUnitdata
1162 ts_GTPC_RANInfoRelay(template (value) GtpPeer peer,
1163 template (value) RANTransparentContainer transparentContainer) := {
1164 peer := peer,
1165 gtpc := ts_GTP1C_PDU(rANInformationRelay, '00000000'O, valueof(ts_RANInfoRelay(transparentContainer)), 0)
1166 }
1167
1168
1169 template RAN_Information_Request_RIM_Container_GTPC
1170 tr_GTPC_RAN_Information_Request_RIM_Container(template RIM_Application_Identity_GTPC app_id := ?,
1171 template RIM_Sequence_Number_GTPC seq := ?,
1172 template RIM_PDU_Indications_GTPC ind := ?,
1173 template RIM_Protocol_Version_Number_GTPC ver := *,
1174 template RAN_Information_Request_Application_Container_GTPC app_cont := *,
1175 template SON_TransferApplicationIdentity son_app_id := *) := {
1176 iEI := '57'O,
1177 ext := '1'B,
1178 lengthIndicator := {
1179 length1 := ?
1180 },
1181 rIM_Application_Identity := app_id,
1182 rIM_Sequence_Number := seq,
1183 rIM_PDU_Indications := ind,
1184 rIM_Protocol_Version_Number := ver,
1185 application_Container := app_cont,
1186 sON_TransferApplicationIdentity := son_app_id
1187 }
Harald Weltec69cf4e2018-02-17 20:57:02 +01001188
1189 /* GTP-U */
1190
1191 template PDU_GTPU tr_GTP1U_PDU(template OCT1 msg_type, template OCT4 teid, template GTPU_IEs ies := ?) := {
1192 pn_bit := ?,
1193 s_bit := ?,
1194 e_bit := ?,
1195 spare := ?,
1196 /* Protocol Type flag (PT) shall be set to '1' in GTP */
1197 pt := '1'B,
1198 /* Version shall be set to decimal 1 ('001'). */
1199 version := '001'B,
1200 messageType := msg_type,
1201 lengthf := ?,
1202 teid := teid,
1203 opt_part := *,
1204 gtpu_IEs := ies
1205 }
1206
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001207 function f_GTPU_s_bit(template (omit) uint16_t seq) return BIT1 {
1208 if (istemplatekind(seq, "omit")) {
1209 return '0'B;
1210 }
1211 return '1'B;
1212 }
1213
1214 function f_GTPU_opt_part(template (omit) uint16_t seq) return template (omit) GTPU_Header_optional_part {
1215 if (istemplatekind(seq, "omit")) {
1216 return omit;
1217 }
1218 var GTPU_Header_optional_part ret := {
1219 sequenceNumber := int2oct(valueof(seq), 2),
1220 npduNumber := '00'O,
1221 nextExtHeader := '00'O,
1222 gTPU_extensionHeader_List := omit
1223 };
1224 return ret;
1225 }
1226
Harald Weltec69cf4e2018-02-17 20:57:02 +01001227 /* generalized GTP-U send template */
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001228 template (value) PDU_GTPU ts_GTP1U_PDU(OCT1 msg_type, template (omit) uint16_t seq, OCT4 teid, GTPU_IEs ies) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +01001229 /* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN
1230 * flag is set to 1. */
1231 pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */
1232 /* If the Sequence Number flag (S) is set to '1' the sequence number field is present and
1233 * meaningful otherwise it is set to '0'. For GTP-U messages Echo Request, Echo Response,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001234 * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'.
1235 *
1236 * Note that the caller must ensure that these conditions hold.
1237 * The caller can either pass a sequence number (we set s_bit to '1'B) when appropriate,
1238 * or may omit the sequence number (we set s_bit to '0'B). */
1239 s_bit := f_GTPU_s_bit(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +01001240 /* Extension header presence */
1241 e_bit := '0'B,
1242 spare := '0'B,
1243 /* Protocol Type flag (PT) shall be set to '1' in GTP */
1244 pt := '1'B,
1245 /* Version shall be set to decimal 1 ('001'). */
1246 version := '001'B,
1247 messageType := msg_type,
1248 lengthf := 0, /* we assume encoder overwrites this */
1249 teid := teid,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001250 opt_part := f_GTPU_opt_part(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +01001251 gtpu_IEs := ies
1252 }
1253
1254 template Gtp1uUnitdata tr_GTPU_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid) := {
1255 peer := peer,
1256 gtpu := tr_GTP1U_PDU(msg_type, teid)
1257 }
1258
1259
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001260 /* template matching reception of GTP-U echo-request/response */
Harald Weltec69cf4e2018-02-17 20:57:02 +01001261 template Gtp1uUnitdata tr_GTPU_PING(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoRequest, '00000000'O);
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001262 template Gtp1uUnitdata tr_GTPU_PONG(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoResponse, '00000000'O);
Harald Weltec69cf4e2018-02-17 20:57:02 +01001263
1264 /* template matching reception of GTP-U GPDU */
1265 template GTPU_IEs t_GPDU(template octetstring data) := {
1266 g_PDU_IEs := {
1267 data := data
1268 }
1269 }
1270 template Gtp1uUnitdata tr_GTPU_GPDU(template GtpPeer peer, template OCT4 teid, template octetstring data := ?) := {
1271 peer := peer,
1272 gtpu := tr_GTP1U_PDU('FF'O, teid, t_GPDU(data))
1273 }
1274
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001275 template GTPU_IEs ts_UEchoReqPDU := {
1276 echoRequest_IEs := {
1277 private_extension_gtpu := omit
1278 }
1279 }
1280
1281 /* master template for sending a GTP-C echo request */
1282 template (value) Gtp1uUnitdata ts_GTPU_PING(GtpPeer peer, uint16_t seq) := {
1283 peer := peer,
1284 gtpu := ts_GTP1U_PDU(echoRequest, seq, '00000000'O, valueof(ts_UEchoReqPDU))
1285 }
1286
Harald Weltec69cf4e2018-02-17 20:57:02 +01001287 template GTPU_IEs ts_UEchoRespPDU(OCT1 restart_counter) := {
1288 echoResponse_IEs := {
1289 recovery_gtpu := {
1290 type_gtpu := '00'O, /* we assume encoder fixes? */
1291 restartCounter := restart_counter
1292 },
1293 private_extension_gtpu := omit
1294 }
1295 }
1296
1297 /* master template for sending a GTP-U echo response */
1298 template Gtp1uUnitdata ts_GTPU_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
1299 peer := peer,
1300 gtpu := ts_GTP1U_PDU(echoResponse, seq, '00000000'O, valueof(ts_UEchoRespPDU(rest_ctr)))
1301 }
1302
Pau Espin Pedrolf3e25382018-07-18 13:46:40 +02001303 template GSNAddress_gtpu ts_UGsnAddr(octetstring ip_addr) := {
1304 type_gtpu := '85'O,
1305 lengthf := lengthof(ip_addr),
1306 gSNAddressValue := ip_addr
1307 }
1308
1309 template TeidDataI_gtpu ts_UteidDataI(OCT4 teid) := {
1310 type_gtpu := '10'O,
1311 teidDataI := teid
1312 }
1313
1314 template GTPU_IEs ts_UErrorIndication(OCT4 teid, octetstring gsn_addr) := {
1315 errorIndication_IEs := {
1316 teidDataI_gtpu := ts_UteidDataI(teid),
1317 gSNAddress_gtpu := ts_UGsnAddr(gsn_addr),
1318 private_extension_gtpu := omit
1319 }
1320 }
1321
1322 /* master template for sending a GTP-U Error indication */
1323 template Gtp1uUnitdata ts_GTPU_ErrorIndication(GtpPeer peer, uint16_t seq, OCT4 teid, octetstring gsn_addr) := {
1324 peer := peer,
1325 gtpu := ts_GTP1U_PDU('1A'O, seq, '00000000'O, valueof(ts_UErrorIndication(teid, gsn_addr)))
1326 }
1327
Harald Weltec69cf4e2018-02-17 20:57:02 +01001328 /* master template for sending a GTP-U user plane data */
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001329 template Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, template (omit) uint16_t seq, OCT4 teid, octetstring data) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +01001330 peer := peer,
1331 gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }})
1332 }
1333}