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 | |
Harald Welte | c69cf4e | 2018-02-17 20:57:02 +0100 | [diff] [blame] | 197 | /* template matching reception of GTP-C echo-request */ |
| 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, |
| 363 | lengthf := 4, |
| 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, |
| 374 | deliverErroneusSDU := omit, |
| 375 | deliveryOrder := omit, |
| 376 | trafficClass := omit, |
| 377 | maxSDUSize := omit, |
| 378 | maxBitrateUplink := omit, |
| 379 | maxBitrateDownlink := omit, |
| 380 | sduErrorRatio := omit, |
| 381 | residualBER := omit, |
| 382 | trafficHandlingPriority := omit, |
| 383 | transferDelay := omit, |
| 384 | guaranteedBitRateUplink := omit, |
| 385 | guaranteedBitRateDownlink := omit, |
| 386 | sourceStatisticsDescriptor := omit, |
| 387 | signallingIndication := omit, |
| 388 | spare4 := omit, |
| 389 | maxBitrateDownlinkExt := omit, |
| 390 | guaranteedBitRateDownlinkExt := omit, |
| 391 | maxBitrateUplinkExt := omit, |
| 392 | guaranteedBitRateUplinkExt := omit |
| 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 | } |
| 1085 | |
| 1086 | /* RAN_Information_Request */ |
| 1087 | template (value) RAN_Information_Request_RIM_Container_GTPC |
| 1088 | ts_GTPC_RAN_Information_Request_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id, |
| 1089 | template (value) RIM_Sequence_Number_GTPC seq, |
| 1090 | template (value) RIM_PDU_Indications_GTPC ind, |
| 1091 | template (omit) RIM_Protocol_Version_Number_GTPC ver := omit, |
| 1092 | template (omit) RAN_Information_Request_Application_Container_GTPC app_cont := omit, |
| 1093 | template (omit) SON_TransferApplicationIdentity son_app_id := omit) := { |
| 1094 | iEI := '57'O, |
| 1095 | ext := '1'B, |
| 1096 | lengthIndicator := { |
| 1097 | length1 := 0 /* overwritten */ |
| 1098 | }, |
| 1099 | rIM_Application_Identity := app_id, |
| 1100 | rIM_Sequence_Number := seq, |
| 1101 | rIM_PDU_Indications := ind, |
| 1102 | rIM_Protocol_Version_Number := ver, |
| 1103 | application_Container := app_cont, |
| 1104 | sON_TransferApplicationIdentity := son_app_id |
| 1105 | } |
| 1106 | template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC |
| 1107 | ts_GTPC_RAN_Information_Request(template (value) RIM_Routing_Information_GTPC dest, |
| 1108 | template (value) RIM_Routing_Information_GTPC src, |
| 1109 | template (value) RAN_Information_Request_RIM_Container_GTPC cont) := { |
| 1110 | bssgpPduType := '71'O, |
| 1111 | destination_Cell_Identifier := dest, |
| 1112 | source_Cell_Identifier := src, |
| 1113 | rIM_Container := cont |
| 1114 | } |
| 1115 | template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO_REQ(template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC pdu) := { |
| 1116 | type_gtpc := '90'O, |
| 1117 | lengthf := 0, /* FIXME */ |
| 1118 | rANTransparentContainerField := { |
| 1119 | pDU_BSSGP_RAN_INFORMATION_REQUEST := pdu |
| 1120 | } |
| 1121 | } |
| 1122 | |
| 1123 | /* RAN_Information */ |
| 1124 | template ApplContainer_or_ApplErrContainer_NACC_GTPC |
Pau Espin Pedrol | 17e0f8c | 2021-12-03 15:11:34 +0100 | [diff] [blame] | 1125 | 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] | 1126 | application_Container := tr_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi) |
| 1127 | } |
| 1128 | template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC |
Pau Espin Pedrol | 17e0f8c | 2021-12-03 15:11:34 +0100 | [diff] [blame] | 1129 | 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] | 1130 | application_Container := ts_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi) |
| 1131 | } |
| 1132 | template ApplContainer_or_ApplErrContainer_GTPC |
| 1133 | tru_GTPC_ApplContainer_or_ApplErrContainer_NACC(template ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := { |
| 1134 | nacc := cont |
| 1135 | } |
| 1136 | template (value) ApplContainer_or_ApplErrContainer_GTPC |
| 1137 | tsu_GTPC_ApplContainer_or_ApplErrContainer_NACC(template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := { |
| 1138 | nacc := cont |
| 1139 | } |
| 1140 | template RAN_Information_RIM_Container_GTPC |
| 1141 | tr_GTPC_RAN_Information_RIM_Container(template RIM_Application_Identity_GTPC app_id, |
| 1142 | template RIM_Sequence_Number_GTPC seq, |
| 1143 | template RIM_PDU_Indications_GTPC ind, |
| 1144 | template RIM_Protocol_Version_Number_GTPC ver := omit, |
| 1145 | template ApplContainer_or_ApplErrContainer_GTPC app_cont := omit, |
| 1146 | template SON_TransferApplicationIdentity son_app_id := omit) := { |
| 1147 | iEI := '58'O, |
| 1148 | ext := '1'B, |
| 1149 | lengthIndicator := { |
| 1150 | length1 := ? |
| 1151 | }, |
| 1152 | rIM_Application_Identity := app_id, |
| 1153 | rIM_Sequence_Number := seq, |
| 1154 | rIM_PDU_Indications := ind, |
| 1155 | rIM_Protocol_Version_Number := ver, |
| 1156 | applContainer_or_ApplErrContainer := app_cont, |
| 1157 | sON_TransferApplicationIdentity := son_app_id |
| 1158 | } |
| 1159 | template (value) RAN_Information_RIM_Container_GTPC |
| 1160 | ts_GTPC_RAN_Information_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id, |
| 1161 | template (value) RIM_Sequence_Number_GTPC seq, |
| 1162 | template (value) RIM_PDU_Indications_GTPC ind, |
| 1163 | template (omit) RIM_Protocol_Version_Number_GTPC ver := omit, |
| 1164 | template (omit) ApplContainer_or_ApplErrContainer_GTPC app_cont := omit, |
| 1165 | template (omit) SON_TransferApplicationIdentity son_app_id := omit) := { |
| 1166 | iEI := '58'O, |
| 1167 | ext := '1'B, |
| 1168 | lengthIndicator := { |
| 1169 | length1 := 0 /* overwritten */ |
| 1170 | }, |
| 1171 | rIM_Application_Identity := app_id, |
| 1172 | rIM_Sequence_Number := seq, |
| 1173 | rIM_PDU_Indications := ind, |
| 1174 | rIM_Protocol_Version_Number := ver, |
| 1175 | applContainer_or_ApplErrContainer := app_cont, |
| 1176 | sON_TransferApplicationIdentity := son_app_id |
| 1177 | } |
| 1178 | template PDU_BSSGP_RAN_INFORMATION_GTPC |
| 1179 | tr_GTPC_RAN_Information(template RIM_Routing_Information_GTPC dest, |
| 1180 | template RIM_Routing_Information_GTPC src, |
| 1181 | template RAN_Information_RIM_Container_GTPC cont) := { |
| 1182 | bssgpPduType := '70'O, |
| 1183 | destination_Cell_Identifier := dest, |
| 1184 | source_Cell_Identifier := src, |
| 1185 | rIM_Container := cont |
| 1186 | } |
| 1187 | template (value) PDU_BSSGP_RAN_INFORMATION_GTPC |
| 1188 | ts_GTPC_RAN_Information(template (value) RIM_Routing_Information_GTPC dest, |
| 1189 | template (value) RIM_Routing_Information_GTPC src, |
| 1190 | template (value) RAN_Information_RIM_Container_GTPC cont) := { |
| 1191 | bssgpPduType := '70'O, |
| 1192 | destination_Cell_Identifier := dest, |
| 1193 | source_Cell_Identifier := src, |
| 1194 | rIM_Container := cont |
| 1195 | } |
| 1196 | template RANTransparentContainer tr_RANTransparentContainer_RAN_INFO(template PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := { |
| 1197 | type_gtpc := '90'O, |
| 1198 | lengthf := ?, |
| 1199 | rANTransparentContainerField := { |
| 1200 | pDU_BSSGP_RAN_INFORMATION := pdu |
| 1201 | } |
| 1202 | } |
| 1203 | template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO(template (value) PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := { |
| 1204 | type_gtpc := '90'O, |
| 1205 | lengthf := 0, /* overwritten */ |
| 1206 | rANTransparentContainerField := { |
| 1207 | pDU_BSSGP_RAN_INFORMATION := pdu |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | template RANTransparentContainer tr_RANTransparentContainer(template RANTransparentContainerField rANTransparentContainerField) := { |
| 1212 | type_gtpc := '90'O, |
| 1213 | lengthf := ?, |
| 1214 | rANTransparentContainerField := rANTransparentContainerField |
| 1215 | } |
| 1216 | template (value) RANTransparentContainer ts_RANTransparentContainer(template (value) RANTransparentContainerField rANTransparentContainerField) := { |
| 1217 | type_gtpc := '90'O, |
| 1218 | lengthf := 0, /* overwritten */ |
| 1219 | rANTransparentContainerField := rANTransparentContainerField |
| 1220 | } |
| 1221 | template GTPC_PDUs tr_RANInfoRelay(template RANTransparentContainer transparentContainer) := { |
| 1222 | ranInformationRelay := { |
| 1223 | transparentContainer := transparentContainer, |
| 1224 | rIM_RoutingAddress := *, |
| 1225 | rIM_RoutingAddress_Discriminator := *, |
| 1226 | private_extension_gtpc := * |
| 1227 | } |
| 1228 | } |
| 1229 | template (value) GTPC_PDUs ts_RANInfoRelay(template (value) RANTransparentContainer transparentContainer) := { |
| 1230 | ranInformationRelay := { |
| 1231 | transparentContainer := transparentContainer, |
| 1232 | rIM_RoutingAddress := omit, |
| 1233 | rIM_RoutingAddress_Discriminator := omit, |
| 1234 | private_extension_gtpc := omit |
| 1235 | } |
| 1236 | } |
| 1237 | template Gtp1cUnitdata |
| 1238 | tr_GTPC_RANInfoRelay(template GtpPeer peer, |
| 1239 | template RANTransparentContainer transparentContainer) := { |
| 1240 | peer := peer, |
| 1241 | gtpc := tr_GTP1C_PDU(rANInformationRelay, '00000000'O, tr_RANInfoRelay(transparentContainer)) |
| 1242 | } |
| 1243 | template (value) Gtp1cUnitdata |
| 1244 | ts_GTPC_RANInfoRelay(template (value) GtpPeer peer, |
| 1245 | template (value) RANTransparentContainer transparentContainer) := { |
| 1246 | peer := peer, |
| 1247 | gtpc := ts_GTP1C_PDU(rANInformationRelay, '00000000'O, valueof(ts_RANInfoRelay(transparentContainer)), 0) |
| 1248 | } |
| 1249 | |
| 1250 | |
| 1251 | template RAN_Information_Request_RIM_Container_GTPC |
| 1252 | tr_GTPC_RAN_Information_Request_RIM_Container(template RIM_Application_Identity_GTPC app_id := ?, |
| 1253 | template RIM_Sequence_Number_GTPC seq := ?, |
| 1254 | template RIM_PDU_Indications_GTPC ind := ?, |
| 1255 | template RIM_Protocol_Version_Number_GTPC ver := *, |
| 1256 | template RAN_Information_Request_Application_Container_GTPC app_cont := *, |
| 1257 | template SON_TransferApplicationIdentity son_app_id := *) := { |
| 1258 | iEI := '57'O, |
| 1259 | ext := '1'B, |
| 1260 | lengthIndicator := { |
| 1261 | length1 := ? |
| 1262 | }, |
| 1263 | rIM_Application_Identity := app_id, |
| 1264 | rIM_Sequence_Number := seq, |
| 1265 | rIM_PDU_Indications := ind, |
| 1266 | rIM_Protocol_Version_Number := ver, |
| 1267 | application_Container := app_cont, |
| 1268 | sON_TransferApplicationIdentity := son_app_id |
| 1269 | } |
Harald Welte | c69cf4e | 2018-02-17 20:57:02 +0100 | [diff] [blame] | 1270 | |
| 1271 | /* GTP-U */ |
| 1272 | |
| 1273 | template PDU_GTPU tr_GTP1U_PDU(template OCT1 msg_type, template OCT4 teid, template GTPU_IEs ies := ?) := { |
| 1274 | pn_bit := ?, |
| 1275 | s_bit := ?, |
| 1276 | e_bit := ?, |
| 1277 | spare := ?, |
| 1278 | /* Protocol Type flag (PT) shall be set to '1' in GTP */ |
| 1279 | pt := '1'B, |
| 1280 | /* Version shall be set to decimal 1 ('001'). */ |
| 1281 | version := '001'B, |
| 1282 | messageType := msg_type, |
| 1283 | lengthf := ?, |
| 1284 | teid := teid, |
| 1285 | opt_part := *, |
| 1286 | gtpu_IEs := ies |
| 1287 | } |
| 1288 | |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 1289 | function f_GTPU_s_bit(template (omit) uint16_t seq) return BIT1 { |
| 1290 | if (istemplatekind(seq, "omit")) { |
| 1291 | return '0'B; |
| 1292 | } |
| 1293 | return '1'B; |
| 1294 | } |
| 1295 | |
| 1296 | function f_GTPU_opt_part(template (omit) uint16_t seq) return template (omit) GTPU_Header_optional_part { |
| 1297 | if (istemplatekind(seq, "omit")) { |
| 1298 | return omit; |
| 1299 | } |
| 1300 | var GTPU_Header_optional_part ret := { |
| 1301 | sequenceNumber := int2oct(valueof(seq), 2), |
| 1302 | npduNumber := '00'O, |
| 1303 | nextExtHeader := '00'O, |
| 1304 | gTPU_extensionHeader_List := omit |
| 1305 | }; |
| 1306 | return ret; |
| 1307 | } |
| 1308 | |
Harald Welte | c69cf4e | 2018-02-17 20:57:02 +0100 | [diff] [blame] | 1309 | /* generalized GTP-U send template */ |
Pau Espin Pedrol | 480e67f | 2022-02-09 16:37:47 +0100 | [diff] [blame] | 1310 | 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] | 1311 | /* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN |
| 1312 | * flag is set to 1. */ |
| 1313 | pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */ |
| 1314 | /* If the Sequence Number flag (S) is set to '1' the sequence number field is present and |
| 1315 | * 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] | 1316 | * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'. |
| 1317 | * |
| 1318 | * Note that the caller must ensure that these conditions hold. |
| 1319 | * The caller can either pass a sequence number (we set s_bit to '1'B) when appropriate, |
| 1320 | * or may omit the sequence number (we set s_bit to '0'B). */ |
| 1321 | s_bit := f_GTPU_s_bit(seq), |
Harald Welte | c69cf4e | 2018-02-17 20:57:02 +0100 | [diff] [blame] | 1322 | /* Extension header presence */ |
| 1323 | e_bit := '0'B, |
| 1324 | spare := '0'B, |
| 1325 | /* Protocol Type flag (PT) shall be set to '1' in GTP */ |
| 1326 | pt := '1'B, |
| 1327 | /* Version shall be set to decimal 1 ('001'). */ |
| 1328 | version := '001'B, |
| 1329 | messageType := msg_type, |
| 1330 | lengthf := 0, /* we assume encoder overwrites this */ |
| 1331 | teid := teid, |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 1332 | opt_part := f_GTPU_opt_part(seq), |
Harald Welte | c69cf4e | 2018-02-17 20:57:02 +0100 | [diff] [blame] | 1333 | gtpu_IEs := ies |
| 1334 | } |
| 1335 | |
| 1336 | template Gtp1uUnitdata tr_GTPU_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid) := { |
| 1337 | peer := peer, |
| 1338 | gtpu := tr_GTP1U_PDU(msg_type, teid) |
| 1339 | } |
| 1340 | |
| 1341 | |
Pau Espin Pedrol | 480e67f | 2022-02-09 16:37:47 +0100 | [diff] [blame] | 1342 | /* template matching reception of GTP-U echo-request/response */ |
Harald Welte | c69cf4e | 2018-02-17 20:57:02 +0100 | [diff] [blame] | 1343 | 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] | 1344 | 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] | 1345 | |
| 1346 | /* template matching reception of GTP-U GPDU */ |
| 1347 | template GTPU_IEs t_GPDU(template octetstring data) := { |
| 1348 | g_PDU_IEs := { |
| 1349 | data := data |
| 1350 | } |
| 1351 | } |
| 1352 | template Gtp1uUnitdata tr_GTPU_GPDU(template GtpPeer peer, template OCT4 teid, template octetstring data := ?) := { |
| 1353 | peer := peer, |
| 1354 | gtpu := tr_GTP1U_PDU('FF'O, teid, t_GPDU(data)) |
| 1355 | } |
| 1356 | |
Pau Espin Pedrol | 480e67f | 2022-02-09 16:37:47 +0100 | [diff] [blame] | 1357 | template GTPU_IEs ts_UEchoReqPDU := { |
| 1358 | echoRequest_IEs := { |
| 1359 | private_extension_gtpu := omit |
| 1360 | } |
| 1361 | } |
| 1362 | |
| 1363 | /* master template for sending a GTP-C echo request */ |
| 1364 | template (value) Gtp1uUnitdata ts_GTPU_PING(GtpPeer peer, uint16_t seq) := { |
| 1365 | peer := peer, |
| 1366 | gtpu := ts_GTP1U_PDU(echoRequest, seq, '00000000'O, valueof(ts_UEchoReqPDU)) |
| 1367 | } |
| 1368 | |
Harald Welte | c69cf4e | 2018-02-17 20:57:02 +0100 | [diff] [blame] | 1369 | template GTPU_IEs ts_UEchoRespPDU(OCT1 restart_counter) := { |
| 1370 | echoResponse_IEs := { |
| 1371 | recovery_gtpu := { |
| 1372 | type_gtpu := '00'O, /* we assume encoder fixes? */ |
| 1373 | restartCounter := restart_counter |
| 1374 | }, |
| 1375 | private_extension_gtpu := omit |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | /* master template for sending a GTP-U echo response */ |
| 1380 | template Gtp1uUnitdata ts_GTPU_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := { |
| 1381 | peer := peer, |
| 1382 | gtpu := ts_GTP1U_PDU(echoResponse, seq, '00000000'O, valueof(ts_UEchoRespPDU(rest_ctr))) |
| 1383 | } |
| 1384 | |
Pau Espin Pedrol | f3e2538 | 2018-07-18 13:46:40 +0200 | [diff] [blame] | 1385 | template GSNAddress_gtpu ts_UGsnAddr(octetstring ip_addr) := { |
| 1386 | type_gtpu := '85'O, |
| 1387 | lengthf := lengthof(ip_addr), |
| 1388 | gSNAddressValue := ip_addr |
| 1389 | } |
| 1390 | |
| 1391 | template TeidDataI_gtpu ts_UteidDataI(OCT4 teid) := { |
| 1392 | type_gtpu := '10'O, |
| 1393 | teidDataI := teid |
| 1394 | } |
| 1395 | |
| 1396 | template GTPU_IEs ts_UErrorIndication(OCT4 teid, octetstring gsn_addr) := { |
| 1397 | errorIndication_IEs := { |
| 1398 | teidDataI_gtpu := ts_UteidDataI(teid), |
| 1399 | gSNAddress_gtpu := ts_UGsnAddr(gsn_addr), |
| 1400 | private_extension_gtpu := omit |
| 1401 | } |
| 1402 | } |
| 1403 | |
| 1404 | /* master template for sending a GTP-U Error indication */ |
| 1405 | template Gtp1uUnitdata ts_GTPU_ErrorIndication(GtpPeer peer, uint16_t seq, OCT4 teid, octetstring gsn_addr) := { |
| 1406 | peer := peer, |
| 1407 | gtpu := ts_GTP1U_PDU('1A'O, seq, '00000000'O, valueof(ts_UErrorIndication(teid, gsn_addr))) |
| 1408 | } |
| 1409 | |
Harald Welte | c69cf4e | 2018-02-17 20:57:02 +0100 | [diff] [blame] | 1410 | /* master template for sending a GTP-U user plane data */ |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 1411 | 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] | 1412 | peer := peer, |
| 1413 | gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }}) |
| 1414 | } |
| 1415 | } |