blob: 94f327e68d93aafbcefe91d7b876c3d9558e5f1d [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
Harald Weltec69cf4e2018-02-17 20:57:02 +0100304 template GTPC_PDUs ts_CreatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
305 BIT4 nsapi, EndUserAddress eua, octetstring apn,
306 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100307 octetstring msisdn, template ProtConfigOptions pco := omit,
308 template (omit) OCT1 ratType := omit) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100309 createPDPContextRequest := {
310 imsi := ts_Imsi(imsi),
311 rai := omit,
312 recovery := ts_Recovery(restart_ctr),
313 selectionMode := {
314 type_gtpc := '0F'O,
315 selectModeValue := '00'B,
316 spare := '111111'B
317 },
318 teidDataI := {
319 type_gtpc := '00'O,
320 teidDataI := teid_data
321 },
322 teidControlPlane := {
323 type_gtpc := '00'O,
324 teidControlPlane := teid_ctrl
325 },
326 nsapi := {
327 type_gtpc := '00'O,
328 nsapi := nsapi,
329 unused := '0000'B
330 },
331 linked_nsapi := omit,
332 charging_char := omit,
333 trace_ref := omit,
334 trace_type := omit,
335 endUserAddress := eua,
336 accessPointName := ts_APN(apn),
337 protConfigOptions := pco,
338 sgsn_addr_signalling := ts_GsnAddr(sgsn_ip_sign),
339 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
340 msisdn := ts_Msisdn(msisdn),
341 qualityOfServiceProfile := ts_QosDefault,
342 tft := omit,
343 triggerId := omit,
344 omcId := omit,
345 commonFlags := omit,
346 aPN_Restriction := omit,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100347 ratType := f_ts_RATType(ratType),
Harald Weltec69cf4e2018-02-17 20:57:02 +0100348 userLocationInformation := omit,
349 mS_TimeZone := omit,
350 imeisv := omit,
351 camelChargingInformationContainer := omit,
352 additionalTraceInfo := omit,
353 correlationID := omit,
354 evolvedAllocationRetentionPriorityI := omit,
355 extendedCommonFlags := omit,
356 userCSGInformation := omit,
357 aPN_AMBR := omit,
358 signallingPriorityIndication := omit,
359 cN_OperatorSelectionEntity := omit,
360 private_extension_gtpc := omit
361 }
362 }
363
364 template Gtp1cUnitdata ts_GTPC_CreatePDP(GtpPeer peer, uint16_t seq, hexstring imsi,
365 OCT1 restart_ctr, OCT4 teid_data,
366 OCT4 teid_ctrl, BIT4 nsapi, EndUserAddress eua,
367 octetstring apn, octetstring sgsn_ip_sign,
368 octetstring sgsn_ip_data, octetstring msisdn,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100369 template ProtConfigOptions pco := omit,
370 template (omit) OCT1 ratType := omit) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100371 peer := peer,
372 gtpc := ts_GTP1C_PDU(createPDPContextRequest, '00000000'O,
373 valueof(ts_CreatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
374 nsapi, eua, apn, sgsn_ip_sign,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100375 sgsn_ip_data, msisdn, pco, ratType)), seq)
Harald Weltec69cf4e2018-02-17 20:57:02 +0100376 }
377
Harald Welteeded9ad2018-02-17 20:57:34 +0100378
379 template NSAPI_GTPC ts_NSAPI(BIT4 nsapi) := {
380 type_gtpc := '14'O,
381 nsapi := nsapi,
382 unused := '0000'B
383 }
384
385 template ReorderingRequired ts_ReorderReq(boolean req := false) := {
386 type_gtpc := '08'O,
387 reordreq := bool2bit(req),
388 spare := '0000000'B
389 }
390
391 template GTPC_PDUs ts_CreatePdpRespPDU(OCT1 cause, OCT4 teid_data, OCT4 teid_ctrl, BIT4 nsapi,
392 octetstring ggsn_ip_sign, octetstring ggsn_ip_data,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100393 OCT4 chg_id, template EndUserAddress eua := omit,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200394 template Recovery_gtpc recovery := omit,
Harald Welteeded9ad2018-02-17 20:57:34 +0100395 template ProtConfigOptions pco := omit) := {
396 createPDPContextResponse := {
397 cause := { '00'O, cause },
398 reorderingRequired := ts_ReorderReq(false),
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200399 recovery := recovery,
Harald Welteeded9ad2018-02-17 20:57:34 +0100400 teidDataI := {
401 type_gtpc := '00'O,
402 teidDataI := teid_data
403 },
404 teidControlPlane := {
405 type_gtpc := '00'O,
406 teidControlPlane := teid_ctrl
407 },
408 nsapi := ts_NSAPI(nsapi),
Harald Welte7aff2ca2018-02-18 15:34:50 +0100409 chargingID := {
410 type_gtpc := '7F'O,
411 chargingID := chg_id
412 },
Harald Welteeded9ad2018-02-17 20:57:34 +0100413 endUserAddress := eua,
414 protConfigOptions := pco,
415 ggsn_addr_controlPlane := ts_GsnAddr(ggsn_ip_sign),
416 ggsn_addr_traffic := ts_GsnAddr(ggsn_ip_data),
417 alt_ggsn_addr_controlPane := omit,
418 alt_ggsn_addr_traffic := omit,
419 qualityOfServiceProfile := ts_QosDefault,
420 commonFlags := omit,
421 aPN_Restriction := omit,
422 mS_InfoChangeReportingAction := omit,
423 bearerControlMode := omit,
424 evolvedAllocationRetentionPriorityI := omit,
425 extendedCommonFlag := omit,
426 csg_information_reporting_action := omit,
427 aPN_AMBR := omit,
428 gGSN_BackOffTime := omit,
429 private_extension_gtpc := omit
430 }
431 }
432
433 template Gtp1cUnitdata ts_GTPC_CreatePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
434 OCT1 cause,
435 OCT4 teid_ctrl, OCT4 teid_data,
436 BIT4 nsapi, octetstring ggsn_ip_sign,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100437 octetstring ggsn_ip_data, OCT4 chg_id,
Harald Welteeded9ad2018-02-17 20:57:34 +0100438 template EndUserAddress eua := omit,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200439 template Recovery_gtpc recovery := omit,
Harald Welteeded9ad2018-02-17 20:57:34 +0100440 template ProtConfigOptions pco := omit) := {
441 peer := peer,
442 gtpc := ts_GTP1C_PDU(createPDPContextResponse, teid,
443 valueof(ts_CreatePdpRespPDU(cause, teid_data, teid_ctrl, nsapi,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100444 ggsn_ip_sign, ggsn_ip_data, chg_id,
Pau Espin Pedrol94013452018-07-17 15:50:21 +0200445 eua, recovery, pco)), seq)
Harald Welteeded9ad2018-02-17 20:57:34 +0100446 }
447
Harald Weltec69cf4e2018-02-17 20:57:02 +0100448 /* PCO send base template */
449 template ProtConfigOptions ts_PCO := {
450 type_gtpc := '84'O,
451 lengthf := 0,
452 configProtocol := '000'B,
453 spare := '0000'B,
454 extension0 := '1'B,
455 protocols := {}
456 }
457 /* PCO receive base template */
458 template ProtConfigOptions tr_PCO := {
459 type_gtpc := '84'O,
460 lengthf := ?,
461 configProtocol := '000'B,
462 spare := ?,
463 extension0 := '1'B,
464 protocols := {}
465 }
466
467 template ProtConfigOptions ts_PCO_IPv6_DNS modifies ts_PCO := {
468 protocols := {
469 { protocolID := '0003'O, lengthProtoID := 0, protoIDContents := ''O }
470 }
471 }
472 template ProtConfigOptions tr_PCO_IPv6_DNS_resp(template OCT16 contents) modifies tr_PCO := {
473 protocols := {
474 *, { protocolID := '0003'O, lengthProtoID := 16, protoIDContents := contents }, *
475 }
476 }
477
478 template ProtConfigOptions ts_PCO_IPv4_DNS_IPCP modifies ts_PCO := {
479 protocols := {
480 /* dummy PAP entry to check if our parser in the GGSN can properly iterate over
481 * the list of protocols, see Change-Id Icc2e6716c33d78d3c3e000f529806228d8aa155e */
482 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
483 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
484 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
485 }
486 }
487
Philipp Maier33e52612018-05-30 17:22:02 +0200488 template ProtConfigOptions ts_PCO_IPv4_PRI_DNS_IPCP modifies ts_PCO := {
489 protocols := {
490 /* dummy PAP entry to check if our parser can cope with a single primary DNS entry
491 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
492 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
493 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
494 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) }
495 }
496 }
497 template ProtConfigOptions ts_PCO_IPv4_SEC_DNS_IPCP modifies ts_PCO := {
498 protocols := {
499 /* dummy PAP entry to check if our parser can cope with a single secondary DNS entry
500 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
501 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
502 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
503 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
504 }
505 }
506 template ProtConfigOptions ts_PCO_IPv4_SEPARATE_DNS_IPCP modifies ts_PCO := {
507 protocols := {
508 /* dummy PAP entry to check if our parser can cope with a primary and secondary DNS
509 * in separate IPCP containers OS#3381 */
510 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
511 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
512 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) },
513 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
514 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
515 }
516 }
517
Harald Weltec69cf4e2018-02-17 20:57:02 +0100518 template ProtocolElement tr_PCO_Proto(OCT2 prot_id) := {
519 protocolID := prot_id,
520 lengthProtoID := ?,
521 protoIDContents := ?
522 }
Harald Weltef8298542019-04-10 10:15:28 +0200523 template ProtocolElement ts_PCOelem_PAP_broken := {
524 protocolID := 'C023'O,
525 lengthProtoID := 60,
526 /* PPP Password Authentication Protocol containing incorrect Peer-Id-Length set to 4 (6-7 should be the valid one), see OS#3914. */
527 protoIDContents := '0100003c'O & '0444435338323700bc1c08087c1508083e00790000150808fd06000001000000000000000000000000000000000000000000000000000000'O
528 }
529 template ProtConfigOptions ts_PCO_PAP_IPv4_DNS modifies ts_PCO := {
530 protocols := {
531 ts_PCOelem_PAP_broken,
532 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
533 }
534 }
Harald Weltec69cf4e2018-02-17 20:57:02 +0100535 template ProtConfigOptions tr_PCO_Contains(OCT2 prot_id) modifies tr_PCO := {
536 protocols := { *, tr_PCO_Proto(prot_id), * }
537 }
538
539 template ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := {
540 protocols := {
541 { protocolID := '000d'O, lengthProtoID := 0, protoIDContents := ''O }
542 }
543 }
544 template ProtConfigOptions tr_PCO_IPv4_DNS_CONT_resp(template OCT4 contents) modifies tr_PCO := {
545 protocols := {
546 *, { protocolID := '000d'O, lengthProtoID := 4, protoIDContents := contents }, *
547 }
548 }
549
550 /* extract a given protocol payload from PCO */
551 function f_PCO_extract_proto(ProtConfigOptions pco, OCT2 protocol, integer nth_match := 1) return octetstring {
552 var integer i;
553 var integer num_matches := 0;
554 for (i := 0; i < lengthof(pco.protocols); i := i + 1) {
555 if (pco.protocols[i].protocolID == protocol) {
556 num_matches := num_matches + 1;
557 if (num_matches == nth_match) {
558 return pco.protocols[i].protoIDContents;
559 }
560 }
561 }
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200562 setverdict(fail, "Could not extract protocol payload from protocol ", protocol);
563 mtc.stop;
Harald Weltec69cf4e2018-02-17 20:57:02 +0100564 return ''O;
565 }
566
567 template IpcpPacket tr_IPCP(template LcpCode code, template uint8_t identifier,
568 template IpcpOptionList opts) := {
569 code := code,
570 identifier := identifier,
571 len := ?,
572 options := opts
573 }
574 template IpcpOption tr_IPCP_PrimaryDns(template OCT4 addr) := {
575 code := IPCP_OPT_PrimaryDNS,
576 len := 6,
577 data := addr
578 }
579 template IpcpOption tr_IPCP_SecondaryDns(template OCT4 addr) := {
580 code := IPCP_OPT_SecondaryDNS,
581 len := 6,
582 data := addr
583 }
584 template IpcpPacket tr_IPCP_Ack_DNS(template uint8_t identifier := ?, template OCT4 dns1 := ?,
585 template OCT4 dns2 := ?) :=
586 tr_IPCP(LCP_Configure_Ack, identifier,
587 { *, tr_IPCP_PrimaryDns(dns1), *, tr_IPCP_SecondaryDns(dns2), * });
588
589 template IpcpPacket ts_IPCP(LcpCode code, uint8_t identifier, template IpcpOptionList opts) := {
590 code := code,
591 identifier := identifier,
592 len := 0, /* overwritten */
593 options := opts
594 }
595 template IpcpPacket ts_IPCP_ReqDNS(uint8_t identifier := 0) :=
596 ts_IPCP(LCP_Configure_Request, identifier,
597 { tr_IPCP_PrimaryDns('00000000'O), tr_IPCP_SecondaryDns('00000000'O) });
598
Philipp Maier33e52612018-05-30 17:22:02 +0200599 template IpcpPacket ts_IPCP_ReqDNS_Primary(uint8_t identifier := 0) :=
600 ts_IPCP(LCP_Configure_Request, identifier,
601 { tr_IPCP_PrimaryDns('00000000'O) });
602 template IpcpPacket ts_IPCP_ReqDNS_Secondary(uint8_t identifier := 0) :=
603 ts_IPCP(LCP_Configure_Request, identifier,
604 { tr_IPCP_SecondaryDns('00000000'O) });
605
Harald Welte57b9b7f2018-02-18 22:28:13 +0100606 function f_teardown_ind_IE(in template (omit) BIT1 ind) return template (omit) TearDownInd {
607 if (istemplatekind(ind, "omit")) {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100608 return omit;
609 }
Harald Weltec69cf4e2018-02-17 20:57:02 +0100610 var TearDownInd ret := {
611 type_gtpc := '13'O,
612 tdInd := valueof(ind),
613 spare:= '0000000'B
614 }
615 return ret;
616 }
617
Harald Welte57b9b7f2018-02-18 22:28:13 +0100618 template GTPC_PDUs ts_DeletePdpPDU(BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100619 deletePDPContextRequest := {
620 cause := omit,
621 tearDownIndicator := f_teardown_ind_IE(teardown_ind),
622 nsapi := {
623 type_gtpc := '14'O,
624 nsapi := nsapi,
625 unused := '0000'B
626 },
627 protConfigOptions := omit,
628 userLocationInformation := omit,
629 mS_TimeZone := omit,
630 extendedCommonFlags := omit,
631 uLI_Timestamp := omit,
632 private_extension_gtpc := omit
633 }
634 }
635
636 template Gtp1cUnitdata ts_GTPC_DeletePDP(GtpPeer peer, uint16_t seq, OCT4 teid,
Harald Welte57b9b7f2018-02-18 22:28:13 +0100637 BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100638 peer := peer,
639 gtpc := ts_GTP1C_PDU(deletePDPContextRequest, teid,
640 valueof(ts_DeletePdpPDU(nsapi, teardown_ind)), seq)
641 }
642
Harald Welte6f203162018-02-18 22:04:55 +0100643 template GTPC_PDUs ts_DeletePdpRespPDU(OCT1 cause,
644 template ProtConfigOptions pco := omit) := {
645 deletePDPContextResponse := {
646 cause := { '00'O, cause },
647 protConfigOptions := pco,
648 userLocationInformation := omit,
649 mS_TimeZone := omit,
650 uLI_Timestamp := omit,
651 private_extension_gtpc := omit
652 }
653 }
654
655 template Gtp1cUnitdata ts_GTPC_DeletePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
656 OCT1 cause,
657 template ProtConfigOptions pco := omit) := {
658 peer := peer,
659 gtpc := ts_GTP1C_PDU(deletePDPContextResponse, teid,
660 valueof(ts_DeletePdpRespPDU(cause, pco)), seq)
661 }
662
663
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200664 /* GTP-C RIM */
665
666 template (value) RIM_Application_Identity_GTPC ts_GTPC_RIM_Application_Identity(OCT1 app_id) := {
667 iEI := '4B'O,
668 ext := '1'B,
669 lengthIndicator := {
670 length1 := 1
671 },
672 rIMApplicationIdentity := app_id
673 }
674 /* 3GPP TS 48.018 11.3.62 */
675 template (value) RIM_Sequence_Number_GTPC ts_GTPC_RIM_Sequence_Number(integer seq) := {
676 iEI := '4C'O,
677 ext := '1'B,
678 lengthIndicator := {
679 length1 := 4
680 },
681 rIMSequenceNumber := int2oct(seq, 4)
682 }
683 template (value) RIM_PDU_Indications_GTPC ts_GTPC_RIM_PDU_Indications(boolean ack, BIT3 type_ext) := {
684 iEI := '4F'O,
685 ext := '1'B,
686 lengthIndicator := {
687 length1 := 1
688 },
689 ack := bool2bit(ack),
690 pDU_Type_Extension := type_ext,
691 reserved := '0000'B
692 }
693 /* 3GPP TS 48.018 11.3.67 */
694 template (value) RIM_Protocol_Version_Number_GTPC ts_GTPC_RIM_Protocol_Version_Number(integer ver) := {
695 iEI := '55'O,
696 ext := '1'B,
697 lengthIndicator := {
698 length1 := 1
699 },
700 rIMProtocolVersionNumber := int2oct(ver, 1)
701 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100702 function tr_GTPC_Cell_Identifier_V(template GTP_CellId cid) return template Cell_Identifier_V_GTPC {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200703 var template Cell_Identifier_V_GTPC ret := {
704 mccDigit1 := ?,
705 mccDigit2 := ?,
706 mccDigit3 := ?,
707 mncDigit3 := ?,
708 mncDigit1 := ?,
709 mncDigit2 := ?,
710 lac := ?,
711 rac := ?,
712 cI_value := ?
713 }
714 if (istemplatekind(cid, "omit")) {
715 return omit;
716 } else if (istemplatekind(cid, "*")) {
717 return *;
718 } else if (istemplatekind(cid, "?")) {
719 return ?;
720 }
721 if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) {
722 if (isvalue(cid.ra_id.lai.mcc_mnc)) {
723 ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0];
724 ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1];
725 ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2];
726 ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3];
727 ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4];
728 ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5];
729 }
730 if (isvalue(cid.ra_id.lai.lac)) {
731 ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2);
732 }
733 }
734 if (isvalue(cid) and isvalue(cid.ra_id)) {
735 ret.rac := f_oct_or_wc(cid.ra_id.rac, 1);
736 }
737 if (isvalue(cid)) {
738 ret.cI_value := f_oct_or_wc(cid.cell_id, 2);
739 }
740 return ret;
741 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100742 template (value) Cell_Identifier_V_GTPC ts_GTPC_Cell_Identifier_V(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200743 mccDigit1 := cid.ra_id.lai.mcc_mnc[0],
744 mccDigit2 := cid.ra_id.lai.mcc_mnc[1],
745 mccDigit3 := cid.ra_id.lai.mcc_mnc[2],
746 mncDigit3 := cid.ra_id.lai.mcc_mnc[3],
747 mncDigit1 := cid.ra_id.lai.mcc_mnc[4],
748 mncDigit2 := cid.ra_id.lai.mcc_mnc[5],
749 lac := int2oct(cid.ra_id.lai.lac, 2),
750 rac := int2oct(cid.ra_id.rac, 1),
751 cI_value := int2oct(cid.cell_id, 2)
752 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100753 template RIM_Routing_Address_GTPC t_GTPC_RIM_Routing_Address_cid(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200754 cell_Identifier := ts_GTPC_Cell_Identifier_V(cid)
755 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100756 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 +0200757 var template ENB_Identifier ret := {
758 mccDigit1 := ?,
759 mccDigit2 := ?,
760 mccDigit3 := ?,
761 mncDigit3 := ?,
762 mncDigit1 := ?,
763 mncDigit2 := ?,
764 tAC := ?,
765 globalENB_ID := ?
766 }
767 if (istemplatekind(cid, "omit") and istemplatekind(tac, "omit") and istemplatekind(gnbid, "omit")) {
768 return omit;
769 } else if (istemplatekind(cid, "*") and istemplatekind(tac, "*") and istemplatekind(gnbid, "*")) {
770 return *;
771 } else if (istemplatekind(cid, "?") and istemplatekind(tac, "?") and istemplatekind(gnbid, "?")) {
772 return ?;
773 }
774 if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) {
775 if (isvalue(cid.ra_id.lai.mcc_mnc)) {
776 ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0];
777 ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1];
778 ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2];
779 ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3];
780 ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4];
781 ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5];
782 }
783 }
784 if (isvalue(tac)) {
785 ret.tAC := int2oct(valueof(tac), 2);
786 }
787 if (isvalue(gnbid)) {
788 ret.globalENB_ID := gnbid;
789 }
790
791 return ret;
792 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100793 template (value) ENB_Identifier ts_GTPC_ENB_Identifier(GTP_CellId cid, integer tac, octetstring gnbid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200794 mccDigit1 := cid.ra_id.lai.mcc_mnc[0],
795 mccDigit2 := cid.ra_id.lai.mcc_mnc[1],
796 mccDigit3 := cid.ra_id.lai.mcc_mnc[2],
797 mncDigit3 := cid.ra_id.lai.mcc_mnc[3],
798 mncDigit1 := cid.ra_id.lai.mcc_mnc[4],
799 mncDigit2 := cid.ra_id.lai.mcc_mnc[5],
800 tAC := int2oct(tac, 2),
801 globalENB_ID := gnbid
802 }
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100803 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 +0200804 eNB_Identifier := ts_GTPC_ENB_Identifier(cid, tac, gnbid)
805 }
806 template RIM_Routing_Information_GTPC
807 tr_GTPC_RIM_Routing_Information(HEX1 addr_discr, template RIM_Routing_Address_GTPC addr) := {
808 iEI := '54'O,
809 ext := '1'B,
810 lengthIndicator := {
811 length1 := ?
812 },
813 rIMRoutingAddressDiscriminator := addr_discr,
814 spare := '0'H,
815 rIM_Routing_Address := addr
816 }
817 template (value) RIM_Routing_Information_GTPC
818 ts_GTPC_RIM_Routing_Information(HEX1 addr_discr, template (value) RIM_Routing_Address_GTPC addr) := {
819 iEI := '54'O,
820 ext := '1'B,
821 lengthIndicator := {
822 length1 := 0 /* overwritten */
823 },
824 rIMRoutingAddressDiscriminator := addr_discr,
825 spare := '0'H,
826 rIM_Routing_Address := addr
827 }
828 /* 3GPP TS 48.018 11.3.63.1.1 */
829 template RAN_Information_Request_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100830 tr_GTPC_RAN_Information_Request_Application_Container_NACC(template GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200831 iEI := '4D'O,
832 ext := '1'B,
833 lengthIndicator := {
834 length1 := ?
835 },
836 reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid)
837 }
838 template (value) RAN_Information_Request_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100839 ts_GTPC_RAN_Information_Request_Application_Container_NACC(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200840 iEI := '4D'O,
841 ext := '1'B,
842 lengthIndicator := {
843 length1 := 0 /* overwritten */
844 },
845 reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid)
846 }
847 /* 3GPP TS 48.018 11.3.63.1 */
848 template RAN_Information_Request_Application_Container_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100849 tru_GTPC_RAN_Information_Request_Application_Container_NACC(template GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200850 nacc := tr_GTPC_RAN_Information_Request_Application_Container_NACC(cid)
851 }
852 template (value) RAN_Information_Request_Application_Container_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100853 tsu_GTPC_RAN_Information_Request_Application_Container_NACC(GTP_CellId cid) := {
Pau Espin Pedrol8c74cbb2021-05-04 15:26:56 +0200854 nacc := ts_GTPC_RAN_Information_Request_Application_Container_NACC(cid)
855 }
856 /* 3GPP TS 48.018 11.3.63.2.1 */
857 template RAN_Information_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100858 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 +0200859 iEI := '4E'O,
860 ext := '1'B,
861 lengthIndicator := {
862 length1 := ?
863 },
864 reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid),
865 typeBit := bool2bit(psi_type),
866 number_of_SI_PSI := int2bit(si_psi_num, 7),
867 sI_PSI := si_psi
868 }
869 template (value) RAN_Information_Application_Container_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100870 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 +0200871 iEI := '4E'O,
872 ext := '1'B,
873 lengthIndicator := {
874 length1 := 0 /* overwritten */
875 },
876 reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid),
877 typeBit := bool2bit(psi_type),
878 number_of_SI_PSI := int2bit(si_psi_num, 7),
879 sI_PSI := si_psi
880 }
881
882 /* RAN_Information_Request */
883 template (value) RAN_Information_Request_RIM_Container_GTPC
884 ts_GTPC_RAN_Information_Request_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id,
885 template (value) RIM_Sequence_Number_GTPC seq,
886 template (value) RIM_PDU_Indications_GTPC ind,
887 template (omit) RIM_Protocol_Version_Number_GTPC ver := omit,
888 template (omit) RAN_Information_Request_Application_Container_GTPC app_cont := omit,
889 template (omit) SON_TransferApplicationIdentity son_app_id := omit) := {
890 iEI := '57'O,
891 ext := '1'B,
892 lengthIndicator := {
893 length1 := 0 /* overwritten */
894 },
895 rIM_Application_Identity := app_id,
896 rIM_Sequence_Number := seq,
897 rIM_PDU_Indications := ind,
898 rIM_Protocol_Version_Number := ver,
899 application_Container := app_cont,
900 sON_TransferApplicationIdentity := son_app_id
901 }
902 template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC
903 ts_GTPC_RAN_Information_Request(template (value) RIM_Routing_Information_GTPC dest,
904 template (value) RIM_Routing_Information_GTPC src,
905 template (value) RAN_Information_Request_RIM_Container_GTPC cont) := {
906 bssgpPduType := '71'O,
907 destination_Cell_Identifier := dest,
908 source_Cell_Identifier := src,
909 rIM_Container := cont
910 }
911 template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO_REQ(template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC pdu) := {
912 type_gtpc := '90'O,
913 lengthf := 0, /* FIXME */
914 rANTransparentContainerField := {
915 pDU_BSSGP_RAN_INFORMATION_REQUEST := pdu
916 }
917 }
918
919 /* RAN_Information */
920 template ApplContainer_or_ApplErrContainer_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100921 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 +0200922 application_Container := tr_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi)
923 }
924 template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC
Pau Espin Pedrol17e0f8c2021-12-03 15:11:34 +0100925 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 +0200926 application_Container := ts_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi)
927 }
928 template ApplContainer_or_ApplErrContainer_GTPC
929 tru_GTPC_ApplContainer_or_ApplErrContainer_NACC(template ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := {
930 nacc := cont
931 }
932 template (value) ApplContainer_or_ApplErrContainer_GTPC
933 tsu_GTPC_ApplContainer_or_ApplErrContainer_NACC(template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := {
934 nacc := cont
935 }
936 template RAN_Information_RIM_Container_GTPC
937 tr_GTPC_RAN_Information_RIM_Container(template RIM_Application_Identity_GTPC app_id,
938 template RIM_Sequence_Number_GTPC seq,
939 template RIM_PDU_Indications_GTPC ind,
940 template RIM_Protocol_Version_Number_GTPC ver := omit,
941 template ApplContainer_or_ApplErrContainer_GTPC app_cont := omit,
942 template SON_TransferApplicationIdentity son_app_id := omit) := {
943 iEI := '58'O,
944 ext := '1'B,
945 lengthIndicator := {
946 length1 := ?
947 },
948 rIM_Application_Identity := app_id,
949 rIM_Sequence_Number := seq,
950 rIM_PDU_Indications := ind,
951 rIM_Protocol_Version_Number := ver,
952 applContainer_or_ApplErrContainer := app_cont,
953 sON_TransferApplicationIdentity := son_app_id
954 }
955 template (value) RAN_Information_RIM_Container_GTPC
956 ts_GTPC_RAN_Information_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id,
957 template (value) RIM_Sequence_Number_GTPC seq,
958 template (value) RIM_PDU_Indications_GTPC ind,
959 template (omit) RIM_Protocol_Version_Number_GTPC ver := omit,
960 template (omit) ApplContainer_or_ApplErrContainer_GTPC app_cont := omit,
961 template (omit) SON_TransferApplicationIdentity son_app_id := omit) := {
962 iEI := '58'O,
963 ext := '1'B,
964 lengthIndicator := {
965 length1 := 0 /* overwritten */
966 },
967 rIM_Application_Identity := app_id,
968 rIM_Sequence_Number := seq,
969 rIM_PDU_Indications := ind,
970 rIM_Protocol_Version_Number := ver,
971 applContainer_or_ApplErrContainer := app_cont,
972 sON_TransferApplicationIdentity := son_app_id
973 }
974 template PDU_BSSGP_RAN_INFORMATION_GTPC
975 tr_GTPC_RAN_Information(template RIM_Routing_Information_GTPC dest,
976 template RIM_Routing_Information_GTPC src,
977 template RAN_Information_RIM_Container_GTPC cont) := {
978 bssgpPduType := '70'O,
979 destination_Cell_Identifier := dest,
980 source_Cell_Identifier := src,
981 rIM_Container := cont
982 }
983 template (value) PDU_BSSGP_RAN_INFORMATION_GTPC
984 ts_GTPC_RAN_Information(template (value) RIM_Routing_Information_GTPC dest,
985 template (value) RIM_Routing_Information_GTPC src,
986 template (value) RAN_Information_RIM_Container_GTPC cont) := {
987 bssgpPduType := '70'O,
988 destination_Cell_Identifier := dest,
989 source_Cell_Identifier := src,
990 rIM_Container := cont
991 }
992 template RANTransparentContainer tr_RANTransparentContainer_RAN_INFO(template PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := {
993 type_gtpc := '90'O,
994 lengthf := ?,
995 rANTransparentContainerField := {
996 pDU_BSSGP_RAN_INFORMATION := pdu
997 }
998 }
999 template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO(template (value) PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := {
1000 type_gtpc := '90'O,
1001 lengthf := 0, /* overwritten */
1002 rANTransparentContainerField := {
1003 pDU_BSSGP_RAN_INFORMATION := pdu
1004 }
1005 }
1006
1007 template RANTransparentContainer tr_RANTransparentContainer(template RANTransparentContainerField rANTransparentContainerField) := {
1008 type_gtpc := '90'O,
1009 lengthf := ?,
1010 rANTransparentContainerField := rANTransparentContainerField
1011 }
1012 template (value) RANTransparentContainer ts_RANTransparentContainer(template (value) RANTransparentContainerField rANTransparentContainerField) := {
1013 type_gtpc := '90'O,
1014 lengthf := 0, /* overwritten */
1015 rANTransparentContainerField := rANTransparentContainerField
1016 }
1017 template GTPC_PDUs tr_RANInfoRelay(template RANTransparentContainer transparentContainer) := {
1018 ranInformationRelay := {
1019 transparentContainer := transparentContainer,
1020 rIM_RoutingAddress := *,
1021 rIM_RoutingAddress_Discriminator := *,
1022 private_extension_gtpc := *
1023 }
1024 }
1025 template (value) GTPC_PDUs ts_RANInfoRelay(template (value) RANTransparentContainer transparentContainer) := {
1026 ranInformationRelay := {
1027 transparentContainer := transparentContainer,
1028 rIM_RoutingAddress := omit,
1029 rIM_RoutingAddress_Discriminator := omit,
1030 private_extension_gtpc := omit
1031 }
1032 }
1033 template Gtp1cUnitdata
1034 tr_GTPC_RANInfoRelay(template GtpPeer peer,
1035 template RANTransparentContainer transparentContainer) := {
1036 peer := peer,
1037 gtpc := tr_GTP1C_PDU(rANInformationRelay, '00000000'O, tr_RANInfoRelay(transparentContainer))
1038 }
1039 template (value) Gtp1cUnitdata
1040 ts_GTPC_RANInfoRelay(template (value) GtpPeer peer,
1041 template (value) RANTransparentContainer transparentContainer) := {
1042 peer := peer,
1043 gtpc := ts_GTP1C_PDU(rANInformationRelay, '00000000'O, valueof(ts_RANInfoRelay(transparentContainer)), 0)
1044 }
1045
1046
1047 template RAN_Information_Request_RIM_Container_GTPC
1048 tr_GTPC_RAN_Information_Request_RIM_Container(template RIM_Application_Identity_GTPC app_id := ?,
1049 template RIM_Sequence_Number_GTPC seq := ?,
1050 template RIM_PDU_Indications_GTPC ind := ?,
1051 template RIM_Protocol_Version_Number_GTPC ver := *,
1052 template RAN_Information_Request_Application_Container_GTPC app_cont := *,
1053 template SON_TransferApplicationIdentity son_app_id := *) := {
1054 iEI := '57'O,
1055 ext := '1'B,
1056 lengthIndicator := {
1057 length1 := ?
1058 },
1059 rIM_Application_Identity := app_id,
1060 rIM_Sequence_Number := seq,
1061 rIM_PDU_Indications := ind,
1062 rIM_Protocol_Version_Number := ver,
1063 application_Container := app_cont,
1064 sON_TransferApplicationIdentity := son_app_id
1065 }
Harald Weltec69cf4e2018-02-17 20:57:02 +01001066
1067 /* GTP-U */
1068
1069 template PDU_GTPU tr_GTP1U_PDU(template OCT1 msg_type, template OCT4 teid, template GTPU_IEs ies := ?) := {
1070 pn_bit := ?,
1071 s_bit := ?,
1072 e_bit := ?,
1073 spare := ?,
1074 /* Protocol Type flag (PT) shall be set to '1' in GTP */
1075 pt := '1'B,
1076 /* Version shall be set to decimal 1 ('001'). */
1077 version := '001'B,
1078 messageType := msg_type,
1079 lengthf := ?,
1080 teid := teid,
1081 opt_part := *,
1082 gtpu_IEs := ies
1083 }
1084
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001085 function f_GTPU_s_bit(template (omit) uint16_t seq) return BIT1 {
1086 if (istemplatekind(seq, "omit")) {
1087 return '0'B;
1088 }
1089 return '1'B;
1090 }
1091
1092 function f_GTPU_opt_part(template (omit) uint16_t seq) return template (omit) GTPU_Header_optional_part {
1093 if (istemplatekind(seq, "omit")) {
1094 return omit;
1095 }
1096 var GTPU_Header_optional_part ret := {
1097 sequenceNumber := int2oct(valueof(seq), 2),
1098 npduNumber := '00'O,
1099 nextExtHeader := '00'O,
1100 gTPU_extensionHeader_List := omit
1101 };
1102 return ret;
1103 }
1104
Harald Weltec69cf4e2018-02-17 20:57:02 +01001105 /* generalized GTP-U send template */
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001106 template 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 +01001107 /* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN
1108 * flag is set to 1. */
1109 pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */
1110 /* If the Sequence Number flag (S) is set to '1' the sequence number field is present and
1111 * meaningful otherwise it is set to '0'. For GTP-U messages Echo Request, Echo Response,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001112 * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'.
1113 *
1114 * Note that the caller must ensure that these conditions hold.
1115 * The caller can either pass a sequence number (we set s_bit to '1'B) when appropriate,
1116 * or may omit the sequence number (we set s_bit to '0'B). */
1117 s_bit := f_GTPU_s_bit(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +01001118 /* Extension header presence */
1119 e_bit := '0'B,
1120 spare := '0'B,
1121 /* Protocol Type flag (PT) shall be set to '1' in GTP */
1122 pt := '1'B,
1123 /* Version shall be set to decimal 1 ('001'). */
1124 version := '001'B,
1125 messageType := msg_type,
1126 lengthf := 0, /* we assume encoder overwrites this */
1127 teid := teid,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001128 opt_part := f_GTPU_opt_part(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +01001129 gtpu_IEs := ies
1130 }
1131
1132 template Gtp1uUnitdata tr_GTPU_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid) := {
1133 peer := peer,
1134 gtpu := tr_GTP1U_PDU(msg_type, teid)
1135 }
1136
1137
1138 /* template matching reception of GTP-U echo-request */
1139 template Gtp1uUnitdata tr_GTPU_PING(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoRequest, '00000000'O);
1140
1141 /* template matching reception of GTP-U GPDU */
1142 template GTPU_IEs t_GPDU(template octetstring data) := {
1143 g_PDU_IEs := {
1144 data := data
1145 }
1146 }
1147 template Gtp1uUnitdata tr_GTPU_GPDU(template GtpPeer peer, template OCT4 teid, template octetstring data := ?) := {
1148 peer := peer,
1149 gtpu := tr_GTP1U_PDU('FF'O, teid, t_GPDU(data))
1150 }
1151
1152 template GTPU_IEs ts_UEchoRespPDU(OCT1 restart_counter) := {
1153 echoResponse_IEs := {
1154 recovery_gtpu := {
1155 type_gtpu := '00'O, /* we assume encoder fixes? */
1156 restartCounter := restart_counter
1157 },
1158 private_extension_gtpu := omit
1159 }
1160 }
1161
1162 /* master template for sending a GTP-U echo response */
1163 template Gtp1uUnitdata ts_GTPU_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
1164 peer := peer,
1165 gtpu := ts_GTP1U_PDU(echoResponse, seq, '00000000'O, valueof(ts_UEchoRespPDU(rest_ctr)))
1166 }
1167
Pau Espin Pedrolf3e25382018-07-18 13:46:40 +02001168 template GSNAddress_gtpu ts_UGsnAddr(octetstring ip_addr) := {
1169 type_gtpu := '85'O,
1170 lengthf := lengthof(ip_addr),
1171 gSNAddressValue := ip_addr
1172 }
1173
1174 template TeidDataI_gtpu ts_UteidDataI(OCT4 teid) := {
1175 type_gtpu := '10'O,
1176 teidDataI := teid
1177 }
1178
1179 template GTPU_IEs ts_UErrorIndication(OCT4 teid, octetstring gsn_addr) := {
1180 errorIndication_IEs := {
1181 teidDataI_gtpu := ts_UteidDataI(teid),
1182 gSNAddress_gtpu := ts_UGsnAddr(gsn_addr),
1183 private_extension_gtpu := omit
1184 }
1185 }
1186
1187 /* master template for sending a GTP-U Error indication */
1188 template Gtp1uUnitdata ts_GTPU_ErrorIndication(GtpPeer peer, uint16_t seq, OCT4 teid, octetstring gsn_addr) := {
1189 peer := peer,
1190 gtpu := ts_GTP1U_PDU('1A'O, seq, '00000000'O, valueof(ts_UErrorIndication(teid, gsn_addr)))
1191 }
1192
Harald Weltec69cf4e2018-02-17 20:57:02 +01001193 /* master template for sending a GTP-U user plane data */
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001194 template Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, template (omit) uint16_t seq, OCT4 teid, octetstring data) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +01001195 peer := peer,
1196 gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }})
1197 }
1198}