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