blob: 031d9b2c2c989c838ee42de1855e49d0167ada3e [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 Pedrol408e0ae2023-12-15 18:56:31 +010044 template (value) Cause_gtpc ts_Cause_gtpc(template (value) GTP_Cause cause) := {
45 type_gtpc := '01'O,
46 causevalue := enum2oct1_Cause_gtpc_tmpl(cause)
47 }
48 private function enum2oct1_Cause_gtpc_tmpl(template GTP_Cause inp) return template OCT1
49 {
50 if (istemplatekind(inp, "omit")) {
51 return omit;
52 } else if (istemplatekind(inp, "*")) {
53 return *;
54 } else if (istemplatekind(inp, "?")) {
55 return ?;
56 } else {
57 return int2oct(enum2int(valueof(inp)), 1);
58 }
59 }
60 template (present) Cause_gtpc tr_Cause_gtpc(template (present) GTP_Cause cause) := {
61 type_gtpc := '01'O,
62 causevalue := enum2oct1_Cause_gtpc_tmpl(cause)
63 }
64 function f_tr_Cause_gtpc(template GTP_Cause cause) return
65 template Cause_gtpc {
66 if (istemplatekind(cause, "omit")) {
67 return omit;
68 } else if (istemplatekind(cause, "*")) {
69 return *;
70 } else {
71 return tr_Cause_gtpc(cause);
72 }
73 }
74
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +020075 private function f_oct_or_wc(template integer inp, integer len) return template octetstring {
76 if (istemplatekind(inp, "omit")) {
77 return omit;
78 } else if (istemplatekind(inp, "*")) {
79 return *;
80 } else if (istemplatekind(inp, "?")) {
81 return ?;
82 }
83 return int2oct(valueof(inp), len);
84 }
85
86 private function f_hex_or_wc(template integer inp, integer len) return template hexstring {
87 if (istemplatekind(inp, "omit")) {
88 return omit;
89 } else if (istemplatekind(inp, "*")) {
90 return *;
91 } else if (istemplatekind(inp, "?")) {
92 return ?;
93 }
94 return int2hex(valueof(inp), len);
95 }
96
Harald Weltec69cf4e2018-02-17 20:57:02 +010097 /* generalized GTP-C receive template */
Philipp Maier57889492023-08-07 12:10:03 +020098 template (present) PDU_GTPC tr_GTP1C_PDU(template (present) OCT1 msg_type, template (present) OCT4 teid, template (present) GTPC_PDUs pdu := ?) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +010099 /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
100 * error if this flag is set to '1'. */
101 pn_bit := '0'B,
102 /* Sequence number flag (S) shall be set to '1'. */
103 s_bit := '1'B,
104 e_bit := ?,
105 spare := ?,
106 /* Protocol Type flag (PT) shall be set to '1'.*/
107 pt := '1'B,
108 /* Version shall be set to decimal 1 ('001'). */
109 version := '001'B,
110 messageType := msg_type,
111 lengthf := ?,
112 teid := teid,
113 opt_part := *,
114 gtpc_pdu := pdu
115 }
116
117 /* generalized GTP-C send template */
Philipp Maier57889492023-08-07 12:10:03 +0200118 template (value) PDU_GTPC ts_GTP1C_PDU(OCT1 msg_type, OCT4 teid, GTPC_PDUs pdu, uint16_t seq_nr) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100119 /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
120 * error if this flag is set to '1'. */
121 pn_bit := '0'B,
122 /* Sequence number flag (S) shall be set to '1'. */
123 s_bit := '1'B,
124 e_bit := '0'B,
125 spare := '0'B,
126 /* Protocol Type flag (PT) shall be set to '1'.*/
127 pt := '1'B,
128 /* Version shall be set to decimal 1 ('001'). */
129 version := '001'B,
130 messageType := msg_type,
131 lengthf := 0, /* we assume encoder overwrites this */
132 teid := teid,
133 opt_part := {
134 sequenceNumber := int2oct(seq_nr, 2),
135 npduNumber := '00'O,
136 nextExtHeader := '00'O,
137 gTPC_extensionHeader_List := omit
138 },
139 gtpc_pdu := pdu
140 }
141
142 /* recovery IE */
Philipp Maier57889492023-08-07 12:10:03 +0200143 template (value) Recovery_gtpc ts_Recovery(OCT1 restart_counter) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100144 type_gtpc := '0E'O,
145 restartCounter := restart_counter
146 }
147
Philipp Maier57889492023-08-07 12:10:03 +0200148 template (present) Recovery_gtpc tr_Recovery(template (present) OCT1 restart_counter) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100149 type_gtpc := '0E'O,
150 restartCounter := restart_counter
151 }
152
Pau Espin Pedrol408e0ae2023-12-15 18:56:31 +0100153 /* Packet TMSI - 7.7.5 */
154 template (value) PacketTMSI ts_PTMSI(OCT4 ptmsi) := {
155 type_gtpc := '05'O,
156 p_tmsi := ptmsi
157 }
158
159 /* PTMSI Signature - 7.7.9 */
160 template (value) PTMSI_Signature ts_PTMSI_sig(OCT3 ptmsi_sig) := {
161 type_gtpc := '0C'O,
162 ptmsi_Signature := ptmsi_sig
163 }
164
Pau Espin Pedrol38968e92022-05-13 16:17:48 +0200165 /* IMEI(SV) IE TS 29.060 7.7.53 */
Philipp Maier57889492023-08-07 12:10:03 +0200166 template (value) IMEISV_gtpc ts_IMEISV(template (value) OCT8 imeisv) := {
Pau Espin Pedrol38968e92022-05-13 16:17:48 +0200167 type_gtpc := '9A'O,
168 lengthf := 8,
169 imeisv := imeisv
170 }
171 private function f_ts_IMEISV(template (omit) OCT8 imeisv)
172 return template (omit) IMEISV_gtpc {
173 if (istemplatekind(imeisv, "omit")) {
174 return omit;
175 }
176 return ts_IMEISV(imeisv);
177 }
178
Philipp Maier57889492023-08-07 12:10:03 +0200179 template (present) IMEISV_gtpc tr_IMEISV(template (present) OCT8 imeisv) := {
Pau Espin Pedrol38968e92022-05-13 16:17:48 +0200180 type_gtpc := '9A'O,
181 lengthf := 8,
182 imeisv := imeisv
183 }
184
Pau Espin Pedrol535ca262022-05-16 14:07:17 +0200185 // MS Time Zone - 7.7.52
186 template (value) MS_TimeZone ts_MS_TimeZone(template (value) OCT1 timeZone := '00'O,
187 template (value) BIT2 daylightSavingTime := '00'B) := {
188 type_gtpc := '99'O,
189 lengthf := 2,
190 timeZone := timeZone,
191 daylightSavingTime := daylightSavingTime,
192 spare1 := '000'B,
193 sgsnAttempsToUpdateMS := '0'B, /* propietary, use it as spare */
194 spare2 := '00'B
195 }
196 function f_ts_MS_TimeZone(template (omit) OCT1 timeZone, template (omit) BIT2 daylightSavingTime)
197 return template (omit) MS_TimeZone {
198 if (istemplatekind(timeZone, "omit") and istemplatekind(daylightSavingTime, "omit")) {
199 return omit;
200 }
201 if (istemplatekind(timeZone, "omit")) {
202 return ts_MS_TimeZone(daylightSavingTime := daylightSavingTime);
203 }
204 if (istemplatekind(daylightSavingTime, "omit")) {
205 return ts_MS_TimeZone(timeZone);
206 }
207 return ts_MS_TimeZone(timeZone, daylightSavingTime);
208 }
209
210 template (present) MS_TimeZone tr_MS_TimeZone(template (present) OCT1 timeZone := ?,
211 template (present) BIT2 daylightSavingTime := ?) := {
212 type_gtpc := '99'O,
213 lengthf := 2,
214 timeZone := timeZone,
215 daylightSavingTime := daylightSavingTime,
216 spare1 := '000'B,
217 sgsnAttempsToUpdateMS := '0'B, /* propietary, use it as spare */
218 spare2 := '00'B
219 }
220
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200221 /* Charging Characteristics IE TS 29.060 7.7.23 */
Philipp Maier57889492023-08-07 12:10:03 +0200222 template (value) ChargingCharacteristics_GTPC ts_ChargingCharacteristics(template (value) OCT2 chargingChar) := {
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200223 type_gtpc := '1A'O,
224 chargingChar := chargingChar
225 }
226 private function f_ts_ChargingCharacteristics(template (omit) OCT2 chargingChar)
227 return template (omit) ChargingCharacteristics_GTPC {
228 if (istemplatekind(chargingChar, "omit")) {
229 return omit;
230 }
231 return ts_ChargingCharacteristics(chargingChar);
232 }
233
Philipp Maier57889492023-08-07 12:10:03 +0200234 template (present) ChargingCharacteristics_GTPC tr_ChargingCharacteristics(template (present) OCT2 chargingChar) := {
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200235 type_gtpc := '1A'O,
236 chargingChar := chargingChar
237 }
238
239
Philipp Maier1c0c7262023-07-24 10:51:53 +0200240 /* template matching reception of GTP-C unit-data */
Philipp Maier57889492023-08-07 12:10:03 +0200241 template (present) Gtp1cUnitdata tr_GTPC_MsgType(template (present) GtpPeer peer,
242 template (present) OCT1 msg_type,
243 template (present) OCT4 teid,
244 template (present) GTPC_PDUs pdus := ?) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100245 peer := peer,
246 gtpc := tr_GTP1C_PDU(msg_type, teid, pdus)
247 }
248
249 /* template matching reception of GTP-C echo-request */
Philipp Maier57889492023-08-07 12:10:03 +0200250 template (present) Gtp1cUnitdata tr_GTPC_PING(template (present) GtpPeer peer) := tr_GTPC_MsgType(peer, echoRequest, '00000000'O);
Harald Weltec69cf4e2018-02-17 20:57:02 +0100251
Philipp Maier57889492023-08-07 12:10:03 +0200252 template (present) GTPC_PDUs tr_EchoRespPDU(template (present) OCT1 restart_counter) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100253 echoResponse := {
254 recovery := tr_Recovery(restart_counter),
255 private_extension_gtpc := *
256 }
257 }
258
259 /* template matching reception of GTP-C echo-response */
Philipp Maier57889492023-08-07 12:10:03 +0200260 template (present) Gtp1cUnitdata tr_GTPC_PONG(template (present) GtpPeer peer) := tr_GTPC_MsgType(peer, echoResponse, '00000000'O, tr_EchoRespPDU(?));
Harald Weltec69cf4e2018-02-17 20:57:02 +0100261
Philipp Maier57889492023-08-07 12:10:03 +0200262 template (value) GTPC_PDUs ts_EchoRespPDU(OCT1 restart_counter) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100263 echoResponse := {
264 recovery := ts_Recovery(restart_counter),
265 private_extension_gtpc := omit
266 }
267 }
268
269 /* master template for senidng a GTP-C echo response */
Philipp Maier57889492023-08-07 12:10:03 +0200270 template (value) Gtp1cUnitdata ts_GTPC_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100271 peer := peer,
272 gtpc := ts_GTP1C_PDU(echoResponse, '00000000'O, valueof(ts_EchoRespPDU(rest_ctr)), seq)
273 }
274
Philipp Maier57889492023-08-07 12:10:03 +0200275 template (value) GTPC_PDUs ts_EchoReqPDU := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100276 echoRequest := {
277 private_extension_gtpc := omit
278 }
279 }
280
281 /* master template for sending a GTP-C echo request */
Philipp Maier57889492023-08-07 12:10:03 +0200282 template (value) Gtp1cUnitdata ts_GTPC_PING(GtpPeer peer, uint16_t seq) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100283 peer := peer,
284 gtpc := ts_GTP1C_PDU(echoRequest, '00000000'O, valueof(ts_EchoReqPDU), seq)
285 }
286
Pau Espin Pedrol0d138c62023-08-31 16:23:18 +0200287 private function f_eua_ipv4_len(template OCT4 ip_addr) return template (present) integer {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100288 if (istemplatekind(ip_addr, "omit")) {
289 return 2;
290 } else if (istemplatekind(ip_addr, "*")) {
291 return ?;
292 } else if (istemplatekind(ip_addr, "?")) {
293 return 6;
294 }
295 return 6;
296 }
297
Pau Espin Pedrol0d138c62023-08-31 16:23:18 +0200298 private function f_eua_ipv6_len(template OCT16 ip_addr) return template (present) integer {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100299 if (istemplatekind(ip_addr, "omit")) {
300 return 2;
301 } else if (istemplatekind(ip_addr, "*")) {
302 return ?;
303 } else if (istemplatekind(ip_addr, "?")) {
304 return 18;
305 }
306 return 18;
307 }
308
Pau Espin Pedrol0d138c62023-08-31 16:23:18 +0200309 private function f_eua_ipv4v6_len(template OCT4 ip_addr4, template OCT16 ip_addr6) return template (present) integer {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100310 var integer len := 2;
311 if (istemplatekind(ip_addr4, "*") or
312 istemplatekind(ip_addr6, "*")) {
313 return ?;
314 }
315 if (not istemplatekind(ip_addr4, "omit")) {
316 len := len + 4;
317 }
318 if (not istemplatekind(ip_addr6, "omit")) {
319 len := len + 16;
320 }
321 return len;
322 }
323
Pau Espin Pedrol0d138c62023-08-31 16:23:18 +0200324 template (present) EndUserAddress t_EuaIPv4(template OCT4 ip_addr) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100325 type_gtpc := '80'O,
326 endUserAddress := {
327 endUserAddressIPv4 := {
328 lengthf := 2,
329 pdp_typeorg := '0001'B,
330 spare := '1111'B,
331 pdp_typenum := '21'O,
332 ipv4_address := ip_addr
333 }
334 }
335 }
Pau Espin Pedrol0d138c62023-08-31 16:23:18 +0200336 template (present) EndUserAddress t_EuaIPv4Dyn := t_EuaIPv4(omit);
Philipp Maier57889492023-08-07 12:10:03 +0200337 template (present) EndUserAddress tr_EuaIPv4(template (present) OCT4 ip_addr) modifies t_EuaIPv4 := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100338 endUserAddress := {
339 endUserAddressIPv4 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100340 lengthf := f_eua_ipv4_len(ip_addr)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100341 }
342 }
343 }
344
Pau Espin Pedrol0d138c62023-08-31 16:23:18 +0200345 template (present) EndUserAddress t_EuaIPv6(template OCT16 ip_addr) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100346 type_gtpc := '80'O,
347 endUserAddress := {
348 endUserAddressIPv6 := {
349 lengthf := 2,
350 pdp_typeorg := '0001'B,
351 spare := '1111'B,
352 pdp_typenum := '57'O,
353 ipv6_address := ip_addr
354 }
355 }
356 }
Pau Espin Pedrol0d138c62023-08-31 16:23:18 +0200357 template (present) EndUserAddress t_EuaIPv6Dyn := t_EuaIPv6(omit);
Philipp Maier57889492023-08-07 12:10:03 +0200358 template (present) EndUserAddress tr_EuaIPv6(template (present) OCT16 ip_addr) modifies t_EuaIPv6 := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100359 endUserAddress := {
360 endUserAddressIPv6 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100361 lengthf := f_eua_ipv6_len(ip_addr)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100362 }
363 }
364 }
365
Oliver Smithee6a0882019-03-08 11:05:46 +0100366 /* 3GPP TS 29.060 Figure 37A: End User Address Information Element for IPv4v6 (both static) */
Pau Espin Pedrol0d138c62023-08-31 16:23:18 +0200367 template (present) EndUserAddress t_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) := {
Oliver Smithee6a0882019-03-08 11:05:46 +0100368 type_gtpc := '80'O,
369 endUserAddress := {
370 endUserAddressIPv4andIPv6 := {
371 lengthf := 2,
372 pdp_typeorg := '0001'B,
373 spare := '1111'B,
374 pdp_typenum := '8D'O,
375 ipv4_address := ip_addr4,
376 ipv6_address := ip_addr6
377 }
378 }
379 }
Pau Espin Pedrol0d138c62023-08-31 16:23:18 +0200380 template (present) EndUserAddress t_EuaIPv4Dynv6Dyn := t_EuaIPv4v6(omit, omit);
Philipp Maier57889492023-08-07 12:10:03 +0200381 template (present) EndUserAddress tr_EuaIPv4v6(template (present) OCT4 ip_addr4,
382 template (present) OCT16 ip_addr6) modifies t_EuaIPv4v6 := {
Oliver Smithee6a0882019-03-08 11:05:46 +0100383 endUserAddress := {
384 endUserAddressIPv4andIPv6 := {
Pau Espin Pedrol001b3e82022-02-23 18:38:37 +0100385 lengthf := f_eua_ipv4v6_len(ip_addr4, ip_addr6)
Oliver Smithee6a0882019-03-08 11:05:46 +0100386 }
387 }
388 }
389
Philipp Maier57889492023-08-07 12:10:03 +0200390 template (value) AccessPointName ts_APN(octetstring apn) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100391 type_gtpc := '83'O,
392 lengthf := lengthof(apn),
393 apn_value := apn
394 }
395
Pau Espin Pedrol408e0ae2023-12-15 18:56:31 +0100396 template (value) GSN_Address_GTPC ts_GsnAddr(template (value) octetstring ip_addr) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100397 type_gtpc := '85'O,
398 lengthf := lengthof(ip_addr),
399 addressf := ip_addr
400 }
401
Philipp Maier57889492023-08-07 12:10:03 +0200402 template (value) MSISDN ts_Msisdn(octetstring msisdn) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100403 type_gtpc := '86'O,
404 lengthf := lengthof(msisdn),
405 msisdn := msisdn
406 }
407
Philipp Maier57889492023-08-07 12:10:03 +0200408 template (value) QualityOfServiceProfile ts_QosDefault := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100409 type_gtpc := '87'O,
Pau Espin Pedrol7d58b082022-06-07 13:30:03 +0200410 lengthf := 17,
Harald Weltec69cf4e2018-02-17 20:57:02 +0100411 allocRetensionPrio := '00'O,
412 qos_ProfileValue := {
413 reliabilityClass := '011'B,
414 delayClass := '001'B,
415 spare1 := '00'B,
416 precedenceClass := '010'B,
417 spare2 := '0'B,
418 peakThroughput := '1001'B,
419 meanThroughput := '11111'B,
420 spare3 := '000'B,
Pau Espin Pedrol7d58b082022-06-07 13:30:03 +0200421 deliverErroneusSDU := '010'B, /* Erroneus SDU are delivered */
422 deliveryOrder := '10'B, /* Without delivery order */
423 trafficClass := '100'B, /* Background */
424 maxSDUSize := '96'O, /* 1500 octets */
425 maxBitrateUplink := 'FE'O, /* 8640, continues in extended octet */
426 maxBitrateDownlink := 'FE'O, /* 8640, continues in extended octet */
427 sduErrorRatio := '0100'B, /* 1x10^-4 */
428 residualBER := '0101'B, /* 1x10^-3 */
429 trafficHandlingPriority := '01'B, /* prio 1 */
430 transferDelay := '000001'B, /* 10 ms */
431 guaranteedBitRateUplink := 'FE'O, /* 8640, continues in extended octet */
432 guaranteedBitRateDownlink := 'FE'O, /* 8640, continues in extended octet */
433 sourceStatisticsDescriptor := '0000'B, /* unknown */
434 signallingIndication := '0'B, /* Not optimized */
435 spare4 := '000'B,
436 maxBitrateDownlinkExt := '5B'O, /* 33 mbps */
437 guaranteedBitRateDownlinkExt := '5B'O, /* 33 mbps */
438 maxBitrateUplinkExt := '6e'O, /* 52 mbps */
439 guaranteedBitRateUplinkExt := '6e'O /* 52 mbps */
Harald Weltec69cf4e2018-02-17 20:57:02 +0100440 }
441 }
442
Philipp Maier57889492023-08-07 12:10:03 +0200443 template (value) IMSI_gtpc ts_Imsi(hexstring digits) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100444 type_gtpc := '02'O,
445 digits := digits,
446 padding := 'F'H
447 }
Pau Espin Pedrol408e0ae2023-12-15 18:56:31 +0100448 function f_ts_Imsi(template (omit) hexstring digits := omit) return template (omit) IMSI_gtpc {
449 var template (omit) IMSI_gtpc imsi;
450 if (istemplatekind(digits, "omit")) {
451 imsi := omit;
452 } else {
453 imsi := ts_Imsi(valueof(digits));
454 }
455 return imsi;
456 }
457 template (present) IMSI_gtpc tr_Imsi(template (present) hexstring digits) := {
458 type_gtpc := '02'O,
459 digits := digits,
460 padding := 'F'H
461 }
462 function f_tr_Imsi(template hexstring digits := *) return template IMSI_gtpc {
463 if (istemplatekind(digits, "omit")) {
464 return omit;
465 } else if (istemplatekind(digits, "*")) {
466 return *;
467 } else {
468 return tr_Imsi(digits);
469 }
470 }
Harald Weltec69cf4e2018-02-17 20:57:02 +0100471
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100472 function f_ts_RATType(template (omit) OCT1 ratType := omit) return template (omit) RATType {
473 var template (omit) RATType rt;
474 if (istemplatekind(ratType, "omit")) {
475 rt := omit;
476 } else {
477 rt := {
478 type_gtpc := '97'O,
479 lengthf := 1,
480 ratTypeValue := ratType
481 };
482 }
483 return rt;
484 }
485
Pau Espin Pedrol408e0ae2023-12-15 18:56:31 +0100486 template (value) RoutingAreaIdentity ts_RoutingAreaIdentity(template (value) hexstring mcc_digits,
487 template (value) hexstring mnc_digits,
488 template (value) OCT2 lac,
489 template (value) OCT1 rac) := {
490 type_gtpc := '03'O,
491 mcc_digits := mcc_digits,
492 mnc_digits := mnc_digits,
493 lac := lac,
494 rac := rac
495 }
496
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100497 template (value) GeographicLocationCGI
498 ts_GeographicLocationCGI(template (value) hexstring mcc,
Philipp Maier57889492023-08-07 12:10:03 +0200499 template (value) hexstring mnc,
500 template (value) OCT2 lac,
501 template (value) OCT2 cI_value) :=
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100502 {
503 mccDigit1 := mcc[0],
504 mccDigit2 := mcc[1],
505 mccDigit3 := mcc[2],
506 mncDigit3 := mnc[2], /* 'F'H for 2 digit MNC */
507 mncDigit1 := mnc[0],
508 mncDigit2 := mnc[1],
509 lac := lac,
510 cI_value := cI_value
511 }
512
Philipp Maier57889492023-08-07 12:10:03 +0200513 template (value) GTPC_PDUs ts_CreatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
514 BIT4 nsapi, EndUserAddress eua, octetstring apn,
515 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
516 octetstring msisdn, template (omit) ProtConfigOptions pco := omit,
517 template (omit) OCT1 ratType := omit,
518 template (omit) UserLocationInformation uli := omit,
519 template (omit) OCT2 charging_char := omit,
520 template (omit) OCT8 imeisv := omit,
521 template (omit) MS_TimeZone ms_tz := omit) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100522 createPDPContextRequest := {
523 imsi := ts_Imsi(imsi),
524 rai := omit,
525 recovery := ts_Recovery(restart_ctr),
526 selectionMode := {
527 type_gtpc := '0F'O,
528 selectModeValue := '00'B,
529 spare := '111111'B
530 },
531 teidDataI := {
532 type_gtpc := '00'O,
533 teidDataI := teid_data
534 },
535 teidControlPlane := {
536 type_gtpc := '00'O,
537 teidControlPlane := teid_ctrl
538 },
539 nsapi := {
540 type_gtpc := '00'O,
541 nsapi := nsapi,
542 unused := '0000'B
543 },
544 linked_nsapi := omit,
Pau Espin Pedrol0e127872022-05-12 17:58:50 +0200545 charging_char := f_ts_ChargingCharacteristics(charging_char),
Harald Weltec69cf4e2018-02-17 20:57:02 +0100546 trace_ref := omit,
547 trace_type := omit,
548 endUserAddress := eua,
549 accessPointName := ts_APN(apn),
550 protConfigOptions := pco,
551 sgsn_addr_signalling := ts_GsnAddr(sgsn_ip_sign),
552 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
553 msisdn := ts_Msisdn(msisdn),
554 qualityOfServiceProfile := ts_QosDefault,
555 tft := omit,
556 triggerId := omit,
557 omcId := omit,
558 commonFlags := omit,
559 aPN_Restriction := omit,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100560 ratType := f_ts_RATType(ratType),
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100561 userLocationInformation := uli,
Pau Espin Pedrol535ca262022-05-16 14:07:17 +0200562 mS_TimeZone := ms_tz,
Pau Espin Pedrol38968e92022-05-13 16:17:48 +0200563 imeisv := f_ts_IMEISV(imeisv),
Harald Weltec69cf4e2018-02-17 20:57:02 +0100564 camelChargingInformationContainer := omit,
565 additionalTraceInfo := omit,
566 correlationID := omit,
567 evolvedAllocationRetentionPriorityI := omit,
568 extendedCommonFlags := omit,
569 userCSGInformation := omit,
570 aPN_AMBR := omit,
571 signallingPriorityIndication := omit,
572 cN_OperatorSelectionEntity := omit,
573 private_extension_gtpc := omit
574 }
575 }
576
Philipp Maier57889492023-08-07 12:10:03 +0200577 template (value) Gtp1cUnitdata ts_GTPC_CreatePDP(GtpPeer peer, uint16_t seq, hexstring imsi,
578 OCT1 restart_ctr, OCT4 teid_data,
579 OCT4 teid_ctrl, BIT4 nsapi, EndUserAddress eua,
580 octetstring apn, octetstring sgsn_ip_sign,
581 octetstring sgsn_ip_data, octetstring msisdn,
582 template (omit) ProtConfigOptions pco := omit,
583 template (omit) OCT1 ratType := omit,
584 template (omit) UserLocationInformation uli := omit,
585 template (omit) OCT2 charging_char := omit,
586 template (omit) OCT8 imeisv := omit,
587 template (omit) MS_TimeZone ms_tz := omit) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100588 peer := peer,
589 gtpc := ts_GTP1C_PDU(createPDPContextRequest, '00000000'O,
590 valueof(ts_CreatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
591 nsapi, eua, apn, sgsn_ip_sign,
Pau Espin Pedrol38968e92022-05-13 16:17:48 +0200592 sgsn_ip_data, msisdn, pco, ratType, uli,
Pau Espin Pedrol535ca262022-05-16 14:07:17 +0200593 charging_char, imeisv, ms_tz)), seq)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100594 }
595
Harald Welteeded9ad2018-02-17 20:57:34 +0100596
Philipp Maier57889492023-08-07 12:10:03 +0200597 template (value) GTPC_PDUs ts_UpdatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
598 BIT4 nsapi,
599 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
600 template (omit) ProtConfigOptions pco := omit,
601 template (omit) OCT1 ratType := omit,
602 template (omit) UserLocationInformation uli := omit) := {
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +0100603 updatePDPContextRequest := {
604 updatePDPContextRequestSGSN := {
605 imsi := ts_Imsi(imsi),
606 rai := omit,
607 recovery := ts_Recovery(restart_ctr),
608 teidDataI := {
609 type_gtpc := '00'O,
610 teidDataI := teid_data
611 },
612 teidControlPlane := {
613 type_gtpc := '00'O,
614 teidControlPlane := teid_ctrl
615 },
616 nsapi := {
617 type_gtpc := '00'O,
618 nsapi := nsapi,
619 unused := '0000'B
620 },
621 trace_ref := omit,
622 trace_type := omit,
623 protConfigOptions := pco,
624 sgsn_addr_controlPlane := ts_GsnAddr(sgsn_ip_sign),
625 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
626 alt_ggsn_addr_controlPane := omit,
627 alt_ggsn_addr_traffic := omit,
628 qualityOfServiceProfile := ts_QosDefault,
629 tft := omit,
630 triggerId := omit,
631 omcId := omit,
632 commonFlags := omit,
633 ratType := f_ts_RATType(ratType),
634 userLocationInformation := uli,
635 mS_TimeZone := omit,
636 additionalTraceInfo := omit,
637 directTunnelFlags := omit,
638 evolvedAllocationRetentionPriorityI := omit,
639 extendedCommonFlags := omit,
640 userCSGInformation := omit,
641 aPN_AMBR := omit,
642 signallingPriorityIndication := omit,
643 cN_OperatorSelectionEntity := omit,
644 private_extension_gtpc := omit
645 }
646 }
647 }
648
Philipp Maier57889492023-08-07 12:10:03 +0200649 template (value) Gtp1cUnitdata ts_GTPC_UpdatePDP(GtpPeer peer, OCT4 teid, uint16_t seq, hexstring imsi,
650 OCT1 restart_ctr, OCT4 teid_data,
651 OCT4 teid_ctrl, BIT4 nsapi, octetstring sgsn_ip_sign,
652 octetstring sgsn_ip_data,
653 template (omit) ProtConfigOptions pco := omit,
654 template (omit) OCT1 ratType := omit,
655 template (omit) UserLocationInformation uli := omit) := {
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +0100656 peer := peer,
657 gtpc := ts_GTP1C_PDU(updatePDPContextRequest, teid,
658 valueof(ts_UpdatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
659 nsapi, sgsn_ip_sign,
660 sgsn_ip_data, pco, ratType, uli)), seq)
661 }
662
663
Philipp Maier57889492023-08-07 12:10:03 +0200664 template (value) NSAPI_GTPC ts_NSAPI(BIT4 nsapi) := {
Harald Welteeded9ad2018-02-17 20:57:34 +0100665 type_gtpc := '14'O,
666 nsapi := nsapi,
667 unused := '0000'B
668 }
669
Philipp Maier57889492023-08-07 12:10:03 +0200670 template (value) ReorderingRequired ts_ReorderReq(boolean req := false) := {
Harald Welteeded9ad2018-02-17 20:57:34 +0100671 type_gtpc := '08'O,
672 reordreq := bool2bit(req),
673 spare := '0000000'B
674 }
675
Philipp Maier57889492023-08-07 12:10:03 +0200676 template (value) GTPC_PDUs ts_CreatePdpRespPDU(OCT1 cause, OCT4 teid_data, OCT4 teid_ctrl, BIT4 nsapi,
677 octetstring ggsn_ip_sign, octetstring ggsn_ip_data,
678 OCT4 chg_id, template (omit) EndUserAddress eua := omit,
679 template (omit) Recovery_gtpc recovery := omit,
680 template (omit) ProtConfigOptions pco := omit) := {
Harald Welteeded9ad2018-02-17 20:57:34 +0100681 createPDPContextResponse := {
682 cause := { '00'O, cause },
683 reorderingRequired := ts_ReorderReq(false),
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200684 recovery := recovery,
Harald Welteeded9ad2018-02-17 20:57:34 +0100685 teidDataI := {
686 type_gtpc := '00'O,
687 teidDataI := teid_data
688 },
689 teidControlPlane := {
690 type_gtpc := '00'O,
691 teidControlPlane := teid_ctrl
692 },
693 nsapi := ts_NSAPI(nsapi),
Harald Welte7aff2ca2018-02-18 15:34:50 +0100694 chargingID := {
695 type_gtpc := '7F'O,
696 chargingID := chg_id
697 },
Harald Welteeded9ad2018-02-17 20:57:34 +0100698 endUserAddress := eua,
699 protConfigOptions := pco,
700 ggsn_addr_controlPlane := ts_GsnAddr(ggsn_ip_sign),
701 ggsn_addr_traffic := ts_GsnAddr(ggsn_ip_data),
702 alt_ggsn_addr_controlPane := omit,
703 alt_ggsn_addr_traffic := omit,
704 qualityOfServiceProfile := ts_QosDefault,
705 commonFlags := omit,
706 aPN_Restriction := omit,
707 mS_InfoChangeReportingAction := omit,
708 bearerControlMode := omit,
709 evolvedAllocationRetentionPriorityI := omit,
710 extendedCommonFlag := omit,
711 csg_information_reporting_action := omit,
712 aPN_AMBR := omit,
713 gGSN_BackOffTime := omit,
714 private_extension_gtpc := omit
715 }
716 }
717
Philipp Maier57889492023-08-07 12:10:03 +0200718 template (value) Gtp1cUnitdata ts_GTPC_CreatePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
719 OCT1 cause,
720 OCT4 teid_ctrl, OCT4 teid_data,
721 BIT4 nsapi, octetstring ggsn_ip_sign,
722 octetstring ggsn_ip_data, OCT4 chg_id,
723 template (omit) EndUserAddress eua := omit,
724 template (omit) Recovery_gtpc recovery := omit,
725 template (omit) ProtConfigOptions pco := omit) := {
Harald Welteeded9ad2018-02-17 20:57:34 +0100726 peer := peer,
727 gtpc := ts_GTP1C_PDU(createPDPContextResponse, teid,
728 valueof(ts_CreatePdpRespPDU(cause, teid_data, teid_ctrl, nsapi,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100729 ggsn_ip_sign, ggsn_ip_data, chg_id,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200730 eua, recovery, pco)), seq)
Harald Welteeded9ad2018-02-17 20:57:34 +0100731 }
732
Harald Weltec69cf4e2018-02-17 20:57:02 +0100733 /* PCO send base template */
Philipp Maier57889492023-08-07 12:10:03 +0200734 template (value) ProtConfigOptions ts_PCO := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100735 type_gtpc := '84'O,
736 lengthf := 0,
737 configProtocol := '000'B,
738 spare := '0000'B,
739 extension0 := '1'B,
740 protocols := {}
741 }
742 /* PCO receive base template */
Philipp Maier57889492023-08-07 12:10:03 +0200743 template (present) ProtConfigOptions tr_PCO := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100744 type_gtpc := '84'O,
745 lengthf := ?,
746 configProtocol := '000'B,
747 spare := ?,
748 extension0 := '1'B,
749 protocols := {}
750 }
751
Philipp Maier57889492023-08-07 12:10:03 +0200752 template (value) ProtConfigOptions ts_PCO_IPv6_DNS modifies ts_PCO := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100753 protocols := {
754 { protocolID := '0003'O, lengthProtoID := 0, protoIDContents := ''O }
755 }
756 }
Philipp Maier57889492023-08-07 12:10:03 +0200757 template (present) ProtConfigOptions tr_PCO_IPv6_DNS_resp(template (present) OCT16 contents) modifies tr_PCO := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100758 protocols := {
759 *, { protocolID := '0003'O, lengthProtoID := 16, protoIDContents := contents }, *
760 }
761 }
762
Philipp Maier57889492023-08-07 12:10:03 +0200763 template (value) ProtConfigOptions ts_PCO_IPv4_DNS_IPCP modifies ts_PCO := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100764 protocols := {
765 /* dummy PAP entry to check if our parser in the GGSN can properly iterate over
766 * the list of protocols, see Change-Id Icc2e6716c33d78d3c3e000f529806228d8aa155e */
767 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
768 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
769 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
770 }
771 }
772
Philipp Maier57889492023-08-07 12:10:03 +0200773 template (value) ProtConfigOptions ts_PCO_IPv4_PRI_DNS_IPCP modifies ts_PCO := {
Philipp Maier33e52612018-05-30 17:22:02 +0200774 protocols := {
775 /* dummy PAP entry to check if our parser can cope with a single primary DNS entry
776 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
777 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
778 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
779 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) }
780 }
781 }
Philipp Maier57889492023-08-07 12:10:03 +0200782 template (value) ProtConfigOptions ts_PCO_IPv4_SEC_DNS_IPCP modifies ts_PCO := {
Philipp Maier33e52612018-05-30 17:22:02 +0200783 protocols := {
784 /* dummy PAP entry to check if our parser can cope with a single secondary DNS entry
785 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
786 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
787 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
788 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
789 }
790 }
Philipp Maier57889492023-08-07 12:10:03 +0200791 template (value) ProtConfigOptions ts_PCO_IPv4_SEPARATE_DNS_IPCP modifies ts_PCO := {
Philipp Maier33e52612018-05-30 17:22:02 +0200792 protocols := {
793 /* dummy PAP entry to check if our parser can cope with a primary and secondary DNS
794 * in separate IPCP containers OS#3381 */
795 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
796 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
797 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) },
798 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
799 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
800 }
801 }
802
Philipp Maier57889492023-08-07 12:10:03 +0200803 template (present) ProtocolElement tr_PCO_Proto(OCT2 prot_id) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100804 protocolID := prot_id,
805 lengthProtoID := ?,
806 protoIDContents := ?
807 }
Philipp Maier57889492023-08-07 12:10:03 +0200808 template (value) ProtocolElement ts_PCOelem_PAP_broken := {
Harald Weltef8298542019-04-10 10:15:28 +0200809 protocolID := 'C023'O,
810 lengthProtoID := 60,
811 /* PPP Password Authentication Protocol containing incorrect Peer-Id-Length set to 4 (6-7 should be the valid one), see OS#3914. */
812 protoIDContents := '0100003c'O & '0444435338323700bc1c08087c1508083e00790000150808fd06000001000000000000000000000000000000000000000000000000000000'O
813 }
Philipp Maier57889492023-08-07 12:10:03 +0200814 template (value) ProtConfigOptions ts_PCO_PAP_IPv4_DNS modifies ts_PCO := {
Harald Weltef8298542019-04-10 10:15:28 +0200815 protocols := {
816 ts_PCOelem_PAP_broken,
817 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
818 }
819 }
Philipp Maier57889492023-08-07 12:10:03 +0200820 template (present) ProtConfigOptions tr_PCO_Contains(OCT2 prot_id) modifies tr_PCO := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100821 protocols := { *, tr_PCO_Proto(prot_id), * }
822 }
823
Philipp Maier57889492023-08-07 12:10:03 +0200824 template (value) ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100825 protocols := {
826 { protocolID := '000d'O, lengthProtoID := 0, protoIDContents := ''O }
827 }
828 }
Philipp Maier57889492023-08-07 12:10:03 +0200829 template (present) ProtConfigOptions tr_PCO_IPv4_DNS_CONT_resp(template (present) OCT4 contents) modifies tr_PCO := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100830 protocols := {
831 *, { protocolID := '000d'O, lengthProtoID := 4, protoIDContents := contents }, *
832 }
833 }
834
835 /* extract a given protocol payload from PCO */
836 function f_PCO_extract_proto(ProtConfigOptions pco, OCT2 protocol, integer nth_match := 1) return octetstring {
837 var integer i;
838 var integer num_matches := 0;
839 for (i := 0; i < lengthof(pco.protocols); i := i + 1) {
840 if (pco.protocols[i].protocolID == protocol) {
841 num_matches := num_matches + 1;
842 if (num_matches == nth_match) {
843 return pco.protocols[i].protoIDContents;
844 }
845 }
846 }
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200847 setverdict(fail, "Could not extract protocol payload from protocol ", protocol);
848 mtc.stop;
Harald Weltec69cf4e2018-02-17 20:57:02 +0100849 return ''O;
850 }
851
Philipp Maier57889492023-08-07 12:10:03 +0200852 template (present) IpcpPacket tr_IPCP(template (present) LcpCode code, template (present)uint8_t identifier,
853 template (present) IpcpOptionList opts) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100854 code := code,
855 identifier := identifier,
856 len := ?,
857 options := opts
858 }
Philipp Maier57889492023-08-07 12:10:03 +0200859 template (present) IpcpOption tr_IPCP_PrimaryDns(template (present) OCT4 addr) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100860 code := IPCP_OPT_PrimaryDNS,
861 len := 6,
862 data := addr
863 }
Philipp Maier57889492023-08-07 12:10:03 +0200864 template (present) IpcpOption tr_IPCP_SecondaryDns(template (present) OCT4 addr) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100865 code := IPCP_OPT_SecondaryDNS,
866 len := 6,
867 data := addr
868 }
Philipp Maier57889492023-08-07 12:10:03 +0200869 template (present) IpcpPacket tr_IPCP_Ack_DNS(template (present) uint8_t identifier := ?,
870 template (present) OCT4 dns1 := ?,
871 template (present) OCT4 dns2 := ?) :=
Harald Weltec69cf4e2018-02-17 20:57:02 +0100872 tr_IPCP(LCP_Configure_Ack, identifier,
873 { *, tr_IPCP_PrimaryDns(dns1), *, tr_IPCP_SecondaryDns(dns2), * });
874
Philipp Maier57889492023-08-07 12:10:03 +0200875 template (value) IpcpPacket ts_IPCP(LcpCode code, uint8_t identifier, template (value) IpcpOptionList opts) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100876 code := code,
877 identifier := identifier,
878 len := 0, /* overwritten */
879 options := opts
880 }
Philipp Maier57889492023-08-07 12:10:03 +0200881 template (value) IpcpPacket ts_IPCP_ReqDNS(uint8_t identifier := 0) :=
Harald Weltec69cf4e2018-02-17 20:57:02 +0100882 ts_IPCP(LCP_Configure_Request, identifier,
883 { tr_IPCP_PrimaryDns('00000000'O), tr_IPCP_SecondaryDns('00000000'O) });
884
Philipp Maier57889492023-08-07 12:10:03 +0200885 template (value) IpcpPacket ts_IPCP_ReqDNS_Primary(uint8_t identifier := 0) :=
Philipp Maier33e52612018-05-30 17:22:02 +0200886 ts_IPCP(LCP_Configure_Request, identifier,
887 { tr_IPCP_PrimaryDns('00000000'O) });
Philipp Maier57889492023-08-07 12:10:03 +0200888 template (value) IpcpPacket ts_IPCP_ReqDNS_Secondary(uint8_t identifier := 0) :=
Philipp Maier33e52612018-05-30 17:22:02 +0200889 ts_IPCP(LCP_Configure_Request, identifier,
890 { tr_IPCP_SecondaryDns('00000000'O) });
891
Harald Welte57b9b7f2018-02-18 22:28:13 +0100892 function f_teardown_ind_IE(in template (omit) BIT1 ind) return template (omit) TearDownInd {
893 if (istemplatekind(ind, "omit")) {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100894 return omit;
895 }
Harald Weltec69cf4e2018-02-17 20:57:02 +0100896 var TearDownInd ret := {
897 type_gtpc := '13'O,
898 tdInd := valueof(ind),
899 spare:= '0000000'B
900 }
901 return ret;
902 }
903
Philipp Maier57889492023-08-07 12:10:03 +0200904 template (value) GTPC_PDUs ts_DeletePdpPDU(BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100905 deletePDPContextRequest := {
906 cause := omit,
907 tearDownIndicator := f_teardown_ind_IE(teardown_ind),
908 nsapi := {
909 type_gtpc := '14'O,
910 nsapi := nsapi,
911 unused := '0000'B
912 },
913 protConfigOptions := omit,
914 userLocationInformation := omit,
915 mS_TimeZone := omit,
916 extendedCommonFlags := omit,
917 uLI_Timestamp := omit,
918 private_extension_gtpc := omit
919 }
920 }
921
Philipp Maier57889492023-08-07 12:10:03 +0200922 template (value) Gtp1cUnitdata ts_GTPC_DeletePDP(GtpPeer peer, uint16_t seq, OCT4 teid,
923 BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100924 peer := peer,
925 gtpc := ts_GTP1C_PDU(deletePDPContextRequest, teid,
926 valueof(ts_DeletePdpPDU(nsapi, teardown_ind)), seq)
927 }
928
Philipp Maier57889492023-08-07 12:10:03 +0200929 template (value) GTPC_PDUs ts_DeletePdpRespPDU(OCT1 cause,
930 template (omit) ProtConfigOptions pco := omit) := {
Harald Welte6f203162018-02-18 22:04:55 +0100931 deletePDPContextResponse := {
932 cause := { '00'O, cause },
933 protConfigOptions := pco,
934 userLocationInformation := omit,
935 mS_TimeZone := omit,
936 uLI_Timestamp := omit,
937 private_extension_gtpc := omit
938 }
939 }
940
Philipp Maier57889492023-08-07 12:10:03 +0200941 template (value) Gtp1cUnitdata ts_GTPC_DeletePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
942 OCT1 cause,
943 template (omit) ProtConfigOptions pco := omit) := {
Harald Welte6f203162018-02-18 22:04:55 +0100944 peer := peer,
945 gtpc := ts_GTP1C_PDU(deletePDPContextResponse, teid,
946 valueof(ts_DeletePdpRespPDU(cause, pco)), seq)
947 }
948
Pau Espin Pedrol408e0ae2023-12-15 18:56:31 +0100949 /* SGSN Context Request - 7.5.3 */
950 template (value) GTPC_PDUs ts_SGSNContextReqPDU(template (value) RoutingAreaIdentity rai,
951 template (value) OCT4 teic,
952 template (value) octetstring sgsn_addr_control,
953 template (omit) hexstring imsi := omit,
954 template (value) BIT1 msValidated := '0'B,
955 template (omit) TLLI tlli := omit,
956 template (omit) PacketTMSI ptmsi := omit,
957 template (omit) PTMSI_Signature ptmsi_sig := omit,
958 template (omit) OCT1 rat_type := omit) := {
959 sgsn_ContextRequest := {
960 imsi := f_ts_Imsi(imsi),
961 routingAreaIdentity := rai,
962 tlli := tlli,
963 packetTMSI := ptmsi,
964 ptmsi_Signature := ptmsi_sig,
965 ms_Validated := {
966 type_gtpc := '0D'O,
967 msValidated := msValidated,
968 spare := '1111111'B
969 },
970 teidControlPlane := {
971 type_gtpc := '11'O,
972 teidControlPlane := teic
973 },
974 sgsn_addr_controlPlane := ts_GsnAddr(sgsn_addr_control),
975 alternative_sgsn_addr_controlPlane := omit,
976 sGSN_Number := omit,
977 ratType := f_ts_RATType(rat_type),
978 hopCounter := omit,
979 private_extension_gtpc := omit
980 }
981 }
982 template (value) Gtp1cUnitdata ts_GTPC_SGSNContextReq(GtpPeer peer, uint16_t seq,
983 template (value) GTPC_PDUs SGSNContextReqPDU) := {
984 peer := peer,
985 gtpc := ts_GTP1C_PDU(sgsnContextRequest, '00000000'O, valueof(SGSNContextReqPDU), seq)
986 }
987
988 /* SGSN Context Response - 7.5.4 */
989 template (present) GTPC_PDUs tr_SGSNContextRespPDU(template (present) GTP_Cause cause := ?,
990 template hexstring imsi := *) := {
991 sgsn_ContextResponse := {
992 cause := tr_Cause_gtpc(cause),
993 imsi := f_tr_Imsi(imsi),
994 teidControlPlane := *,
995 rabContext := *,
996 radioPrioritySMS := *,
997 radioPriority := *,
998 packetFlowID := *,
999 charging_char := *,
1000 mm_Context := *,
1001 pdp_Context := *,
1002 sgsn_addr_controlPlane := *,
1003 pdpContextPriorization := *,
1004 radioPriority_LCS := *,
1005 mBMS_UE_Context := *,
1006 subscribedRFSP_Index := *,
1007 rFSP_IndexInUse := *,
1008 colocatedGGSN_PGW_FQDN := *,
1009 evolvedAllocationRetentionPriorityII := *,
1010 extendedCommonFlags := *,
1011 ue_network_capability := *,
1012 ue_ambr := *,
1013 apn_ambr_nsapi := *,
1014 signallingPriorityIndication_nsapi := *,
1015 higher_bitrates_than_16mbps_flag := *,
1016 selectionMode_nsapi := *,
1017 localHomeNetworkID_nsapi := *,
1018 uE_UsageType := *,
1019 extendedCommonFlagsII := *,
1020 private_extension_gtpc := *
1021 }
1022 }
1023 template (present) Gtp1cUnitdata tr_GTPC_SGSNContextResp(template (present) GtpPeer peer := ?,
1024 template (present) OCT4 teid := ?,
1025 template (present) GTPC_PDUs SGSNContextRespPDU := ?)
1026 := tr_GTPC_MsgType(peer, sgsnContextResponse, teid, SGSNContextRespPDU);
1027
1028 /* SGSN Context Acknowledge - 7.5.5 */
1029 template (value) GTPC_PDUs ts_SGSNContextAckPDU(template (value) GTP_Cause cause := GTP_CAUSE_REQUEST_ACCEPTED) := {
1030 sgsn_ContextAcknowledge := {
1031 cause := ts_Cause_gtpc(cause),
1032 teidDataII := omit,
1033 sgsn_AddressForUserTraffic := omit,
1034 sgsn_Number := omit,
1035 nodeIdentifier := omit,
1036 private_extension_gtpc := omit
1037 }
1038 }
Pau Espin Pedrolca651b52023-12-20 18:37:39 +01001039 template (value) Gtp1cUnitdata ts_GTPC_SGSNContextAck(GtpPeer peer, OCT4 teid, uint16_t seq,
Pau Espin Pedrol408e0ae2023-12-15 18:56:31 +01001040 template (value) GTPC_PDUs SGSNContextAckPDU := ts_SGSNContextAckPDU(GTP_CAUSE_REQUEST_ACCEPTED)) := {
1041 peer := peer,
Pau Espin Pedrolca651b52023-12-20 18:37:39 +01001042 gtpc := ts_GTP1C_PDU(sgsnContextAcknowledge, teid, valueof(SGSNContextAckPDU), seq)
Pau Espin Pedrol408e0ae2023-12-15 18:56:31 +01001043 }
Harald Welte6f203162018-02-18 22:04:55 +01001044
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001045 /* GTP-C RIM */
1046
1047 template (value) RIM_Application_Identity_GTPC ts_GTPC_RIM_Application_Identity(OCT1 app_id) := {
1048 iEI := '4B'O,
1049 ext := '1'B,
1050 lengthIndicator := {
1051 length1 := 1
1052 },
1053 rIMApplicationIdentity := app_id
1054 }
1055 /* 3GPP TS 48.018 11.3.62 */
1056 template (value) RIM_Sequence_Number_GTPC ts_GTPC_RIM_Sequence_Number(integer seq) := {
1057 iEI := '4C'O,
1058 ext := '1'B,
1059 lengthIndicator := {
1060 length1 := 4
1061 },
1062 rIMSequenceNumber := int2oct(seq, 4)
1063 }
1064 template (value) RIM_PDU_Indications_GTPC ts_GTPC_RIM_PDU_Indications(boolean ack, BIT3 type_ext) := {
1065 iEI := '4F'O,
1066 ext := '1'B,
1067 lengthIndicator := {
1068 length1 := 1
1069 },
1070 ack := bool2bit(ack),
1071 pDU_Type_Extension := type_ext,
1072 reserved := '0000'B
1073 }
1074 /* 3GPP TS 48.018 11.3.67 */
1075 template (value) RIM_Protocol_Version_Number_GTPC ts_GTPC_RIM_Protocol_Version_Number(integer ver) := {
1076 iEI := '55'O,
1077 ext := '1'B,
1078 lengthIndicator := {
1079 length1 := 1
1080 },
1081 rIMProtocolVersionNumber := int2oct(ver, 1)
1082 }
Philipp Maier57889492023-08-07 12:10:03 +02001083 function tr_GTPC_Cell_Identifier_V(template (present) GTP_CellId cid) return template (present) Cell_Identifier_V_GTPC {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001084 var template Cell_Identifier_V_GTPC ret := {
1085 mccDigit1 := ?,
1086 mccDigit2 := ?,
1087 mccDigit3 := ?,
1088 mncDigit3 := ?,
1089 mncDigit1 := ?,
1090 mncDigit2 := ?,
1091 lac := ?,
1092 rac := ?,
1093 cI_value := ?
1094 }
Philipp Maier57889492023-08-07 12:10:03 +02001095 if (istemplatekind(cid, "?")) {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001096 return ?;
1097 }
1098 if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) {
1099 if (isvalue(cid.ra_id.lai.mcc_mnc)) {
1100 ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0];
1101 ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1];
1102 ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2];
1103 ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3];
1104 ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4];
1105 ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5];
1106 }
1107 if (isvalue(cid.ra_id.lai.lac)) {
1108 ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2);
1109 }
1110 }
1111 if (isvalue(cid) and isvalue(cid.ra_id)) {
1112 ret.rac := f_oct_or_wc(cid.ra_id.rac, 1);
1113 }
1114 if (isvalue(cid)) {
1115 ret.cI_value := f_oct_or_wc(cid.cell_id, 2);
1116 }
1117 return ret;
1118 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001119 template (value) Cell_Identifier_V_GTPC ts_GTPC_Cell_Identifier_V(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001120 mccDigit1 := cid.ra_id.lai.mcc_mnc[0],
1121 mccDigit2 := cid.ra_id.lai.mcc_mnc[1],
1122 mccDigit3 := cid.ra_id.lai.mcc_mnc[2],
1123 mncDigit3 := cid.ra_id.lai.mcc_mnc[3],
1124 mncDigit1 := cid.ra_id.lai.mcc_mnc[4],
1125 mncDigit2 := cid.ra_id.lai.mcc_mnc[5],
1126 lac := int2oct(cid.ra_id.lai.lac, 2),
1127 rac := int2oct(cid.ra_id.rac, 1),
1128 cI_value := int2oct(cid.cell_id, 2)
1129 }
Philipp Maier57889492023-08-07 12:10:03 +02001130 template (value) RIM_Routing_Address_GTPC t_GTPC_RIM_Routing_Address_cid(GTP_CellId cid) := {
1131 cell_Identifier := ts_GTPC_Cell_Identifier_V(cid)
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001132 }
Philipp Maier57889492023-08-07 12:10:03 +02001133 function tr_GTPC_ENB_Identifier(template (present) GTP_CellId cid,
1134 template (present) integer tac,
1135 template (present) octetstring gnbid) return template (present) ENB_Identifier {
1136 var template (present) ENB_Identifier ret := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001137 mccDigit1 := ?,
1138 mccDigit2 := ?,
1139 mccDigit3 := ?,
1140 mncDigit3 := ?,
1141 mncDigit1 := ?,
1142 mncDigit2 := ?,
1143 tAC := ?,
1144 globalENB_ID := ?
1145 }
Philipp Maier57889492023-08-07 12:10:03 +02001146 if (istemplatekind(cid, "?") and istemplatekind(tac, "?") and istemplatekind(gnbid, "?")) {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001147 return ?;
1148 }
1149 if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) {
1150 if (isvalue(cid.ra_id.lai.mcc_mnc)) {
1151 ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0];
1152 ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1];
1153 ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2];
1154 ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3];
1155 ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4];
1156 ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5];
1157 }
1158 }
1159 if (isvalue(tac)) {
1160 ret.tAC := int2oct(valueof(tac), 2);
1161 }
1162 if (isvalue(gnbid)) {
1163 ret.globalENB_ID := gnbid;
1164 }
1165
1166 return ret;
1167 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001168 template (value) ENB_Identifier ts_GTPC_ENB_Identifier(GTP_CellId cid, integer tac, octetstring gnbid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001169 mccDigit1 := cid.ra_id.lai.mcc_mnc[0],
1170 mccDigit2 := cid.ra_id.lai.mcc_mnc[1],
1171 mccDigit3 := cid.ra_id.lai.mcc_mnc[2],
1172 mncDigit3 := cid.ra_id.lai.mcc_mnc[3],
1173 mncDigit1 := cid.ra_id.lai.mcc_mnc[4],
1174 mncDigit2 := cid.ra_id.lai.mcc_mnc[5],
1175 tAC := int2oct(tac, 2),
1176 globalENB_ID := gnbid
1177 }
Philipp Maier57889492023-08-07 12:10:03 +02001178 template (value) RIM_Routing_Address_GTPC t_GTPC_RIM_Routing_Address_enbid(GTP_CellId cid, integer tac, octetstring gnbid) := {
1179 eNB_Identifier := ts_GTPC_ENB_Identifier(cid, tac, gnbid)
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001180 }
Philipp Maier57889492023-08-07 12:10:03 +02001181 template (present) RIM_Routing_Information_GTPC
1182 tr_GTPC_RIM_Routing_Information(HEX1 addr_discr, template (present) RIM_Routing_Address_GTPC addr) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001183 iEI := '54'O,
1184 ext := '1'B,
1185 lengthIndicator := {
1186 length1 := ?
1187 },
1188 rIMRoutingAddressDiscriminator := addr_discr,
1189 spare := '0'H,
1190 rIM_Routing_Address := addr
1191 }
1192 template (value) RIM_Routing_Information_GTPC
1193 ts_GTPC_RIM_Routing_Information(HEX1 addr_discr, template (value) RIM_Routing_Address_GTPC addr) := {
1194 iEI := '54'O,
1195 ext := '1'B,
1196 lengthIndicator := {
1197 length1 := 0 /* overwritten */
1198 },
1199 rIMRoutingAddressDiscriminator := addr_discr,
1200 spare := '0'H,
1201 rIM_Routing_Address := addr
1202 }
1203 /* 3GPP TS 48.018 11.3.63.1.1 */
Philipp Maier57889492023-08-07 12:10:03 +02001204 template (present) RAN_Information_Request_Application_Container_NACC_GTPC
1205 tr_GTPC_RAN_Information_Request_Application_Container_NACC(template (present) GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001206 iEI := '4D'O,
1207 ext := '1'B,
1208 lengthIndicator := {
1209 length1 := ?
1210 },
1211 reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid)
1212 }
1213 template (value) RAN_Information_Request_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001214 ts_GTPC_RAN_Information_Request_Application_Container_NACC(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001215 iEI := '4D'O,
1216 ext := '1'B,
1217 lengthIndicator := {
1218 length1 := 0 /* overwritten */
1219 },
1220 reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid)
1221 }
1222 /* 3GPP TS 48.018 11.3.63.1 */
Philipp Maier57889492023-08-07 12:10:03 +02001223 template (present) RAN_Information_Request_Application_Container_GTPC
1224 tru_GTPC_RAN_Information_Request_Application_Container_NACC(template (present) GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001225 nacc := tr_GTPC_RAN_Information_Request_Application_Container_NACC(cid)
1226 }
1227 template (value) RAN_Information_Request_Application_Container_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001228 tsu_GTPC_RAN_Information_Request_Application_Container_NACC(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001229 nacc := ts_GTPC_RAN_Information_Request_Application_Container_NACC(cid)
1230 }
1231 /* 3GPP TS 48.018 11.3.63.2.1 */
Philipp Maier57889492023-08-07 12:10:03 +02001232 template (present) RAN_Information_Application_Container_NACC_GTPC
1233 tr_GTPC_RAN_Information_Application_Container_NACC(template (present) GTP_CellId cid, boolean psi_type, integer si_psi_num, octetstring si_psi) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001234 iEI := '4E'O,
1235 ext := '1'B,
1236 lengthIndicator := {
1237 length1 := ?
1238 },
1239 reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid),
1240 typeBit := bool2bit(psi_type),
1241 number_of_SI_PSI := int2bit(si_psi_num, 7),
1242 sI_PSI := si_psi
1243 }
1244 template (value) RAN_Information_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001245 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 +02001246 iEI := '4E'O,
1247 ext := '1'B,
1248 lengthIndicator := {
1249 length1 := 0 /* overwritten */
1250 },
1251 reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid),
1252 typeBit := bool2bit(psi_type),
1253 number_of_SI_PSI := int2bit(si_psi_num, 7),
1254 sI_PSI := si_psi
1255 }
Philipp Maierf7cb0bb2023-07-28 12:35:38 +02001256 external function enc_RIM_Routing_Address_GTPC(in RIM_Routing_Address_GTPC ra) return octetstring
1257 with { extension "prototype(convert) encode(RAW)" };
Philipp Maier21bac7a2023-08-24 12:40:17 +02001258 external function dec_RIM_Routing_Address_GTPC(in octetstring stream) return RIM_Routing_Address_GTPC
Philipp Maierf7cb0bb2023-07-28 12:35:38 +02001259 with { extension "prototype(convert) decode(RAW)" };
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001260
1261 /* RAN_Information_Request */
1262 template (value) RAN_Information_Request_RIM_Container_GTPC
1263 ts_GTPC_RAN_Information_Request_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id,
1264 template (value) RIM_Sequence_Number_GTPC seq,
1265 template (value) RIM_PDU_Indications_GTPC ind,
1266 template (omit) RIM_Protocol_Version_Number_GTPC ver := omit,
1267 template (omit) RAN_Information_Request_Application_Container_GTPC app_cont := omit,
1268 template (omit) SON_TransferApplicationIdentity son_app_id := omit) := {
1269 iEI := '57'O,
1270 ext := '1'B,
1271 lengthIndicator := {
1272 length1 := 0 /* overwritten */
1273 },
1274 rIM_Application_Identity := app_id,
1275 rIM_Sequence_Number := seq,
1276 rIM_PDU_Indications := ind,
1277 rIM_Protocol_Version_Number := ver,
1278 application_Container := app_cont,
1279 sON_TransferApplicationIdentity := son_app_id
1280 }
1281 template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC
1282 ts_GTPC_RAN_Information_Request(template (value) RIM_Routing_Information_GTPC dest,
1283 template (value) RIM_Routing_Information_GTPC src,
Philipp Maier6cef1c32023-07-24 11:01:52 +02001284 template (value) RAN_Information_Request_RIM_Container_GTPC cont) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001285 bssgpPduType := '71'O,
1286 destination_Cell_Identifier := dest,
1287 source_Cell_Identifier := src,
1288 rIM_Container := cont
1289 }
Philipp Maier57889492023-08-07 12:10:03 +02001290 template (present) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC
1291 tr_GTPC_RAN_Information_Request(template (present) RIM_Routing_Information_GTPC dest := ?,
1292 template (present) RIM_Routing_Information_GTPC src := ?,
1293 template (present) RAN_Information_Request_RIM_Container_GTPC cont := ?) := {
Philipp Maier4b81c6e2023-07-24 11:03:15 +02001294 bssgpPduType := '71'O,
1295 destination_Cell_Identifier := dest,
1296 source_Cell_Identifier := src,
1297 rIM_Container := cont
1298 }
1299
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001300 template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO_REQ(template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC pdu) := {
1301 type_gtpc := '90'O,
1302 lengthf := 0, /* FIXME */
1303 rANTransparentContainerField := {
1304 pDU_BSSGP_RAN_INFORMATION_REQUEST := pdu
1305 }
1306 }
Philipp Maier57889492023-08-07 12:10:03 +02001307 template (present) RANTransparentContainer tr_RANTransparentContainer_RAN_INFO_REQ(template (present) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC pdu := ?) := {
Philipp Maieredce92f2023-07-26 11:02:10 +02001308 type_gtpc := '90'O,
1309 lengthf := ?,
1310 rANTransparentContainerField := {
1311 pDU_BSSGP_RAN_INFORMATION_REQUEST := pdu
1312 }
1313 }
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001314
1315 /* RAN_Information */
Philipp Maier57889492023-08-07 12:10:03 +02001316 template (present) ApplContainer_or_ApplErrContainer_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001317 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 +02001318 application_Container := tr_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi)
1319 }
1320 template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +01001321 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 +02001322 application_Container := ts_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi)
1323 }
Philipp Maier57889492023-08-07 12:10:03 +02001324 template (present) ApplContainer_or_ApplErrContainer_GTPC
1325 tru_GTPC_ApplContainer_or_ApplErrContainer_NACC(template (present) ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001326 nacc := cont
1327 }
1328 template (value) ApplContainer_or_ApplErrContainer_GTPC
1329 tsu_GTPC_ApplContainer_or_ApplErrContainer_NACC(template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := {
1330 nacc := cont
1331 }
Philipp Maier57889492023-08-07 12:10:03 +02001332 template (present) RAN_Information_RIM_Container_GTPC
1333 tr_GTPC_RAN_Information_RIM_Container(template (present) RIM_Application_Identity_GTPC app_id,
1334 template (present) RIM_Sequence_Number_GTPC seq,
1335 template (present) RIM_PDU_Indications_GTPC ind,
1336 template RIM_Protocol_Version_Number_GTPC ver := *,
1337 template ApplContainer_or_ApplErrContainer_GTPC app_cont := *,
1338 template SON_TransferApplicationIdentity son_app_id := *) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001339 iEI := '58'O,
1340 ext := '1'B,
1341 lengthIndicator := {
1342 length1 := ?
1343 },
1344 rIM_Application_Identity := app_id,
1345 rIM_Sequence_Number := seq,
1346 rIM_PDU_Indications := ind,
1347 rIM_Protocol_Version_Number := ver,
1348 applContainer_or_ApplErrContainer := app_cont,
1349 sON_TransferApplicationIdentity := son_app_id
1350 }
1351 template (value) RAN_Information_RIM_Container_GTPC
1352 ts_GTPC_RAN_Information_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id,
1353 template (value) RIM_Sequence_Number_GTPC seq,
1354 template (value) RIM_PDU_Indications_GTPC ind,
1355 template (omit) RIM_Protocol_Version_Number_GTPC ver := omit,
1356 template (omit) ApplContainer_or_ApplErrContainer_GTPC app_cont := omit,
1357 template (omit) SON_TransferApplicationIdentity son_app_id := omit) := {
1358 iEI := '58'O,
1359 ext := '1'B,
1360 lengthIndicator := {
1361 length1 := 0 /* overwritten */
1362 },
1363 rIM_Application_Identity := app_id,
1364 rIM_Sequence_Number := seq,
1365 rIM_PDU_Indications := ind,
1366 rIM_Protocol_Version_Number := ver,
1367 applContainer_or_ApplErrContainer := app_cont,
1368 sON_TransferApplicationIdentity := son_app_id
1369 }
Philipp Maier57889492023-08-07 12:10:03 +02001370 template (present) PDU_BSSGP_RAN_INFORMATION_GTPC
1371 tr_GTPC_RAN_Information(template (present) RIM_Routing_Information_GTPC dest,
1372 template (present) RIM_Routing_Information_GTPC src,
1373 template (present) RAN_Information_RIM_Container_GTPC cont) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001374 bssgpPduType := '70'O,
1375 destination_Cell_Identifier := dest,
1376 source_Cell_Identifier := src,
1377 rIM_Container := cont
1378 }
1379 template (value) PDU_BSSGP_RAN_INFORMATION_GTPC
1380 ts_GTPC_RAN_Information(template (value) RIM_Routing_Information_GTPC dest,
1381 template (value) RIM_Routing_Information_GTPC src,
1382 template (value) RAN_Information_RIM_Container_GTPC cont) := {
1383 bssgpPduType := '70'O,
1384 destination_Cell_Identifier := dest,
1385 source_Cell_Identifier := src,
1386 rIM_Container := cont
1387 }
Philipp Maier57889492023-08-07 12:10:03 +02001388 template (present) RANTransparentContainer tr_RANTransparentContainer_RAN_INFO(template (present) PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001389 type_gtpc := '90'O,
1390 lengthf := ?,
1391 rANTransparentContainerField := {
1392 pDU_BSSGP_RAN_INFORMATION := pdu
1393 }
1394 }
1395 template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO(template (value) PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := {
1396 type_gtpc := '90'O,
1397 lengthf := 0, /* overwritten */
1398 rANTransparentContainerField := {
1399 pDU_BSSGP_RAN_INFORMATION := pdu
1400 }
1401 }
1402
Philipp Maier57889492023-08-07 12:10:03 +02001403 template (present) RANTransparentContainer tr_RANTransparentContainer(template (present) RANTransparentContainerField rANTransparentContainerField) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001404 type_gtpc := '90'O,
1405 lengthf := ?,
1406 rANTransparentContainerField := rANTransparentContainerField
1407 }
1408 template (value) RANTransparentContainer ts_RANTransparentContainer(template (value) RANTransparentContainerField rANTransparentContainerField) := {
1409 type_gtpc := '90'O,
1410 lengthf := 0, /* overwritten */
1411 rANTransparentContainerField := rANTransparentContainerField
1412 }
Philipp Maier57889492023-08-07 12:10:03 +02001413 template (present) GTPC_PDUs tr_RANInfoRelay(template (present) RANTransparentContainer transparentContainer) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001414 ranInformationRelay := {
1415 transparentContainer := transparentContainer,
1416 rIM_RoutingAddress := *,
1417 rIM_RoutingAddress_Discriminator := *,
1418 private_extension_gtpc := *
1419 }
1420 }
Philipp Maier05ad55c2023-07-24 10:56:46 +02001421 template (value) GTPC_PDUs ts_RANInfoRelay(template (value) RANTransparentContainer transparentContainer,
1422 template (omit) RIM_RoutingAddress ra := omit,
1423 template (omit) RIM_RoutingAddress_Discriminator ra_discr := omit) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001424 ranInformationRelay := {
1425 transparentContainer := transparentContainer,
Philipp Maier05ad55c2023-07-24 10:56:46 +02001426 rIM_RoutingAddress := ra,
1427 rIM_RoutingAddress_Discriminator := ra_discr,
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001428 private_extension_gtpc := omit
1429 }
1430 }
Philipp Maier57889492023-08-07 12:10:03 +02001431 template (present) Gtp1cUnitdata
1432 tr_GTPC_RANInfoRelay(template (present) GtpPeer peer,
1433 template (present) RANTransparentContainer transparentContainer) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001434 peer := peer,
1435 gtpc := tr_GTP1C_PDU(rANInformationRelay, '00000000'O, tr_RANInfoRelay(transparentContainer))
1436 }
1437 template (value) Gtp1cUnitdata
1438 ts_GTPC_RANInfoRelay(template (value) GtpPeer peer,
Philipp Maier05ad55c2023-07-24 10:56:46 +02001439 template (value) RANTransparentContainer transparentContainer,
1440 template (omit) RIM_RoutingAddress ra := omit,
1441 template (omit) RIM_RoutingAddress_Discriminator ra_discr := omit) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001442 peer := peer,
Philipp Maier05ad55c2023-07-24 10:56:46 +02001443 gtpc := ts_GTP1C_PDU(rANInformationRelay, '00000000'O, valueof(ts_RANInfoRelay(transparentContainer, ra, ra_discr)), 0)
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001444 }
1445
1446
Philipp Maier57889492023-08-07 12:10:03 +02001447 template (present) RAN_Information_Request_RIM_Container_GTPC
1448 tr_GTPC_RAN_Information_Request_RIM_Container(template (present) RIM_Application_Identity_GTPC app_id := ?,
1449 template (present) RIM_Sequence_Number_GTPC seq := ?,
1450 template (present) RIM_PDU_Indications_GTPC ind := ?,
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +02001451 template RIM_Protocol_Version_Number_GTPC ver := *,
1452 template RAN_Information_Request_Application_Container_GTPC app_cont := *,
1453 template SON_TransferApplicationIdentity son_app_id := *) := {
1454 iEI := '57'O,
1455 ext := '1'B,
1456 lengthIndicator := {
1457 length1 := ?
1458 },
1459 rIM_Application_Identity := app_id,
1460 rIM_Sequence_Number := seq,
1461 rIM_PDU_Indications := ind,
1462 rIM_Protocol_Version_Number := ver,
1463 application_Container := app_cont,
1464 sON_TransferApplicationIdentity := son_app_id
1465 }
Harald Weltec69cf4e2018-02-17 20:57:02 +01001466
1467 /* GTP-U */
1468
Philipp Maier57889492023-08-07 12:10:03 +02001469 template (present) PDU_GTPU tr_GTP1U_PDU(template (present) OCT1 msg_type,
1470 template (present) OCT4 teid,
1471 template (present) GTPU_IEs ies := ?) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +01001472 pn_bit := ?,
1473 s_bit := ?,
1474 e_bit := ?,
1475 spare := ?,
1476 /* Protocol Type flag (PT) shall be set to '1' in GTP */
1477 pt := '1'B,
1478 /* Version shall be set to decimal 1 ('001'). */
1479 version := '001'B,
1480 messageType := msg_type,
1481 lengthf := ?,
1482 teid := teid,
1483 opt_part := *,
1484 gtpu_IEs := ies
1485 }
1486
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001487 function f_GTPU_s_bit(template (omit) uint16_t seq) return BIT1 {
1488 if (istemplatekind(seq, "omit")) {
1489 return '0'B;
1490 }
1491 return '1'B;
1492 }
1493
1494 function f_GTPU_opt_part(template (omit) uint16_t seq) return template (omit) GTPU_Header_optional_part {
1495 if (istemplatekind(seq, "omit")) {
1496 return omit;
1497 }
1498 var GTPU_Header_optional_part ret := {
1499 sequenceNumber := int2oct(valueof(seq), 2),
1500 npduNumber := '00'O,
1501 nextExtHeader := '00'O,
1502 gTPU_extensionHeader_List := omit
1503 };
1504 return ret;
1505 }
1506
Harald Weltec69cf4e2018-02-17 20:57:02 +01001507 /* generalized GTP-U send template */
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001508 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 +01001509 /* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN
1510 * flag is set to 1. */
1511 pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */
1512 /* If the Sequence Number flag (S) is set to '1' the sequence number field is present and
1513 * meaningful otherwise it is set to '0'. For GTP-U messages Echo Request, Echo Response,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001514 * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'.
1515 *
1516 * Note that the caller must ensure that these conditions hold.
1517 * The caller can either pass a sequence number (we set s_bit to '1'B) when appropriate,
1518 * or may omit the sequence number (we set s_bit to '0'B). */
1519 s_bit := f_GTPU_s_bit(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +01001520 /* Extension header presence */
1521 e_bit := '0'B,
1522 spare := '0'B,
1523 /* Protocol Type flag (PT) shall be set to '1' in GTP */
1524 pt := '1'B,
1525 /* Version shall be set to decimal 1 ('001'). */
1526 version := '001'B,
1527 messageType := msg_type,
1528 lengthf := 0, /* we assume encoder overwrites this */
1529 teid := teid,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001530 opt_part := f_GTPU_opt_part(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +01001531 gtpu_IEs := ies
1532 }
1533
Philipp Maier57889492023-08-07 12:10:03 +02001534 template (present) Gtp1uUnitdata tr_GTPU_MsgType(template (present) GtpPeer peer,
1535 template (present) OCT1 msg_type,
1536 template (present) OCT4 teid) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +01001537 peer := peer,
1538 gtpu := tr_GTP1U_PDU(msg_type, teid)
1539 }
1540
1541
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001542 /* template matching reception of GTP-U echo-request/response */
Philipp Maier57889492023-08-07 12:10:03 +02001543 template (present) Gtp1uUnitdata tr_GTPU_PING(template (present) GtpPeer peer) := tr_GTPU_MsgType(peer, echoRequest, '00000000'O);
1544 template (present) Gtp1uUnitdata tr_GTPU_PONG(template (present) GtpPeer peer) := tr_GTPU_MsgType(peer, echoResponse, '00000000'O);
Harald Weltec69cf4e2018-02-17 20:57:02 +01001545
1546 /* template matching reception of GTP-U GPDU */
Philipp Maier57889492023-08-07 12:10:03 +02001547 template GTPU_IEs t_GPDU(template (present) octetstring data) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +01001548 g_PDU_IEs := {
1549 data := data
1550 }
1551 }
Philipp Maier57889492023-08-07 12:10:03 +02001552 template (present) Gtp1uUnitdata tr_GTPU_GPDU(template (present) GtpPeer peer,
1553 template (present) OCT4 teid,
1554 template (present) octetstring data := ?) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +01001555 peer := peer,
1556 gtpu := tr_GTP1U_PDU('FF'O, teid, t_GPDU(data))
1557 }
1558
Philipp Maier57889492023-08-07 12:10:03 +02001559 template (present) GTPU_IEs ts_UEchoReqPDU := {
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001560 echoRequest_IEs := {
1561 private_extension_gtpu := omit
1562 }
1563 }
1564
1565 /* master template for sending a GTP-C echo request */
1566 template (value) Gtp1uUnitdata ts_GTPU_PING(GtpPeer peer, uint16_t seq) := {
1567 peer := peer,
1568 gtpu := ts_GTP1U_PDU(echoRequest, seq, '00000000'O, valueof(ts_UEchoReqPDU))
1569 }
1570
Harald Weltec69cf4e2018-02-17 20:57:02 +01001571 template GTPU_IEs ts_UEchoRespPDU(OCT1 restart_counter) := {
1572 echoResponse_IEs := {
1573 recovery_gtpu := {
1574 type_gtpu := '00'O, /* we assume encoder fixes? */
1575 restartCounter := restart_counter
1576 },
1577 private_extension_gtpu := omit
1578 }
1579 }
1580
1581 /* master template for sending a GTP-U echo response */
Philipp Maier57889492023-08-07 12:10:03 +02001582 template (present) Gtp1uUnitdata ts_GTPU_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +01001583 peer := peer,
1584 gtpu := ts_GTP1U_PDU(echoResponse, seq, '00000000'O, valueof(ts_UEchoRespPDU(rest_ctr)))
1585 }
1586
Philipp Maier57889492023-08-07 12:10:03 +02001587 template (value) GSNAddress_gtpu ts_UGsnAddr(octetstring ip_addr) := {
Pau Espin Pedrolf3e25382018-07-18 13:46:40 +02001588 type_gtpu := '85'O,
1589 lengthf := lengthof(ip_addr),
1590 gSNAddressValue := ip_addr
1591 }
1592
Philipp Maier57889492023-08-07 12:10:03 +02001593 template (value) TeidDataI_gtpu ts_UteidDataI(OCT4 teid) := {
Pau Espin Pedrolf3e25382018-07-18 13:46:40 +02001594 type_gtpu := '10'O,
1595 teidDataI := teid
1596 }
1597
Philipp Maier57889492023-08-07 12:10:03 +02001598 template (value) GTPU_IEs ts_UErrorIndication(OCT4 teid, octetstring gsn_addr) := {
Pau Espin Pedrolf3e25382018-07-18 13:46:40 +02001599 errorIndication_IEs := {
1600 teidDataI_gtpu := ts_UteidDataI(teid),
1601 gSNAddress_gtpu := ts_UGsnAddr(gsn_addr),
1602 private_extension_gtpu := omit
1603 }
1604 }
1605
1606 /* master template for sending a GTP-U Error indication */
Philipp Maier57889492023-08-07 12:10:03 +02001607 template (value) Gtp1uUnitdata ts_GTPU_ErrorIndication(GtpPeer peer, uint16_t seq, OCT4 teid, octetstring gsn_addr) := {
Pau Espin Pedrolf3e25382018-07-18 13:46:40 +02001608 peer := peer,
1609 gtpu := ts_GTP1U_PDU('1A'O, seq, '00000000'O, valueof(ts_UErrorIndication(teid, gsn_addr)))
1610 }
1611
Harald Weltec69cf4e2018-02-17 20:57:02 +01001612 /* master template for sending a GTP-U user plane data */
Philipp Maier57889492023-08-07 12:10:03 +02001613 template (value) Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, template (omit) uint16_t seq, OCT4 teid, octetstring data) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +01001614 peer := peer,
1615 gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }})
1616 }
Philipp Maier653a0142023-08-04 15:22:37 +02001617
1618 /* 3GPP TS 29.060, section 7.7.57 */
1619 template (value) RIM_RoutingAddress ts_RIM_RoutingAddress(octetstring addr_value) := {
1620 type_gtpc := '9F'O,
1621 lengthf := 0, /* we assume encoder overwrites this */
1622 rIM_RoutingAddressValue := addr_value
1623 }
1624 template (present) RIM_RoutingAddress tr_RIM_RoutingAddress(template (present) octetstring addr_value := ?) := {
1625 type_gtpc := '9F'O,
1626 lengthf := ?,
1627 rIM_RoutingAddressValue := addr_value
1628 }
1629
1630 /* 3GPP TS 29.060, section 7.7.77 */
1631 template (value) RIM_RoutingAddress_Discriminator ts_RIM_RoutingAddress_Discriminator(bitstring addr_discr) := {
1632 type_gtpc := 'B2'O,
1633 lengthf := 0, /* we assume encoder overwrites this */
1634 rra_discriminator := addr_discr,
1635 spare := '0000'B
1636 }
1637 template (present) RIM_RoutingAddress_Discriminator tr_RIM_RoutingAddress_Discriminator(template (present) bitstring addr_discr := ?) := {
1638 type_gtpc := 'B2'O,
1639 lengthf := ?,
1640 rra_discriminator := addr_discr,
1641 spare := '0000'B
1642 }
Harald Weltec69cf4e2018-02-17 20:57:02 +01001643}