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