Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 1 | module BSSMAP_Templates { |
| 2 | |
| 3 | import from General_Types all; |
| 4 | import from Osmocom_Types all; |
| 5 | import from BSSAP_Types all; |
| 6 | |
| 7 | type integer BssmapCause; |
| 8 | |
| 9 | template PDU_BSSAP ts_BSSAP_BSSMAP := { |
| 10 | discriminator := '0'B, |
| 11 | spare := '0000000'B, |
| 12 | dlci := omit, |
| 13 | lengthIndicator := 0, /* overwritten by codec */ |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 14 | pdu := { |
| 15 | bssmap := ? |
| 16 | } |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | template PDU_BSSAP tr_BSSAP_BSSMAP := { |
| 20 | discriminator := '0'B, |
| 21 | spare := '0000000'B, |
| 22 | dlci := omit, |
| 23 | lengthIndicator := ?, |
| 24 | pdu := { |
| 25 | bssmap := ? |
| 26 | } |
| 27 | } |
| 28 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 29 | template PDU_BSSAP ts_BSSAP_DTAP := { |
| 30 | discriminator := '1'B, |
| 31 | spare := '0000000'B, |
| 32 | dlci := omit, |
| 33 | lengthIndicator := 0, /* overwritten by codec */ |
| 34 | pdu := { |
| 35 | dtap := ? |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | template PDU_BSSAP tr_BSSAP_DTAP := { |
| 40 | discriminator := '1'B, |
| 41 | spare := '0000000'B, |
| 42 | dlci := omit, |
| 43 | lengthIndicator := ?, |
| 44 | pdu := { |
| 45 | dtap := ? |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 50 | template (value) BSSMAP_IE_Cause ts_BSSMAP_IE_Cause(BssmapCause val) := { |
| 51 | elementIdentifier := '04'O, |
| 52 | lengthIndicator := 0, |
| 53 | causeValue := int2bit(val, 7), |
| 54 | extensionCauseValue := '0'B, |
| 55 | spare1 := omit |
| 56 | } |
| 57 | |
| 58 | template (value) PDU_BSSAP ts_BSSMAP_Reset(BssmapCause cause) modifies ts_BSSAP_BSSMAP := { |
| 59 | pdu := { |
| 60 | bssmap := { |
| 61 | reset := { |
| 62 | messageType := '30'O, |
| 63 | cause := ts_BSSMAP_IE_Cause(cause), |
| 64 | a_InterfaceSelectorForReset := omit |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 70 | template PDU_BSSAP tr_BSSMAP_Reset modifies tr_BSSAP_BSSMAP := { |
| 71 | pdu := { |
| 72 | bssmap := { |
| 73 | reset := { |
| 74 | messageType := '30'O, |
| 75 | cause := ?, |
| 76 | a_InterfaceSelectorForReset := * |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 82 | template (value) PDU_BSSAP ts_BSSMAP_ResetAck modifies ts_BSSAP_BSSMAP := { |
| 83 | pdu := { |
| 84 | bssmap := { |
| 85 | resetAck := { |
| 86 | messageType := '31'O, |
| 87 | a_InterfaceSelectorForReset := omit |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | template PDU_BSSAP tr_BSSMAP_ResetAck modifies tr_BSSAP_BSSMAP := { |
| 94 | pdu := { |
| 95 | bssmap := { |
| 96 | resetAck := { |
| 97 | messageType := '31'O, |
| 98 | a_InterfaceSelectorForReset := * |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | template BSSMAP_IE_CellIdentifier ts_BSSMAP_IE_CellID := { |
| 105 | elementIdentifier := '05'O, |
| 106 | lengthIndicator := 0, |
| 107 | cellIdentifierDiscriminator := '0000'B, |
| 108 | spare1_4 := '0000'B, |
| 109 | cellIdentification := ? |
| 110 | } |
| 111 | |
| 112 | type uint16_t BssmapLAC; |
| 113 | type uint16_t BssmapCI; |
| 114 | |
| 115 | /* |
| 116 | template BSSMAP_IE_CellIdentifier ts_CellId_CGI(mcc, mnc, lac, ci) |
| 117 | modifies ts_BSSMAP_IE_CellID := { |
| 118 | cellIdentification := { |
| 119 | cI_LAC_CGI := { |
| 120 | mnc_mcc := FIXME, |
| 121 | lac := int2oct(lac, 2), |
| 122 | ci := int2oct(ci, 2) |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | */ |
| 127 | |
| 128 | template BSSMAP_IE_CellIdentifier ts_CellID_LAC_CI(BssmapLAC lac, BssmapCI ci) |
| 129 | modifies ts_BSSMAP_IE_CellID := { |
| 130 | cellIdentification := { |
| 131 | cI_LAC_CI := { |
| 132 | lac := int2oct(lac, 2), |
| 133 | ci := int2oct(ci, 2) |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | template BSSMAP_IE_CellIdentifier ts_CellId_CI(BssmapCI ci) |
| 139 | modifies ts_BSSMAP_IE_CellID := { |
| 140 | cellIdentification := { |
| 141 | cI_CI := int2oct(ci, 2) |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | template BSSMAP_IE_CellIdentifier ts_CellId_none |
| 146 | modifies ts_BSSMAP_IE_CellID := { |
| 147 | cellIdentification := { |
| 148 | cI_noCell := ''O |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | |
| 153 | template BSSMAP_IE_Layer3Information ts_BSSMAP_IE_L3Info(octetstring l3info) := { |
| 154 | elementIdentifier := '17'O, |
| 155 | lengthIndicator := 0, |
| 156 | layer3info := l3info |
| 157 | } |
| 158 | |
Harald Welte | f8a0bda | 2017-12-09 00:53:17 +0100 | [diff] [blame] | 159 | template BSSMAP_IE_Layer3Information tr_BSSMAP_IE_L3Info(template octetstring l3info) := { |
| 160 | elementIdentifier := '17'O, |
| 161 | lengthIndicator := ?, |
| 162 | layer3info := l3info |
| 163 | } |
| 164 | |
| 165 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 166 | template PDU_BSSAP ts_BSSMAP_ComplL3(BSSMAP_IE_CellIdentifier cell_id, octetstring l3_info) |
| 167 | modifies ts_BSSAP_BSSMAP := { |
| 168 | pdu := { |
| 169 | bssmap := { |
| 170 | completeLayer3Information := { |
| 171 | messageType := '57'O, |
| 172 | cellIdentifier := cell_id, |
| 173 | layer3Information := ts_BSSMAP_IE_L3Info(l3_info), |
| 174 | chosenChannel := omit, |
| 175 | lSAIdentifier := omit, |
| 176 | aPDU := omit, |
| 177 | codecList := omit, |
| 178 | redirectAttemptFlag := omit, |
| 179 | sendSequenceNumber := omit, |
| 180 | iMSI := omit |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
Harald Welte | f8a0bda | 2017-12-09 00:53:17 +0100 | [diff] [blame] | 186 | template PDU_BSSAP tr_BSSMAP_ComplL3(template octetstring l3_info := ?, |
| 187 | template BSSMAP_IE_CellIdentifier cell_id := ?) |
| 188 | modifies tr_BSSAP_BSSMAP := { |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 189 | pdu := { |
| 190 | bssmap := { |
Harald Welte | f8a0bda | 2017-12-09 00:53:17 +0100 | [diff] [blame] | 191 | completeLayer3Information := { |
| 192 | messageType := '57'O, |
| 193 | cellIdentifier := cell_id, |
| 194 | layer3Information := tr_BSSMAP_IE_L3Info(l3_info), |
| 195 | chosenChannel := *, |
| 196 | lSAIdentifier := *, |
| 197 | aPDU := *, |
| 198 | codecList := *, |
| 199 | redirectAttemptFlag := *, |
| 200 | sendSequenceNumber := *, |
| 201 | iMSI := * |
| 202 | } |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 207 | template BSSMAP_IE_CellIdentifierList ts_BSSMAP_IE_CidList(BSSMAP_FIELD_CellIdentificationList cid_list) := { |
| 208 | elementIdentifier := '1A'O, |
| 209 | lengthIndicator := 0, /* overwritten */ |
| 210 | cellIdentifierDiscriminator := '0000'B, /* overwritten */ |
| 211 | spare1_4 := '0000'B, |
| 212 | cellIdentificationList := cid_list |
| 213 | } |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 214 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 215 | template PDU_BSSAP ts_BSSMAP_HandoReq(BssmapCause cause, BSSMAP_FIELD_CellIdentificationList cid_list) |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 216 | modifies ts_BSSAP_BSSMAP := { |
| 217 | pdu := { |
| 218 | bssmap := { |
| 219 | handoverRequired := { |
| 220 | messageType := '11'O, |
| 221 | cause := ts_BSSMAP_IE_Cause(cause), |
| 222 | responseRequest := omit, |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 223 | cellIdentifierList := ts_BSSMAP_IE_CidList(cid_list), |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 224 | circuitPoolList := omit, |
| 225 | currentChannelType1 := omit, |
| 226 | speechVersion := omit, |
| 227 | queueingIndicator := omit, |
| 228 | oldToNewBSSInfo := omit, |
| 229 | sourceToTargetRNCTransparentInfo := omit, |
| 230 | sourceToTargetRNCTransparentInfoCDMA := omit, |
| 231 | gERANClassmark := omit, |
| 232 | talkerPriority := omit, |
| 233 | speechCodec := omit, |
| 234 | cSG_Identifier := omit |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 240 | const OCT1 ChRate_TCHF := '08'O; |
| 241 | const OCT1 ChRate_TCHH := '09'O; |
| 242 | |
| 243 | template (value) BSSMAP_IE_ChannelType ts_BSSMAP_IE_ChannelType := { |
| 244 | elementIdentifier := '0B'O, /* overwritten */ |
| 245 | lengthIndicator := 0, /* overwritten */ |
| 246 | speechOrDataIndicator := '0001'B, /* speech */ |
| 247 | spare1_4 := '0000'B, |
| 248 | channelRateAndType := ChRate_TCHF, |
| 249 | speechId_DataIndicator := '01'O /* FRv1 */ |
| 250 | } |
| 251 | |
| 252 | template (value) BSSMAP_IE_CircuitIdentityCode ts_BSSMAP_IE_CIC(uint11_t span, uint5_t ts) := { |
| 253 | elementIdentifier := '01'O, /* overwritten */ |
| 254 | cicHigh := bit2oct(substr(int2bit(span, 11) << 5, 0, 8)), |
| 255 | cicLow := bit2oct((substr(int2bit(span, 11), 8, 3) << 5) & int2bit(ts, 5)) |
| 256 | } |
| 257 | |
Harald Welte | ab05d6c | 2017-11-23 18:50:52 +0100 | [diff] [blame] | 258 | template (value) PDU_BSSAP ts_BSSMAP_AssignmentReq(uint11_t span, uint5_t ts) |
Harald Welte | 365f4ed | 2017-11-23 00:00:43 +0100 | [diff] [blame] | 259 | modifies ts_BSSAP_BSSMAP := { |
| 260 | pdu := { |
| 261 | bssmap := { |
| 262 | assignmentRequest := { |
| 263 | messageType :='01'O, /* overwritten */ |
| 264 | channelType := ts_BSSMAP_IE_ChannelType, |
| 265 | layer3HeaderInfo := omit, |
| 266 | priority := omit, |
| 267 | circuitIdentityCode := ts_BSSMAP_IE_CIC(span, ts), |
| 268 | downLinkDTX_Flag := omit, |
| 269 | interferenceBandToBeUsed := omit, |
| 270 | classmarkInformationType2 := omit, |
| 271 | groupCallReference := omit, |
| 272 | talkerFlag := omit, |
| 273 | configurationEvolutionIndication := omit, |
| 274 | lsaAccesControlSuppression := omit, |
| 275 | serviceHandover := omit, |
| 276 | encryptionInformation := omit, |
| 277 | talkerPriority := omit, |
| 278 | aoIPTransportLayer := omit, |
| 279 | codecList := omit, |
| 280 | callIdentifier := omit, |
| 281 | kC128 := omit, |
| 282 | globalCallReference := omit, |
| 283 | lCLS_Configuration := omit, |
| 284 | lCLS_ConnectionStatusControl := omit, |
| 285 | lCLS_CorrelationNotNeeded := omit |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | } |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 290 | |
Harald Welte | ab05d6c | 2017-11-23 18:50:52 +0100 | [diff] [blame] | 291 | template PDU_BSSAP tr_BSSMAP_AssignmentReq modifies tr_BSSAP_BSSMAP := { |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 292 | pdu := { |
| 293 | bssmap := { |
| 294 | assignmentRequest := { |
| 295 | messageType :='01'O, /* overwritten */ |
| 296 | channelType := ?, |
| 297 | layer3HeaderInfo := *, |
| 298 | priority := *, |
| 299 | circuitIdentityCode := ?, |
| 300 | downLinkDTX_Flag := *, |
| 301 | interferenceBandToBeUsed := *, |
| 302 | classmarkInformationType2 := *, |
| 303 | groupCallReference := *, |
| 304 | talkerFlag := *, |
| 305 | configurationEvolutionIndication := *, |
| 306 | lsaAccesControlSuppression := *, |
| 307 | serviceHandover := *, |
| 308 | encryptionInformation := *, |
| 309 | talkerPriority := *, |
| 310 | aoIPTransportLayer := *, |
| 311 | codecList := *, |
| 312 | callIdentifier := *, |
| 313 | kC128 := *, |
| 314 | globalCallReference := *, |
| 315 | lCLS_Configuration := *, |
| 316 | lCLS_ConnectionStatusControl := *, |
| 317 | lCLS_CorrelationNotNeeded := * |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | template (value) PDU_BSSAP ts_BSSMAP_AssignmentComplete(BSSMAP_IE_CircuitIdentityCode cic) |
| 324 | modifies ts_BSSAP_BSSMAP := { |
| 325 | pdu := { |
| 326 | bssmap := { |
| 327 | assignmentComplete := { |
| 328 | messageType :='02'O, /* overwritten */ |
Harald Welte | 7ed2b08 | 2017-11-23 18:52:13 +0100 | [diff] [blame] | 329 | rR_Cause := omit, |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 330 | circuitIdentityCode := cic, |
| 331 | cellIdentifier := omit, |
| 332 | chosenChannel := omit, |
| 333 | chosenEncryptionAlgorithm := omit, |
| 334 | circuitPool := omit, |
| 335 | speechVersion := omit, |
| 336 | lSAIdentifier := omit, |
| 337 | talkerPriority := omit, |
| 338 | aoIPTransportLayer := omit, |
| 339 | speechCodec := omit, |
| 340 | codecList := omit, |
| 341 | lCLS_BSS_Status := omit |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | template PDU_BSSAP tr_BSSMAP_AssignmentComplete modifies tr_BSSAP_BSSMAP := { |
| 348 | pdu := { |
| 349 | bssmap := { |
| 350 | assignmentComplete := { |
| 351 | messageType := '02'O, /* overwritten */ |
Harald Welte | 7ed2b08 | 2017-11-23 18:52:13 +0100 | [diff] [blame] | 352 | rR_Cause := *, |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 353 | circuitIdentityCode := ?, |
| 354 | cellIdentifier := *, |
| 355 | chosenChannel := *, |
| 356 | chosenEncryptionAlgorithm := *, |
| 357 | circuitPool := *, |
| 358 | speechVersion := *, |
| 359 | lSAIdentifier := *, |
| 360 | talkerPriority := *, |
| 361 | aoIPTransportLayer := *, |
| 362 | speechCodec := *, |
| 363 | codecList := *, |
| 364 | lCLS_BSS_Status := * |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | template (value) PDU_BSSAP ts_BSSMAP_ClearCommand(BssmapCause cause) |
| 371 | modifies ts_BSSAP_BSSMAP := { |
| 372 | pdu := { |
| 373 | bssmap := { |
| 374 | clearCommand := { |
| 375 | messageType := '20'O, /* overwritten */ |
| 376 | layer3HeaderInfo := omit, |
| 377 | cause := ts_BSSMAP_IE_Cause(cause), |
| 378 | cSFB_Indication := omit |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | template PDU_BSSAP tr_BSSMAP_ClearCommand modifies tr_BSSAP_BSSMAP := { |
| 385 | pdu := { |
| 386 | bssmap := { |
| 387 | clearCommand := { |
| 388 | messageType := '20'O, /* overwritten */ |
| 389 | layer3HeaderInfo := *, |
| 390 | cause := ?, |
| 391 | cSFB_Indication := * |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | template (value) PDU_BSSAP ts_BSSMAP_ClearComplete |
| 398 | modifies ts_BSSAP_BSSMAP := { |
| 399 | pdu := { |
| 400 | bssmap := { |
| 401 | clearComplete := { |
| 402 | messageType := '21'O /* overwritten */ |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | |
Harald Welte | c859df5 | 2017-11-24 23:41:41 +0100 | [diff] [blame] | 408 | template PDU_BSSAP tr_BSSMAP_ClearComplete modifies tr_BSSAP_BSSMAP := { |
| 409 | pdu := { |
| 410 | bssmap := { |
| 411 | clearComplete := { |
| 412 | messageType := '21'O |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | } |
| 417 | |
Harald Welte | cfa79ad | 2017-12-09 22:33:47 +0100 | [diff] [blame] | 418 | template PDU_BSSAP tr_BSSMAP_ClearRequest modifies tr_BSSAP_BSSMAP := { |
| 419 | pdu := { |
| 420 | bssmap := { |
| 421 | clearRequest := { |
| 422 | messageType := '22'O, /* overwritten */ |
| 423 | cause := ? |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 430 | function f_hex_is_odd_length(hexstring digits) return bitstring { |
| 431 | if (lengthof(digits) rem 2 == 1) { |
| 432 | return '1'B; |
| 433 | } else { |
| 434 | return '0'B; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | template BSSMAP_IE_IMSI ts_BSSMAP_Imsi(hexstring imsi_digits) := { |
| 439 | elementIdentifier := '08'O, |
| 440 | lengthIndicator := 0, /* overwritten */ |
| 441 | typeOfIdentity := '001'B, /* IMSI */ |
| 442 | oddEvenIndicator := f_hex_is_odd_length(imsi_digits), |
| 443 | digits := imsi_digits |
| 444 | } |
| 445 | |
| 446 | template PDU_BSSAP ts_BSSMAP_Paging(hexstring imsi_digits, BSSMAP_FIELD_CellIdentificationList cid_list, |
| 447 | template integer tmsi := omit) |
| 448 | modifies ts_BSSAP_BSSMAP := { |
| 449 | pdu := { |
| 450 | bssmap := { |
| 451 | paging := { |
| 452 | messageType := '51'O, |
| 453 | iMSI := ts_BSSMAP_Imsi(imsi_digits), |
| 454 | tMSI := omit, // FIXME: convert tmsi, |
| 455 | cellIdentifierList := ts_BSSMAP_IE_CidList(cid_list), |
| 456 | channelNeeded := omit, |
| 457 | eMLPP_Priority := omit, |
| 458 | pagingInformation := omit /* only VGCS/VBS flag */ |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | |
Harald Welte | c859df5 | 2017-11-24 23:41:41 +0100 | [diff] [blame] | 464 | |
| 465 | |
Harald Welte | c76f29f | 2017-11-22 12:46:46 +0100 | [diff] [blame] | 466 | } |