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