blob: f6fda36eb8da19a55c8956e0c002a6742d81d574 [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 Pedrol38968e92022-05-13 16:17:48 +0200122 /* IMEI(SV) IE TS 29.060 7.7.53 */
123 template IMEISV_gtpc ts_IMEISV(template (value) OCT8 imeisv) := {
124 type_gtpc := '9A'O,
125 lengthf := 8,
126 imeisv := imeisv
127 }
128 private function f_ts_IMEISV(template (omit) OCT8 imeisv)
129 return template (omit) IMEISV_gtpc {
130 if (istemplatekind(imeisv, "omit")) {
131 return omit;
132 }
133 return ts_IMEISV(imeisv);
134 }
135
136 template IMEISV_gtpc tr_IMEISV(template (present) OCT8 imeisv) := {
137 type_gtpc := '9A'O,
138 lengthf := 8,
139 imeisv := imeisv
140 }
141
Pau Espin Pedrol535ca262022-05-16 14:07:17 +0200142 // MS Time Zone - 7.7.52
143 template (value) MS_TimeZone ts_MS_TimeZone(template (value) OCT1 timeZone := '00'O,
144 template (value) BIT2 daylightSavingTime := '00'B) := {
145 type_gtpc := '99'O,
146 lengthf := 2,
147 timeZone := timeZone,
148 daylightSavingTime := daylightSavingTime,
149 spare1 := '000'B,
150 sgsnAttempsToUpdateMS := '0'B, /* propietary, use it as spare */
151 spare2 := '00'B
152 }
153 function f_ts_MS_TimeZone(template (omit) OCT1 timeZone, template (omit) BIT2 daylightSavingTime)
154 return template (omit) MS_TimeZone {
155 if (istemplatekind(timeZone, "omit") and istemplatekind(daylightSavingTime, "omit")) {
156 return omit;
157 }
158 if (istemplatekind(timeZone, "omit")) {
159 return ts_MS_TimeZone(daylightSavingTime := daylightSavingTime);
160 }
161 if (istemplatekind(daylightSavingTime, "omit")) {
162 return ts_MS_TimeZone(timeZone);
163 }
164 return ts_MS_TimeZone(timeZone, daylightSavingTime);
165 }
166
167 template (present) MS_TimeZone tr_MS_TimeZone(template (present) OCT1 timeZone := ?,
168 template (present) BIT2 daylightSavingTime := ?) := {
169 type_gtpc := '99'O,
170 lengthf := 2,
171 timeZone := timeZone,
172 daylightSavingTime := daylightSavingTime,
173 spare1 := '000'B,
174 sgsnAttempsToUpdateMS := '0'B, /* propietary, use it as spare */
175 spare2 := '00'B
176 }
177
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200178 /* Charging Characteristics IE TS 29.060 7.7.23 */
179 template ChargingCharacteristics_GTPC ts_ChargingCharacteristics(template (value) OCT2 chargingChar) := {
180 type_gtpc := '1A'O,
181 chargingChar := chargingChar
182 }
183 private function f_ts_ChargingCharacteristics(template (omit) OCT2 chargingChar)
184 return template (omit) ChargingCharacteristics_GTPC {
185 if (istemplatekind(chargingChar, "omit")) {
186 return omit;
187 }
188 return ts_ChargingCharacteristics(chargingChar);
189 }
190
191 template ChargingCharacteristics_GTPC tr_ChargingCharacteristics(template (present) OCT2 chargingChar) := {
192 type_gtpc := '1A'O,
193 chargingChar := chargingChar
194 }
195
196
Philipp Maier1c0c7262023-07-24 10:51:53 +0200197 /* template matching reception of GTP-C unit-data */
Harald Weltec69cf4e2018-02-17 20:57:02 +0100198 template Gtp1cUnitdata tr_GTPC_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdus := ?) := {
199 peer := peer,
200 gtpc := tr_GTP1C_PDU(msg_type, teid, pdus)
201 }
202
203 /* template matching reception of GTP-C echo-request */
204 template Gtp1cUnitdata tr_GTPC_PING(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoRequest, '00000000'O);
205
206 template GTPC_PDUs tr_EchoRespPDU(template OCT1 restart_counter) := {
207 echoResponse := {
208 recovery := tr_Recovery(restart_counter),
209 private_extension_gtpc := *
210 }
211 }
212
213 /* template matching reception of GTP-C echo-response */
214 template Gtp1cUnitdata tr_GTPC_PONG(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoResponse, '00000000'O, tr_EchoRespPDU(?));
215
216 template GTPC_PDUs ts_EchoRespPDU(OCT1 restart_counter) := {
217 echoResponse := {
218 recovery := ts_Recovery(restart_counter),
219 private_extension_gtpc := omit
220 }
221 }
222
223 /* master template for senidng a GTP-C echo response */
224 template Gtp1cUnitdata ts_GTPC_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
225 peer := peer,
226 gtpc := ts_GTP1C_PDU(echoResponse, '00000000'O, valueof(ts_EchoRespPDU(rest_ctr)), seq)
227 }
228
229 template GTPC_PDUs ts_EchoReqPDU := {
230 echoRequest := {
231 private_extension_gtpc := omit
232 }
233 }
234
235 /* master template for sending a GTP-C echo request */
236 template Gtp1cUnitdata ts_GTPC_PING(GtpPeer peer, uint16_t seq) := {
237 peer := peer,
238 gtpc := ts_GTP1C_PDU(echoRequest, '00000000'O, valueof(ts_EchoReqPDU), seq)
239 }
240
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100241 private function f_eua_ipv4_len(template OCT4 ip_addr) return template integer {
242 if (istemplatekind(ip_addr, "omit")) {
243 return 2;
244 } else if (istemplatekind(ip_addr, "*")) {
245 return ?;
246 } else if (istemplatekind(ip_addr, "?")) {
247 return 6;
248 }
249 return 6;
250 }
251
252 private function f_eua_ipv6_len(template OCT16 ip_addr) return template integer {
253 if (istemplatekind(ip_addr, "omit")) {
254 return 2;
255 } else if (istemplatekind(ip_addr, "*")) {
256 return ?;
257 } else if (istemplatekind(ip_addr, "?")) {
258 return 18;
259 }
260 return 18;
261 }
262
263 private function f_eua_ipv4v6_len(template OCT4 ip_addr4, template OCT16 ip_addr6) return template integer {
264 var integer len := 2;
265 if (istemplatekind(ip_addr4, "*") or
266 istemplatekind(ip_addr6, "*")) {
267 return ?;
268 }
269 if (not istemplatekind(ip_addr4, "omit")) {
270 len := len + 4;
271 }
272 if (not istemplatekind(ip_addr6, "omit")) {
273 len := len + 16;
274 }
275 return len;
276 }
277
Harald Weltec69cf4e2018-02-17 20:57:02 +0100278 template EndUserAddress t_EuaIPv4(template OCT4 ip_addr) := {
279 type_gtpc := '80'O,
280 endUserAddress := {
281 endUserAddressIPv4 := {
282 lengthf := 2,
283 pdp_typeorg := '0001'B,
284 spare := '1111'B,
285 pdp_typenum := '21'O,
286 ipv4_address := ip_addr
287 }
288 }
289 }
290 template EndUserAddress t_EuaIPv4Dyn := t_EuaIPv4(omit);
291 template EndUserAddress tr_EuaIPv4(template OCT4 ip_addr) modifies t_EuaIPv4 := {
292 endUserAddress := {
293 endUserAddressIPv4 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100294 lengthf := f_eua_ipv4_len(ip_addr)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100295 }
296 }
297 }
298
299 template EndUserAddress t_EuaIPv6(template OCT16 ip_addr) := {
300 type_gtpc := '80'O,
301 endUserAddress := {
302 endUserAddressIPv6 := {
303 lengthf := 2,
304 pdp_typeorg := '0001'B,
305 spare := '1111'B,
306 pdp_typenum := '57'O,
307 ipv6_address := ip_addr
308 }
309 }
310 }
311 template EndUserAddress t_EuaIPv6Dyn := t_EuaIPv6(omit);
312 template EndUserAddress tr_EuaIPv6(template OCT16 ip_addr) modifies t_EuaIPv6 := {
313 endUserAddress := {
314 endUserAddressIPv6 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100315 lengthf := f_eua_ipv6_len(ip_addr)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100316 }
317 }
318 }
319
Oliver Smithee6a0882019-03-08 11:05:46 +0100320 /* 3GPP TS 29.060 Figure 37A: End User Address Information Element for IPv4v6 (both static) */
321 template EndUserAddress t_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) := {
322 type_gtpc := '80'O,
323 endUserAddress := {
324 endUserAddressIPv4andIPv6 := {
325 lengthf := 2,
326 pdp_typeorg := '0001'B,
327 spare := '1111'B,
328 pdp_typenum := '8D'O,
329 ipv4_address := ip_addr4,
330 ipv6_address := ip_addr6
331 }
332 }
333 }
334 template EndUserAddress t_EuaIPv4Dynv6Dyn := t_EuaIPv4v6(omit, omit);
335 template EndUserAddress tr_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) modifies t_EuaIPv4v6 := {
336 endUserAddress := {
337 endUserAddressIPv4andIPv6 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100338 lengthf := f_eua_ipv4v6_len(ip_addr4, ip_addr6)
Oliver Smithee6a0882019-03-08 11:05:46 +0100339 }
340 }
341 }
342
Harald Weltec69cf4e2018-02-17 20:57:02 +0100343 template AccessPointName ts_APN(octetstring apn) := {
344 type_gtpc := '83'O,
345 lengthf := lengthof(apn),
346 apn_value := apn
347 }
348
349 template GSN_Address_GTPC ts_GsnAddr(octetstring ip_addr) := {
350 type_gtpc := '85'O,
351 lengthf := lengthof(ip_addr),
352 addressf := ip_addr
353 }
354
355 template MSISDN ts_Msisdn(octetstring msisdn) := {
356 type_gtpc := '86'O,
357 lengthf := lengthof(msisdn),
358 msisdn := msisdn
359 }
360
361 template QualityOfServiceProfile ts_QosDefault := {
362 type_gtpc := '87'O,
Pau Espin Pedrol7d58b082022-06-07 13:30:03 +0200363 lengthf := 17,
Harald Weltec69cf4e2018-02-17 20:57:02 +0100364 allocRetensionPrio := '00'O,
365 qos_ProfileValue := {
366 reliabilityClass := '011'B,
367 delayClass := '001'B,
368 spare1 := '00'B,
369 precedenceClass := '010'B,
370 spare2 := '0'B,
371 peakThroughput := '1001'B,
372 meanThroughput := '11111'B,
373 spare3 := '000'B,
Pau Espin Pedrol7d58b082022-06-07 13:30:03 +0200374 deliverErroneusSDU := '010'B, /* Erroneus SDU are delivered */
375 deliveryOrder := '10'B, /* Without delivery order */
376 trafficClass := '100'B, /* Background */
377 maxSDUSize := '96'O, /* 1500 octets */
378 maxBitrateUplink := 'FE'O, /* 8640, continues in extended octet */
379 maxBitrateDownlink := 'FE'O, /* 8640, continues in extended octet */
380 sduErrorRatio := '0100'B, /* 1x10^-4 */
381 residualBER := '0101'B, /* 1x10^-3 */
382 trafficHandlingPriority := '01'B, /* prio 1 */
383 transferDelay := '000001'B, /* 10 ms */
384 guaranteedBitRateUplink := 'FE'O, /* 8640, continues in extended octet */
385 guaranteedBitRateDownlink := 'FE'O, /* 8640, continues in extended octet */
386 sourceStatisticsDescriptor := '0000'B, /* unknown */
387 signallingIndication := '0'B, /* Not optimized */
388 spare4 := '000'B,
389 maxBitrateDownlinkExt := '5B'O, /* 33 mbps */
390 guaranteedBitRateDownlinkExt := '5B'O, /* 33 mbps */
391 maxBitrateUplinkExt := '6e'O, /* 52 mbps */
392 guaranteedBitRateUplinkExt := '6e'O /* 52 mbps */
Harald Weltec69cf4e2018-02-17 20:57:02 +0100393 }
394 }
395
396 template IMSI_gtpc ts_Imsi(hexstring digits) := {
397 type_gtpc := '02'O,
398 digits := digits,
399 padding := 'F'H
400 }
401
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100402 function f_ts_RATType(template (omit) OCT1 ratType := omit) return template (omit) RATType {
403 var template (omit) RATType rt;
404 if (istemplatekind(ratType, "omit")) {
405 rt := omit;
406 } else {
407 rt := {
408 type_gtpc := '97'O,
409 lengthf := 1,
410 ratTypeValue := ratType
411 };
412 }
413 return rt;
414 }
415
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100416 template (value) GeographicLocationCGI
417 ts_GeographicLocationCGI(template (value) hexstring mcc,
418 template (value) hexstring mnc,
419 template (value) OCT2 lac,
420 template (value) OCT2 cI_value) :=
421 {
422 mccDigit1 := mcc[0],
423 mccDigit2 := mcc[1],
424 mccDigit3 := mcc[2],
425 mncDigit3 := mnc[2], /* 'F'H for 2 digit MNC */
426 mncDigit1 := mnc[0],
427 mncDigit2 := mnc[1],
428 lac := lac,
429 cI_value := cI_value
430 }
431
Harald Weltec69cf4e2018-02-17 20:57:02 +0100432 template GTPC_PDUs ts_CreatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
433 BIT4 nsapi, EndUserAddress eua, octetstring apn,
434 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100435 octetstring msisdn, template ProtConfigOptions pco := omit,
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100436 template (omit) OCT1 ratType := omit,
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200437 template (omit) UserLocationInformation uli := omit,
Pau Espin Pedrol38968e92022-05-13 16:17:48 +0200438 template (omit) OCT2 charging_char := omit,
Pau Espin Pedrol535ca262022-05-16 14:07:17 +0200439 template (omit) OCT8 imeisv := omit,
440 template(omit) MS_TimeZone ms_tz := omit) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100441 createPDPContextRequest := {
442 imsi := ts_Imsi(imsi),
443 rai := omit,
444 recovery := ts_Recovery(restart_ctr),
445 selectionMode := {
446 type_gtpc := '0F'O,
447 selectModeValue := '00'B,
448 spare := '111111'B
449 },
450 teidDataI := {
451 type_gtpc := '00'O,
452 teidDataI := teid_data
453 },
454 teidControlPlane := {
455 type_gtpc := '00'O,
456 teidControlPlane := teid_ctrl
457 },
458 nsapi := {
459 type_gtpc := '00'O,
460 nsapi := nsapi,
461 unused := '0000'B
462 },
463 linked_nsapi := omit,
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200464 charging_char := f_ts_ChargingCharacteristics(charging_char),
Harald Weltec69cf4e2018-02-17 20:57:02 +0100465 trace_ref := omit,
466 trace_type := omit,
467 endUserAddress := eua,
468 accessPointName := ts_APN(apn),
469 protConfigOptions := pco,
470 sgsn_addr_signalling := ts_GsnAddr(sgsn_ip_sign),
471 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
472 msisdn := ts_Msisdn(msisdn),
473 qualityOfServiceProfile := ts_QosDefault,
474 tft := omit,
475 triggerId := omit,
476 omcId := omit,
477 commonFlags := omit,
478 aPN_Restriction := omit,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100479 ratType := f_ts_RATType(ratType),
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100480 userLocationInformation := uli,
Pau Espin Pedrol535ca262022-05-16 14:07:17 +0200481 mS_TimeZone := ms_tz,
Pau Espin Pedrol38968e92022-05-13 16:17:48 +0200482 imeisv := f_ts_IMEISV(imeisv),
Harald Weltec69cf4e2018-02-17 20:57:02 +0100483 camelChargingInformationContainer := omit,
484 additionalTraceInfo := omit,
485 correlationID := omit,
486 evolvedAllocationRetentionPriorityI := omit,
487 extendedCommonFlags := omit,
488 userCSGInformation := omit,
489 aPN_AMBR := omit,
490 signallingPriorityIndication := omit,
491 cN_OperatorSelectionEntity := omit,
492 private_extension_gtpc := omit
493 }
494 }
495
496 template Gtp1cUnitdata ts_GTPC_CreatePDP(GtpPeer peer, uint16_t seq, hexstring imsi,
497 OCT1 restart_ctr, OCT4 teid_data,
498 OCT4 teid_ctrl, BIT4 nsapi, EndUserAddress eua,
499 octetstring apn, octetstring sgsn_ip_sign,
500 octetstring sgsn_ip_data, octetstring msisdn,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100501 template ProtConfigOptions pco := omit,
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100502 template (omit) OCT1 ratType := omit,
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200503 template (omit) UserLocationInformation uli := omit,
Pau Espin Pedrol38968e92022-05-13 16:17:48 +0200504 template (omit) OCT2 charging_char := omit,
Pau Espin Pedrol535ca262022-05-16 14:07:17 +0200505 template (omit) OCT8 imeisv := omit,
506 template(omit) MS_TimeZone ms_tz := omit) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100507 peer := peer,
508 gtpc := ts_GTP1C_PDU(createPDPContextRequest, '00000000'O,
509 valueof(ts_CreatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
510 nsapi, eua, apn, sgsn_ip_sign,
Pau Espin Pedrol38968e92022-05-13 16:17:48 +0200511 sgsn_ip_data, msisdn, pco, ratType, uli,
Pau Espin Pedrol535ca262022-05-16 14:07:17 +0200512 charging_char, imeisv, ms_tz)), seq)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100513 }
514
Harald Welteeded9ad2018-02-17 20:57:34 +0100515
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +0100516 template GTPC_PDUs ts_UpdatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
517 BIT4 nsapi,
518 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
519 template ProtConfigOptions pco := omit,
520 template (omit) OCT1 ratType := omit,
521 template (omit) UserLocationInformation uli := omit) := {
522 updatePDPContextRequest := {
523 updatePDPContextRequestSGSN := {
524 imsi := ts_Imsi(imsi),
525 rai := omit,
526 recovery := ts_Recovery(restart_ctr),
527 teidDataI := {
528 type_gtpc := '00'O,
529 teidDataI := teid_data
530 },
531 teidControlPlane := {
532 type_gtpc := '00'O,
533 teidControlPlane := teid_ctrl
534 },
535 nsapi := {
536 type_gtpc := '00'O,
537 nsapi := nsapi,
538 unused := '0000'B
539 },
540 trace_ref := omit,
541 trace_type := omit,
542 protConfigOptions := pco,
543 sgsn_addr_controlPlane := ts_GsnAddr(sgsn_ip_sign),
544 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
545 alt_ggsn_addr_controlPane := omit,
546 alt_ggsn_addr_traffic := omit,
547 qualityOfServiceProfile := ts_QosDefault,
548 tft := omit,
549 triggerId := omit,
550 omcId := omit,
551 commonFlags := omit,
552 ratType := f_ts_RATType(ratType),
553 userLocationInformation := uli,
554 mS_TimeZone := omit,
555 additionalTraceInfo := omit,
556 directTunnelFlags := omit,
557 evolvedAllocationRetentionPriorityI := omit,
558 extendedCommonFlags := omit,
559 userCSGInformation := omit,
560 aPN_AMBR := omit,
561 signallingPriorityIndication := omit,
562 cN_OperatorSelectionEntity := omit,
563 private_extension_gtpc := omit
564 }
565 }
566 }
567
568 template Gtp1cUnitdata ts_GTPC_UpdatePDP(GtpPeer peer, OCT4 teid, uint16_t seq, hexstring imsi,
569 OCT1 restart_ctr, OCT4 teid_data,
570 OCT4 teid_ctrl, BIT4 nsapi, octetstring sgsn_ip_sign,
571 octetstring sgsn_ip_data,
572 template ProtConfigOptions pco := omit,
573 template (omit) OCT1 ratType := omit,
574 template (omit) UserLocationInformation uli := omit) := {
575 peer := peer,
576 gtpc := ts_GTP1C_PDU(updatePDPContextRequest, teid,
577 valueof(ts_UpdatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
578 nsapi, sgsn_ip_sign,
579 sgsn_ip_data, pco, ratType, uli)), seq)
580 }
581
582
Harald Welteeded9ad2018-02-17 20:57:34 +0100583 template NSAPI_GTPC ts_NSAPI(BIT4 nsapi) := {
584 type_gtpc := '14'O,
585 nsapi := nsapi,
586 unused := '0000'B
587 }
588
589 template ReorderingRequired ts_ReorderReq(boolean req := false) := {
590 type_gtpc := '08'O,
591 reordreq := bool2bit(req),
592 spare := '0000000'B
593 }
594
595 template GTPC_PDUs ts_CreatePdpRespPDU(OCT1 cause, OCT4 teid_data, OCT4 teid_ctrl, BIT4 nsapi,
596 octetstring ggsn_ip_sign, octetstring ggsn_ip_data,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100597 OCT4 chg_id, template EndUserAddress eua := omit,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200598 template Recovery_gtpc recovery := omit,
Harald Welteeded9ad2018-02-17 20:57:34 +0100599 template ProtConfigOptions pco := omit) := {
600 createPDPContextResponse := {
601 cause := { '00'O, cause },
602 reorderingRequired := ts_ReorderReq(false),
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200603 recovery := recovery,
Harald Welteeded9ad2018-02-17 20:57:34 +0100604 teidDataI := {
605 type_gtpc := '00'O,
606 teidDataI := teid_data
607 },
608 teidControlPlane := {
609 type_gtpc := '00'O,
610 teidControlPlane := teid_ctrl
611 },
612 nsapi := ts_NSAPI(nsapi),
Harald Welte7aff2ca2018-02-18 15:34:50 +0100613 chargingID := {
614 type_gtpc := '7F'O,
615 chargingID := chg_id
616 },
Harald Welteeded9ad2018-02-17 20:57:34 +0100617 endUserAddress := eua,
618 protConfigOptions := pco,
619 ggsn_addr_controlPlane := ts_GsnAddr(ggsn_ip_sign),
620 ggsn_addr_traffic := ts_GsnAddr(ggsn_ip_data),
621 alt_ggsn_addr_controlPane := omit,
622 alt_ggsn_addr_traffic := omit,
623 qualityOfServiceProfile := ts_QosDefault,
624 commonFlags := omit,
625 aPN_Restriction := omit,
626 mS_InfoChangeReportingAction := omit,
627 bearerControlMode := omit,
628 evolvedAllocationRetentionPriorityI := omit,
629 extendedCommonFlag := omit,
630 csg_information_reporting_action := omit,
631 aPN_AMBR := omit,
632 gGSN_BackOffTime := omit,
633 private_extension_gtpc := omit
634 }
635 }
636
637 template Gtp1cUnitdata ts_GTPC_CreatePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
638 OCT1 cause,
639 OCT4 teid_ctrl, OCT4 teid_data,
640 BIT4 nsapi, octetstring ggsn_ip_sign,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100641 octetstring ggsn_ip_data, OCT4 chg_id,
Harald Welteeded9ad2018-02-17 20:57:34 +0100642 template EndUserAddress eua := omit,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200643 template Recovery_gtpc recovery := omit,
Harald Welteeded9ad2018-02-17 20:57:34 +0100644 template ProtConfigOptions pco := omit) := {
645 peer := peer,
646 gtpc := ts_GTP1C_PDU(createPDPContextResponse, teid,
647 valueof(ts_CreatePdpRespPDU(cause, teid_data, teid_ctrl, nsapi,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100648 ggsn_ip_sign, ggsn_ip_data, chg_id,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200649 eua, recovery, pco)), seq)
Harald Welteeded9ad2018-02-17 20:57:34 +0100650 }
651
Harald Weltec69cf4e2018-02-17 20:57:02 +0100652 /* PCO send base template */
653 template ProtConfigOptions ts_PCO := {
654 type_gtpc := '84'O,
655 lengthf := 0,
656 configProtocol := '000'B,
657 spare := '0000'B,
658 extension0 := '1'B,
659 protocols := {}
660 }
661 /* PCO receive base template */
662 template ProtConfigOptions tr_PCO := {
663 type_gtpc := '84'O,
664 lengthf := ?,
665 configProtocol := '000'B,
666 spare := ?,
667 extension0 := '1'B,
668 protocols := {}
669 }
670
671 template ProtConfigOptions ts_PCO_IPv6_DNS modifies ts_PCO := {
672 protocols := {
673 { protocolID := '0003'O, lengthProtoID := 0, protoIDContents := ''O }
674 }
675 }
676 template ProtConfigOptions tr_PCO_IPv6_DNS_resp(template OCT16 contents) modifies tr_PCO := {
677 protocols := {
678 *, { protocolID := '0003'O, lengthProtoID := 16, protoIDContents := contents }, *
679 }
680 }
681
682 template ProtConfigOptions ts_PCO_IPv4_DNS_IPCP modifies ts_PCO := {
683 protocols := {
684 /* dummy PAP entry to check if our parser in the GGSN can properly iterate over
685 * the list of protocols, see Change-Id Icc2e6716c33d78d3c3e000f529806228d8aa155e */
686 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
687 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
688 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
689 }
690 }
691
Philipp Maier33e52612018-05-30 17:22:02 +0200692 template ProtConfigOptions ts_PCO_IPv4_PRI_DNS_IPCP modifies ts_PCO := {
693 protocols := {
694 /* dummy PAP entry to check if our parser can cope with a single primary DNS entry
695 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
696 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
697 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
698 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) }
699 }
700 }
701 template ProtConfigOptions ts_PCO_IPv4_SEC_DNS_IPCP modifies ts_PCO := {
702 protocols := {
703 /* dummy PAP entry to check if our parser can cope with a single secondary DNS entry
704 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
705 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
706 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
707 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
708 }
709 }
710 template ProtConfigOptions ts_PCO_IPv4_SEPARATE_DNS_IPCP modifies ts_PCO := {
711 protocols := {
712 /* dummy PAP entry to check if our parser can cope with a primary and secondary DNS
713 * in separate IPCP containers OS#3381 */
714 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
715 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
716 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) },
717 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
718 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
719 }
720 }
721
Harald Weltec69cf4e2018-02-17 20:57:02 +0100722 template ProtocolElement tr_PCO_Proto(OCT2 prot_id) := {
723 protocolID := prot_id,
724 lengthProtoID := ?,
725 protoIDContents := ?
726 }
Harald Weltef8298542019-04-10 10:15:28 +0200727 template ProtocolElement ts_PCOelem_PAP_broken := {
728 protocolID := 'C023'O,
729 lengthProtoID := 60,
730 /* PPP Password Authentication Protocol containing incorrect Peer-Id-Length set to 4 (6-7 should be the valid one), see OS#3914. */
731 protoIDContents := '0100003c'O & '0444435338323700bc1c08087c1508083e00790000150808fd06000001000000000000000000000000000000000000000000000000000000'O
732 }
733 template ProtConfigOptions ts_PCO_PAP_IPv4_DNS modifies ts_PCO := {
734 protocols := {
735 ts_PCOelem_PAP_broken,
736 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
737 }
738 }
Harald Weltec69cf4e2018-02-17 20:57:02 +0100739 template ProtConfigOptions tr_PCO_Contains(OCT2 prot_id) modifies tr_PCO := {
740 protocols := { *, tr_PCO_Proto(prot_id), * }
741 }
742
743 template ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := {
744 protocols := {
745 { protocolID := '000d'O, lengthProtoID := 0, protoIDContents := ''O }
746 }
747 }
748 template ProtConfigOptions tr_PCO_IPv4_DNS_CONT_resp(template OCT4 contents) modifies tr_PCO := {
749 protocols := {
750 *, { protocolID := '000d'O, lengthProtoID := 4, protoIDContents := contents }, *
751 }
752 }
753
754 /* extract a given protocol payload from PCO */
755 function f_PCO_extract_proto(ProtConfigOptions pco, OCT2 protocol, integer nth_match := 1) return octetstring {
756 var integer i;
757 var integer num_matches := 0;
758 for (i := 0; i < lengthof(pco.protocols); i := i + 1) {
759 if (pco.protocols[i].protocolID == protocol) {
760 num_matches := num_matches + 1;
761 if (num_matches == nth_match) {
762 return pco.protocols[i].protoIDContents;
763 }
764 }
765 }
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200766 setverdict(fail, "Could not extract protocol payload from protocol ", protocol);
767 mtc.stop;
Harald Weltec69cf4e2018-02-17 20:57:02 +0100768 return ''O;
769 }
770
771 template IpcpPacket tr_IPCP(template LcpCode code, template uint8_t identifier,
772 template IpcpOptionList opts) := {
773 code := code,
774 identifier := identifier,
775 len := ?,
776 options := opts
777 }
778 template IpcpOption tr_IPCP_PrimaryDns(template OCT4 addr) := {
779 code := IPCP_OPT_PrimaryDNS,
780 len := 6,
781 data := addr
782 }
783 template IpcpOption tr_IPCP_SecondaryDns(template OCT4 addr) := {
784 code := IPCP_OPT_SecondaryDNS,
785 len := 6,
786 data := addr
787 }
788 template IpcpPacket tr_IPCP_Ack_DNS(template uint8_t identifier := ?, template OCT4 dns1 := ?,
789 template OCT4 dns2 := ?) :=
790 tr_IPCP(LCP_Configure_Ack, identifier,
791 { *, tr_IPCP_PrimaryDns(dns1), *, tr_IPCP_SecondaryDns(dns2), * });
792
793 template IpcpPacket ts_IPCP(LcpCode code, uint8_t identifier, template IpcpOptionList opts) := {
794 code := code,
795 identifier := identifier,
796 len := 0, /* overwritten */
797 options := opts
798 }
799 template IpcpPacket ts_IPCP_ReqDNS(uint8_t identifier := 0) :=
800 ts_IPCP(LCP_Configure_Request, identifier,
801 { tr_IPCP_PrimaryDns('00000000'O), tr_IPCP_SecondaryDns('00000000'O) });
802
Philipp Maier33e52612018-05-30 17:22:02 +0200803 template IpcpPacket ts_IPCP_ReqDNS_Primary(uint8_t identifier := 0) :=
804 ts_IPCP(LCP_Configure_Request, identifier,
805 { tr_IPCP_PrimaryDns('00000000'O) });
806 template IpcpPacket ts_IPCP_ReqDNS_Secondary(uint8_t identifier := 0) :=
807 ts_IPCP(LCP_Configure_Request, identifier,
808 { tr_IPCP_SecondaryDns('00000000'O) });
809
Harald Welte57b9b7f2018-02-18 22:28:13 +0100810 function f_teardown_ind_IE(in template (omit) BIT1 ind) return template (omit) TearDownInd {
811 if (istemplatekind(ind, "omit")) {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100812 return omit;
813 }
Harald Weltec69cf4e2018-02-17 20:57:02 +0100814 var TearDownInd ret := {
815 type_gtpc := '13'O,
816 tdInd := valueof(ind),
817 spare:= '0000000'B
818 }
819 return ret;
820 }
821
Harald Welte57b9b7f2018-02-18 22:28:13 +0100822 template GTPC_PDUs ts_DeletePdpPDU(BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100823 deletePDPContextRequest := {
824 cause := omit,
825 tearDownIndicator := f_teardown_ind_IE(teardown_ind),
826 nsapi := {
827 type_gtpc := '14'O,
828 nsapi := nsapi,
829 unused := '0000'B
830 },
831 protConfigOptions := omit,
832 userLocationInformation := omit,
833 mS_TimeZone := omit,
834 extendedCommonFlags := omit,
835 uLI_Timestamp := omit,
836 private_extension_gtpc := omit
837 }
838 }
839
840 template Gtp1cUnitdata ts_GTPC_DeletePDP(GtpPeer peer, uint16_t seq, OCT4 teid,
Harald Welte57b9b7f2018-02-18 22:28:13 +0100841 BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100842 peer := peer,
843 gtpc := ts_GTP1C_PDU(deletePDPContextRequest, teid,
844 valueof(ts_DeletePdpPDU(nsapi, teardown_ind)), seq)
845 }
846
Harald Welte6f203162018-02-18 22:04:55 +0100847 template GTPC_PDUs ts_DeletePdpRespPDU(OCT1 cause,
848 template ProtConfigOptions pco := omit) := {
849 deletePDPContextResponse := {
850 cause := { '00'O, cause },
851 protConfigOptions := pco,
852 userLocationInformation := omit,
853 mS_TimeZone := omit,
854 uLI_Timestamp := omit,
855 private_extension_gtpc := omit
856 }
857 }
858
859 template Gtp1cUnitdata ts_GTPC_DeletePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
860 OCT1 cause,
861 template ProtConfigOptions pco := omit) := {
862 peer := peer,
863 gtpc := ts_GTP1C_PDU(deletePDPContextResponse, teid,
864 valueof(ts_DeletePdpRespPDU(cause, pco)), seq)
865 }
866
867
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200868 /* GTP-C RIM */
869
870 template (value) RIM_Application_Identity_GTPC ts_GTPC_RIM_Application_Identity(OCT1 app_id) := {
871 iEI := '4B'O,
872 ext := '1'B,
873 lengthIndicator := {
874 length1 := 1
875 },
876 rIMApplicationIdentity := app_id
877 }
878 /* 3GPP TS 48.018 11.3.62 */
879 template (value) RIM_Sequence_Number_GTPC ts_GTPC_RIM_Sequence_Number(integer seq) := {
880 iEI := '4C'O,
881 ext := '1'B,
882 lengthIndicator := {
883 length1 := 4
884 },
885 rIMSequenceNumber := int2oct(seq, 4)
886 }
887 template (value) RIM_PDU_Indications_GTPC ts_GTPC_RIM_PDU_Indications(boolean ack, BIT3 type_ext) := {
888 iEI := '4F'O,
889 ext := '1'B,
890 lengthIndicator := {
891 length1 := 1
892 },
893 ack := bool2bit(ack),
894 pDU_Type_Extension := type_ext,
895 reserved := '0000'B
896 }
897 /* 3GPP TS 48.018 11.3.67 */
898 template (value) RIM_Protocol_Version_Number_GTPC ts_GTPC_RIM_Protocol_Version_Number(integer ver) := {
899 iEI := '55'O,
900 ext := '1'B,
901 lengthIndicator := {
902 length1 := 1
903 },
904 rIMProtocolVersionNumber := int2oct(ver, 1)
905 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100906 function tr_GTPC_Cell_Identifier_V(template GTP_CellId cid) return template Cell_Identifier_V_GTPC {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200907 var template Cell_Identifier_V_GTPC ret := {
908 mccDigit1 := ?,
909 mccDigit2 := ?,
910 mccDigit3 := ?,
911 mncDigit3 := ?,
912 mncDigit1 := ?,
913 mncDigit2 := ?,
914 lac := ?,
915 rac := ?,
916 cI_value := ?
917 }
918 if (istemplatekind(cid, "omit")) {
919 return omit;
920 } else if (istemplatekind(cid, "*")) {
921 return *;
922 } else if (istemplatekind(cid, "?")) {
923 return ?;
924 }
925 if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) {
926 if (isvalue(cid.ra_id.lai.mcc_mnc)) {
927 ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0];
928 ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1];
929 ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2];
930 ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3];
931 ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4];
932 ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5];
933 }
934 if (isvalue(cid.ra_id.lai.lac)) {
935 ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2);
936 }
937 }
938 if (isvalue(cid) and isvalue(cid.ra_id)) {
939 ret.rac := f_oct_or_wc(cid.ra_id.rac, 1);
940 }
941 if (isvalue(cid)) {
942 ret.cI_value := f_oct_or_wc(cid.cell_id, 2);
943 }
944 return ret;
945 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100946 template (value) Cell_Identifier_V_GTPC ts_GTPC_Cell_Identifier_V(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200947 mccDigit1 := cid.ra_id.lai.mcc_mnc[0],
948 mccDigit2 := cid.ra_id.lai.mcc_mnc[1],
949 mccDigit3 := cid.ra_id.lai.mcc_mnc[2],
950 mncDigit3 := cid.ra_id.lai.mcc_mnc[3],
951 mncDigit1 := cid.ra_id.lai.mcc_mnc[4],
952 mncDigit2 := cid.ra_id.lai.mcc_mnc[5],
953 lac := int2oct(cid.ra_id.lai.lac, 2),
954 rac := int2oct(cid.ra_id.rac, 1),
955 cI_value := int2oct(cid.cell_id, 2)
956 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100957 template RIM_Routing_Address_GTPC t_GTPC_RIM_Routing_Address_cid(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200958 cell_Identifier := ts_GTPC_Cell_Identifier_V(cid)
959 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100960 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 +0200961 var template ENB_Identifier ret := {
962 mccDigit1 := ?,
963 mccDigit2 := ?,
964 mccDigit3 := ?,
965 mncDigit3 := ?,
966 mncDigit1 := ?,
967 mncDigit2 := ?,
968 tAC := ?,
969 globalENB_ID := ?
970 }
971 if (istemplatekind(cid, "omit") and istemplatekind(tac, "omit") and istemplatekind(gnbid, "omit")) {
972 return omit;
973 } else if (istemplatekind(cid, "*") and istemplatekind(tac, "*") and istemplatekind(gnbid, "*")) {
974 return *;
975 } else if (istemplatekind(cid, "?") and istemplatekind(tac, "?") and istemplatekind(gnbid, "?")) {
976 return ?;
977 }
978 if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) {
979 if (isvalue(cid.ra_id.lai.mcc_mnc)) {
980 ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0];
981 ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1];
982 ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2];
983 ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3];
984 ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4];
985 ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5];
986 }
987 }
988 if (isvalue(tac)) {
989 ret.tAC := int2oct(valueof(tac), 2);
990 }
991 if (isvalue(gnbid)) {
992 ret.globalENB_ID := gnbid;
993 }
994
995 return ret;
996 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100997 template (value) ENB_Identifier ts_GTPC_ENB_Identifier(GTP_CellId cid, integer tac, octetstring gnbid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200998 mccDigit1 := cid.ra_id.lai.mcc_mnc[0],
999 mccDigit2 := cid.ra_id.lai.mcc_mnc[1],
1000 mccDigit3 := cid.ra_id.lai.mcc_mnc[2],
1001 mncDigit3 := cid.ra_id.lai.mcc_mnc[3],
1002 mncDigit1 := cid.ra_id.lai.mcc_mnc[4],
1003 mncDigit2 := cid.ra_id.lai.mcc_mnc[5],
1004 tAC := int2oct(tac, 2),
1005 globalENB_ID := gnbid
1006 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001007 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 +02001008 eNB_Identifier := ts_GTPC_ENB_Identifier(cid, tac, gnbid)
1009 }
1010 template RIM_Routing_Information_GTPC
1011 tr_GTPC_RIM_Routing_Information(HEX1 addr_discr, template RIM_Routing_Address_GTPC addr) := {
1012 iEI := '54'O,
1013 ext := '1'B,
1014 lengthIndicator := {
1015 length1 := ?
1016 },
1017 rIMRoutingAddressDiscriminator := addr_discr,
1018 spare := '0'H,
1019 rIM_Routing_Address := addr
1020 }
1021 template (value) RIM_Routing_Information_GTPC
1022 ts_GTPC_RIM_Routing_Information(HEX1 addr_discr, template (value) RIM_Routing_Address_GTPC addr) := {
1023 iEI := '54'O,
1024 ext := '1'B,
1025 lengthIndicator := {
1026 length1 := 0 /* overwritten */
1027 },
1028 rIMRoutingAddressDiscriminator := addr_discr,
1029 spare := '0'H,
1030 rIM_Routing_Address := addr
1031 }
1032 /* 3GPP TS 48.018 11.3.63.1.1 */
1033 template RAN_Information_Request_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001034 tr_GTPC_RAN_Information_Request_Application_Container_NACC(template GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001035 iEI := '4D'O,
1036 ext := '1'B,
1037 lengthIndicator := {
1038 length1 := ?
1039 },
1040 reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid)
1041 }
1042 template (value) RAN_Information_Request_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001043 ts_GTPC_RAN_Information_Request_Application_Container_NACC(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001044 iEI := '4D'O,
1045 ext := '1'B,
1046 lengthIndicator := {
1047 length1 := 0 /* overwritten */
1048 },
1049 reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid)
1050 }
1051 /* 3GPP TS 48.018 11.3.63.1 */
1052 template RAN_Information_Request_Application_Container_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001053 tru_GTPC_RAN_Information_Request_Application_Container_NACC(template GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001054 nacc := tr_GTPC_RAN_Information_Request_Application_Container_NACC(cid)
1055 }
1056 template (value) RAN_Information_Request_Application_Container_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001057 tsu_GTPC_RAN_Information_Request_Application_Container_NACC(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001058 nacc := ts_GTPC_RAN_Information_Request_Application_Container_NACC(cid)
1059 }
1060 /* 3GPP TS 48.018 11.3.63.2.1 */
1061 template RAN_Information_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001062 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 +02001063 iEI := '4E'O,
1064 ext := '1'B,
1065 lengthIndicator := {
1066 length1 := ?
1067 },
1068 reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid),
1069 typeBit := bool2bit(psi_type),
1070 number_of_SI_PSI := int2bit(si_psi_num, 7),
1071 sI_PSI := si_psi
1072 }
1073 template (value) RAN_Information_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001074 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 +02001075 iEI := '4E'O,
1076 ext := '1'B,
1077 lengthIndicator := {
1078 length1 := 0 /* overwritten */
1079 },
1080 reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid),
1081 typeBit := bool2bit(psi_type),
1082 number_of_SI_PSI := int2bit(si_psi_num, 7),
1083 sI_PSI := si_psi
1084 }
1085
1086 /* RAN_Information_Request */
1087 template (value) RAN_Information_Request_RIM_Container_GTPC
1088 ts_GTPC_RAN_Information_Request_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id,
1089 template (value) RIM_Sequence_Number_GTPC seq,
1090 template (value) RIM_PDU_Indications_GTPC ind,
1091 template (omit) RIM_Protocol_Version_Number_GTPC ver := omit,
1092 template (omit) RAN_Information_Request_Application_Container_GTPC app_cont := omit,
1093 template (omit) SON_TransferApplicationIdentity son_app_id := omit) := {
1094 iEI := '57'O,
1095 ext := '1'B,
1096 lengthIndicator := {
1097 length1 := 0 /* overwritten */
1098 },
1099 rIM_Application_Identity := app_id,
1100 rIM_Sequence_Number := seq,
1101 rIM_PDU_Indications := ind,
1102 rIM_Protocol_Version_Number := ver,
1103 application_Container := app_cont,
1104 sON_TransferApplicationIdentity := son_app_id
1105 }
1106 template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC
1107 ts_GTPC_RAN_Information_Request(template (value) RIM_Routing_Information_GTPC dest,
1108 template (value) RIM_Routing_Information_GTPC src,
Philipp Maier6cef1c32023-07-24 11:01:52 +02001109 template (value) RAN_Information_Request_RIM_Container_GTPC cont) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001110 bssgpPduType := '71'O,
1111 destination_Cell_Identifier := dest,
1112 source_Cell_Identifier := src,
1113 rIM_Container := cont
1114 }
Philipp Maier4b81c6e2023-07-24 11:03:15 +02001115 template PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC
1116 tr_GTPC_RAN_Information_Request(template RIM_Routing_Information_GTPC dest := ?,
1117 template RIM_Routing_Information_GTPC src := ?,
1118 template RAN_Information_Request_RIM_Container_GTPC cont := ?) := {
1119 bssgpPduType := '71'O,
1120 destination_Cell_Identifier := dest,
1121 source_Cell_Identifier := src,
1122 rIM_Container := cont
1123 }
1124
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001125 template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO_REQ(template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC pdu) := {
1126 type_gtpc := '90'O,
1127 lengthf := 0, /* FIXME */
1128 rANTransparentContainerField := {
1129 pDU_BSSGP_RAN_INFORMATION_REQUEST := pdu
1130 }
1131 }
Philipp Maieredce92f2023-07-26 11:02:10 +02001132 template RANTransparentContainer tr_RANTransparentContainer_RAN_INFO_REQ(template PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC pdu := ?) := {
1133 type_gtpc := '90'O,
1134 lengthf := ?,
1135 rANTransparentContainerField := {
1136 pDU_BSSGP_RAN_INFORMATION_REQUEST := pdu
1137 }
1138 }
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001139
1140 /* RAN_Information */
1141 template ApplContainer_or_ApplErrContainer_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001142 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 +02001143 application_Container := tr_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi)
1144 }
1145 template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001146 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 +02001147 application_Container := ts_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi)
1148 }
1149 template ApplContainer_or_ApplErrContainer_GTPC
1150 tru_GTPC_ApplContainer_or_ApplErrContainer_NACC(template ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := {
1151 nacc := cont
1152 }
1153 template (value) ApplContainer_or_ApplErrContainer_GTPC
1154 tsu_GTPC_ApplContainer_or_ApplErrContainer_NACC(template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := {
1155 nacc := cont
1156 }
1157 template RAN_Information_RIM_Container_GTPC
1158 tr_GTPC_RAN_Information_RIM_Container(template RIM_Application_Identity_GTPC app_id,
1159 template RIM_Sequence_Number_GTPC seq,
1160 template RIM_PDU_Indications_GTPC ind,
1161 template RIM_Protocol_Version_Number_GTPC ver := omit,
1162 template ApplContainer_or_ApplErrContainer_GTPC app_cont := omit,
1163 template SON_TransferApplicationIdentity son_app_id := omit) := {
1164 iEI := '58'O,
1165 ext := '1'B,
1166 lengthIndicator := {
1167 length1 := ?
1168 },
1169 rIM_Application_Identity := app_id,
1170 rIM_Sequence_Number := seq,
1171 rIM_PDU_Indications := ind,
1172 rIM_Protocol_Version_Number := ver,
1173 applContainer_or_ApplErrContainer := app_cont,
1174 sON_TransferApplicationIdentity := son_app_id
1175 }
1176 template (value) RAN_Information_RIM_Container_GTPC
1177 ts_GTPC_RAN_Information_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id,
1178 template (value) RIM_Sequence_Number_GTPC seq,
1179 template (value) RIM_PDU_Indications_GTPC ind,
1180 template (omit) RIM_Protocol_Version_Number_GTPC ver := omit,
1181 template (omit) ApplContainer_or_ApplErrContainer_GTPC app_cont := omit,
1182 template (omit) SON_TransferApplicationIdentity son_app_id := omit) := {
1183 iEI := '58'O,
1184 ext := '1'B,
1185 lengthIndicator := {
1186 length1 := 0 /* overwritten */
1187 },
1188 rIM_Application_Identity := app_id,
1189 rIM_Sequence_Number := seq,
1190 rIM_PDU_Indications := ind,
1191 rIM_Protocol_Version_Number := ver,
1192 applContainer_or_ApplErrContainer := app_cont,
1193 sON_TransferApplicationIdentity := son_app_id
1194 }
1195 template PDU_BSSGP_RAN_INFORMATION_GTPC
1196 tr_GTPC_RAN_Information(template RIM_Routing_Information_GTPC dest,
1197 template RIM_Routing_Information_GTPC src,
1198 template RAN_Information_RIM_Container_GTPC cont) := {
1199 bssgpPduType := '70'O,
1200 destination_Cell_Identifier := dest,
1201 source_Cell_Identifier := src,
1202 rIM_Container := cont
1203 }
1204 template (value) PDU_BSSGP_RAN_INFORMATION_GTPC
1205 ts_GTPC_RAN_Information(template (value) RIM_Routing_Information_GTPC dest,
1206 template (value) RIM_Routing_Information_GTPC src,
1207 template (value) RAN_Information_RIM_Container_GTPC cont) := {
1208 bssgpPduType := '70'O,
1209 destination_Cell_Identifier := dest,
1210 source_Cell_Identifier := src,
1211 rIM_Container := cont
1212 }
1213 template RANTransparentContainer tr_RANTransparentContainer_RAN_INFO(template PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := {
1214 type_gtpc := '90'O,
1215 lengthf := ?,
1216 rANTransparentContainerField := {
1217 pDU_BSSGP_RAN_INFORMATION := pdu
1218 }
1219 }
1220 template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO(template (value) PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := {
1221 type_gtpc := '90'O,
1222 lengthf := 0, /* overwritten */
1223 rANTransparentContainerField := {
1224 pDU_BSSGP_RAN_INFORMATION := pdu
1225 }
1226 }
1227
1228 template RANTransparentContainer tr_RANTransparentContainer(template RANTransparentContainerField rANTransparentContainerField) := {
1229 type_gtpc := '90'O,
1230 lengthf := ?,
1231 rANTransparentContainerField := rANTransparentContainerField
1232 }
1233 template (value) RANTransparentContainer ts_RANTransparentContainer(template (value) RANTransparentContainerField rANTransparentContainerField) := {
1234 type_gtpc := '90'O,
1235 lengthf := 0, /* overwritten */
1236 rANTransparentContainerField := rANTransparentContainerField
1237 }
1238 template GTPC_PDUs tr_RANInfoRelay(template RANTransparentContainer transparentContainer) := {
1239 ranInformationRelay := {
1240 transparentContainer := transparentContainer,
1241 rIM_RoutingAddress := *,
1242 rIM_RoutingAddress_Discriminator := *,
1243 private_extension_gtpc := *
1244 }
1245 }
Philipp Maier05ad55c2023-07-24 10:56:46 +02001246 template (value) GTPC_PDUs ts_RANInfoRelay(template (value) RANTransparentContainer transparentContainer,
1247 template (omit) RIM_RoutingAddress ra := omit,
1248 template (omit) RIM_RoutingAddress_Discriminator ra_discr := omit) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001249 ranInformationRelay := {
1250 transparentContainer := transparentContainer,
Philipp Maier05ad55c2023-07-24 10:56:46 +02001251 rIM_RoutingAddress := ra,
1252 rIM_RoutingAddress_Discriminator := ra_discr,
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001253 private_extension_gtpc := omit
1254 }
1255 }
1256 template Gtp1cUnitdata
1257 tr_GTPC_RANInfoRelay(template GtpPeer peer,
1258 template RANTransparentContainer transparentContainer) := {
1259 peer := peer,
1260 gtpc := tr_GTP1C_PDU(rANInformationRelay, '00000000'O, tr_RANInfoRelay(transparentContainer))
1261 }
1262 template (value) Gtp1cUnitdata
1263 ts_GTPC_RANInfoRelay(template (value) GtpPeer peer,
Philipp Maier05ad55c2023-07-24 10:56:46 +02001264 template (value) RANTransparentContainer transparentContainer,
1265 template (omit) RIM_RoutingAddress ra := omit,
1266 template (omit) RIM_RoutingAddress_Discriminator ra_discr := omit) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001267 peer := peer,
Philipp Maier05ad55c2023-07-24 10:56:46 +02001268 gtpc := ts_GTP1C_PDU(rANInformationRelay, '00000000'O, valueof(ts_RANInfoRelay(transparentContainer, ra, ra_discr)), 0)
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001269 }
1270
1271
1272 template RAN_Information_Request_RIM_Container_GTPC
1273 tr_GTPC_RAN_Information_Request_RIM_Container(template RIM_Application_Identity_GTPC app_id := ?,
1274 template RIM_Sequence_Number_GTPC seq := ?,
1275 template RIM_PDU_Indications_GTPC ind := ?,
1276 template RIM_Protocol_Version_Number_GTPC ver := *,
1277 template RAN_Information_Request_Application_Container_GTPC app_cont := *,
1278 template SON_TransferApplicationIdentity son_app_id := *) := {
1279 iEI := '57'O,
1280 ext := '1'B,
1281 lengthIndicator := {
1282 length1 := ?
1283 },
1284 rIM_Application_Identity := app_id,
1285 rIM_Sequence_Number := seq,
1286 rIM_PDU_Indications := ind,
1287 rIM_Protocol_Version_Number := ver,
1288 application_Container := app_cont,
1289 sON_TransferApplicationIdentity := son_app_id
1290 }
Harald Weltec69cf4e2018-02-17 20:57:02 +01001291
1292 /* GTP-U */
1293
1294 template PDU_GTPU tr_GTP1U_PDU(template OCT1 msg_type, template OCT4 teid, template GTPU_IEs ies := ?) := {
1295 pn_bit := ?,
1296 s_bit := ?,
1297 e_bit := ?,
1298 spare := ?,
1299 /* Protocol Type flag (PT) shall be set to '1' in GTP */
1300 pt := '1'B,
1301 /* Version shall be set to decimal 1 ('001'). */
1302 version := '001'B,
1303 messageType := msg_type,
1304 lengthf := ?,
1305 teid := teid,
1306 opt_part := *,
1307 gtpu_IEs := ies
1308 }
1309
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001310 function f_GTPU_s_bit(template (omit) uint16_t seq) return BIT1 {
1311 if (istemplatekind(seq, "omit")) {
1312 return '0'B;
1313 }
1314 return '1'B;
1315 }
1316
1317 function f_GTPU_opt_part(template (omit) uint16_t seq) return template (omit) GTPU_Header_optional_part {
1318 if (istemplatekind(seq, "omit")) {
1319 return omit;
1320 }
1321 var GTPU_Header_optional_part ret := {
1322 sequenceNumber := int2oct(valueof(seq), 2),
1323 npduNumber := '00'O,
1324 nextExtHeader := '00'O,
1325 gTPU_extensionHeader_List := omit
1326 };
1327 return ret;
1328 }
1329
Harald Weltec69cf4e2018-02-17 20:57:02 +01001330 /* generalized GTP-U send template */
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001331 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 +01001332 /* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN
1333 * flag is set to 1. */
1334 pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */
1335 /* If the Sequence Number flag (S) is set to '1' the sequence number field is present and
1336 * meaningful otherwise it is set to '0'. For GTP-U messages Echo Request, Echo Response,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001337 * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'.
1338 *
1339 * Note that the caller must ensure that these conditions hold.
1340 * The caller can either pass a sequence number (we set s_bit to '1'B) when appropriate,
1341 * or may omit the sequence number (we set s_bit to '0'B). */
1342 s_bit := f_GTPU_s_bit(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +01001343 /* Extension header presence */
1344 e_bit := '0'B,
1345 spare := '0'B,
1346 /* Protocol Type flag (PT) shall be set to '1' in GTP */
1347 pt := '1'B,
1348 /* Version shall be set to decimal 1 ('001'). */
1349 version := '001'B,
1350 messageType := msg_type,
1351 lengthf := 0, /* we assume encoder overwrites this */
1352 teid := teid,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001353 opt_part := f_GTPU_opt_part(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +01001354 gtpu_IEs := ies
1355 }
1356
1357 template Gtp1uUnitdata tr_GTPU_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid) := {
1358 peer := peer,
1359 gtpu := tr_GTP1U_PDU(msg_type, teid)
1360 }
1361
1362
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001363 /* template matching reception of GTP-U echo-request/response */
Harald Weltec69cf4e2018-02-17 20:57:02 +01001364 template Gtp1uUnitdata tr_GTPU_PING(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoRequest, '00000000'O);
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001365 template Gtp1uUnitdata tr_GTPU_PONG(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoResponse, '00000000'O);
Harald Weltec69cf4e2018-02-17 20:57:02 +01001366
1367 /* template matching reception of GTP-U GPDU */
1368 template GTPU_IEs t_GPDU(template octetstring data) := {
1369 g_PDU_IEs := {
1370 data := data
1371 }
1372 }
1373 template Gtp1uUnitdata tr_GTPU_GPDU(template GtpPeer peer, template OCT4 teid, template octetstring data := ?) := {
1374 peer := peer,
1375 gtpu := tr_GTP1U_PDU('FF'O, teid, t_GPDU(data))
1376 }
1377
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001378 template GTPU_IEs ts_UEchoReqPDU := {
1379 echoRequest_IEs := {
1380 private_extension_gtpu := omit
1381 }
1382 }
1383
1384 /* master template for sending a GTP-C echo request */
1385 template (value) Gtp1uUnitdata ts_GTPU_PING(GtpPeer peer, uint16_t seq) := {
1386 peer := peer,
1387 gtpu := ts_GTP1U_PDU(echoRequest, seq, '00000000'O, valueof(ts_UEchoReqPDU))
1388 }
1389
Harald Weltec69cf4e2018-02-17 20:57:02 +01001390 template GTPU_IEs ts_UEchoRespPDU(OCT1 restart_counter) := {
1391 echoResponse_IEs := {
1392 recovery_gtpu := {
1393 type_gtpu := '00'O, /* we assume encoder fixes? */
1394 restartCounter := restart_counter
1395 },
1396 private_extension_gtpu := omit
1397 }
1398 }
1399
1400 /* master template for sending a GTP-U echo response */
1401 template Gtp1uUnitdata ts_GTPU_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
1402 peer := peer,
1403 gtpu := ts_GTP1U_PDU(echoResponse, seq, '00000000'O, valueof(ts_UEchoRespPDU(rest_ctr)))
1404 }
1405
Pau Espin Pedrolf3e25382018-07-18 13:46:40 +02001406 template GSNAddress_gtpu ts_UGsnAddr(octetstring ip_addr) := {
1407 type_gtpu := '85'O,
1408 lengthf := lengthof(ip_addr),
1409 gSNAddressValue := ip_addr
1410 }
1411
1412 template TeidDataI_gtpu ts_UteidDataI(OCT4 teid) := {
1413 type_gtpu := '10'O,
1414 teidDataI := teid
1415 }
1416
1417 template GTPU_IEs ts_UErrorIndication(OCT4 teid, octetstring gsn_addr) := {
1418 errorIndication_IEs := {
1419 teidDataI_gtpu := ts_UteidDataI(teid),
1420 gSNAddress_gtpu := ts_UGsnAddr(gsn_addr),
1421 private_extension_gtpu := omit
1422 }
1423 }
1424
1425 /* master template for sending a GTP-U Error indication */
1426 template Gtp1uUnitdata ts_GTPU_ErrorIndication(GtpPeer peer, uint16_t seq, OCT4 teid, octetstring gsn_addr) := {
1427 peer := peer,
1428 gtpu := ts_GTP1U_PDU('1A'O, seq, '00000000'O, valueof(ts_UErrorIndication(teid, gsn_addr)))
1429 }
1430
Harald Weltec69cf4e2018-02-17 20:57:02 +01001431 /* master template for sending a GTP-U user plane data */
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001432 template Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, template (omit) uint16_t seq, OCT4 teid, octetstring data) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +01001433 peer := peer,
1434 gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }})
1435 }
1436}