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