blob: 0c5c0033ca040d81e7d19f64c882cfe45c6934aa [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
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200122 /* Charging Characteristics IE TS 29.060 7.7.23 */
123 template ChargingCharacteristics_GTPC ts_ChargingCharacteristics(template (value) OCT2 chargingChar) := {
124 type_gtpc := '1A'O,
125 chargingChar := chargingChar
126 }
127 private function f_ts_ChargingCharacteristics(template (omit) OCT2 chargingChar)
128 return template (omit) ChargingCharacteristics_GTPC {
129 if (istemplatekind(chargingChar, "omit")) {
130 return omit;
131 }
132 return ts_ChargingCharacteristics(chargingChar);
133 }
134
135 template ChargingCharacteristics_GTPC tr_ChargingCharacteristics(template (present) OCT2 chargingChar) := {
136 type_gtpc := '1A'O,
137 chargingChar := chargingChar
138 }
139
140
Harald Weltec69cf4e2018-02-17 20:57:02 +0100141 /* template matching reception of GTP-C echo-request */
142 template Gtp1cUnitdata tr_GTPC_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdus := ?) := {
143 peer := peer,
144 gtpc := tr_GTP1C_PDU(msg_type, teid, pdus)
145 }
146
147 /* template matching reception of GTP-C echo-request */
148 template Gtp1cUnitdata tr_GTPC_PING(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoRequest, '00000000'O);
149
150 template GTPC_PDUs tr_EchoRespPDU(template OCT1 restart_counter) := {
151 echoResponse := {
152 recovery := tr_Recovery(restart_counter),
153 private_extension_gtpc := *
154 }
155 }
156
157 /* template matching reception of GTP-C echo-response */
158 template Gtp1cUnitdata tr_GTPC_PONG(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoResponse, '00000000'O, tr_EchoRespPDU(?));
159
160 template GTPC_PDUs ts_EchoRespPDU(OCT1 restart_counter) := {
161 echoResponse := {
162 recovery := ts_Recovery(restart_counter),
163 private_extension_gtpc := omit
164 }
165 }
166
167 /* master template for senidng a GTP-C echo response */
168 template Gtp1cUnitdata ts_GTPC_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
169 peer := peer,
170 gtpc := ts_GTP1C_PDU(echoResponse, '00000000'O, valueof(ts_EchoRespPDU(rest_ctr)), seq)
171 }
172
173 template GTPC_PDUs ts_EchoReqPDU := {
174 echoRequest := {
175 private_extension_gtpc := omit
176 }
177 }
178
179 /* master template for sending a GTP-C echo request */
180 template Gtp1cUnitdata ts_GTPC_PING(GtpPeer peer, uint16_t seq) := {
181 peer := peer,
182 gtpc := ts_GTP1C_PDU(echoRequest, '00000000'O, valueof(ts_EchoReqPDU), seq)
183 }
184
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100185 private function f_eua_ipv4_len(template OCT4 ip_addr) return template integer {
186 if (istemplatekind(ip_addr, "omit")) {
187 return 2;
188 } else if (istemplatekind(ip_addr, "*")) {
189 return ?;
190 } else if (istemplatekind(ip_addr, "?")) {
191 return 6;
192 }
193 return 6;
194 }
195
196 private function f_eua_ipv6_len(template OCT16 ip_addr) return template integer {
197 if (istemplatekind(ip_addr, "omit")) {
198 return 2;
199 } else if (istemplatekind(ip_addr, "*")) {
200 return ?;
201 } else if (istemplatekind(ip_addr, "?")) {
202 return 18;
203 }
204 return 18;
205 }
206
207 private function f_eua_ipv4v6_len(template OCT4 ip_addr4, template OCT16 ip_addr6) return template integer {
208 var integer len := 2;
209 if (istemplatekind(ip_addr4, "*") or
210 istemplatekind(ip_addr6, "*")) {
211 return ?;
212 }
213 if (not istemplatekind(ip_addr4, "omit")) {
214 len := len + 4;
215 }
216 if (not istemplatekind(ip_addr6, "omit")) {
217 len := len + 16;
218 }
219 return len;
220 }
221
Harald Weltec69cf4e2018-02-17 20:57:02 +0100222 template EndUserAddress t_EuaIPv4(template OCT4 ip_addr) := {
223 type_gtpc := '80'O,
224 endUserAddress := {
225 endUserAddressIPv4 := {
226 lengthf := 2,
227 pdp_typeorg := '0001'B,
228 spare := '1111'B,
229 pdp_typenum := '21'O,
230 ipv4_address := ip_addr
231 }
232 }
233 }
234 template EndUserAddress t_EuaIPv4Dyn := t_EuaIPv4(omit);
235 template EndUserAddress tr_EuaIPv4(template OCT4 ip_addr) modifies t_EuaIPv4 := {
236 endUserAddress := {
237 endUserAddressIPv4 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100238 lengthf := f_eua_ipv4_len(ip_addr)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100239 }
240 }
241 }
242
243 template EndUserAddress t_EuaIPv6(template OCT16 ip_addr) := {
244 type_gtpc := '80'O,
245 endUserAddress := {
246 endUserAddressIPv6 := {
247 lengthf := 2,
248 pdp_typeorg := '0001'B,
249 spare := '1111'B,
250 pdp_typenum := '57'O,
251 ipv6_address := ip_addr
252 }
253 }
254 }
255 template EndUserAddress t_EuaIPv6Dyn := t_EuaIPv6(omit);
256 template EndUserAddress tr_EuaIPv6(template OCT16 ip_addr) modifies t_EuaIPv6 := {
257 endUserAddress := {
258 endUserAddressIPv6 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100259 lengthf := f_eua_ipv6_len(ip_addr)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100260 }
261 }
262 }
263
Oliver Smithee6a0882019-03-08 11:05:46 +0100264 /* 3GPP TS 29.060 Figure 37A: End User Address Information Element for IPv4v6 (both static) */
265 template EndUserAddress t_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) := {
266 type_gtpc := '80'O,
267 endUserAddress := {
268 endUserAddressIPv4andIPv6 := {
269 lengthf := 2,
270 pdp_typeorg := '0001'B,
271 spare := '1111'B,
272 pdp_typenum := '8D'O,
273 ipv4_address := ip_addr4,
274 ipv6_address := ip_addr6
275 }
276 }
277 }
278 template EndUserAddress t_EuaIPv4Dynv6Dyn := t_EuaIPv4v6(omit, omit);
279 template EndUserAddress tr_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) modifies t_EuaIPv4v6 := {
280 endUserAddress := {
281 endUserAddressIPv4andIPv6 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100282 lengthf := f_eua_ipv4v6_len(ip_addr4, ip_addr6)
Oliver Smithee6a0882019-03-08 11:05:46 +0100283 }
284 }
285 }
286
Harald Weltec69cf4e2018-02-17 20:57:02 +0100287 template AccessPointName ts_APN(octetstring apn) := {
288 type_gtpc := '83'O,
289 lengthf := lengthof(apn),
290 apn_value := apn
291 }
292
293 template GSN_Address_GTPC ts_GsnAddr(octetstring ip_addr) := {
294 type_gtpc := '85'O,
295 lengthf := lengthof(ip_addr),
296 addressf := ip_addr
297 }
298
299 template MSISDN ts_Msisdn(octetstring msisdn) := {
300 type_gtpc := '86'O,
301 lengthf := lengthof(msisdn),
302 msisdn := msisdn
303 }
304
305 template QualityOfServiceProfile ts_QosDefault := {
306 type_gtpc := '87'O,
307 lengthf := 4,
308 allocRetensionPrio := '00'O,
309 qos_ProfileValue := {
310 reliabilityClass := '011'B,
311 delayClass := '001'B,
312 spare1 := '00'B,
313 precedenceClass := '010'B,
314 spare2 := '0'B,
315 peakThroughput := '1001'B,
316 meanThroughput := '11111'B,
317 spare3 := '000'B,
318 deliverErroneusSDU := omit,
319 deliveryOrder := omit,
320 trafficClass := omit,
321 maxSDUSize := omit,
322 maxBitrateUplink := omit,
323 maxBitrateDownlink := omit,
324 sduErrorRatio := omit,
325 residualBER := omit,
326 trafficHandlingPriority := omit,
327 transferDelay := omit,
328 guaranteedBitRateUplink := omit,
329 guaranteedBitRateDownlink := omit,
330 sourceStatisticsDescriptor := omit,
331 signallingIndication := omit,
332 spare4 := omit,
333 maxBitrateDownlinkExt := omit,
334 guaranteedBitRateDownlinkExt := omit,
335 maxBitrateUplinkExt := omit,
336 guaranteedBitRateUplinkExt := omit
337 }
338 }
339
340 template IMSI_gtpc ts_Imsi(hexstring digits) := {
341 type_gtpc := '02'O,
342 digits := digits,
343 padding := 'F'H
344 }
345
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100346 function f_ts_RATType(template (omit) OCT1 ratType := omit) return template (omit) RATType {
347 var template (omit) RATType rt;
348 if (istemplatekind(ratType, "omit")) {
349 rt := omit;
350 } else {
351 rt := {
352 type_gtpc := '97'O,
353 lengthf := 1,
354 ratTypeValue := ratType
355 };
356 }
357 return rt;
358 }
359
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100360 template (value) GeographicLocationCGI
361 ts_GeographicLocationCGI(template (value) hexstring mcc,
362 template (value) hexstring mnc,
363 template (value) OCT2 lac,
364 template (value) OCT2 cI_value) :=
365 {
366 mccDigit1 := mcc[0],
367 mccDigit2 := mcc[1],
368 mccDigit3 := mcc[2],
369 mncDigit3 := mnc[2], /* 'F'H for 2 digit MNC */
370 mncDigit1 := mnc[0],
371 mncDigit2 := mnc[1],
372 lac := lac,
373 cI_value := cI_value
374 }
375
Harald Weltec69cf4e2018-02-17 20:57:02 +0100376 template GTPC_PDUs ts_CreatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
377 BIT4 nsapi, EndUserAddress eua, octetstring apn,
378 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100379 octetstring msisdn, template ProtConfigOptions pco := omit,
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100380 template (omit) OCT1 ratType := omit,
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200381 template (omit) UserLocationInformation uli := omit,
382 template (omit) OCT2 charging_char := omit) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100383 createPDPContextRequest := {
384 imsi := ts_Imsi(imsi),
385 rai := omit,
386 recovery := ts_Recovery(restart_ctr),
387 selectionMode := {
388 type_gtpc := '0F'O,
389 selectModeValue := '00'B,
390 spare := '111111'B
391 },
392 teidDataI := {
393 type_gtpc := '00'O,
394 teidDataI := teid_data
395 },
396 teidControlPlane := {
397 type_gtpc := '00'O,
398 teidControlPlane := teid_ctrl
399 },
400 nsapi := {
401 type_gtpc := '00'O,
402 nsapi := nsapi,
403 unused := '0000'B
404 },
405 linked_nsapi := omit,
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200406 charging_char := f_ts_ChargingCharacteristics(charging_char),
Harald Weltec69cf4e2018-02-17 20:57:02 +0100407 trace_ref := omit,
408 trace_type := omit,
409 endUserAddress := eua,
410 accessPointName := ts_APN(apn),
411 protConfigOptions := pco,
412 sgsn_addr_signalling := ts_GsnAddr(sgsn_ip_sign),
413 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
414 msisdn := ts_Msisdn(msisdn),
415 qualityOfServiceProfile := ts_QosDefault,
416 tft := omit,
417 triggerId := omit,
418 omcId := omit,
419 commonFlags := omit,
420 aPN_Restriction := omit,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100421 ratType := f_ts_RATType(ratType),
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100422 userLocationInformation := uli,
Harald Weltec69cf4e2018-02-17 20:57:02 +0100423 mS_TimeZone := omit,
424 imeisv := omit,
425 camelChargingInformationContainer := omit,
426 additionalTraceInfo := omit,
427 correlationID := omit,
428 evolvedAllocationRetentionPriorityI := omit,
429 extendedCommonFlags := omit,
430 userCSGInformation := omit,
431 aPN_AMBR := omit,
432 signallingPriorityIndication := omit,
433 cN_OperatorSelectionEntity := omit,
434 private_extension_gtpc := omit
435 }
436 }
437
438 template Gtp1cUnitdata ts_GTPC_CreatePDP(GtpPeer peer, uint16_t seq, hexstring imsi,
439 OCT1 restart_ctr, OCT4 teid_data,
440 OCT4 teid_ctrl, BIT4 nsapi, EndUserAddress eua,
441 octetstring apn, octetstring sgsn_ip_sign,
442 octetstring sgsn_ip_data, octetstring msisdn,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100443 template ProtConfigOptions pco := omit,
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100444 template (omit) OCT1 ratType := omit,
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200445 template (omit) UserLocationInformation uli := omit,
446 template (omit) OCT2 charging_char := omit) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100447 peer := peer,
448 gtpc := ts_GTP1C_PDU(createPDPContextRequest, '00000000'O,
449 valueof(ts_CreatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
450 nsapi, eua, apn, sgsn_ip_sign,
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200451 sgsn_ip_data, msisdn, pco, ratType, uli, charging_char)), seq)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100452 }
453
Harald Welteeded9ad2018-02-17 20:57:34 +0100454
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +0100455 template GTPC_PDUs ts_UpdatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
456 BIT4 nsapi,
457 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
458 template ProtConfigOptions pco := omit,
459 template (omit) OCT1 ratType := omit,
460 template (omit) UserLocationInformation uli := omit) := {
461 updatePDPContextRequest := {
462 updatePDPContextRequestSGSN := {
463 imsi := ts_Imsi(imsi),
464 rai := omit,
465 recovery := ts_Recovery(restart_ctr),
466 teidDataI := {
467 type_gtpc := '00'O,
468 teidDataI := teid_data
469 },
470 teidControlPlane := {
471 type_gtpc := '00'O,
472 teidControlPlane := teid_ctrl
473 },
474 nsapi := {
475 type_gtpc := '00'O,
476 nsapi := nsapi,
477 unused := '0000'B
478 },
479 trace_ref := omit,
480 trace_type := omit,
481 protConfigOptions := pco,
482 sgsn_addr_controlPlane := ts_GsnAddr(sgsn_ip_sign),
483 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
484 alt_ggsn_addr_controlPane := omit,
485 alt_ggsn_addr_traffic := omit,
486 qualityOfServiceProfile := ts_QosDefault,
487 tft := omit,
488 triggerId := omit,
489 omcId := omit,
490 commonFlags := omit,
491 ratType := f_ts_RATType(ratType),
492 userLocationInformation := uli,
493 mS_TimeZone := omit,
494 additionalTraceInfo := omit,
495 directTunnelFlags := omit,
496 evolvedAllocationRetentionPriorityI := omit,
497 extendedCommonFlags := omit,
498 userCSGInformation := omit,
499 aPN_AMBR := omit,
500 signallingPriorityIndication := omit,
501 cN_OperatorSelectionEntity := omit,
502 private_extension_gtpc := omit
503 }
504 }
505 }
506
507 template Gtp1cUnitdata ts_GTPC_UpdatePDP(GtpPeer peer, OCT4 teid, uint16_t seq, hexstring imsi,
508 OCT1 restart_ctr, OCT4 teid_data,
509 OCT4 teid_ctrl, BIT4 nsapi, octetstring sgsn_ip_sign,
510 octetstring sgsn_ip_data,
511 template ProtConfigOptions pco := omit,
512 template (omit) OCT1 ratType := omit,
513 template (omit) UserLocationInformation uli := omit) := {
514 peer := peer,
515 gtpc := ts_GTP1C_PDU(updatePDPContextRequest, teid,
516 valueof(ts_UpdatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
517 nsapi, sgsn_ip_sign,
518 sgsn_ip_data, pco, ratType, uli)), seq)
519 }
520
521
Harald Welteeded9ad2018-02-17 20:57:34 +0100522 template NSAPI_GTPC ts_NSAPI(BIT4 nsapi) := {
523 type_gtpc := '14'O,
524 nsapi := nsapi,
525 unused := '0000'B
526 }
527
528 template ReorderingRequired ts_ReorderReq(boolean req := false) := {
529 type_gtpc := '08'O,
530 reordreq := bool2bit(req),
531 spare := '0000000'B
532 }
533
534 template GTPC_PDUs ts_CreatePdpRespPDU(OCT1 cause, OCT4 teid_data, OCT4 teid_ctrl, BIT4 nsapi,
535 octetstring ggsn_ip_sign, octetstring ggsn_ip_data,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100536 OCT4 chg_id, template EndUserAddress eua := omit,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200537 template Recovery_gtpc recovery := omit,
Harald Welteeded9ad2018-02-17 20:57:34 +0100538 template ProtConfigOptions pco := omit) := {
539 createPDPContextResponse := {
540 cause := { '00'O, cause },
541 reorderingRequired := ts_ReorderReq(false),
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200542 recovery := recovery,
Harald Welteeded9ad2018-02-17 20:57:34 +0100543 teidDataI := {
544 type_gtpc := '00'O,
545 teidDataI := teid_data
546 },
547 teidControlPlane := {
548 type_gtpc := '00'O,
549 teidControlPlane := teid_ctrl
550 },
551 nsapi := ts_NSAPI(nsapi),
Harald Welte7aff2ca2018-02-18 15:34:50 +0100552 chargingID := {
553 type_gtpc := '7F'O,
554 chargingID := chg_id
555 },
Harald Welteeded9ad2018-02-17 20:57:34 +0100556 endUserAddress := eua,
557 protConfigOptions := pco,
558 ggsn_addr_controlPlane := ts_GsnAddr(ggsn_ip_sign),
559 ggsn_addr_traffic := ts_GsnAddr(ggsn_ip_data),
560 alt_ggsn_addr_controlPane := omit,
561 alt_ggsn_addr_traffic := omit,
562 qualityOfServiceProfile := ts_QosDefault,
563 commonFlags := omit,
564 aPN_Restriction := omit,
565 mS_InfoChangeReportingAction := omit,
566 bearerControlMode := omit,
567 evolvedAllocationRetentionPriorityI := omit,
568 extendedCommonFlag := omit,
569 csg_information_reporting_action := omit,
570 aPN_AMBR := omit,
571 gGSN_BackOffTime := omit,
572 private_extension_gtpc := omit
573 }
574 }
575
576 template Gtp1cUnitdata ts_GTPC_CreatePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
577 OCT1 cause,
578 OCT4 teid_ctrl, OCT4 teid_data,
579 BIT4 nsapi, octetstring ggsn_ip_sign,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100580 octetstring ggsn_ip_data, OCT4 chg_id,
Harald Welteeded9ad2018-02-17 20:57:34 +0100581 template EndUserAddress eua := omit,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200582 template Recovery_gtpc recovery := omit,
Harald Welteeded9ad2018-02-17 20:57:34 +0100583 template ProtConfigOptions pco := omit) := {
584 peer := peer,
585 gtpc := ts_GTP1C_PDU(createPDPContextResponse, teid,
586 valueof(ts_CreatePdpRespPDU(cause, teid_data, teid_ctrl, nsapi,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100587 ggsn_ip_sign, ggsn_ip_data, chg_id,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200588 eua, recovery, pco)), seq)
Harald Welteeded9ad2018-02-17 20:57:34 +0100589 }
590
Harald Weltec69cf4e2018-02-17 20:57:02 +0100591 /* PCO send base template */
592 template ProtConfigOptions ts_PCO := {
593 type_gtpc := '84'O,
594 lengthf := 0,
595 configProtocol := '000'B,
596 spare := '0000'B,
597 extension0 := '1'B,
598 protocols := {}
599 }
600 /* PCO receive base template */
601 template ProtConfigOptions tr_PCO := {
602 type_gtpc := '84'O,
603 lengthf := ?,
604 configProtocol := '000'B,
605 spare := ?,
606 extension0 := '1'B,
607 protocols := {}
608 }
609
610 template ProtConfigOptions ts_PCO_IPv6_DNS modifies ts_PCO := {
611 protocols := {
612 { protocolID := '0003'O, lengthProtoID := 0, protoIDContents := ''O }
613 }
614 }
615 template ProtConfigOptions tr_PCO_IPv6_DNS_resp(template OCT16 contents) modifies tr_PCO := {
616 protocols := {
617 *, { protocolID := '0003'O, lengthProtoID := 16, protoIDContents := contents }, *
618 }
619 }
620
621 template ProtConfigOptions ts_PCO_IPv4_DNS_IPCP modifies ts_PCO := {
622 protocols := {
623 /* dummy PAP entry to check if our parser in the GGSN can properly iterate over
624 * the list of protocols, see Change-Id Icc2e6716c33d78d3c3e000f529806228d8aa155e */
625 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
626 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
627 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
628 }
629 }
630
Philipp Maier33e52612018-05-30 17:22:02 +0200631 template ProtConfigOptions ts_PCO_IPv4_PRI_DNS_IPCP modifies ts_PCO := {
632 protocols := {
633 /* dummy PAP entry to check if our parser can cope with a single primary DNS entry
634 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
635 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
636 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
637 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) }
638 }
639 }
640 template ProtConfigOptions ts_PCO_IPv4_SEC_DNS_IPCP modifies ts_PCO := {
641 protocols := {
642 /* dummy PAP entry to check if our parser can cope with a single secondary DNS entry
643 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
644 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
645 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
646 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
647 }
648 }
649 template ProtConfigOptions ts_PCO_IPv4_SEPARATE_DNS_IPCP modifies ts_PCO := {
650 protocols := {
651 /* dummy PAP entry to check if our parser can cope with a primary and secondary DNS
652 * in separate IPCP containers OS#3381 */
653 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
654 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
655 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) },
656 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
657 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
658 }
659 }
660
Harald Weltec69cf4e2018-02-17 20:57:02 +0100661 template ProtocolElement tr_PCO_Proto(OCT2 prot_id) := {
662 protocolID := prot_id,
663 lengthProtoID := ?,
664 protoIDContents := ?
665 }
Harald Weltef8298542019-04-10 10:15:28 +0200666 template ProtocolElement ts_PCOelem_PAP_broken := {
667 protocolID := 'C023'O,
668 lengthProtoID := 60,
669 /* PPP Password Authentication Protocol containing incorrect Peer-Id-Length set to 4 (6-7 should be the valid one), see OS#3914. */
670 protoIDContents := '0100003c'O & '0444435338323700bc1c08087c1508083e00790000150808fd06000001000000000000000000000000000000000000000000000000000000'O
671 }
672 template ProtConfigOptions ts_PCO_PAP_IPv4_DNS modifies ts_PCO := {
673 protocols := {
674 ts_PCOelem_PAP_broken,
675 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
676 }
677 }
Harald Weltec69cf4e2018-02-17 20:57:02 +0100678 template ProtConfigOptions tr_PCO_Contains(OCT2 prot_id) modifies tr_PCO := {
679 protocols := { *, tr_PCO_Proto(prot_id), * }
680 }
681
682 template ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := {
683 protocols := {
684 { protocolID := '000d'O, lengthProtoID := 0, protoIDContents := ''O }
685 }
686 }
687 template ProtConfigOptions tr_PCO_IPv4_DNS_CONT_resp(template OCT4 contents) modifies tr_PCO := {
688 protocols := {
689 *, { protocolID := '000d'O, lengthProtoID := 4, protoIDContents := contents }, *
690 }
691 }
692
693 /* extract a given protocol payload from PCO */
694 function f_PCO_extract_proto(ProtConfigOptions pco, OCT2 protocol, integer nth_match := 1) return octetstring {
695 var integer i;
696 var integer num_matches := 0;
697 for (i := 0; i < lengthof(pco.protocols); i := i + 1) {
698 if (pco.protocols[i].protocolID == protocol) {
699 num_matches := num_matches + 1;
700 if (num_matches == nth_match) {
701 return pco.protocols[i].protoIDContents;
702 }
703 }
704 }
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200705 setverdict(fail, "Could not extract protocol payload from protocol ", protocol);
706 mtc.stop;
Harald Weltec69cf4e2018-02-17 20:57:02 +0100707 return ''O;
708 }
709
710 template IpcpPacket tr_IPCP(template LcpCode code, template uint8_t identifier,
711 template IpcpOptionList opts) := {
712 code := code,
713 identifier := identifier,
714 len := ?,
715 options := opts
716 }
717 template IpcpOption tr_IPCP_PrimaryDns(template OCT4 addr) := {
718 code := IPCP_OPT_PrimaryDNS,
719 len := 6,
720 data := addr
721 }
722 template IpcpOption tr_IPCP_SecondaryDns(template OCT4 addr) := {
723 code := IPCP_OPT_SecondaryDNS,
724 len := 6,
725 data := addr
726 }
727 template IpcpPacket tr_IPCP_Ack_DNS(template uint8_t identifier := ?, template OCT4 dns1 := ?,
728 template OCT4 dns2 := ?) :=
729 tr_IPCP(LCP_Configure_Ack, identifier,
730 { *, tr_IPCP_PrimaryDns(dns1), *, tr_IPCP_SecondaryDns(dns2), * });
731
732 template IpcpPacket ts_IPCP(LcpCode code, uint8_t identifier, template IpcpOptionList opts) := {
733 code := code,
734 identifier := identifier,
735 len := 0, /* overwritten */
736 options := opts
737 }
738 template IpcpPacket ts_IPCP_ReqDNS(uint8_t identifier := 0) :=
739 ts_IPCP(LCP_Configure_Request, identifier,
740 { tr_IPCP_PrimaryDns('00000000'O), tr_IPCP_SecondaryDns('00000000'O) });
741
Philipp Maier33e52612018-05-30 17:22:02 +0200742 template IpcpPacket ts_IPCP_ReqDNS_Primary(uint8_t identifier := 0) :=
743 ts_IPCP(LCP_Configure_Request, identifier,
744 { tr_IPCP_PrimaryDns('00000000'O) });
745 template IpcpPacket ts_IPCP_ReqDNS_Secondary(uint8_t identifier := 0) :=
746 ts_IPCP(LCP_Configure_Request, identifier,
747 { tr_IPCP_SecondaryDns('00000000'O) });
748
Harald Welte57b9b7f2018-02-18 22:28:13 +0100749 function f_teardown_ind_IE(in template (omit) BIT1 ind) return template (omit) TearDownInd {
750 if (istemplatekind(ind, "omit")) {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100751 return omit;
752 }
Harald Weltec69cf4e2018-02-17 20:57:02 +0100753 var TearDownInd ret := {
754 type_gtpc := '13'O,
755 tdInd := valueof(ind),
756 spare:= '0000000'B
757 }
758 return ret;
759 }
760
Harald Welte57b9b7f2018-02-18 22:28:13 +0100761 template GTPC_PDUs ts_DeletePdpPDU(BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100762 deletePDPContextRequest := {
763 cause := omit,
764 tearDownIndicator := f_teardown_ind_IE(teardown_ind),
765 nsapi := {
766 type_gtpc := '14'O,
767 nsapi := nsapi,
768 unused := '0000'B
769 },
770 protConfigOptions := omit,
771 userLocationInformation := omit,
772 mS_TimeZone := omit,
773 extendedCommonFlags := omit,
774 uLI_Timestamp := omit,
775 private_extension_gtpc := omit
776 }
777 }
778
779 template Gtp1cUnitdata ts_GTPC_DeletePDP(GtpPeer peer, uint16_t seq, OCT4 teid,
Harald Welte57b9b7f2018-02-18 22:28:13 +0100780 BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100781 peer := peer,
782 gtpc := ts_GTP1C_PDU(deletePDPContextRequest, teid,
783 valueof(ts_DeletePdpPDU(nsapi, teardown_ind)), seq)
784 }
785
Harald Welte6f203162018-02-18 22:04:55 +0100786 template GTPC_PDUs ts_DeletePdpRespPDU(OCT1 cause,
787 template ProtConfigOptions pco := omit) := {
788 deletePDPContextResponse := {
789 cause := { '00'O, cause },
790 protConfigOptions := pco,
791 userLocationInformation := omit,
792 mS_TimeZone := omit,
793 uLI_Timestamp := omit,
794 private_extension_gtpc := omit
795 }
796 }
797
798 template Gtp1cUnitdata ts_GTPC_DeletePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
799 OCT1 cause,
800 template ProtConfigOptions pco := omit) := {
801 peer := peer,
802 gtpc := ts_GTP1C_PDU(deletePDPContextResponse, teid,
803 valueof(ts_DeletePdpRespPDU(cause, pco)), seq)
804 }
805
806
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200807 /* GTP-C RIM */
808
809 template (value) RIM_Application_Identity_GTPC ts_GTPC_RIM_Application_Identity(OCT1 app_id) := {
810 iEI := '4B'O,
811 ext := '1'B,
812 lengthIndicator := {
813 length1 := 1
814 },
815 rIMApplicationIdentity := app_id
816 }
817 /* 3GPP TS 48.018 11.3.62 */
818 template (value) RIM_Sequence_Number_GTPC ts_GTPC_RIM_Sequence_Number(integer seq) := {
819 iEI := '4C'O,
820 ext := '1'B,
821 lengthIndicator := {
822 length1 := 4
823 },
824 rIMSequenceNumber := int2oct(seq, 4)
825 }
826 template (value) RIM_PDU_Indications_GTPC ts_GTPC_RIM_PDU_Indications(boolean ack, BIT3 type_ext) := {
827 iEI := '4F'O,
828 ext := '1'B,
829 lengthIndicator := {
830 length1 := 1
831 },
832 ack := bool2bit(ack),
833 pDU_Type_Extension := type_ext,
834 reserved := '0000'B
835 }
836 /* 3GPP TS 48.018 11.3.67 */
837 template (value) RIM_Protocol_Version_Number_GTPC ts_GTPC_RIM_Protocol_Version_Number(integer ver) := {
838 iEI := '55'O,
839 ext := '1'B,
840 lengthIndicator := {
841 length1 := 1
842 },
843 rIMProtocolVersionNumber := int2oct(ver, 1)
844 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100845 function tr_GTPC_Cell_Identifier_V(template GTP_CellId cid) return template Cell_Identifier_V_GTPC {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200846 var template Cell_Identifier_V_GTPC ret := {
847 mccDigit1 := ?,
848 mccDigit2 := ?,
849 mccDigit3 := ?,
850 mncDigit3 := ?,
851 mncDigit1 := ?,
852 mncDigit2 := ?,
853 lac := ?,
854 rac := ?,
855 cI_value := ?
856 }
857 if (istemplatekind(cid, "omit")) {
858 return omit;
859 } else if (istemplatekind(cid, "*")) {
860 return *;
861 } else if (istemplatekind(cid, "?")) {
862 return ?;
863 }
864 if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) {
865 if (isvalue(cid.ra_id.lai.mcc_mnc)) {
866 ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0];
867 ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1];
868 ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2];
869 ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3];
870 ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4];
871 ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5];
872 }
873 if (isvalue(cid.ra_id.lai.lac)) {
874 ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2);
875 }
876 }
877 if (isvalue(cid) and isvalue(cid.ra_id)) {
878 ret.rac := f_oct_or_wc(cid.ra_id.rac, 1);
879 }
880 if (isvalue(cid)) {
881 ret.cI_value := f_oct_or_wc(cid.cell_id, 2);
882 }
883 return ret;
884 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100885 template (value) Cell_Identifier_V_GTPC ts_GTPC_Cell_Identifier_V(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200886 mccDigit1 := cid.ra_id.lai.mcc_mnc[0],
887 mccDigit2 := cid.ra_id.lai.mcc_mnc[1],
888 mccDigit3 := cid.ra_id.lai.mcc_mnc[2],
889 mncDigit3 := cid.ra_id.lai.mcc_mnc[3],
890 mncDigit1 := cid.ra_id.lai.mcc_mnc[4],
891 mncDigit2 := cid.ra_id.lai.mcc_mnc[5],
892 lac := int2oct(cid.ra_id.lai.lac, 2),
893 rac := int2oct(cid.ra_id.rac, 1),
894 cI_value := int2oct(cid.cell_id, 2)
895 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100896 template RIM_Routing_Address_GTPC t_GTPC_RIM_Routing_Address_cid(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200897 cell_Identifier := ts_GTPC_Cell_Identifier_V(cid)
898 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100899 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 +0200900 var template ENB_Identifier ret := {
901 mccDigit1 := ?,
902 mccDigit2 := ?,
903 mccDigit3 := ?,
904 mncDigit3 := ?,
905 mncDigit1 := ?,
906 mncDigit2 := ?,
907 tAC := ?,
908 globalENB_ID := ?
909 }
910 if (istemplatekind(cid, "omit") and istemplatekind(tac, "omit") and istemplatekind(gnbid, "omit")) {
911 return omit;
912 } else if (istemplatekind(cid, "*") and istemplatekind(tac, "*") and istemplatekind(gnbid, "*")) {
913 return *;
914 } else if (istemplatekind(cid, "?") and istemplatekind(tac, "?") and istemplatekind(gnbid, "?")) {
915 return ?;
916 }
917 if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) {
918 if (isvalue(cid.ra_id.lai.mcc_mnc)) {
919 ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0];
920 ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1];
921 ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2];
922 ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3];
923 ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4];
924 ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5];
925 }
926 }
927 if (isvalue(tac)) {
928 ret.tAC := int2oct(valueof(tac), 2);
929 }
930 if (isvalue(gnbid)) {
931 ret.globalENB_ID := gnbid;
932 }
933
934 return ret;
935 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100936 template (value) ENB_Identifier ts_GTPC_ENB_Identifier(GTP_CellId cid, integer tac, octetstring gnbid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200937 mccDigit1 := cid.ra_id.lai.mcc_mnc[0],
938 mccDigit2 := cid.ra_id.lai.mcc_mnc[1],
939 mccDigit3 := cid.ra_id.lai.mcc_mnc[2],
940 mncDigit3 := cid.ra_id.lai.mcc_mnc[3],
941 mncDigit1 := cid.ra_id.lai.mcc_mnc[4],
942 mncDigit2 := cid.ra_id.lai.mcc_mnc[5],
943 tAC := int2oct(tac, 2),
944 globalENB_ID := gnbid
945 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100946 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 +0200947 eNB_Identifier := ts_GTPC_ENB_Identifier(cid, tac, gnbid)
948 }
949 template RIM_Routing_Information_GTPC
950 tr_GTPC_RIM_Routing_Information(HEX1 addr_discr, template RIM_Routing_Address_GTPC addr) := {
951 iEI := '54'O,
952 ext := '1'B,
953 lengthIndicator := {
954 length1 := ?
955 },
956 rIMRoutingAddressDiscriminator := addr_discr,
957 spare := '0'H,
958 rIM_Routing_Address := addr
959 }
960 template (value) RIM_Routing_Information_GTPC
961 ts_GTPC_RIM_Routing_Information(HEX1 addr_discr, template (value) RIM_Routing_Address_GTPC addr) := {
962 iEI := '54'O,
963 ext := '1'B,
964 lengthIndicator := {
965 length1 := 0 /* overwritten */
966 },
967 rIMRoutingAddressDiscriminator := addr_discr,
968 spare := '0'H,
969 rIM_Routing_Address := addr
970 }
971 /* 3GPP TS 48.018 11.3.63.1.1 */
972 template RAN_Information_Request_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100973 tr_GTPC_RAN_Information_Request_Application_Container_NACC(template GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200974 iEI := '4D'O,
975 ext := '1'B,
976 lengthIndicator := {
977 length1 := ?
978 },
979 reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid)
980 }
981 template (value) RAN_Information_Request_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100982 ts_GTPC_RAN_Information_Request_Application_Container_NACC(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200983 iEI := '4D'O,
984 ext := '1'B,
985 lengthIndicator := {
986 length1 := 0 /* overwritten */
987 },
988 reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid)
989 }
990 /* 3GPP TS 48.018 11.3.63.1 */
991 template RAN_Information_Request_Application_Container_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100992 tru_GTPC_RAN_Information_Request_Application_Container_NACC(template GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200993 nacc := tr_GTPC_RAN_Information_Request_Application_Container_NACC(cid)
994 }
995 template (value) RAN_Information_Request_Application_Container_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100996 tsu_GTPC_RAN_Information_Request_Application_Container_NACC(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200997 nacc := ts_GTPC_RAN_Information_Request_Application_Container_NACC(cid)
998 }
999 /* 3GPP TS 48.018 11.3.63.2.1 */
1000 template RAN_Information_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001001 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 +02001002 iEI := '4E'O,
1003 ext := '1'B,
1004 lengthIndicator := {
1005 length1 := ?
1006 },
1007 reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid),
1008 typeBit := bool2bit(psi_type),
1009 number_of_SI_PSI := int2bit(si_psi_num, 7),
1010 sI_PSI := si_psi
1011 }
1012 template (value) RAN_Information_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001013 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 +02001014 iEI := '4E'O,
1015 ext := '1'B,
1016 lengthIndicator := {
1017 length1 := 0 /* overwritten */
1018 },
1019 reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid),
1020 typeBit := bool2bit(psi_type),
1021 number_of_SI_PSI := int2bit(si_psi_num, 7),
1022 sI_PSI := si_psi
1023 }
1024
1025 /* RAN_Information_Request */
1026 template (value) RAN_Information_Request_RIM_Container_GTPC
1027 ts_GTPC_RAN_Information_Request_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id,
1028 template (value) RIM_Sequence_Number_GTPC seq,
1029 template (value) RIM_PDU_Indications_GTPC ind,
1030 template (omit) RIM_Protocol_Version_Number_GTPC ver := omit,
1031 template (omit) RAN_Information_Request_Application_Container_GTPC app_cont := omit,
1032 template (omit) SON_TransferApplicationIdentity son_app_id := omit) := {
1033 iEI := '57'O,
1034 ext := '1'B,
1035 lengthIndicator := {
1036 length1 := 0 /* overwritten */
1037 },
1038 rIM_Application_Identity := app_id,
1039 rIM_Sequence_Number := seq,
1040 rIM_PDU_Indications := ind,
1041 rIM_Protocol_Version_Number := ver,
1042 application_Container := app_cont,
1043 sON_TransferApplicationIdentity := son_app_id
1044 }
1045 template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC
1046 ts_GTPC_RAN_Information_Request(template (value) RIM_Routing_Information_GTPC dest,
1047 template (value) RIM_Routing_Information_GTPC src,
1048 template (value) RAN_Information_Request_RIM_Container_GTPC cont) := {
1049 bssgpPduType := '71'O,
1050 destination_Cell_Identifier := dest,
1051 source_Cell_Identifier := src,
1052 rIM_Container := cont
1053 }
1054 template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO_REQ(template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC pdu) := {
1055 type_gtpc := '90'O,
1056 lengthf := 0, /* FIXME */
1057 rANTransparentContainerField := {
1058 pDU_BSSGP_RAN_INFORMATION_REQUEST := pdu
1059 }
1060 }
1061
1062 /* RAN_Information */
1063 template ApplContainer_or_ApplErrContainer_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001064 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 +02001065 application_Container := tr_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi)
1066 }
1067 template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001068 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 +02001069 application_Container := ts_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi)
1070 }
1071 template ApplContainer_or_ApplErrContainer_GTPC
1072 tru_GTPC_ApplContainer_or_ApplErrContainer_NACC(template ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := {
1073 nacc := cont
1074 }
1075 template (value) ApplContainer_or_ApplErrContainer_GTPC
1076 tsu_GTPC_ApplContainer_or_ApplErrContainer_NACC(template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := {
1077 nacc := cont
1078 }
1079 template RAN_Information_RIM_Container_GTPC
1080 tr_GTPC_RAN_Information_RIM_Container(template RIM_Application_Identity_GTPC app_id,
1081 template RIM_Sequence_Number_GTPC seq,
1082 template RIM_PDU_Indications_GTPC ind,
1083 template RIM_Protocol_Version_Number_GTPC ver := omit,
1084 template ApplContainer_or_ApplErrContainer_GTPC app_cont := omit,
1085 template SON_TransferApplicationIdentity son_app_id := omit) := {
1086 iEI := '58'O,
1087 ext := '1'B,
1088 lengthIndicator := {
1089 length1 := ?
1090 },
1091 rIM_Application_Identity := app_id,
1092 rIM_Sequence_Number := seq,
1093 rIM_PDU_Indications := ind,
1094 rIM_Protocol_Version_Number := ver,
1095 applContainer_or_ApplErrContainer := app_cont,
1096 sON_TransferApplicationIdentity := son_app_id
1097 }
1098 template (value) RAN_Information_RIM_Container_GTPC
1099 ts_GTPC_RAN_Information_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id,
1100 template (value) RIM_Sequence_Number_GTPC seq,
1101 template (value) RIM_PDU_Indications_GTPC ind,
1102 template (omit) RIM_Protocol_Version_Number_GTPC ver := omit,
1103 template (omit) ApplContainer_or_ApplErrContainer_GTPC app_cont := omit,
1104 template (omit) SON_TransferApplicationIdentity son_app_id := omit) := {
1105 iEI := '58'O,
1106 ext := '1'B,
1107 lengthIndicator := {
1108 length1 := 0 /* overwritten */
1109 },
1110 rIM_Application_Identity := app_id,
1111 rIM_Sequence_Number := seq,
1112 rIM_PDU_Indications := ind,
1113 rIM_Protocol_Version_Number := ver,
1114 applContainer_or_ApplErrContainer := app_cont,
1115 sON_TransferApplicationIdentity := son_app_id
1116 }
1117 template PDU_BSSGP_RAN_INFORMATION_GTPC
1118 tr_GTPC_RAN_Information(template RIM_Routing_Information_GTPC dest,
1119 template RIM_Routing_Information_GTPC src,
1120 template RAN_Information_RIM_Container_GTPC cont) := {
1121 bssgpPduType := '70'O,
1122 destination_Cell_Identifier := dest,
1123 source_Cell_Identifier := src,
1124 rIM_Container := cont
1125 }
1126 template (value) PDU_BSSGP_RAN_INFORMATION_GTPC
1127 ts_GTPC_RAN_Information(template (value) RIM_Routing_Information_GTPC dest,
1128 template (value) RIM_Routing_Information_GTPC src,
1129 template (value) RAN_Information_RIM_Container_GTPC cont) := {
1130 bssgpPduType := '70'O,
1131 destination_Cell_Identifier := dest,
1132 source_Cell_Identifier := src,
1133 rIM_Container := cont
1134 }
1135 template RANTransparentContainer tr_RANTransparentContainer_RAN_INFO(template PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := {
1136 type_gtpc := '90'O,
1137 lengthf := ?,
1138 rANTransparentContainerField := {
1139 pDU_BSSGP_RAN_INFORMATION := pdu
1140 }
1141 }
1142 template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO(template (value) PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := {
1143 type_gtpc := '90'O,
1144 lengthf := 0, /* overwritten */
1145 rANTransparentContainerField := {
1146 pDU_BSSGP_RAN_INFORMATION := pdu
1147 }
1148 }
1149
1150 template RANTransparentContainer tr_RANTransparentContainer(template RANTransparentContainerField rANTransparentContainerField) := {
1151 type_gtpc := '90'O,
1152 lengthf := ?,
1153 rANTransparentContainerField := rANTransparentContainerField
1154 }
1155 template (value) RANTransparentContainer ts_RANTransparentContainer(template (value) RANTransparentContainerField rANTransparentContainerField) := {
1156 type_gtpc := '90'O,
1157 lengthf := 0, /* overwritten */
1158 rANTransparentContainerField := rANTransparentContainerField
1159 }
1160 template GTPC_PDUs tr_RANInfoRelay(template RANTransparentContainer transparentContainer) := {
1161 ranInformationRelay := {
1162 transparentContainer := transparentContainer,
1163 rIM_RoutingAddress := *,
1164 rIM_RoutingAddress_Discriminator := *,
1165 private_extension_gtpc := *
1166 }
1167 }
1168 template (value) GTPC_PDUs ts_RANInfoRelay(template (value) RANTransparentContainer transparentContainer) := {
1169 ranInformationRelay := {
1170 transparentContainer := transparentContainer,
1171 rIM_RoutingAddress := omit,
1172 rIM_RoutingAddress_Discriminator := omit,
1173 private_extension_gtpc := omit
1174 }
1175 }
1176 template Gtp1cUnitdata
1177 tr_GTPC_RANInfoRelay(template GtpPeer peer,
1178 template RANTransparentContainer transparentContainer) := {
1179 peer := peer,
1180 gtpc := tr_GTP1C_PDU(rANInformationRelay, '00000000'O, tr_RANInfoRelay(transparentContainer))
1181 }
1182 template (value) Gtp1cUnitdata
1183 ts_GTPC_RANInfoRelay(template (value) GtpPeer peer,
1184 template (value) RANTransparentContainer transparentContainer) := {
1185 peer := peer,
1186 gtpc := ts_GTP1C_PDU(rANInformationRelay, '00000000'O, valueof(ts_RANInfoRelay(transparentContainer)), 0)
1187 }
1188
1189
1190 template RAN_Information_Request_RIM_Container_GTPC
1191 tr_GTPC_RAN_Information_Request_RIM_Container(template RIM_Application_Identity_GTPC app_id := ?,
1192 template RIM_Sequence_Number_GTPC seq := ?,
1193 template RIM_PDU_Indications_GTPC ind := ?,
1194 template RIM_Protocol_Version_Number_GTPC ver := *,
1195 template RAN_Information_Request_Application_Container_GTPC app_cont := *,
1196 template SON_TransferApplicationIdentity son_app_id := *) := {
1197 iEI := '57'O,
1198 ext := '1'B,
1199 lengthIndicator := {
1200 length1 := ?
1201 },
1202 rIM_Application_Identity := app_id,
1203 rIM_Sequence_Number := seq,
1204 rIM_PDU_Indications := ind,
1205 rIM_Protocol_Version_Number := ver,
1206 application_Container := app_cont,
1207 sON_TransferApplicationIdentity := son_app_id
1208 }
Harald Weltec69cf4e2018-02-17 20:57:02 +01001209
1210 /* GTP-U */
1211
1212 template PDU_GTPU tr_GTP1U_PDU(template OCT1 msg_type, template OCT4 teid, template GTPU_IEs ies := ?) := {
1213 pn_bit := ?,
1214 s_bit := ?,
1215 e_bit := ?,
1216 spare := ?,
1217 /* Protocol Type flag (PT) shall be set to '1' in GTP */
1218 pt := '1'B,
1219 /* Version shall be set to decimal 1 ('001'). */
1220 version := '001'B,
1221 messageType := msg_type,
1222 lengthf := ?,
1223 teid := teid,
1224 opt_part := *,
1225 gtpu_IEs := ies
1226 }
1227
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001228 function f_GTPU_s_bit(template (omit) uint16_t seq) return BIT1 {
1229 if (istemplatekind(seq, "omit")) {
1230 return '0'B;
1231 }
1232 return '1'B;
1233 }
1234
1235 function f_GTPU_opt_part(template (omit) uint16_t seq) return template (omit) GTPU_Header_optional_part {
1236 if (istemplatekind(seq, "omit")) {
1237 return omit;
1238 }
1239 var GTPU_Header_optional_part ret := {
1240 sequenceNumber := int2oct(valueof(seq), 2),
1241 npduNumber := '00'O,
1242 nextExtHeader := '00'O,
1243 gTPU_extensionHeader_List := omit
1244 };
1245 return ret;
1246 }
1247
Harald Weltec69cf4e2018-02-17 20:57:02 +01001248 /* generalized GTP-U send template */
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001249 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 +01001250 /* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN
1251 * flag is set to 1. */
1252 pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */
1253 /* If the Sequence Number flag (S) is set to '1' the sequence number field is present and
1254 * meaningful otherwise it is set to '0'. For GTP-U messages Echo Request, Echo Response,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001255 * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'.
1256 *
1257 * Note that the caller must ensure that these conditions hold.
1258 * The caller can either pass a sequence number (we set s_bit to '1'B) when appropriate,
1259 * or may omit the sequence number (we set s_bit to '0'B). */
1260 s_bit := f_GTPU_s_bit(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +01001261 /* Extension header presence */
1262 e_bit := '0'B,
1263 spare := '0'B,
1264 /* Protocol Type flag (PT) shall be set to '1' in GTP */
1265 pt := '1'B,
1266 /* Version shall be set to decimal 1 ('001'). */
1267 version := '001'B,
1268 messageType := msg_type,
1269 lengthf := 0, /* we assume encoder overwrites this */
1270 teid := teid,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001271 opt_part := f_GTPU_opt_part(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +01001272 gtpu_IEs := ies
1273 }
1274
1275 template Gtp1uUnitdata tr_GTPU_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid) := {
1276 peer := peer,
1277 gtpu := tr_GTP1U_PDU(msg_type, teid)
1278 }
1279
1280
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001281 /* template matching reception of GTP-U echo-request/response */
Harald Weltec69cf4e2018-02-17 20:57:02 +01001282 template Gtp1uUnitdata tr_GTPU_PING(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoRequest, '00000000'O);
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001283 template Gtp1uUnitdata tr_GTPU_PONG(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoResponse, '00000000'O);
Harald Weltec69cf4e2018-02-17 20:57:02 +01001284
1285 /* template matching reception of GTP-U GPDU */
1286 template GTPU_IEs t_GPDU(template octetstring data) := {
1287 g_PDU_IEs := {
1288 data := data
1289 }
1290 }
1291 template Gtp1uUnitdata tr_GTPU_GPDU(template GtpPeer peer, template OCT4 teid, template octetstring data := ?) := {
1292 peer := peer,
1293 gtpu := tr_GTP1U_PDU('FF'O, teid, t_GPDU(data))
1294 }
1295
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001296 template GTPU_IEs ts_UEchoReqPDU := {
1297 echoRequest_IEs := {
1298 private_extension_gtpu := omit
1299 }
1300 }
1301
1302 /* master template for sending a GTP-C echo request */
1303 template (value) Gtp1uUnitdata ts_GTPU_PING(GtpPeer peer, uint16_t seq) := {
1304 peer := peer,
1305 gtpu := ts_GTP1U_PDU(echoRequest, seq, '00000000'O, valueof(ts_UEchoReqPDU))
1306 }
1307
Harald Weltec69cf4e2018-02-17 20:57:02 +01001308 template GTPU_IEs ts_UEchoRespPDU(OCT1 restart_counter) := {
1309 echoResponse_IEs := {
1310 recovery_gtpu := {
1311 type_gtpu := '00'O, /* we assume encoder fixes? */
1312 restartCounter := restart_counter
1313 },
1314 private_extension_gtpu := omit
1315 }
1316 }
1317
1318 /* master template for sending a GTP-U echo response */
1319 template Gtp1uUnitdata ts_GTPU_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
1320 peer := peer,
1321 gtpu := ts_GTP1U_PDU(echoResponse, seq, '00000000'O, valueof(ts_UEchoRespPDU(rest_ctr)))
1322 }
1323
Pau Espin Pedrolf3e25382018-07-18 13:46:40 +02001324 template GSNAddress_gtpu ts_UGsnAddr(octetstring ip_addr) := {
1325 type_gtpu := '85'O,
1326 lengthf := lengthof(ip_addr),
1327 gSNAddressValue := ip_addr
1328 }
1329
1330 template TeidDataI_gtpu ts_UteidDataI(OCT4 teid) := {
1331 type_gtpu := '10'O,
1332 teidDataI := teid
1333 }
1334
1335 template GTPU_IEs ts_UErrorIndication(OCT4 teid, octetstring gsn_addr) := {
1336 errorIndication_IEs := {
1337 teidDataI_gtpu := ts_UteidDataI(teid),
1338 gSNAddress_gtpu := ts_UGsnAddr(gsn_addr),
1339 private_extension_gtpu := omit
1340 }
1341 }
1342
1343 /* master template for sending a GTP-U Error indication */
1344 template Gtp1uUnitdata ts_GTPU_ErrorIndication(GtpPeer peer, uint16_t seq, OCT4 teid, octetstring gsn_addr) := {
1345 peer := peer,
1346 gtpu := ts_GTP1U_PDU('1A'O, seq, '00000000'O, valueof(ts_UErrorIndication(teid, gsn_addr)))
1347 }
1348
Harald Weltec69cf4e2018-02-17 20:57:02 +01001349 /* master template for sending a GTP-U user plane data */
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001350 template Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, template (omit) uint16_t seq, OCT4 teid, octetstring data) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +01001351 peer := peer,
1352 gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }})
1353 }
1354}