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