1#!/usr/bin/env python 2 3# This file is part of Scapy 4# Scapy is free software: you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation, either version 2 of the License, or 7# any later version. 8# 9# Scapy is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with Scapy. If not, see <http://www.gnu.org/licenses/>. 16 17# scapy.contrib.description = PPI 18# scapy.contrib.status = loads 19 20 #################################################################### 21 # This file holds the GSM UM interface implementation for Scapy # 22 # author: Laurent Weber <k@0xbadcab1e.lu> # 23 # # 24 # Some examples on how to use this script: # 25 # http://0xbadcab1e.lu/scapy_gsm_um-howto.txt # 26 # # 27 # tested on: scapy-version: 2.2.0 (dev) # 28 #################################################################### 29 30from __future__ import print_function 31import logging 32from types import IntType 33from types import NoneType 34from types import StringType 35#from time import sleep 36import socket 37logging.getLogger("scapy").setLevel(1) 38 39from scapy.packet import * 40from scapy.fields import * 41 42# This method is intended to send gsm air packets. It uses a unix domain 43# socket. It opens a socket, sends the parameter to the socket and 44# closes the socket. 45# typeSock determines the type of the socket, can be: 46# 0 for UDP Socket 47# 1 for Unix Domain Socket 48# 2 for TCP 49 50 51def sendum(x, typeSock=0): 52 try: 53 if not isinstance(x, str): 54 x = str(x) 55 if typeSock is 0: 56 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 57 host = '127.0.0.1' 58 port = 28670 # default for openBTS 59 s.connect((host, port)) 60 elif typeSock is 1: 61 s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 62 s.connect("/tmp/osmoL") 63 elif typeSock is 2: 64 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 65 host = '127.0.0.1' 66 port = 43797 67 s.connect((host, port)) 68 s.send(x) 69 s.close() 70 except: 71 print("[Error]: There was a problem when trying to transmit data.\ 72 Please make sure you started the socket server.") 73 74# Known Bugs/Problems: 75# If a message uses multiple times the same IE you cannot set the values 76# of this IE's if you use the preconfigured packets. You need to build 77# the IE's by hand and than assemble them as entire messages. 78 79# The ErrorLength class is a custom exception that gets raised when a 80# packet doesn't have the correct size. 81 82 83class ErrorLength(Exception): 84 def __str__(self): 85 error = "ERROR: Please make sure you build entire, 8 bit fields." 86 return repr(error) 87### 88# This method computes the length of the actual IE. 89# It computes how many "None" fields have to be removed (if any). 90# The method returns an integer containing the number of bytes that have to be 91# cut off the packet. 92# parameter length contains the max length of the IE can be found in 93# 0408 94# The parameter fields contains the value of the fields (not the default but 95# the real, actual value. 96# The parameter fields2 contains fields_desc. 97# Location contains the location of the length field in the IE. Everything 98# after the the length field has to be counted (04.07 11.2.1.1.2) 99 100 101def adapt(min_length, max_length, fields, fields2, location=2): 102 # find out how much bytes there are between min_length and the location of 103 # the length field 104 location = min_length - location 105 i = len(fields) - 1 106 rm = mysum = 0 107 while i >= 0: 108 if fields[i] is None: 109 rm += 1 110 try: 111 mysum += fields2[i].size 112 except AttributeError: # ByteFields don't have .size 113 mysum += 8 114 else: 115 break 116 i -= 1 117 if mysum % 8 is 0: 118 length = mysum / 8 # Number of bytes we have to delete 119 dyn_length = (max_length - min_length - length) 120 if dyn_length < 0: 121 dyn_length = 0 122 if length is max_length: # Fix for packets that have all values set 123 length -= min_length # to None 124 return [length, dyn_length + location] 125 else: 126 raise ErrorLength() 127 128 129def examples(example=None): 130 if example == None: 131 print("""This command presents some example to introduce scapy 132gsm-um to new users. 133The following parameters can be used: 134 examples("imsiDetach") 135 examples("call") 136 examples("dissect")""") 137 elif example == "imsiDetach": 138 print(""" 139>>> a=imsiDetachIndication() 140... a.typeOfId=1; a.odd=1; a.idDigit1=0xF; 141... a.idDigit2_1=2; a.idDigit2=7; a.idDigit3_1=0; 142... a.idDigit3=7; a.idDigit4_1=7; a.idDigit4=2; 143... a.idDigit5_1=0; a.idDigit5=0; a.idDigit6_1=0; 144... a.idDigit6=1; a.idDigit7_1=2; a.idDigit7=7; 145... a.idDigit8_1=7; a.idDigit8=5; a.idDigit9_1=1; a.idDigit9=4; 146>>> hexdump(a) 1470000 05 01 00 08 F0 27 07 72 00 01 27 75 14 .....'.r..'u. 148>>> sendum(a) 149""") 150 elif example == "call": 151 print(""" 152If you use an USRP and the testcall function this sets up a phonecall: 153>>> sendum(setupMobileOriginated()) 154>>> sendum(connectAcknowledge()) 155""") 156 157 158# Section 10.2/3 159class TpPd(Packet): 160 """Skip indicator and transaction identifier and Protocol Discriminator""" 161 name = "Skip Indicator And Transaction Identifier and Protocol \ 162Discriminator" 163 fields_desc = [ 164 BitField("ti", 0x0, 4), 165 BitField("pd", 0x3, 4) 166 ] 167 168 169class MessageType(Packet): 170 """Message Type Section 10.4""" 171 name = "Message Type" 172 fields_desc = [ 173 XByteField("mesType", 0x3C) 174 ] 175 176 177## 178# Message for Radio Resources management (RR) Section 9.1 179### 180 181# Network to MS 182def additionalAssignment(MobileAllocation_presence=0, 183 StartingTime_presence=0): 184 """ADDITIONAL ASSIGNMENT Section 9.1.1""" 185 # Mandatory 186 a = TpPd(pd=0x6) 187 b = MessageType(mesType=0x3B) # 00111011 188 c = ChannelDescription() 189 packet = a / b / c 190 # Not Mandatory 191 if MobileAllocation_presence is 1: 192 d = MobileAllocationHdr(ieiMA=0x72, eightBitMA=0x0) 193 packet = packet / d 194 if StartingTime_presence is 1: 195 e = StartingTimeHdr(ieiST=0x7C, eightBitST=0x0) 196 packet = packet / e 197 return packet 198 199 200# Network to MS 201def assignmentCommand(FrequencyList_presence=0, 202 CellChannelDescription_presence=0, 203 CellChannelDescription_presence1=0, 204 MultislotAllocation_presence=0, 205 ChannelMode_presence=0, ChannelMode_presence1=0, 206 ChannelMode_presence2=0, ChannelMode_presence3=0, 207 ChannelMode_presence4=0, ChannelMode_presence5=0, 208 ChannelMode_presence6=0, ChannelMode_presence7=0, 209 ChannelDescription=0, ChannelMode2_presence=0, 210 MobileAllocation_presence=0, StartingTime_presence=0, 211 FrequencyList_presence1=0, 212 ChannelDescription2_presence=0, 213 ChannelDescription_presence=0, 214 FrequencyChannelSequence_presence=0, 215 MobileAllocation_presence1=0, 216 CipherModeSetting_presence=0, 217 VgcsTargetModeIdentication_presence=0, 218 MultiRateConfiguration_presence=0): 219 """ASSIGNMENT COMMAND Section 9.1.2""" 220 a = TpPd(pd=0x6) 221 b = MessageType(mesType=0x2e) # 101110 222 c = ChannelDescription2() 223 d = PowerCommand() 224 packet = a / b / c / d 225 if FrequencyList_presence is 1: 226 e = FrequencyListHdr(ieiFL=0x05, eightBitFL=0x0) 227 packet = packet / e 228 if CellChannelDescription_presence is 1: 229 f = CellChannelDescriptionHdr(ieiCCD=0x62, eightBitCCD=0x0) 230 packet = packet / f 231 if MultislotAllocation_presence is 1: 232 g = MultislotAllocationHdr(ieiMSA=0x10, eightBitMSA=0x0) 233 packet = packet / g 234 if ChannelMode_presence is 1: 235 h = ChannelModeHdr(ieiCM=0x63, eightBitCM=0x0) 236 packet = packet / h 237 if ChannelMode_presence1 is 1: 238 i = ChannelModeHdr(ieiCM=0x11, eightBitCM=0x0) 239 packet = packet / i 240 if ChannelMode_presence2 is 1: 241 j = ChannelModeHdr(ieiCM=0x13, eightBitCM=0x0) 242 packet = packet / j 243 if ChannelMode_presence3 is 1: 244 k = ChannelModeHdr(ieiCM=0x14, eightBitCM=0x0) 245 packet = packet / k 246 if ChannelMode_presence4 is 1: 247 l = ChannelModeHdr(ieiCM=0x15, eightBitCM=0x0) 248 packet = packet / l 249 if ChannelMode_presence5 is 1: 250 m = ChannelModeHdr(ieiCM=0x16, eightBitCM=0x0) 251 packet = packet / m 252 if ChannelMode_presence6 is 1: 253 n = ChannelModeHdr(ieiCM=0x17, eightBitCM=0x0) 254 packet = packet / n 255 if ChannelMode_presence7 is 1: 256 o = ChannelModeHdr(ieiCM=0x18, eightBitCM=0x0) 257 packet = packet / o 258 if ChannelDescription_presence is 1: 259 p = ChannelDescriptionHdr(ieiCD=0x64, eightBitCD=0x0) 260 packet = packet / p 261 if ChannelMode2_presence is 1: 262 q = ChannelMode2Hdr(ieiCM2=0x66, eightBitCM2=0x0) 263 packet = packet / q 264 if MobileAllocation_presence is 1: 265 r = MobileAllocationHdr(ieiMA=0x72, eightBitMA=0x0) 266 packet = packet / r 267 if StartingTime_presence is 1: 268 s = StartingTimeHdr(ieiST=0x7C, eightBitST=0x0) 269 packet = packet / s 270 if FrequencyList_presence1 is 1: 271 t = FrequencyListHdr(ieiFL=0x19, eightBitFL=0x0) 272 packet = packet / t 273 if ChannelDescription2_presence is 1: 274 u = ChannelDescription2Hdr(ieiCD2=0x1C, eightBitCD2=0x0) 275 packet = packet / u 276 if ChannelDescription_presence is 1: 277 v = ChannelDescriptionHdr(ieiCD=0x1D, eightBitCD=0x0) 278 packet = packet / v 279 if FrequencyChannelSequence_presence is 1: 280 w = FrequencyChannelSequenceHdr(ieiFCS=0x1E, eightBitFCS=0x0) 281 packet = packet / w 282 if MobileAllocation_presence1 is 1: 283 x = MobileAllocationHdr(ieiMA=0x21, eightBitMA=0x0) 284 packet = packet / x 285 if CipherModeSetting_presence is 1: 286 y = CipherModeSettingHdr(ieiCMS=0x9, eightBitCMS=0x0) 287 packet = packet / y 288 if VgcsTargetModeIdentication_presence is 1: 289 z = VgcsTargetModeIdenticationHdr(ieiVTMI=0x01, eightBitVTMI=0x0) 290 packet = packet / z 291 if MultiRateConfiguration_presence is 1: 292 aa = MultiRateConfigurationHdr(ieiMRC=0x03, eightBitMRC=0x0) 293 packet = packet / aa 294 return packet 295 296 297# MS to Network 298def assignmentComplete(): 299 """ASSIGNMENT COMPLETE Section 9.1.3""" 300 a = TpPd(pd=0x6) 301 b = MessageType(mesType=0x29) # 00101001 302 c = RrCause() 303 packet = a / b / c 304 return packet 305 306 307# MS to Network 308def assignmentFailure(): 309 """ASSIGNMENT FAILURE Section 9.1.4""" 310 a = TpPd(pd=0x6) 311 b = MessageType(mesType=0x2F) # 00101111 312 c = RrCause() 313 packet = a / b / c 314 return packet 315 316 317# Network to MS 318def channelModeModify(VgcsTargetModeIdentication_presence=0, 319 MultiRateConfiguration_presence=0): 320 """CHANNEL MODE MODIFY Section 9.1.5""" 321 a = TpPd(pd=0x6) 322 b = MessageType(mesType=0x8) # 0001000 323 c = ChannelDescription2() 324 d = ChannelMode() 325 packet = a / b / c / d 326 if VgcsTargetModeIdentication is 1: 327 e = VgcsTargetModeIdenticationHdr(ieiVTMI=0x01, eightBitVTMI=0x0) 328 packet = packet / e 329 if MultiRateConfiguration is 1: 330 f = MultiRateConfigurationHdr(ieiMRC=0x03, eightBitMRC=0x0) 331 packet = packet / f 332 return packet 333 334 335def channelModeModifyAcknowledge(): 336 """CHANNEL MODE MODIFY ACKNOWLEDGE Section 9.1.6""" 337 a = TpPd(pd=0x6) 338 b = MessageType(mesType=0x17) # 00010111 339 c = ChannelDescription2() 340 d = ChannelMode() 341 packet = a / b / c / d 342 return packet 343 344 345# Network to MS 346def channelRelease(BaRange_presence=0, GroupChannelDescription_presence=0, 347 GroupCipherKeyNumber_presence=0, GprsResumption_presence=0, 348 BaListPref_presence=0): 349 """CHANNEL RELEASE Section 9.1.7""" 350 a = TpPd(pd=0x6) 351 b = MessageType(mesType=0xD) # 00001101 352 c = RrCause() 353 packet = a / b / c 354 if BaRange_presence is 1: 355 d = BaRangeHdr(ieiBR=0x73, eightBitBR=0x0) 356 packet = packet / d 357 if GroupChannelDescription_presence is 1: 358 e = GroupChannelDescriptionHdr(ieiGCD=0x74, eightBitGCD=0x0) 359 packet = packet / e 360 if GroupCipherKeyNumber_presence is 1: 361 f = GroupCipherKeyNumber(ieiGCKN=0x8) 362 packet = packet / f 363 if GprsResumption_presence is 1: 364 g = GprsResumptionHdr(ieiGR=0xC, eightBitGR=0x0) 365 packet = packet / g 366 if BaListPref_presence is 1: 367 h = BaListPrefHdr(ieiBLP=0x75, eightBitBLP=0x0) 368 packet = packet / h 369 return packet 370 371 372class ChannelRequest(Packet): 373 """Channel request Section 9.1.8""" 374 name = "Channel Request" 375 fields_desc = [ 376 ByteField("estCause", 0x0) 377 ] 378 379 380def channelRequest(): 381 return ChannelRequest() 382 383 384# Network to MS 385def cipheringModeCommand(): 386 """CIPHERING MODE COMMAND Section 9.1.9""" 387 a = TpPd(pd=0x6) 388 b = MessageType(mesType=0x35) # 00110101 389 c = RrCause() 390 #d=cipherModeSetting() 391 #e=cipherResponse() 392 # FIX 393 d = CipherModeSettingAndcipherResponse() 394 packet = a / b / c / d 395 return packet 396 397 398def cipheringModeComplete(MobileId_presence=0): 399 """CIPHERING MODE COMPLETE Section 9.1.10""" 400 a = TpPd(pd=0x6) 401 b = MessageType(mesType=0x32) # 00110010 402 packet = a / b 403 if MobileId_presence is 1: 404 c = MobileIdHdr(ieiMI=0x17, eightBitMI=0x0) 405 packet = packet / c 406 return packet 407 408 409# Network to MS 410def classmarkChange(MobileStationClassmark3_presence=0): 411 """CLASSMARK CHANGE Section 9.1.11""" 412 a = TpPd(pd=0x6) 413 b = MessageType(mesType=0x16) # 00010110 414 c = MobileStationClassmark2() 415 packet = a / b / c 416 if MobileStationClassmark3_presence is 1: 417 e = MobileStationClassmark3(ieiMSC3=0x20) 418 packet = packet / e 419 return packet 420 421 422# Network to MS 423def classmarkEnquiry(): 424 """CLASSMARK ENQUIRY Section 9.1.12""" 425 a = TpPd(pd=0x6) 426 b = MessageType(mesType=0x13) # 00010011 427 packet = a / b 428 return packet 429# 9.1.12a Spare 430 431 432# Network to MS 433def configurationChangeCommand(ChannelMode_presence=0, 434 ChannelMode_presence1=0, 435 ChannelMode_presence2=0, 436 ChannelMode_presence3=0, 437 ChannelMode_presence4=0, 438 ChannelMode_presence5=0, 439 ChannelMode_presence6=0, 440 ChannelMode_presence7=0): 441 """CONFIGURATION CHANGE COMMAND Section 9.1.12b""" 442 a = TpPd(pd=0x6) 443 b = MessageType(mesType=0x30) # 00110000 444 c = MultislotAllocation() 445 packet = a / b / c 446 if ChannelMode_presence is 1: 447 d = ChannelModeHdr(ieiCM=0x63, eightBitCM=0x0) 448 packet = packet / d 449 if ChannelMode_presence1 is 1: 450 e = ChannelModeHdr(ieiCM=0x11, eightBitCM=0x0) 451 packet = packet / e 452 if ChannelMode_presence2 is 1: 453 f = ChannelModeHdr(ieiCM=0x13, eightBitCM=0x0) 454 packet = packet / f 455 if ChannelMode_presence3 is 1: 456 g = ChannelModeHdr(ieiCM=0x14, eightBitCM=0x0) 457 packet = packet / g 458 if ChannelMode_presence4 is 1: 459 h = ChannelModeHdr(ieiCM=0x15, eightBitCM=0x0) 460 packet = packet / h 461 if ChannelMode_presence5 is 1: 462 i = ChannelModeHdr(ieiCM=0x16, eightBitCM=0x0) 463 packet = packet / i 464 if ChannelMode_presence6 is 1: 465 j = ChannelModeHdr(ieiCM=0x17, eightBitCM=0x0) 466 packet = packet / j 467 if ChannelMode_presence7 is 1: 468 k = ChannelModeHdr(ieiCM=0x18, eightBitCM=0x0) 469 packet = packet / k 470 return packet 471 472 473def configurationChangeAcknowledge(): 474 """CONFIGURATION CHANGE ACKNOWLEDGE Section 9.1.12c""" 475 a = TpPd(pd=0x6) 476 b = MessageType(mesType=0x31) # 00110001 477 c = MobileId() 478 packet = a / b / c 479 return packet 480 481 482def configurationChangeReject(): 483 """CONFIGURATION CHANGE REJECT Section 9.1.12d""" 484 a = TpPd(pd=0x6) 485 b = MessageType(mesType=0x33) # 00110011 486 c = RrCause() 487 packet = a / b / c 488 return packet 489 490 491# Network to MS 492def frequencyRedefinition(CellChannelDescription_presence=0): 493 """Frequency redefinition Section 9.1.13""" 494 a = TpPd(pd=0x6) 495 b = MessageType(mesType=0x14) # 00010100 496 c = ChannelDescription() 497 d = MobileAllocation() 498 e = StartingTime() 499 packet = a / b / c / d / e 500 if CellChannelDescription_presence is 1: 501 f = CellChannelDescriptionHdr(ieiCCD=0x62, eightBitCCD=0x0) 502 packet = packet / f 503 return packet 504 505 506# Network to MS 507def pdchAssignmentCommand(ChannelDescription_presence=0, 508 CellChannelDescription_presence=0, 509 MobileAllocation_presence=0, 510 StartingTime_presence=0, FrequencyList_presence=0, 511 ChannelDescription_presence1=0, 512 FrequencyChannelSequence_presence=0, 513 MobileAllocation_presence1=0, 514 PacketChannelDescription_presence=0, 515 DedicatedModeOrTBF_presence=0): 516 """PDCH ASSIGNMENT COMMAND Section 9.1.13a""" 517 a = TpPd(pd=0x6) 518 b = MessageType(mesType=0x23) # 00100011 519 c = ChannelDescription() 520 packet = a / b / c 521 if ChannelDescription_presence is 1: 522 d = ChannelDescriptionHdr(ieiCD=0x62, eightBitCD=0x0) 523 packet = packet / d 524 if CellChannelDescription_presence is 1: 525 e = CellChannelDescriptionHdr(ieiCCD=0x05, eightBitCCD=0x0) 526 packet = packet / e 527 if MobileAllocation_presence is 1: 528 f = MobileAllocationHdr(ieiMA=0x72, eightBitMA=0x0) 529 packet = packet / f 530 if StartingTime_presence is 1: 531 g = StartingTimeHdr(ieiST=0x7C, eightBitST=0x0) 532 packet = packet / g 533 if FrequencyList_presence is 1: 534 h = FrequencyListHdr(ieiFL=0x19, eightBitFL=0x0) 535 packet = packet / h 536 if ChannelDescription_presence1 is 1: 537 i = ChannelDescriptionHdr(ieiCD=0x1C, eightBitCD=0x0) 538 packet = packet / i 539 if FrequencyChannelSequence_presence is 1: 540 j = FrequencyChannelSequenceHdr(ieiFCS=0x1E, eightBitFCS=0x0) 541 packet = packet / j 542 if MobileAllocation_presence1 is 1: 543 k = MobileAllocationHdr(ieiMA=0x21, eightBitMA=0x0) 544 packet = packet / k 545 if PacketChannelDescription_presence is 1: 546 l = PacketChannelDescription(ieiPCD=0x22) 547 packet = packet / l 548 if DedicatedModeOrTBF_presence is 1: 549 m = DedicatedModeOrTBFHdr(ieiDMOT=0x23, eightBitDMOT=0x0) 550 packet = packet / m 551 return packet 552 553 554def gprsSuspensionRequest(): 555 """GPRS SUSPENSION REQUEST Section 9.1.13b""" 556 a = TpPd(pd=0x6) 557 b = MessageType() 558 c = Tlli() 559 d = RoutingAreaIdentification() 560 e = SuspensionCause() 561 packet = a / b / c / d / e 562 return packet 563 564 565class HandoverAccess(Packet): 566 name = "Handover Access" # Section 9.1.14" 567 fields_desc = [ 568 ByteField("handover", None), 569 ] 570 571 572# Network to MS 573def handoverCommand(SynchronizationIndication_presence=0, 574 FrequencyShortList_presence=0, FrequencyList_presence=0, 575 CellChannelDescription_presence=0, 576 MultislotAllocation_presence=0, 577 ChannelMode_presence=0, ChannelMode_presence1=0, 578 ChannelMode_presence2=0, 579 ChannelMode_presence3=0, ChannelMode_presence4=0, 580 ChannelMode_presence5=0, 581 ChannelMode_presence6=0, ChannelMode_presence7=0, 582 ChannelDescription_presence1=0, ChannelMode2_presence=0, 583 FrequencyChannelSequence_presence=0, 584 MobileAllocation_presence=0, 585 StartingTime_presence=0, TimeDifference_presence=0, 586 TimingAdvance_presence=0, 587 FrequencyShortList_presence1=0, 588 FrequencyList_presence1=0, 589 ChannelDescription2_presence=0, 590 ChannelDescription_presence2=0, 591 FrequencyChannelSequence_presence1=0, 592 MobileAllocation_presence1=0, 593 CipherModeSetting_presence=0, 594 VgcsTargetModeIdentication_presence=0, 595 MultiRateConfiguration_presence=0): 596 """HANDOVER COMMAND Section 9.1.15""" 597 name = "Handover Command" 598 a = TpPd(pd=0x6) 599 b = MessageType(mesType=0x2b) # 00101011 600 c = CellDescription() 601 d = ChannelDescription2() 602 e = HandoverReference() 603 f = PowerCommandAndAccessType() 604 packet = a / b / c / d / e / f 605 if SynchronizationIndication_presence is 1: 606 g = SynchronizationIndicationHdr(ieiSI=0xD, eightBitSI=0x0) 607 packet = packet / g 608 if FrequencyShortList_presence is 1: 609 h = FrequencyShortListHdr(ieiFSL=0x02) 610 packet = packet / h 611 if FrequencyList_presence is 1: 612 i = FrequencyListHdr(ieiFL=0x05, eightBitFL=0x0) 613 packet = packet / i 614 if CellChannelDescription_presence is 1: 615 j = CellChannelDescriptionHdr(ieiCCD=0x62, eightBitCCD=0x0) 616 packet = packet / j 617 if MultislotAllocation_presence is 1: 618 k = MultislotAllocationHdr(ieiMSA=0x10, eightBitMSA=0x0) 619 packet = packet / k 620 if ChannelMode_presence is 1: 621 l = ChannelModeHdr(ieiCM=0x63, eightBitCM=0x0) 622 packet = packet / l 623 if ChannelMode_presence1 is 1: 624 m = ChannelModeHdr(ieiCM=0x11, eightBitCM=0x0) 625 packet = packet / m 626 if ChannelMode_presence2 is 1: 627 n = ChannelModeHdr(ieiCM=0x13, eightBitCM=0x0) 628 packet = packet / n 629 if ChannelMode_presence3 is 1: 630 o = ChannelModeHdr(ieiCM=0x14, eightBitCM=0x0) 631 packet = packet / o 632 if ChannelMode_presence4 is 1: 633 p = ChannelModeHdr(ieiCM=0x15, eightBitCM=0x0) 634 packet = packet / p 635 if ChannelMode_presence5 is 1: 636 q = ChannelModeHdr(ieiCM=0x16, eightBitCM=0x0) 637 packet = packet / q 638 if ChannelMode_presence6 is 1: 639 r = ChannelModeHdr(ieiCM=0x17, eightBitCM=0x0) 640 packet = packet / r 641 if ChannelMode_presence7 is 1: 642 s = ChannelModeHdr(ieiCM=0x18, eightBitCM=0x0) 643 packet = packet / s 644 if ChannelDescription_presence1 is 1: 645 s1 = ChannelDescriptionHdr(ieiCD=0x64, eightBitCD=0x0) 646 packet = packet / s1 647 if ChannelMode2_presence is 1: 648 t = ChannelMode2Hdr(ieiCM2=0x66, eightBitCM2=0x0) 649 packet = packet / t 650 if FrequencyChannelSequence_presence is 1: 651 u = FrequencyChannelSequenceHdr(ieiFCS=0x69, eightBitFCS=0x0) 652 packet = packet / u 653 if MobileAllocation_presence is 1: 654 v = MobileAllocationHdr(ieiMA=0x72, eightBitMA=0x0) 655 packet = packet / v 656 if StartingTime_presence is 1: 657 w = StartingTimeHdr(ieiST=0x7C, eightBitST=0x0) 658 packet = packet / w 659 if TimeDifference_presence is 1: 660 x = TimeDifferenceHdr(ieiTD=0x7B, eightBitTD=0x0) 661 packet = packet / x 662 if TimingAdvance_presence is 1: 663 y = TimingAdvanceHdr(ieiTA=0x7D, eightBitTA=0x0) 664 packet = packet / y 665 if FrequencyShortList_presence1 is 1: 666 z = FrequencyShortListHdr(ieiFSL=0x12) 667 packet = packet / z 668 if FrequencyList_presence1 is 1: 669 aa = FrequencyListHdr(ieiFL=0x19, eightBitFL=0x0) 670 packet = packet / aa 671 if ChannelDescription2_presence is 1: 672 ab = ChannelDescription2Hdr(ieiCD2=0x1C, eightBitCD2=0x0) 673 packet = packet / ab 674 if ChannelDescription_presence2 is 1: 675 ac = ChannelDescriptionHdr(ieiCD=0x1D, eightBitCD=0x0) 676 packet = packet / ac 677 if FrequencyChannelSequence_presence1 is 1: 678 ad = FrequencyChannelSequenceHdr(ieiFCS=0x1E, eightBitFCS=0x0) 679 packet = packet / ad 680 if MobileAllocation_presence1 is 1: 681 ae = MobileAllocationHdr(ieiMA=0x21, eightBitMA=0x0) 682 packet = packet / ae 683 if CipherModeSetting_presence is 1: 684 af = CipherModeSettingHdr(ieiCMS=0x9, eightBitCMS=0x0) 685 packet = packet / af 686 if VgcsTargetModeIdentication_presence is 1: 687 ag = VgcsTargetModeIdenticationHdr(ieiVTMI=0x01, eightBitVTMI=0x0) 688 packet = packet / ag 689 if MultiRateConfiguration_presence is 1: 690 ah = MultiRateConfigurationHdr(ieiMRC=0x03, eightBitMRC=0x0) 691 packet = packet / ah 692 return packet 693 694 695def handoverComplete(MobileTimeDifference_presence=0): 696 """HANDOVER COMPLETE Section 9.1.16""" 697 a = TpPd(pd=0x6) 698 b = MessageType(mesType=0x2c) # 00101100 699 c = RrCause() 700 packet = a / b / c 701 if MobileTimeDifference_presence is 1: 702 d = MobileTimeDifferenceHdr(ieiMTD=0x77, eightBitMTD=0x0) 703 packet = packet / d 704 return packet 705 706 707def handoverFailure(): 708 """HANDOVER FAILURE Section 9.1.17""" 709 a = TpPd(pd=0x6) 710 b = MessageType(mesType=0x28) # 00101000 711 c = RrCause() 712 packet = a / b / c 713 return packet 714 715 716#The L2 pseudo length of this message is the sum of lengths of all 717#information elements present in the message except 718#the IA Rest Octets and L2 Pseudo Length information elements. 719# Network to MS 720def immediateAssignment(ChannelDescription_presence=0, 721 PacketChannelDescription_presence=0, 722 StartingTime_presence=0): 723 """IMMEDIATE ASSIGNMENT Section 9.1.18""" 724 a = L2PseudoLength() 725 b = TpPd(pd=0x6) 726 c = MessageType(mesType=0x3F) # 00111111 727 d = PageModeAndDedicatedModeOrTBF() 728 packet = a / b / c / d 729 if ChannelDescription_presence is 1: 730 f = ChannelDescription() 731 packet = packet / f 732 if PacketChannelDescription_presence is 1: 733 g = PacketChannelDescription() 734 packet = packet / g 735 h = RequestReference() 736 i = TimingAdvance() 737 j = MobileAllocation() 738 packet = packet / h / i / j 739 if StartingTime_presence is 1: 740 k = StartingTimeHdr(ieiST=0x7C, eightBitST=0x0) 741 packet = packet / k 742 l = IaRestOctets() 743 packet = packet / l 744 return packet 745 746 747#The L2 pseudo length of this message is the sum of lengths of all 748#information elements present in the message except 749#the IAX Rest Octets and L2 Pseudo Length information elements. 750 751# Network to MS 752def immediateAssignmentExtended(StartingTime_presence=0): 753 """IMMEDIATE ASSIGNMENT EXTENDED Section 9.1.19""" 754 a = L2PseudoLength() 755 b = TpPd(pd=0x6) 756 c = MessageType(mesType=0x39) # 00111001 757 d = PageModeAndSpareHalfOctets() 758 f = ChannelDescription() 759 g = RequestReference() 760 h = TimingAdvance() 761 i = MobileAllocation() 762 packet = a / b / c / d / f / g / h / i 763 if StartingTime_presence is 1: 764 j = StartingTimeHdr(ieiST=0x7C, eightBitST=0x0) 765 packet = packet / j 766 k = IaxRestOctets() 767 packet = packet / k 768 return packet 769 770 771# This message has L2 pseudo length 19 772# Network to MS 773def immediateAssignmentReject(): 774 """IMMEDIATE ASSIGNMENT REJECT Section 9.1.20""" 775 a = L2PseudoLength(l2pLength=0x13) 776 b = TpPd(pd=0x6) 777 c = MessageType(mesType=0x3a) # 00111010 778 d = PageModeAndSpareHalfOctets() 779 f = RequestReference() 780 g = WaitIndication() 781 h = RequestReference() 782 i = WaitIndication() 783 j = RequestReference() 784 k = WaitIndication() 785 l = RequestReference() 786 m = WaitIndication() 787 n = IraRestOctets() 788 packet = a / b / c / d / f / g / h / i / j / k / l / m / n 789 return packet 790 791 792def measurementReport(): 793 """MEASUREMENT REPORT Section 9.1.21""" 794 a = TpPd(pd=0x6) 795 b = MessageType(mesType=0x15) # 00010101 796 c = MeasurementResults() 797 packet = a / b / c 798 return packet 799 800 801# len max 20 802class NotificationFacch(): 803 """NOTIFICATION/FACCH Section 9.1.21a""" 804 name = "Notification/facch" 805 fields_desc = [ 806 BitField("rr", 0x0, 1), 807 BitField("msgTyoe", 0x0, 5), 808 BitField("layer2Header", 0x0, 2), 809 BitField("frChanDes", 0x0, 24) 810 ] 811 812 813# The L2 pseudo length of this message has a value one 814# Network to MS 815def notificationNch(): 816 """NOTIFICATION/NCH Section 9.1.21b""" 817 a = L2PseudoLength(l2pLength=0x01) 818 b = TpPd(pd=0x6) 819 c = MessageType(mesType=0x20) # 00100000 820 d = NtNRestOctets() 821 packet = a / b / c / d 822 return packet 823 824 825def notificationResponse(): 826 """NOTIFICATION RESPONSE Section 9.1.21d""" 827 a = TpPd(pd=0x6) 828 b = MessageType(mesType=0x26) # 00100110 829 c = MobileStationClassmark2() 830 d = MobileId() 831 e = DescriptiveGroupOrBroadcastCallReference() 832 packet = a / b / c / d / e 833 return packet 834 835 836# Network to MS 837def rrCellChangeOrder(): 838 """RR-CELL CHANGE ORDER Section 9.1.21e""" 839 a = TpPd(pd=0x6) 840 b = MessageType(mesType=0x8) # 00001000 841 c = CellDescription() 842 d = NcModeAndSpareHalfOctets() 843 packet = a / b / c / d 844 return packet 845 846 847# Network to MS 848def pagingRequestType1(MobileId_presence=0): 849 """PAGING REQUEST TYPE 1 Section 9.1.22""" 850 #The L2 pseudo length of this message is the sum of lengths of all 851 #information elements present in the message except 852 #the P1 Rest Octets and L2 Pseudo Length information elements. 853 a = L2PseudoLength() 854 b = TpPd(pd=0x6) 855 c = MessageType(mesType=0x21) # 00100001 856 d = PageModeAndChannelNeeded() 857 f = MobileId() 858 packet = a / b / c / d / f 859 if MobileId_presence is 1: 860 g = MobileIdHdr(ieiMI=0x17, eightBitMI=0x0) 861 packet = packet / g 862 h = P1RestOctets() 863 packet = packet / h 864 return packet 865 866 867# The L2 pseudo length of this message is the sum of lengths of all 868# information elements present in the message except 869# Network to MS 870def pagingRequestType2(MobileId_presence=0): 871 """PAGING REQUEST TYPE 2 Section 9.1.23""" 872 a = L2PseudoLength() 873 b = TpPd(pd=0x6) 874 c = MessageType(mesType=0x22) # 00100010 875 d = PageModeAndChannelNeeded() 876 f = MobileId() 877 g = MobileId() 878 packet = a / b / c / d / f / g 879 if MobileId_presence is 1: 880 h = MobileIdHdr(ieiMI=0x17, eightBitMI=0x0) 881 packet = packet / h 882 i = P2RestOctets() 883 packet = packet / i 884 return packet 885 886 887# Network to MS 888def pagingRequestType3(): 889 """PAGING REQUEST TYPE 3 Section 9.1.24""" 890# This message has a L2 Pseudo Length of 19 891 a = L2PseudoLength(l2pLength=0x13) 892 b = TpPd(pd=0x6) 893 c = MessageType(mesType=0x24) # 00100100 894 d = PageModeAndChannelNeeded() 895 e = TmsiPTmsi() 896 f = TmsiPTmsi() 897 g = TmsiPTmsi() 898 h = TmsiPTmsi() 899 i = P3RestOctets() 900 packet = a / b / c / d / e / f / g / h / i 901 return packet 902 903 904def pagingResponse(): 905 """PAGING RESPONSE Section 9.1.25""" 906 a = TpPd(pd=0x6) 907 b = MessageType(mesType=0x27) # 00100111 908 c = CiphKeySeqNrAndSpareHalfOctets() 909 d = MobileStationClassmark2() 910 e = MobileId() 911 packet = a / b / c / d / e 912 return packet 913 914 915# Network to MS 916def partialRelease(): 917 """PARTIAL RELEASE Section 9.1.26""" 918 a = TpPd(pd=0x6) 919 b = MessageType(mesType=0xa) # 00001010 920 c = ChannelDescription() 921 packet = a / b / c 922 return packet 923 924 925def partialReleaseComplete(): 926 """PARTIAL RELEASE COMPLETE Section 9.1.27""" 927 a = TpPd(pd=0x6) 928 b = MessageType(mesType=0xf) # 00001111 929 packet = a / b 930 return packet 931 932 933# Network to MS 934def physicalInformation(): 935 """PHYSICAL INFORMATION Section 9.1.28""" 936 a = TpPd(pd=0x6) 937 b = MessageType(mesType=0x2d) # 00101101 938 c = TimingAdvance() 939 packet = a / b / c 940 return packet 941 942 943def rrInitialisationRequest(): 944 """RR Initialisation Request Section 9.1.28.a""" 945 a = TpPd(pd=0x6) 946 b = MessageType(mesType=0x3c) # 00111100 947 c = CiphKeySeqNrAndMacModeAndChannelCodingRequest() 948 e = MobileStationClassmark2() 949 f = Tlli() 950 g = ChannelRequestDescription() 951 h = GprsMeasurementResults() 952 packet = a / b / c / e / f / g / h 953 return packet 954 955 956def rrStatus(): 957 """RR STATUS Section 9.1.29""" 958 a = TpPd(pd=0x6) 959 b = MessageType(mesType=0x12) # 00010010 960 c = RrCause() 961 packet = a / b / c 962 return packet 963 964 965# It does not 966# follow the basic format. Its length is _25_ bits. The 967# order of bit transmission is defined in GSM 04.04. 968# Network to MS 969class SynchronizationChannelInformation(): 970 """SYNCHRONIZATION CHANNEL INFORMATION Section 9.1.30""" 971 name = "Synchronization Channel Information" 972 fields_desc = [ 973 BitField("bsic", 0x0, 5), 974 BitField("t1Hi", 0x0, 3), 975 ByteField("t1Mi", 0x0), 976 BitField("t1Lo", 0x0, 1), 977 BitField("t2", 0x0, 5), 978 BitField("t3Hi", 0x0, 2), 979 BitField("t3Lo", 0x0, 1) 980 ] 981 982 983# This message has a L2 Pseudo Length of 21. 984# Network to MS 985def systemInformationType1(): 986 """SYSTEM INFORMATION TYPE 1 Section 9.1.31""" 987 a = L2PseudoLength(l2pLength=0x15) 988 b = TpPd(pd=0x6) 989 c = MessageType(mesType=0x19) # 00011001 990 d = CellChannelDescription() 991 e = RachControlParameters() 992 f = Si1RestOctets() 993 packet = a / b / c / d / e / f 994 return packet 995 996 997# This message has a L2 Pseudo Length of 22. 998# Network to MS 999def systemInformationType2(): 1000 """SYSTEM INFORMATION TYPE 2 Section 9.1.32""" 1001 a = L2PseudoLength(l2pLength=0x16) 1002 b = TpPd(pd=0x6) 1003 c = MessageType(mesType=0x1a) # 00011010 1004 d = NeighbourCellsDescription() 1005 e = NccPermitted() 1006 f = RachControlParameters() 1007 packet = a / b / c / d / e / f 1008 return packet 1009 1010 1011# This message has a L2 pseudo length of 21 1012# Network to MS 1013def systemInformationType2bis(): 1014 """SYSTEM INFORMATION TYPE 2bis Section 9.1.33""" 1015 a = L2PseudoLength(l2pLength=0x15) 1016 b = TpPd(pd=0x6) 1017 c = MessageType(mesType=0x2) # 00000010 1018 d = NeighbourCellsDescription() 1019 e = RachControlParameters() 1020 f = Si2bisRestOctets() 1021 packet = a / b / c / d / e / f 1022 return packet 1023 1024 1025# This message has a L2 pseudo length of 18 1026# Network to MS 1027def systemInformationType2ter(): 1028 """SYSTEM INFORMATION TYPE 2ter Section 9.1.34""" 1029 a = L2PseudoLength(l2pLength=0x12) 1030 b = TpPd(pd=0x6) 1031 c = MessageType(mesType=0x3) # 00000011 1032 d = NeighbourCellsDescription2() 1033 e = Si2terRestOctets() 1034 packet = a / b / c / d / e 1035 return packet 1036 1037 1038# This message has a L2 Pseudo Length of 18 1039# Network to MS 1040def systemInformationType3(): 1041 """SYSTEM INFORMATION TYPE 3 Section 9.1.35""" 1042 a = L2PseudoLength(l2pLength=0x12) 1043 b = TpPd(pd=0x6) 1044 c = MessageType(mesType=0x1b) # 00011011 1045 d = CellIdentity() 1046 e = LocalAreaId() 1047 f = ControlChannelDescription() 1048 g = CellOptionsBCCH() 1049 h = CellSelectionParameters() 1050 i = RachControlParameters() 1051 j = Si3RestOctets() 1052 packet = a / b / c / d / e / f / g / h / i / j 1053 return packet 1054 1055 1056#The L2 pseudo length of this message is the 1057#sum of lengths of all information elements present in the message except 1058#the SI 4 Rest Octets and L2 Pseudo Length 1059# Network to MS 1060def systemInformationType4(ChannelDescription_presence=0, 1061 MobileAllocation_presence=0): 1062 """SYSTEM INFORMATION TYPE 4 Section 9.1.36""" 1063 a = L2PseudoLength() 1064 b = TpPd(pd=0x6) 1065 c = MessageType(mesType=0x1C) # 000111100 1066 d = LocalAreaId() 1067 e = CellSelectionParameters() 1068 f = RachControlParameters() 1069 packet = a / b / c / d / e / f 1070 if ChannelDescription_presence is 1: 1071 g = ChannelDescriptionHdr(ieiCD=0x64, eightBitCD=0x0) 1072 packet = packet / g 1073 if MobileAllocation_presence is 1: 1074 h = MobileAllocationHdr(ieiMA=0x72, eightBitMA=0x0) 1075 packet = packet / h 1076 i = Si4RestOctets() 1077 packet = packet / i 1078 return packet 1079 1080 1081#This message has a L2 Pseudo Length of 18 1082# Network to MS 1083def systemInformationType5(): 1084 """SYSTEM INFORMATION TYPE 5 Section 9.1.37""" 1085 a = L2PseudoLength(l2pLength=0x12) 1086 b = TpPd(pd=0x6) 1087 c = MessageType(mesType=0x35) # 000110101 1088 d = NeighbourCellsDescription() 1089 packet = a / b / c / d 1090 return packet 1091 1092 1093#This message has a L2 Pseudo Length of 18 1094# Network to MS 1095def systemInformationType5bis(): 1096 """SYSTEM INFORMATION TYPE 5bis Section 9.1.38""" 1097 a = L2PseudoLength(l2pLength=0x12) 1098 b = TpPd(pd=0x6) 1099 c = MessageType(mesType=0x5) # 00000101 1100 d = NeighbourCellsDescription() 1101 packet = a / b / c / d 1102 return packet 1103 1104 1105# This message has a L2 Pseudo Length of 18 1106# Network to MS 1107def systemInformationType5ter(): 1108 """SYSTEM INFORMATION TYPE 5ter Section 9.1.39""" 1109 a = L2PseudoLength(l2pLength=0x12) 1110 b = TpPd(pd=0x6) 1111 c = MessageType(mesType=0x6) # 00000110 1112 d = NeighbourCellsDescription2() 1113 packet = a / b / c / d 1114 return packet 1115 1116 1117#This message has a L2 Pseudo Length of 11 1118# Network to MS 1119def systemInformationType6(): 1120 """SYSTEM INFORMATION TYPE 6 Section 9.1.40""" 1121 a = L2PseudoLength(l2pLength=0x0b) 1122 b = TpPd(pd=0x6) 1123 c = MessageType(mesType=0x1e) # 00011011 1124 d = CellIdentity() 1125 e = LocalAreaId() 1126 f = CellOptionsBCCH() 1127 g = NccPermitted() 1128 h = Si6RestOctets() 1129 packet = a / b / c / d / e / f / g 1130 return packet 1131 1132 1133# The L2 pseudo length of this message has the value 1 1134# Network to MS 1135def systemInformationType7(): 1136 """SYSTEM INFORMATION TYPE 7 Section 9.1.41""" 1137 a = L2PseudoLength(l2pLength=0x01) 1138 b = TpPd(pd=0x6) 1139 c = MessageType(mesType=0x37) # 000110111 1140 d = Si7RestOctets() 1141 packet = a / b / c / d 1142 return packet 1143 1144 1145# The L2 pseudo length of this message has the value 1 1146# Network to MS 1147def systemInformationType8(): 1148 """SYSTEM INFORMATION TYPE 8 Section 9.1.42""" 1149 a = L2PseudoLength(l2pLength=0x01) 1150 b = TpPd(pd=0x6) 1151 c = MessageType(mesType=0x18) # 00011000 1152 d = Si8RestOctets() 1153 packet = a / b / c / d 1154 return packet 1155 1156 1157# The L2 pseudo length of this message has the value 1 1158# Network to MS 1159def systemInformationType9(): 1160 """SYSTEM INFORMATION TYPE 9 Section 9.1.43""" 1161 a = L2PseudoLength(l2pLength=0x01) 1162 b = TpPd(pd=0x6) 1163 c = MessageType(mesType=0x4) # 00000100 1164 d = Si9RestOctets() 1165 packet = a / b / c / d 1166 return packet 1167 1168 1169# The L2 pseudo length of this message has the value 0 1170# Network to MS 1171def systemInformationType13(): 1172 """SYSTEM INFORMATION TYPE 13 Section 9.1.43a""" 1173 a = L2PseudoLength(l2pLength=0x00) 1174 b = TpPd(pd=0x6) 1175 c = MessageType(mesType=0x0) # 00000000 1176 d = Si13RestOctets() 1177 packet = a / b / c / d 1178 return packet 1179# 1180# 9.1.43b / c spare 1181# 1182 1183 1184# The L2 pseudo length of this message has the value 1 1185# Network to MS 1186def systemInformationType16(): 1187 """SYSTEM INFORMATION TYPE 16 Section 9.1.43d""" 1188 a = L2PseudoLength(l2pLength=0x01) 1189 b = TpPd(pd=0x6) 1190 c = MessageType(mesType=0x3d) # 00111101 1191 d = Si16RestOctets() 1192 packet = a / b / c / d 1193 return packet 1194 1195 1196# The L2 pseudo length of this message has the value 1 1197# Network to MS 1198def systemInformationType17(): 1199 """SYSTEM INFORMATION TYPE 17 Section 9.1.43e""" 1200 a = L2PseudoLength(l2pLength=0x01) 1201 b = TpPd(pd=0x6) 1202 c = MessageType(mesType=0x3e) # 00111110 1203 d = Si17RestOctets() 1204 packet = a / b / c / d 1205 return packet 1206 1207 1208def talkerIndication(): 1209 """TALKER INDICATION Section 9.1.44""" 1210 a = TpPd(pd=0x6) 1211 b = MessageType(mesType=0x11) # 00010001 1212 c = MobileStationClassmark2() 1213 d = MobileId() 1214 packet = a / b / c / d 1215 return packet 1216 1217 1218class UplinkAccess(): 1219 """UPLINK ACCESS Section 9.1.45""" 1220 name = "Uplink Access" 1221 fields_desc = [ 1222 ByteField("establishment", 0x0) 1223 ] 1224 1225 1226# Network to MS 1227def uplinkBusy(): 1228 """UPLINK BUSY Section 9.1.46""" 1229 name = "Uplink Busy" 1230 a = TpPd(pd=0x6) 1231 b = MessageType(mesType=0x2a) # 00101010 1232 packet = a / b 1233 return packet 1234 1235 1236# Network to MS 1237class UplinkFree(): 1238 """UPLINK FREE Section 9.1.47""" 1239 name = "Uplink Free" 1240 fields_desc = [ 1241 BitField("pd", 0x0, 1), 1242 BitField("msgType", 0x0, 5), 1243 BitField("layer2Header", 0x0, 2), 1244 BitField("uplinkAccess", 0x0, 1), 1245 BitField("lOrH", 0x0, 1), # 0 for L, 1 for H 1246 BitField("upIdCode", 0x0, 6), 1247 ] 1248 1249 1250def uplinkRelease(): 1251 """UPLINK RELEASE Section 9.1.48""" 1252 a = TpPd(pd=0x6) 1253 b = MessageType(mesType=0xe) # 00001110 1254 c = RrCause() 1255 packet = a / b / c 1256 return packet 1257 1258 1259# Network to MS 1260def vgcsUplinkGrant(): 1261 """VGCS UPLINK GRANT Section 9.1.49""" 1262 a = TpPd(pd=0x6) 1263 b = MessageType(mesType=0x9) # 00001001 1264 c = RrCause() 1265 d = RequestReference() 1266 e = TimingAdvance() 1267 packet = a / b / c / d / e 1268 return packet 1269 1270 1271# Network to MS 1272def systemInformationType10(): 1273 """SYSTEM INFORMATION TYPE 10 Section 9.1.50""" 1274 name = "SyStem Information Type 10" 1275 fields_desc = [ 1276 BitField("pd", 0x0, 1), 1277 BitField("msgType", 0x0, 5), 1278 BitField("layer2Header", 0x0, 2), 1279 BitField("si10", 0x0, 160) 1280 ] 1281 1282 1283# Network to MS 1284# The L2 pseudo length of this message has the value 18 1285def extendedMeasurementOrder(): 1286 """EXTENDED MEASUREMENT ORDER Section 9.1.51""" 1287 a = L2PseudoLength(l2pLength=0x12) 1288 b = TpPd(pd=0x6) 1289 c = MessageType(mesType=0x37) # 00110111 1290 d = ExtendedMeasurementFrequencyList() 1291 packet = a / b / c / d 1292 return packet 1293 1294 1295def extendedMeasurementReport(): 1296 """EXTENDED MEASUREMENT REPORT Section 9.1.52""" 1297 a = TpPd(pd=0x6) 1298 b = MessageType(mesType=0x36) # 00110110 1299 c = ExtendedMeasurementResults() 1300 packet = a / b / c 1301 return packet 1302 1303 1304def applicationInformation(): 1305 """APPLICATION INFORMATION Section 9.1.53""" 1306 a = TpPd(pd=0x6) 1307 b = MessageType(mesType=0x38) # 00111000 1308 c = ApduIDAndApduFlags() 1309 e = ApduData() 1310 packet = a / b / c / e 1311 return packet 1312# 1313# 9.2 Messages for mobility management 1314# 1315 1316 1317# Network to MS 1318def authenticationReject(): 1319 """AUTHENTICATION REJECT Section 9.2.1""" 1320 a = TpPd(pd=0x5) 1321 b = MessageType(mesType=0x11) # 00010001 1322 packet = a / b 1323 return packet 1324 1325 1326# Network to MS 1327def authenticationRequest(): 1328 """AUTHENTICATION REQUEST Section 9.2.2""" 1329 a = TpPd(pd=0x5) 1330 b = MessageType(mesType=0x12) # 00010010 1331 c = CiphKeySeqNrAndSpareHalfOctets() 1332 d = AuthenticationParameterRAND() 1333 packet = a / b / c / d 1334 return packet 1335 1336 1337def authenticationResponse(): 1338 """AUTHENTICATION RESPONSE Section 9.2.3""" 1339 a = TpPd(pd=0x5) 1340 b = MessageType(mesType=0x14) # 00010100 1341 c = AuthenticationParameterSRES() 1342 packet = a / b / c 1343 return packet 1344 1345 1346def cmReestablishmentRequest(LocalAreaId_presence=0): 1347 """CM RE-ESTABLISHMENT REQUEST Section 9.2.4""" 1348 a = TpPd(pd=0x5) 1349 b = MessageType(mesType=0x28) # 00101000 1350 c = CiphKeySeqNrAndSpareHalfOctets() 1351 e = MobileStationClassmark2() 1352 f = MobileId() 1353 if LocalAreaId_presence is 1: 1354 g = LocalAreaId(iei=0x13, eightbit=0x0) 1355 packet = packet / g 1356 packet = a / b / c / e / f 1357 return packet 1358 1359 1360# Network to MS 1361def cmServiceAccept(): 1362 """CM SERVICE ACCEPT Section 9.2.5""" 1363 a = TpPd(pd=0x5) 1364 b = MessageType(mesType=0x21) # 00100001 1365 packet = a / b 1366 return packet 1367 1368 1369# Network to MS 1370def cmServicePrompt(): 1371 """CM SERVICE PROMPT Section 9.2.5a""" 1372 a = TpPd(pd=0x5) 1373 b = MessageType(mesType=0x25) # 00100101 1374 c = PdAndSapi() 1375 packet = a / b / c 1376 return packet 1377 1378 1379# Network to MS 1380def cmServiceReject(): 1381 """CM SERVICE REJECT Section 9.2.6""" 1382 a = TpPd(pd=0x5) 1383 b = MessageType(mesType=0x22) # 00100010 1384 c = RejectCause() 1385 packet = a / b / c 1386 return packet 1387 1388 1389def cmServiceAbort(): 1390 """CM SERVICE ABORT Section 9.2.7""" 1391 a = TpPd(pd=0x5) 1392 b = MessageType(mesType=0x23) # 00100011 1393 packet = a / b 1394 return packet 1395 1396 1397# Network to MS 1398def abort(): 1399 """ABORT Section 9.2.8""" 1400 a = TpPd(pd=0x5) 1401 b = MessageType(mesType=0x29) # 00101001 1402 c = RejectCause() 1403 packet = a / b / c 1404 return packet 1405 1406 1407def cmServiceRequest(PriorityLevel_presence=0): 1408 """CM SERVICE REQUEST Section 9.2.9""" 1409 a = TpPd(pd=0x5) 1410 b = MessageType(mesType=0x24) # 00100100 1411 c = CmServiceTypeAndCiphKeySeqNr() 1412 e = MobileStationClassmark2() 1413 f = MobileId() 1414 packet = a / b / c / e / f 1415 if PriorityLevel_presence is 1: 1416 g = PriorityLevelHdr(ieiPL=0x8, eightBitPL=0x0) 1417 packet = packet / g 1418 return packet 1419 1420 1421# Network to MS 1422def identityRequest(): 1423 """IDENTITY REQUEST Section 9.2.10""" 1424 a = TpPd(pd=0x5) 1425 b = MessageType(mesType=0x8) # 00001000 1426 c = IdentityTypeAndSpareHalfOctets() 1427 packet = a / b / c 1428 return packet 1429 1430 1431def identityResponse(): 1432 """IDENTITY RESPONSE Section 9.2.11""" 1433 a = TpPd(pd=0x5) 1434 b = MessageType(mesType=0x9) # 00001001 1435 c = MobileId() 1436 packet = a / b / c 1437 return packet 1438 1439 1440def imsiDetachIndication(): 1441 """IMSI DETACH INDICATION Section 9.2.12""" 1442 a = TpPd(pd=0x5) 1443 b = MessageType(mesType=0x1) # 00000001 1444 c = MobileStationClassmark1() 1445 d = MobileId() 1446 packet = a / b / c / d 1447 return packet 1448 1449 1450# Network to MS 1451def locationUpdatingAccept(MobileId_presence=0, 1452 FollowOnProceed_presence=0, 1453 CtsPermission_presence=0): 1454 """LOCATION UPDATING ACCEPT Section 9.2.13""" 1455 a = TpPd(pd=0x5) 1456 b = MessageType(mesType=0x02) # 00000010 1457 c = LocalAreaId() 1458 packet = a / b / c 1459 if MobileId_presence is 1: 1460 d = MobileIdHdr(ieiMI=0x17, eightBitMI=0x0) 1461 packet = packet / d 1462 if FollowOnProceed_presence is 1: 1463 e = FollowOnProceed(ieiFOP=0xA1) 1464 packet = packet / e 1465 if CtsPermission_presence is 1: 1466 f = CtsPermissionHdr(ieiCP=0xA2, eightBitCP=0x0) 1467 packet = packet / f 1468 return packet 1469 1470 1471# Network to MS 1472def locationUpdatingReject(): 1473 """LOCATION UPDATING REJECT Section 9.2.14""" 1474 a = TpPd(pd=0x5) 1475 b = MessageType(mesType=0x4) # 0x00000100 1476 c = RejectCause() 1477 packet = a / b / c 1478 return packet 1479 1480 1481def locationUpdatingRequest(): 1482 """LOCATION UPDATING REQUEST Section 9.2.15""" 1483 a = TpPd(pd=0x5) 1484 b = MessageType(mesType=0x8) # 00001000 1485 c = LocationUpdatingTypeAndCiphKeySeqNr() 1486 e = LocalAreaId() 1487 f = MobileStationClassmark1() 1488 g = MobileId() 1489 packet = a / b / c / e / f / g 1490 return packet 1491 1492 1493# Network to MS 1494def mmInformation(NetworkName_presence=0, NetworkName_presence1=0, 1495 TimeZone_presence=0, TimeZoneAndTime_presence=0, 1496 LsaIdentifier_presence=0): 1497 """MM INFORMATION Section 9.2.15a""" 1498 a = TpPd(pd=0x5) 1499 b = MessageType(mesType=0x32) # 00110010 1500 packet = a / b 1501 if NetworkName_presence is 1: 1502 c = NetworkNameHdr(ieiNN=0x43, eightBitNN=0x0) 1503 packet = packet / c 1504 if NetworkName_presence1 is 1: 1505 d = NetworkNameHdr(ieiNN=0x45, eightBitNN=0x0) 1506 packet = packet / d 1507 if TimeZone_presence is 1: 1508 e = TimeZoneHdr(ieiTZ=0x46, eightBitTZ=0x0) 1509 packet = packet / e 1510 if TimeZoneAndTime_presence is 1: 1511 f = TimeZoneAndTimeHdr(ieiTZAT=0x47, eightBitTZAT=0x0) 1512 packet = packet / f 1513 if LsaIdentifier_presence is 1: 1514 g = LsaIdentifierHdr(ieiLI=0x48, eightBitLI=0x0) 1515 packet = packet / g 1516 return packet 1517 1518 1519def mmStatus(): 1520 """MM STATUS Section 9.2.16""" 1521 a = TpPd(pd=0x5) 1522 b = MessageType(mesType=0x31) # 00110001 1523 c = RejectCause() 1524 packet = a / b / c 1525 return packet 1526 1527 1528# Network to MS 1529def tmsiReallocationCommand(): 1530 """TMSI REALLOCATION COMMAND Section 9.2.17""" 1531 a = TpPd(pd=0x5) 1532 b = MessageType(mesType=0x1a) # 00011010 1533 c = LocalAreaId() 1534 d = MobileId() 1535 packet = a / b / c / d 1536 return packet 1537 1538 1539def tmsiReallocationComplete(): 1540 """TMSI REALLOCATION COMPLETE Section 9.2.18""" 1541 a = TpPd(pd=0x5) 1542 b = MessageType(mesType=0x1b) # 00011011 1543 packet = a / b 1544 return packet 1545 1546 1547def mmNull(): 1548 """MM NULL Section 9.2.19""" 1549 a = TpPd(pd=0x5) 1550 b = MessageType(mesType=0x30) # 00110000 1551 packet = a / b 1552 return packet 1553 1554# 1555# 9.3 Messages for circuit-switched call control 1556# 1557 1558 1559# Network to MS 1560def alertingNetToMs(Facility_presence=0, ProgressIndicator_presence=0, 1561 UserUser_presence=0): 1562 """ALERTING Section 9.3.1.1""" 1563 a = TpPd(pd=0x3) 1564 b = MessageType(mesType=0x1) # 00000001 1565 packet = a / b 1566 if Facility_presence is 1: 1567 c = FacilityHdr(ieiF=0x1C) 1568 packet = packet / c 1569 if ProgressIndicator_presence is 1: 1570 d = ProgressIndicatorHdr(ieiPI=0x1E) 1571 packet = packet / d 1572 if UserUser_presence is 1: 1573 e = UserUserHdr(ieiUU=0x7E) 1574 packet = packet / e 1575 return packet 1576 1577 1578def alertingMsToNet(Facility_presence=0, UserUser_presence=0, 1579 SsVersionIndicator_presence=0): 1580 """ALERTING Section 9.3.1.2""" 1581 a = TpPd(pd=0x3) 1582 b = MessageType(mesType=0x1) # 00000001 1583 packet = a / b 1584 if Facility_presence is 1: 1585 c = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 1586 packet = packet / c 1587 if UserUser_presence is 1: 1588 d = UserUserHdr(ieiUU=0x7E, eightBitUU=0x0) 1589 packet = packet / d 1590 if SsVersionIndicator_presence is 1: 1591 e = SsVersionIndicatorHdr(ieiSVI=0x7F, eightBitSVI=0x0) 1592 packet = packet / e 1593 return packet 1594 1595 1596def callConfirmed(RepeatIndicator_presence=0, 1597 BearerCapability_presence=0, BearerCapability_presence1=0, 1598 Cause_presence=0, CallControlCapabilities_presence=0): 1599 """CALL CONFIRMED Section 9.3.2""" 1600 a = TpPd(pd=0x3) 1601 b = MessageType(mesType=0x8) # 00001000 1602 packet = a / b 1603 if RepeatIndicator_presence is 1: 1604 c = RepeatIndicatorHdr(ieiRI=0xD, eightBitRI=0x0) 1605 packet = packet / c 1606 if BearerCapability_presence is 1: 1607 d = BearerCapabilityHdr(ieiBC=0x04, eightBitBC=0x0) 1608 packet = packet / d 1609 if BearerCapability_presence1 is 1: 1610 e = BearerCapabilityHdr(ieiBC=0x04, eightBitBC=0x0) 1611 packet = packet / e 1612 if Cause_presence is 1: 1613 f = CauseHdr(ieiC=0x08, eightBitC=0x0) 1614 packet = packet / f 1615 if CallControlCapabilities_presence is 1: 1616 g = CallControlCapabilitiesHdr(ieiCCC=0x15, eightBitCCC=0x0) 1617 packet = packet / g 1618 return packet 1619 1620 1621# Network to MS 1622def callProceeding(RepeatIndicator_presence=0, 1623 BearerCapability_presence=0, 1624 BearerCapability_presence1=0, 1625 Facility_presence=0, ProgressIndicator_presence=0, 1626 PriorityLevel_presence=0): 1627 """CALL PROCEEDING Section 9.3.3""" 1628 a = TpPd(pd=0x3) 1629 b = MessageType(mesType=0x2) # 00000010 1630 packet = a / b 1631 if RepeatIndicator_presence is 1: 1632 c = RepeatIndicatorHdr(ieiRI=0xD, eightBitRI=0x0) 1633 packet = packet / c 1634 if BearerCapability_presence is 1: 1635 d = BearerCapabilityHdr(ieiBC=0x04, eightBitBC=0x0) 1636 packet = packet / d 1637 if BearerCapability_presence1 is 1: 1638 e = BearerCapabilityHdr(ieiBC=0x04, eightBitBC=0x0) 1639 packet = packet / e 1640 if Facility_presence is 1: 1641 f = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 1642 packet = packet / f 1643 if ProgressIndicator_presence is 1: 1644 g = ProgressIndicatorHdr(ieiPI=0x1E, eightBitPI=0x0) 1645 packet = packet / g 1646 if PriorityLevel_presence is 1: 1647 h = PriorityLevelHdr(ieiPL=0x80, eightBitPL=0x0) 1648 packet = packet / h 1649 return packet 1650 1651 1652# Network to MS 1653def congestionControl(Cause_presence=0): 1654 """CONGESTION CONTROL Section 9.3.4""" 1655 a = TpPd(pd=0x3) 1656 b = MessageType(mesType=0x39) # 00111001 1657 c = CongestionLevelAndSpareHalfOctets() 1658 packet = a / b / c 1659 if Cause_presence is 1: 1660 e = CauseHdr(ieiC=0x08, eightBitC=0x0) 1661 packet = packet / e 1662 return packet 1663 1664 1665# Network to MS 1666def connectNetToMs(Facility_presence=0, ProgressIndicator_presence=0, 1667 ConnectedNumber_presence=0, ConnectedSubaddress_presence=0, 1668 UserUser_presence=0): 1669 """CONNECT Section 9.3.5.1""" 1670 a = TpPd(pd=0x3) 1671 b = MessageType(mesType=0x7) # 00000111 1672 packet = a / b 1673 if Facility_presence is 1: 1674 c = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 1675 packet = packet / c 1676 if ProgressIndicator_presence is 1: 1677 d = ProgressIndicatorHdr(ieiPI=0x1E, eightBitPI=0x0) 1678 packet = packet / d 1679 if ConnectedNumber_presence is 1: 1680 e = ConnectedNumberHdr(ieiCN=0x4C, eightBitCN=0x0) 1681 packet = packet / e 1682 if ConnectedSubaddress_presence is 1: 1683 f = ConnectedSubaddressHdr(ieiCS=0x4D, eightBitCS=0x0) 1684 packet = packet / f 1685 if UserUser_presence is 1: 1686 g = UserUserHdr(ieiUU=0x7F, eightBitUU=0x0) 1687 packet = packet / g 1688 return packet 1689 1690 1691def connectMsToNet(Facility_presence=0, ConnectedSubaddress_presence=0, 1692 UserUser_presence=0, SsVersionIndicator_presence=0): 1693 """CONNECT Section 9.3.5.2""" 1694 a = TpPd(pd=0x3) 1695 b = MessageType(mesType=0x7) # 00000111 1696 packet = a / b 1697 if Facility_presence is 1: 1698 c = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 1699 packet = packet / c 1700 if ConnectedSubaddress_presence is 1: 1701 d = ConnectedSubaddressHdr(ieiCS=0x4D, eightBitCS=0x0) 1702 packet = packet / d 1703 if UserUser_presence is 1: 1704 e = UserUserHdr(ieiUU=0x7F, eightBitUU=0x0) 1705 packet = packet / e 1706 if SsVersionIndicator_presence is 1: 1707 f = SsVersionIndicatorHdr(ieiSVI=0x7F, eightBitSVI=0x0) 1708 packet = packet / f 1709 return packet 1710 1711 1712def connectAcknowledge(): 1713 """CONNECT ACKNOWLEDGE Section 9.3.6""" 1714 a = TpPd(pd=0x3) 1715 b = MessageType(mesType=0xf) # 00001111 1716 packet = a / b 1717 return packet 1718 1719 1720# Network to MS 1721def disconnectNetToMs(Facility_presence=0, ProgressIndicator_presence=0, 1722 UserUser_presence=0, AllowedActions_presence=0): 1723 """DISCONNECT Section 9.3.7.1""" 1724 a = TpPd(pd=0x3) 1725 b = MessageType(mesType=0x25) # 00100101 1726 c = Cause() 1727 packet = a / b / c 1728 if Facility_presence is 1: 1729 d = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 1730 packet = packet / d 1731 if ProgressIndicator_presence is 1: 1732 e = ProgressIndicatorHdr(ieiPI=0x1E, eightBitPI=0x0) 1733 packet = packet / e 1734 if UserUser_presence is 1: 1735 f = UserUserHdr(ieiUU=0x7E, eightBitUU=0x0) 1736 packet = packet / f 1737 if AllowedActions_presence is 1: 1738 g = AllowedActionsHdr(ieiAA=0x7B, eightBitAA=0x0) 1739 packet = packet / g 1740 return packet 1741 1742 1743def disconnectMsToNet(Facility_presence=0, UserUser_presence=0, 1744 SsVersionIndicator_presence=0): 1745 """Disconnect Section 9.3.7.2""" 1746 a = TpPd(pd=0x3) 1747 b = MessageType(mesType=0x25) # 00100101 1748 c = Cause() 1749 packet = a / b / c 1750 if Facility_presence is 1: 1751 d = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 1752 packet = packet / d 1753 if UserUser_presence is 1: 1754 e = UserUserHdr(ieiUU=0x7E, eightBitUU=0x0) 1755 packet = packet / e 1756 if SsVersionIndicator_presence is 1: 1757 f = SsVersionIndicatorHdr(ieiSVI=0x7F, eightBitSVI=0x0) 1758 packet = packet / f 1759 return packet 1760 1761 1762def emergencySetup(BearerCapability_presence=0): 1763 """EMERGENCY SETUP Section 9.3.8""" 1764 a = TpPd(pd=0x3) 1765 b = MessageType(mesType=0xe) # 00001110 1766 packet = a / b 1767 if BearerCapability_presence is 1: 1768 c = BearerCapabilityHdr(ieiBC=0x04, eightBitBC=0x0) 1769 packet = packet / c 1770 return packet 1771 1772 1773# Network to MS 1774def facilityNetToMs(): 1775 """FACILITY Section 9.3.9.1""" 1776 a = TpPd(pd=0x3) 1777 b = MessageType(mesType=0x3a) # 00111010 1778 c = Facility() 1779 packet = a / b / c 1780 return packet 1781 1782 1783def facilityMsToNet(SsVersionIndicator_presence=0): 1784 """FACILITY Section 9.3.9.2""" 1785 a = TpPd(pd=0x3) 1786 b = MessageType(mesType=0x3a) # 00111010 1787 c = Facility() 1788 packet = a / b / c 1789 if SsVersionIndicator_presence is 1: 1790 d = SsVersionIndicatorHdr(ieiSVI=0x7F, eightBitSVI=0x0) 1791 packet = packet / d 1792 return packet 1793 1794 1795def hold(): 1796 """HOLD Section 9.3.10""" 1797 a = TpPd(pd=0x3) 1798 b = MessageType(mesType=0x18) # 00011000 1799 packet = a / b 1800 return packet 1801 1802 1803# Network to MS 1804def holdAcknowledge(): 1805 """HOLD ACKNOWLEDGE Section 9.3.11""" 1806 a = TpPd(pd=0x3) 1807 b = MessageType(mesType=0x19) # 00011001 1808 packet = a / b 1809 return packet 1810 1811 1812# Network to MS 1813def holdReject(): 1814 """HOLD REJECT Section 9.3.12""" 1815 a = TpPd(pd=0x3) 1816 b = MessageType(mesType=0x1a) # 00011010 1817 c = Cause() 1818 packet = a / b / c 1819 return packet 1820 1821 1822def modify(LowLayerCompatibility_presence=0, 1823 HighLayerCompatibility_presence=0, 1824 ReverseCallSetupDirection_presence=0): 1825 """MODIFY Section 9.3.13""" 1826 a = TpPd(pd=0x3) 1827 b = MessageType(mesType=0x17) # 00010111 1828 c = BearerCapability() 1829 packet = a / b / c 1830 if LowLayerCompatibility_presence is 1: 1831 d = LowLayerCompatibilityHdr(ieiLLC=0x7C, eightBitLLC=0x0) 1832 packet = packet / d 1833 if HighLayerCompatibility_presence is 1: 1834 e = HighLayerCompatibilityHdr(ieiHLC=0x7D, eightBitHLC=0x0) 1835 packet = packet / e 1836 if ReverseCallSetupDirection_presence is 1: 1837 f = ReverseCallSetupDirectionHdr(ieiRCSD=0xA3) 1838 packet = packet / f 1839 return packet 1840 1841 1842def modifyComplete(LowLayerCompatibility_presence=0, 1843 HighLayerCompatibility_presence=0, 1844 ReverseCallSetupDirection_presence=0): 1845 """MODIFY COMPLETE Section 9.3.14""" 1846 a = TpPd(pd=0x3) 1847 b = MessageType(mesType=0x1f) # 00011111 1848 c = BearerCapability() 1849 packet = a / b / c 1850 if LowLayerCompatibility_presence is 1: 1851 d = LowLayerCompatibilityHdr(ieiLLC=0x7C, eightBitLLC=0x0) 1852 packet = packet / d 1853 if HighLayerCompatibility_presence is 1: 1854 e = HighLayerCompatibilityHdr(ieiHLC=0x7D, eightBitHLC=0x0) 1855 packet = packet / e 1856 if ReverseCallSetupDirection_presence is 1: 1857 f = ReverseCallSetupDirection(ieiRCSD=0xA3) 1858 packet = packet / f 1859 return packet 1860 1861 1862def modifyReject(LowLayerCompatibility_presence=0, 1863 HighLayerCompatibility_presence=0): 1864 """MODIFY REJECT Section 9.3.15""" 1865 a = TpPd(pd=0x3) 1866 b = MessageType(mesType=0x13) # 00010011 1867 c = BearerCapability() 1868 d = Cause() 1869 packet = a / b / c / d 1870 if LowLayerCompatibility_presence is 1: 1871 e = LowLayerCompatibilityHdr(ieiLLC=0x7C, eightBitLLC=0x0) 1872 packet = packet / e 1873 if HighLayerCompatibility_presence is 1: 1874 f = HighLayerCompatibilityHdr(ieiHLC=0x7D, eightBitHLC=0x0) 1875 packet = packet / f 1876 return packet 1877 1878 1879def notify(): 1880 """NOTIFY Section 9.3.16""" 1881 a = TpPd(pd=0x3) 1882 b = MessageType(mesType=0x3e) # 00111110 1883 c = NotificationIndicator() 1884 packet = a / b / c 1885 return packet 1886 1887 1888# Network to MS 1889def progress(UserUser_presence=0): 1890 """PROGRESS Section 9.3.17""" 1891 a = TpPd(pd=0x3) 1892 b = MessageType(mesType=0x3) # 00000011 1893 c = ProgressIndicator() 1894 packet = a / b / c 1895 if UserUser_presence is 1: 1896 d = UserUserHdr() 1897 packet = packet / d 1898 return packet 1899 1900 1901# Network to MS 1902def ccEstablishment(): 1903 """CC-ESTABLISHMENT Section 9.3.17a""" 1904 a = TpPd(pd=0x3) 1905 b = MessageType(mesType=0x4) # 00000100 1906 c = SetupContainer() 1907 packet = a / b / c 1908 return packet 1909 1910 1911def ccEstablishmentConfirmed(RepeatIndicator_presence=0, 1912 BearerCapability_presence=0, 1913 BearerCapability_presence1=0, 1914 Cause_presence=0): 1915 """CC-ESTABLISHMENT CONFIRMED Section 9.3.17b""" 1916 a = TpPd(pd=0x3) 1917 b = MessageType(mesType=0x6) # 00000110 1918 packet = a / b 1919 if RepeatIndicator_presence is 1: 1920 c = RepeatIndicatorHdr(ieiRI=0xD, eightBitRI=0x0) 1921 packet = packet / c 1922 if BearerCapability_presence is 1: 1923 d = BearerCapabilityHdr(ieiBC=0x04, eightBitBC=0x0) 1924 packet = packet / d 1925 if BearerCapability_presence1 is 1: 1926 e = BearerCapabilityHdr(ieiBC=0x04, eightBitBC=0x0) 1927 packet = packet / e 1928 if Cause_presence is 1: 1929 f = CauseHdr(ieiC=0x08, eightBitC=0x0) 1930 packet = packet / f 1931 return packet 1932 1933 1934# Network to MS 1935def releaseNetToMs(): 1936 """RELEASE Section 9.3.18.1""" 1937 a = TpPd(pd=0x3) 1938 b = MessageType(mesType=0x2d) # 00101101 1939 c = CauseHdr(ieiC=0x08, eightBitC=0x0) 1940 d = CauseHdr(ieiC=0x08, eightBitC=0x0) 1941 e = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 1942 f = UserUserHdr(ieiUU=0x7E, eightBitUU=0x0) 1943 packet = a / b / c / d / e / f 1944 return packet 1945 1946 1947def releaseMsToNet(Cause_presence=0, Cause_presence1=0, 1948 Facility_presence=0, UserUser_presence=0, 1949 SsVersionIndicator_presence=0): 1950 """RELEASE Section 9.3.18.2""" 1951 a = TpPd(pd=0x3) 1952 b = MessageType(mesType=0x2d) # 00101101 1953 packet = a / b 1954 if Cause_presence is 1: 1955 c = CauseHdr(ieiC=0x08, eightBitC=0x0) 1956 packet = packet / c 1957 if Cause_presence1 is 1: 1958 d = CauseHdr(ieiC=0x08, eightBitC=0x0) 1959 packet = packet / d 1960 if Facility_presence is 1: 1961 e = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 1962 packet = packet / e 1963 if UserUser_presence is 1: 1964 f = UserUserHdr(ieiUU=0x7E, eightBitUU=0x0) 1965 packet = packet / f 1966 if SsVersionIndicator_presence is 1: 1967 g = SsVersionIndicatorHdr(ieiSVI=0x7F, eightBitSVI=0x0) 1968 packet = packet / g 1969 return packet 1970 1971 1972# Network to MS 1973def recall(): 1974 """RECALL Section 9.3.18a""" 1975 a = TpPd(pd=0x3) 1976 b = MessageType(mesType=0xb) # 00001011 1977 c = RecallType() 1978 d = Facility() 1979 packet = a / b / c / d 1980 return packet 1981 1982 1983# Network to MS 1984def releaseCompleteNetToMs(Cause_presence=0, Facility_presence=0, 1985 UserUser_presence=0): 1986 """RELEASE COMPLETE Section 9.3.19.1""" 1987 a = TpPd(pd=0x3) 1988 b = MessageType(mesType=0x2a) # 00101010 1989 packet = a / b 1990 if Cause_presence is 1: 1991 c = CauseHdr(ieiC=0x08, eightBitC=0x0) 1992 packet = packet / c 1993 if Facility_presence is 1: 1994 d = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 1995 packet = packet / d 1996 if UserUser_presence is 1: 1997 e = UserUserHdr(ieiUU=0x7E, eightBitUU=0x0) 1998 packet = packet / e 1999 return packet 2000 2001 2002def releaseCompleteMsToNet(Cause_presence=0, Facility_presence=0, 2003 UserUser_presence=0, SsVersionIndicator_presence=0): 2004 """RELEASE COMPLETE Section 9.3.19.2""" 2005 a = TpPd(pd=0x3) 2006 b = MessageType(mesType=0x2a) # 00101010 2007 packet = a / b 2008 if Cause_presence is 1: 2009 c = CauseHdr(ieiC=0x08, eightBitC=0x0) 2010 packet = packet / c 2011 if Facility_presence is 1: 2012 d = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 2013 packet = packet / d 2014 if UserUser_presence is 1: 2015 e = UserUserHdr(ieiUU=0x7E, eightBitUU=0x0) 2016 packet = packet / e 2017 if SsVersionIndicator_presence is 1: 2018 f = SsVersionIndicatorHdr(ieiSVI=0x7F, eightBitSVI=0x0) 2019 packet = packet / f 2020 return packet 2021 2022 2023def retrieve(): 2024 """RETRIEVE Section 9.3.20""" 2025 a = TpPd(pd=0x3) 2026 b = MessageType(mesType=0x1c) # 00011100 2027 packet = a / b 2028 return packet 2029 2030 2031# Network to MS 2032def retrieveAcknowledge(): 2033 """RETRIEVE ACKNOWLEDGE Section 9.3.21""" 2034 a = TpPd(pd=0x3) 2035 b = MessageType(mesType=0x1d) # 00011101 2036 packet = a / b 2037 return packet 2038 2039 2040# Network to MS 2041def retrieveReject(): 2042 """RETRIEVE REJECT Section 9.3.22""" 2043 a = TpPd(pd=0x3) 2044 b = MessageType(mesType=0x1e) # 00011110 2045 c = Cause() 2046 packet = a / b / c 2047 return packet 2048 2049 2050# Network to MS 2051def setupMobileTerminated(RepeatIndicator_presence=0, 2052 BearerCapability_presence=0, 2053 BearerCapability_presence1=0, 2054 Facility_presence=0, ProgressIndicator_presence=0, 2055 Signal_presence=0, 2056 CallingPartyBcdNumber_presence=0, 2057 CallingPartySubaddress_presence=0, 2058 CalledPartyBcdNumber_presence=0, 2059 CalledPartySubaddress_presence=0, 2060# RecallType_presence=0, 2061 RedirectingPartyBcdNumber_presence=0, 2062 RedirectingPartySubaddress_presence=0, 2063 RepeatIndicator_presence1=0, 2064 LowLayerCompatibility_presence=0, 2065 LowLayerCompatibility_presence1=0, 2066 RepeatIndicator_presence2=0, 2067 HighLayerCompatibility_presence=0, 2068 HighLayerCompatibility_presence1=0, 2069 UserUser_presence=0, PriorityLevel_presence=0, 2070 AlertingPattern_presence=0): 2071 """SETUP Section 9.3.23.1""" 2072 a = TpPd(pd=0x3) 2073 b = MessageType(mesType=0x5) # 00000101 2074 packet = a / b 2075 if RepeatIndicator_presence is 1: 2076 c = RepeatIndicatorHdr(ieiRI=0xD, eightBitRI=0x0) 2077 packet = packet / c 2078 if BearerCapability_presence is 1: 2079 d = BearerCapabilityHdr(ieiBC=0x04, eightBitBC=0x0) 2080 packet = packet / d 2081 if BearerCapability_presence1 is 1: 2082 e = BearerCapabilityHdr(ieiBC=0x04, eightBitBC=0x0) 2083 packet = packet / e 2084 if Facility_presence is 1: 2085 f = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 2086 packet = packet / f 2087 if ProgressIndicator_presence is 1: 2088 g = ProgressIndicatorHdr(ieiPI=0x1E, eightBitPI=0x0) 2089 packet = packet / g 2090 if Signal_presence is 1: 2091 h = SignalHdr(ieiS=0x34, eightBitS=0x0) 2092 packet = packet / h 2093 if CallingPartyBcdNumber_presence is 1: 2094 i = CallingPartyBcdNumberHdr(ieiCPBN=0x5C, eightBitCPBN=0x0) 2095 packet = packet / i 2096 if CallingPartySubaddress_presence is 1: 2097 j = CallingPartySubaddressHdr(ieiCPS=0x5D, eightBitCPS=0x0) 2098 packet = packet / j 2099 if CalledPartyBcdNumber_presence is 1: 2100 k = CalledPartyBcdNumberHdr(ieiCPBN=0x5E, eightBitCPBN=0x0) 2101 packet = packet / k 2102 if CalledPartySubaddress_presence is 1: 2103 l = CalledPartySubaddressHdr(ieiCPS=0x6D, eightBitCPS=0x0) 2104 packet = packet / l 2105 if RedirectingPartyBcdNumber_presence is 1: 2106 n = RedirectingPartyBcdNumberHdr(ieiRPBN=0x74, eightBitRPBN=0x0) 2107 packet = packet / n 2108 if RedirectingPartySubaddress_presence is 1: 2109 m = RedirectingPartySubaddress_presence(ieiRPBN=0x75, eightBitRPBN=0x0) 2110 packet = packet / m 2111 if RepeatIndicator_presence1 is 1: 2112 o = RepeatIndicatorHdr(ieiRI=0xD0, eightBitRI=0x0) 2113 packet = packet / o 2114 if LowLayerCompatibility_presence is 1: 2115 p = LowLayerCompatibilityHdr(ieiLLC=0x7C, eightBitLLC=0x0) 2116 packet = packet / p 2117 if LowLayerCompatibility_presence1 is 1: 2118 q = LowLayerCompatibilityHdr(ieiLLC=0x7C, eightBitLLC=0x0) 2119 packet = packet / q 2120 if RepeatIndicator_presence2 is 1: 2121 r = RepeatIndicatorHdr(ieiRI=0xD, eightBitRI=0x0) 2122 packet = packet / r 2123 if HighLayerCompatibility_presence is 1: 2124 s = HighLayerCompatibilityHdr(ieiHLC=0x7D, eightBitHLC=0x0) 2125 packet = packet / s 2126 if HighLayerCompatibility_presence1 is 1: 2127 t = HighLayerCompatibilityHdr(ieiHLC=0x7D, eightBitHLC=0x0) 2128 packet = packet / t 2129 if UserUser_presence is 1: 2130 u = UserUserHdr(ieiUU=0x7E, eightBitUU=0x0) 2131 packet = packet / u 2132 if PriorityLevel_presence is 1: 2133 v = PriorityLevelHdr(ieiPL=0x8, eightBitPL=0x0) 2134 packet = packet / v 2135 if AlertingPattern_presence is 1: 2136 w = AlertingPatternHdr(ieiAP=0x19, eightBitAP=0x0) 2137 packet = packet / w 2138 return packet 2139 2140 2141def setupMobileOriginated(RepeatIndicator_presence=0, 2142 BearerCapability_presence=0, 2143 BearerCapability_presence1=0, 2144 Facility_presence=0, 2145 CallingPartySubaddress_presence=0, 2146 CalledPartyBcdNumber_presence=0, 2147 CalledPartySubaddress_presence=0, 2148 RepeatIndicator_presence1=0, 2149 LowLayerCompatibility_presence=0, 2150 LowLayerCompatibility_presence1=0, 2151 RepeatIndicator_presence2=0, 2152 HighLayerCompatibility_presence=0, 2153 HighLayerCompatibility_presence1=0, 2154 UserUser_presence=0, SsVersionIndicator_presence=0, 2155 ClirSuppression_presence=0, 2156 ClirInvocation_presence=0, 2157 CallControlCapabilities_presence=0, 2158 Facility_presence1=0, 2159 Facility_presence2=0): 2160 """SETUP Section 9.3.23.2""" 2161 a = TpPd(pd=0x3) 2162 b = MessageType(mesType=0x5) # 00000101 2163 packet = a / b 2164 if RepeatIndicator_presence is 1: 2165 c = RepeatIndicatorHdr(ieiRI=0xD, eightBitRI=0x0) 2166 packet = packet / c 2167 if BearerCapability_presence is 1: 2168 d = BearerCapabilityHdr(ieiBC=0x04, eightBitBC=0x0) 2169 packet = packet / d 2170 if BearerCapability_presence1 is 1: 2171 e = BearerCapabilityHdr(ieiBC=0x04, eightBitBC=0x0) 2172 packet = packet / e 2173 if Facility_presence is 1: 2174 f = FacilityHdr(ieiF=0x1C, eightBitF=0x0) 2175 packet = packet / f 2176 if CallingPartySubaddress_presence is 1: 2177 g = CallingPartySubaddressHdr(ieiCPS=0x5D, eightBitCPS=0x0) 2178 packet = packet / g 2179 if CalledPartyBcdNumber_presence is 1: 2180 h = CalledPartyBcdNumberHdr(ieiCPBN=0x5E, eightBitCPBN=0x0) 2181 packet = packet / h 2182 if CalledPartySubaddress_presence is 1: 2183 i = CalledPartySubaddressHdr(ieiCPS=0x6D, eightBitCPS=0x0) 2184 packet = packet / i 2185 if RepeatIndicator_presence1 is 1: 2186 j = RepeatIndicatorHdr(ieiRI=0xD0, eightBitRI=0x0) 2187 packet = packet / j 2188 if LowLayerCompatibility_presence is 1: 2189 k = LowLayerCompatibilityHdr(ieiLLC=0x7C, eightBitLLC=0x0) 2190 packet = packet / k 2191 if LowLayerCompatibility_presence1 is 1: 2192 l = LowLayerCompatibilityHdr(ieiLLC=0x7C, eightBitLLC=0x0) 2193 packet = packet / l 2194 if RepeatIndicator_presence2 is 1: 2195 m = RepeatIndicatorHdr(ieiRI=0xD, eightBitRI=0x0) 2196 packet = packet / m 2197 if HighLayerCompatibility_presence is 1: 2198 n = HighLayerCompatibilityHdr(ieiHLC=0x7D, eightBitHLC=0x0) 2199 packet = packet / n 2200 if HighLayerCompatibility_presence1 is 1: 2201 o = HighLayerCompatibilityHdr(ieiHLC=0x7D, eightBitHLC=0x0) 2202 packet = packet / o 2203 if UserUser_presence is 1: 2204 p = UserUserHdr(ieiUU=0x7E, eightBitUU=0x0) 2205 packet = packet / p 2206 if SsVersionIndicator_presence is 1: 2207 q = SsVersionIndicatorHdr(ieiSVI=0x7F, eightBitSVI=0x0) 2208 packet = packet / q 2209 if ClirSuppression_presence is 1: 2210 r = ClirSuppressionHdr(ieiCS=0xA1, eightBitCS=0x0) 2211 packet = packet / r 2212 if ClirInvocation_presence is 1: 2213 s = ClirInvocationHdr(ieiCI=0xA2, eightBitCI=0x0) 2214 packet = packet / s 2215 if CallControlCapabilities_presence is 1: 2216 t = CallControlCapabilitiesHdr(ieiCCC=0x15, eightBitCCC=0x0) 2217 packet = packet / t 2218 if Facility_presence1 is 1: 2219 u = FacilityHdr(ieiF=0x1D, eightBitF=0x0) 2220 packet = packet / u 2221 if Facility_presence2 is 1: 2222 v = FacilityHdr(ieiF=0x1B, eightBitF=0x0) 2223 packet = packet / v 2224 return packet 2225 2226 2227def startCc(CallControlCapabilities_presence=0): 2228 """START CC Section 9.3.23a""" 2229 a = TpPd(pd=0x3) 2230 b = MessageType(mesType=0x9) # 00001001 2231 packet = a / b 2232 if CallControlCapabilities_presence is 1: 2233 c = CallControlCapabilitiesHdr(ieiCCC=0x15, eightBitCCC=0x0) 2234 packet = packet / c 2235 return packet 2236 2237 2238def startDtmf(): 2239 """START DTMF Section 9.3.24""" 2240 a = TpPd(pd=0x3) 2241 b = MessageType(mesType=0x35) # 00110101 2242 c = KeypadFacilityHdr(ieiKF=0x2C, eightBitKF=0x0) 2243 packet = a / b / c 2244 return packet 2245 2246 2247# Network to MS 2248def startDtmfAcknowledge(): 2249 """START DTMF ACKNOWLEDGE Section 9.3.25""" 2250 a = TpPd(pd=0x3) 2251 b = MessageType(mesType=0x32) # 00110010 2252 c = KeypadFacilityHdr(ieiKF=0x2C, eightBitKF=0x0) 2253 packet = a / b / c 2254 return packet 2255 2256 2257# Network to MS 2258def startDtmfReject(): 2259 """ START DTMF REJECT Section 9.3.26""" 2260 a = TpPd(pd=0x3) 2261 b = MessageType(mesType=0x37) # 00110111 2262 c = Cause() 2263 packet = a / b / c 2264 return packet 2265 2266 2267def status(AuxiliaryStates_presence=0): 2268 """STATUS Section 9.3.27""" 2269 a = TpPd(pd=0x3) 2270 b = MessageType(mesType=0x3d) # 00111101 2271 c = Cause() 2272 d = CallState() 2273 packet = a / b / c / d 2274 if AuxiliaryStates_presence is 1: 2275 e = AuxiliaryStatesHdr(ieiAS=0x24, eightBitAS=0x0) 2276 packet = packet / e 2277 return packet 2278 2279 2280def statusEnquiry(): 2281 """STATUS ENQUIRY Section 9.3.28""" 2282 a = TpPd(pd=0x3) 2283 b = MessageType(mesType=0x34) # 00110100 2284 packet = a / b 2285 return packet 2286 2287 2288def stopDtmf(): 2289 """STOP DTMF Section 9.3.29""" 2290 a = TpPd(pd=0x3) 2291 b = MessageType(mesType=0x31) # 00110001 2292 packet = a / b 2293 return packet 2294 2295 2296# Network to MS 2297def stopDtmfAcknowledge(): 2298 """STOP DTMF ACKNOWLEDGE Section 9.3.30""" 2299 a = TpPd(pd=0x3) 2300 b = MessageType(mesType=0x32) # 00110010 2301 packet = a / b 2302 return packet 2303 2304 2305def userInformation(MoreData_presence=0): 2306 """USER INFORMATION Section 9.3.31""" 2307 a = TpPd(pd=0x3) 2308 b = MessageType(mesType=0x20) # 000100000 2309 c = UserUser() 2310 packet = a / b / c 2311 if MoreData_presence is 1: 2312 d = MoreDataHdr(ieiMD=0xA0, eightBitMD=0x0) 2313 packet = packet / d 2314 return packet 2315 2316# 2317# 9.4 GPRS Mobility Management Messages 2318# 2319 2320 2321def attachRequest(PTmsiSignature_presence=0, GprsTimer_presence=0, 2322 TmsiStatus_presence=0): 2323 """ATTACH REQUEST Section 9.4.1""" 2324 a = TpPd(pd=0x3) 2325 b = MessageType(mesType=0x1) # 0000001 2326 c = MsNetworkCapability() 2327 d = AttachTypeAndCiphKeySeqNr() 2328 f = DrxParameter() 2329 g = MobileId() 2330 h = RoutingAreaIdentification() 2331 i = MsRadioAccessCapability() 2332 packet = a / b / c / d / f / g / h / i 2333 if PTmsiSignature_presence is 1: 2334 j = PTmsiSignature(ieiPTS=0x19) 2335 packet = packet / j 2336 if GprsTimer_presence is 1: 2337 k = GprsTimer(ieiGT=0x17) 2338 packet = packet / k 2339 if TmsiStatus_presence is 1: 2340 l = TmsiStatus(ieiTS=0x9) 2341 packet = packet / l 2342 return packet 2343 2344 2345def attachAccept(PTmsiSignature_presence=0, GprsTimer_presence=0, 2346 MobileId_presence=0, MobileId_presence1=0, 2347 GmmCause_presence=0): 2348 """ATTACH ACCEPT Section 9.4.2""" 2349 a = TpPd(pd=0x3) 2350 b = MessageType(mesType=0x2) # 00000010 2351 c = AttachResult() 2352 d = ForceToStandby() 2353 e = GprsTimer() 2354 f = RadioPriorityAndSpareHalfOctets() 2355 h = RoutingAreaIdentification() 2356 packet = a / b / c / d / e / f / h 2357 if PTmsiSignature_presence is 1: 2358 i = PTmsiSignature(ieiPTS=0x19) 2359 packet = packet / i 2360 if GprsTimer_presence is 1: 2361 j = GprsTimer(ieiGT=0x17) 2362 packet = packet / j 2363 if MobileId_presence is 1: 2364 k = MobileIdHdr(ieiMI=0x18, eightBitMI=0x0) 2365 packet = packet / k 2366 if MobileId_presence1 is 1: 2367 l = MobileIdHdr(ieiMI=0x23, eightBitMI=0x0) 2368 packet = packet / l 2369 if GmmCause_presence is 1: 2370 m = GmmCause(ieiGC=0x25) 2371 packet = packet / m 2372 return packet 2373 2374 2375def attachComplete(): 2376 """ATTACH COMPLETE Section 9.4.3""" 2377 a = TpPd(pd=0x3) 2378 b = MessageType(mesType=0x3) # 00000011 2379 packet = a / b 2380 return packet 2381 2382 2383def attachReject(): 2384 """ATTACH REJECT Section 9.4.4""" 2385 a = TpPd(pd=0x3) 2386 b = MessageType(mesType=0x1) # 00000001 2387 c = GmmCause() 2388 packet = a / b / c 2389 return packet 2390 2391 2392def detachRequest(GmmCause_presence=0): 2393 """DETACH REQUEST Section 9.4.5""" 2394 a = TpPd(pd=0x3) 2395 b = MessageType(mesType=0x5) # 00000101 2396 c = DetachTypeAndForceToStandby() 2397 packet = a / b / c 2398 if GmmCause_presence is 1: 2399 e = GmmCause(ieiGC=0x25) 2400 packet = packet / e 2401 return packet 2402 2403 2404def detachRequestMsOriginating(): 2405 """DETACH REQUEST Section 9.4.5.2""" 2406 a = TpPd(pd=0x3) 2407 b = MessageType(mesType=0x5) # 00000101 2408 c = DetachTypeAndSpareHalfOctets() 2409 packet = a / b / c 2410 return packet 2411 2412 2413def detachAcceptMsTerminated(): 2414 """DETACH ACCEPT Section 9.4.6.1""" 2415 a = TpPd(pd=0x3) 2416 b = MessageType(mesType=0x6) # 00000110 2417 packet = a / b 2418 return packet 2419 2420 2421def detachAcceptMsOriginating(): 2422 """DETACH ACCEPT Section 9.4.6.2""" 2423 a = TpPd(pd=0x3) 2424 b = MessageType(mesType=0x6) # 00000110 2425 c = ForceToStandbyAndSpareHalfOctets() 2426 packet = a / b / c 2427 return packet 2428 2429 2430def ptmsiReallocationCommand(PTmsiSignature_presence=0): 2431 """P-TMSI REALLOCATION COMMAND Section 9.4.7""" 2432 a = TpPd(pd=0x3) 2433 b = MessageType(mesType=0x10) # 00010000 2434 c = MobileId() 2435 d = RoutingAreaIdentification() 2436 e = ForceToStandbyAndSpareHalfOctets() 2437 packet = a / b / c / d / e 2438 if PTmsiSignature_presence is 1: 2439 g = PTmsiSignature(ieiPTS=0x19) 2440 packet = packet / g 2441 return packet 2442 2443 2444def ptmsiReallocationComplete(): 2445 """P-TMSI REALLOCATION COMPLETE Section 9.4.8""" 2446 a = TpPd(pd=0x3) 2447 b = MessageType(mesType=0x11) # 00010001 2448 packet = a / b 2449 return packet 2450 2451 2452def authenticationAndCipheringRequest( 2453 AuthenticationParameterRAND_presence=0, 2454 CiphKeySeqNr_presence=0): 2455 """AUTHENTICATION AND CIPHERING REQUEST Section 9.4.9""" 2456 a = TpPd(pd=0x3) 2457 b = MessageType(mesType=0x12) # 00010010 2458 d = CipheringAlgorithmAndImeisvRequest() 2459 e = ForceToStandbyAndAcReferenceNumber() 2460 packet = a / b / d / e 2461 if AuthenticationParameterRAND_presence is 1: 2462 g = AuthenticationParameterRAND(ieiAPR=0x21) 2463 packet = packet / g 2464 if CiphKeySeqNr_presence is 1: 2465 h = CiphKeySeqNrHdr(ieiCKSN=0x08, eightBitCKSN=0x0) 2466 packet = packet / h 2467 return packet 2468 2469 2470def authenticationAndCipheringResponse( 2471 AuthenticationParameterSRES_presence=0, 2472 MobileId_presence=0): 2473 """AUTHENTICATION AND CIPHERING RESPONSE Section 9.4.10""" 2474 a = TpPd(pd=0x3) 2475 b = MessageType(mesType=0x13) # 00010011 2476 c = AcReferenceNumberAndSpareHalfOctets() 2477 packet = a / b / c 2478 if AuthenticationParameterSRES_presence is 1: 2479 e = AuthenticationParameterSRES(ieiAPS=0x22) 2480 packet = packet / e 2481 if MobileId_presence is 1: 2482 f = MobileIdHdr(ieiMI=0x23, eightBitMI=0x0) 2483 packet = packet / f 2484 return packet 2485 2486 2487def authenticationAndCipheringReject(): 2488 """AUTHENTICATION AND CIPHERING REJECT Section 9.4.11""" 2489 a = TpPd(pd=0x3) 2490 b = MessageType(mesType=0x14) # 00010100 2491 packet = a / b 2492 return packet 2493 2494 2495def identityRequest(): 2496 """IDENTITY REQUEST Section 9.4.12""" 2497 a = TpPd(pd=0x3) 2498 b = MessageType(mesType=0x15) # 00010101 2499 c = IdentityType2AndforceToStandby() 2500 packet = a / b / c 2501 return packet 2502 2503 2504def identityResponse(): 2505 """IDENTITY RESPONSE Section 9.4.13""" 2506 a = TpPd(pd=0x3) 2507 b = MessageType(mesType=0x16) # 00010110 2508 c = MobileId() 2509 packet = a / b / c 2510 return packet 2511 2512 2513def routingAreaUpdateRequest(PTmsiSignature_presence=0, 2514 GprsTimer_presence=0, 2515 DrxParameter_presence=0, 2516 TmsiStatus_presence=0): 2517 """ROUTING AREA UPDATE REQUEST Section 9.4.14""" 2518 a = TpPd(pd=0x3) 2519 b = MessageType(mesType=0x8) # 00001000 2520 c = UpdateTypeAndCiphKeySeqNr() 2521 e = RoutingAreaIdentification() 2522 f = MsNetworkCapability() 2523 packet = a / b / c / e / f 2524 if PTmsiSignature_presence is 1: 2525 g = PTmsiSignature(ieiPTS=0x19) 2526 packet = packet / g 2527 if GprsTimer_presence is 1: 2528 h = GprsTimer(ieiGT=0x17) 2529 packet = packet / h 2530 if DrxParameter_presence is 1: 2531 i = DrxParameter(ieiDP=0x27) 2532 packet = packet / i 2533 if TmsiStatus_presence is 1: 2534 j = TmsiStatus(ieiTS=0x9) 2535 packet = packet / j 2536 return packet 2537 2538 2539def routingAreaUpdateAccept(PTmsiSignature_presence=0, 2540 MobileId_presence=0, MobileId_presence1=0, 2541 ReceiveNpduNumbersList_presence=0, 2542 GprsTimer_presence=0, GmmCause_presence=0): 2543 """ROUTING AREA UPDATE ACCEPT Section 9.4.15""" 2544 a = TpPd(pd=0x3) 2545 b = MessageType(mesType=0x9) # 00001001 2546 c = ForceToStandbyAndUpdateResult() 2547 e = GprsTimer() 2548 f = RoutingAreaIdentification() 2549 packet = a / b / c / e / f 2550 if PTmsiSignature_presence is 1: 2551 g = PTmsiSignature(ieiPTS=0x19) 2552 packet = packet / g 2553 if MobileId_presence is 1: 2554 h = MobileIdHdr(ieiMI=0x18, eightBitMI=0x0) 2555 packet = packet / h 2556 if MobileId_presence1 is 1: 2557 i = MobileIdHdr(ieiMI=0x23, eightBitMI=0x0) 2558 packet = packet / i 2559 if ReceiveNpduNumbersList_presence is 1: 2560 j = ReceiveNpduNumbersList(ieiRNNL=0x26) 2561 packet = packet / j 2562 if GprsTimer_presence is 1: 2563 k = GprsTimer(ieiGT=0x17) 2564 packet = packet / k 2565 if GmmCause_presence is 1: 2566 l = GmmCause(ieiGC=0x25) 2567 packet = packet / l 2568 return packet 2569 2570 2571def routingAreaUpdateComplete(ReceiveNpduNumbersList_presence=0): 2572 """ROUTING AREA UPDATE COMPLETE Section 9.4.16""" 2573 a = TpPd(pd=0x3) 2574 b = MessageType(mesType=0xa) # 00001010 2575 packet = a / b 2576 if ReceiveNpduNumbersList_presence is 1: 2577 c = ReceiveNpduNumbersList(ieiRNNL=0x26) 2578 packet = packet / c 2579 return packet 2580 2581 2582def routingAreaUpdateReject(): 2583 """ROUTING AREA UPDATE REJECT Section 9.4.17""" 2584 a = TpPd(pd=0x3) 2585 b = MessageType(mesType=0xb) # 00001011 2586 c = GmmCause() 2587 d = ForceToStandbyAndSpareHalfOctets() 2588 packet = a / b / c / d 2589 return packet 2590 2591 2592def gmmStatus(): 2593 """GMM STATUS Section 9.4.18""" 2594 a = TpPd(pd=0x3) 2595 b = MessageType(mesType=0x20) # 00100000 2596 c = GmmCause() 2597 packet = a / b / c 2598 return packet 2599 2600 2601def gmmInformation(NetworkName_presence=0, NetworkName_presence1=0, 2602 TimeZone_presence=0, TimeZoneAndTime_presence=0, 2603 LsaIdentifier_presence=0): 2604 """GMM INFORMATION Section 9.4.19""" 2605 a = TpPd(pd=0x3) 2606 b = MessageType(mesType=0x21) # 00100001 2607 packet = a / b 2608 if NetworkName_presence is 1: 2609 c = NetworkNameHdr(ieiNN=0x43, eightBitNN=0x0) 2610 packet = packet / c 2611 if NetworkName_presence1 is 1: 2612 d = NetworkNameHdr(ieiNN=0x45, eightBitNN=0x0) 2613 packet = packet / d 2614 if TimeZone_presence is 1: 2615 e = TimeZoneHdr(ieiTZ=0x46, eightBitTZ=0x0) 2616 packet = packet / e 2617 if TimeZoneAndTime_presence is 1: 2618 f = TimeZoneAndTimeHdr(ieiTZAT=0x47, eightBitTZAT=0x0) 2619 packet = packet / f 2620 if LsaIdentifier_presence is 1: 2621 g = LsaIdentifierHdr(ieiLI=0x48, eightBitLI=0x0) 2622 packet = packet / g 2623 return packet 2624 2625# 2626# 9.5 GPRS Session Management Messages 2627# 2628 2629 2630def activatePdpContextRequest(AccessPointName_presence=0, 2631 ProtocolConfigurationOptions_presence=0): 2632 """ACTIVATE PDP CONTEXT REQUEST Section 9.5.1""" 2633 a = TpPd(pd=0x8) 2634 b = MessageType(mesType=0x41) # 01000001 2635 c = NetworkServiceAccessPointIdentifier() 2636 d = LlcServiceAccessPointIdentifier() 2637 e = QualityOfService() 2638 f = PacketDataProtocolAddress() 2639 packet = a / b / c / d / e / f 2640 if AccessPointName_presence is 1: 2641 g = AccessPointName(ieiAPN=0x28) 2642 packet = packet / g 2643 if ProtocolConfigurationOptions_presence is 1: 2644 h = ProtocolConfigurationOptions(ieiPCO=0x27) 2645 packet = packet / h 2646 return packet 2647 2648 2649def activatePdpContextAccept(PacketDataProtocolAddress_presence=0, 2650 ProtocolConfigurationOptions_presence=0): 2651 """ACTIVATE PDP CONTEXT ACCEPT Section 9.5.2""" 2652 a = TpPd(pd=0x8) 2653 b = MessageType(mesType=0x42) # 01000010 2654 c = LlcServiceAccessPointIdentifier() 2655 d = QualityOfService() 2656 e = RadioPriorityAndSpareHalfOctets() 2657 packet = a / b / c / d / e 2658 if PacketDataProtocolAddress_presence is 1: 2659 f = PacketDataProtocolAddress(ieiPDPA=0x2B) 2660 packet = packet / f 2661 if ProtocolConfigurationOptions_presence is 1: 2662 g = ProtocolConfigurationOptions(ieiPCO=0x27) 2663 packet = packet / g 2664 return packet 2665 2666 2667def activatePdpContextReject(ProtocolConfigurationOptions_presence=0): 2668 """ACTIVATE PDP CONTEXT REJECT Section 9.5.3""" 2669 a = TpPd(pd=0x8) 2670 b = MessageType(mesType=0x43) # 01000011 2671 c = SmCause() 2672 packet = a / b / c 2673 if ProtocolConfigurationOptions_presence is 1: 2674 d = ProtocolConfigurationOptions(ieiPCO=0x27) 2675 packet = packet / d 2676 return packet 2677 2678 2679def requestPdpContextActivation(AccessPointName_presence=0): 2680 """REQUEST PDP CONTEXT ACTIVATION Section 9.5.4""" 2681 a = TpPd(pd=0x8) 2682 b = MessageType(mesType=0x44) # 01000100 2683 c = PacketDataProtocolAddress() 2684 packet = a / b / c 2685 if AccessPointName_presence is 1: 2686 d = AccessPointName(ieiAPN=0x28) 2687 packet = packet / d 2688 return packet 2689 2690 2691def requestPdpContextActivationReject(): 2692 """REQUEST PDP CONTEXT ACTIVATION REJECT Section 9.5.5""" 2693 a = TpPd(pd=0x8) 2694 b = MessageType(mesType=0x45) # 01000101 2695 c = SmCause() 2696 packet = a / b / c 2697 return packet 2698 2699 2700def modifyPdpContextRequest(): 2701 """MODIFY PDP CONTEXT REQUEST Section 9.5.6""" 2702 a = TpPd(pd=0x8) 2703 b = MessageType(mesType=0x48) # 01001000 2704 c = RadioPriorityAndSpareHalfOctets() 2705 d = LlcServiceAccessPointIdentifier() 2706 e = QualityOfService() 2707 packet = a / b / c / d / e 2708 return packet 2709 2710 2711def modifyPdpContextAccept(): 2712 """MODIFY PDP CONTEXT ACCEPT Section 9.5.7""" 2713 a = TpPd(pd=0x8) 2714 b = MessageType(mesType=0x45) # 01000101 2715 packet = a / b 2716 return packet 2717 2718 2719def deactivatePdpContextRequest(): 2720 """DEACTIVATE PDP CONTEXT REQUEST Section 9.5.8""" 2721 a = TpPd(pd=0x8) 2722 b = MessageType(mesType=0x46) # 01000110 2723 c = SmCause() 2724 packet = a / b / c 2725 return packet 2726 2727 2728def deactivatePdpContextAccept(): 2729 """DEACTIVATE PDP CONTEXT ACCEPT Section 9.5.9""" 2730 a = TpPd(pd=0x8) 2731 b = MessageType(mesType=0x47) # 01000111 2732 packet = a / b 2733 return packet 2734 2735 2736def activateAaPdpContextRequest(AccessPointName_presence=0, 2737 ProtocolConfigurationOptions_presence=0, 2738 GprsTimer_presence=0): 2739 """ACTIVATE AA PDP CONTEXT REQUEST Section 9.5.10""" 2740 a = TpPd(pd=0x8) 2741 b = MessageType(mesType=0x50) # 01010000 2742 c = NetworkServiceAccessPointIdentifier() 2743 d = LlcServiceAccessPointIdentifier() 2744 e = QualityOfService() 2745 f = PacketDataProtocolAddress() 2746 packet = a / b / c / d / e / f 2747 if AccessPointName_presence is 1: 2748 g = AccessPointName(ieiAPN=0x28) 2749 packet = packet / g 2750 if ProtocolConfigurationOptions_presence is 1: 2751 h = ProtocolConfigurationOptions(ieiPCO=0x27) 2752 packet = packet / h 2753 if GprsTimer_presence is 1: 2754 i = GprsTimer(ieiGT=0x29) 2755 packet = packet / i 2756 return packet 2757 2758 2759def activateAaPdpContextAccept(ProtocolConfigurationOptions_presence=0, 2760 GprsTimer_presence=0): 2761 """ACTIVATE AA PDP CONTEXT ACCEPT Section 9.5.11""" 2762 a = TpPd(pd=0x8) 2763 b = MessageType(mesType=0x51) # 01010001 2764 c = LlcServiceAccessPointIdentifier() 2765 d = QualityOfService() 2766 e = MobileId() 2767 f = PacketDataProtocolAddress() 2768 g = RadioPriorityAndSpareHalfOctets() 2769 packet = a / b / c / d / e / f / g 2770 if ProtocolConfigurationOptions_presence is 1: 2771 i = ProtocolConfigurationOptions(ieiPCO=0x27) 2772 packet = packet / i 2773 if GprsTimer_presence is 1: 2774 j = GprsTimer(ieiGT=0x29) 2775 packet = packet / j 2776 return packet 2777 2778 2779def activateAaPdpContextReject(ProtocolConfigurationOptions_presence=0): 2780 """ACTIVATE AA PDP CONTEXT REJECT Section 9.5.12""" 2781 a = TpPd(pd=0x8) 2782 b = MessageType(mesType=0x52) # 01010010 2783 c = SmCause() 2784 packet = a / b / c 2785 if ProtocolConfigurationOptions_presence is 1: 2786 d = ProtocolConfigurationOptions(ieiPCO=0x27) 2787 packet = packet / d 2788 return packet 2789 2790 2791def deactivateAaPdpContextRequest(): 2792 """DEACTIVATE AA PDP CONTEXT REQUEST Section 9.5.13""" 2793 a = TpPd(pd=0x8) 2794 b = MessageType(mesType=0x53) # 01010011 2795 c = AaDeactivationCauseAndSpareHalfOctets() 2796 packet = a / b / c 2797 return packet 2798 2799 2800def deactivateAaPdpContextAccept(): 2801 """DEACTIVATE AA PDP CONTEXT ACCEPT Section 9.5.14""" 2802 a = TpPd(pd=0x8) 2803 b = MessageType(mesType=0x54) # 01010100 2804 packet = a / b 2805 return packet 2806 2807 2808def smStatus(): 2809 """SM STATUS Section 9.5.15""" 2810 a = TpPd(pd=0x8) 2811 b = MessageType(mesType=0x55) # 01010101 2812 c = SmCause() 2813 packet = a / b / c 2814 return packet 2815 2816 2817# ============================================# 2818# Information Elements contents (Section 10) # 2819# =========================================== # 2820 2821#### 2822# This section contains the elements we need to build the messages 2823#### 2824 2825# 2826# Common information elements: 2827# 2828class CellIdentityHdr(Packet): 2829 """ Cell identity Section 10.5.1.1 """ 2830 name = "Cell Identity" 2831 fields_desc = [ 2832 BitField("eightBitCI", None, 1), 2833 XBitField("ieiCI", None, 7), 2834 ByteField("ciValue1", 0x0), 2835 ByteField("ciValue2", 0x0) 2836 ] 2837 2838 2839class CiphKeySeqNrHdr(Packet): 2840 """ Ciphering Key Sequence Number Section 10.5.1.2 """ 2841 name = "Cipher Key Sequence Number" 2842 fields_desc = [ 2843 XBitField("ieiCKSN", None, 4), 2844 BitField("spare", 0x0, 1), 2845 BitField("keySeq", 0x0, 3) 2846 ] 2847 2848 2849# Fix 1/2 len problem 2850class CiphKeySeqNrAndSpareHalfOctets(Packet): 2851 name = "Cipher Key Sequence Number and Spare Half Octets" 2852 fields_desc = [ 2853 BitField("spare", 0x0, 1), 2854 BitField("keySeq", 0x0, 3), 2855 BitField("spareHalfOctets", 0x0, 4) 2856 ] 2857 2858 2859# Fix 1/2 len problem 2860class CiphKeySeqNrAndMacModeAndChannelCodingRequest(Packet): 2861 name = "Cipher Key Sequence Number and Mac Mode And Channel Coding Request" 2862 fields_desc = [ 2863 BitField("spare", 0x0, 1), 2864 BitField("keySeq", 0x0, 3), 2865 BitField("macMode", 0x0, 2), 2866 BitField("cs", 0x0, 2) 2867 ] 2868 2869 2870class LocalAreaIdHdr(Packet): 2871 """ Local Area Identification Section 10.5.1.3 """ 2872 name = "Location Area Identification" 2873 fields_desc = [ 2874 BitField("eightBitLAI", None, 1), 2875 XBitField("ieiLAI", None, 7), 2876 BitField("mccDigit2", 0x0, 4), 2877 BitField("mccDigit1", 0x0, 4), 2878 BitField("mncDigit3", 0x0, 4), 2879 BitField("mccDigit3", 0x0, 4), 2880 BitField("mncDigit2", 0x0, 4), 2881 BitField("mncDigit1", 0x0, 4), 2882 ByteField("lac1", 0x0), 2883 ByteField("lac2", 0x0) 2884 ] 2885# 2886# The Mobile Identity is a type 4 information element with a minimum 2887# length of 3 octet and 11 octets length maximal. 2888# 2889 2890 2891# len 3 - 11 2892class MobileIdHdr(Packet): 2893 """ Mobile Identity Section 10.5.1.4 """ 2894 name = "Mobile Identity" 2895 fields_desc = [ 2896 BitField("eightBitMI", 0x0, 1), 2897 XBitField("ieiMI", 0x0, 7), 2898 2899 XByteField("lengthMI", None), 2900 2901 BitField("idDigit1", 0x0, 4), 2902 BitField("oddEven", 0x0, 1), 2903 BitField("typeOfId", 0x0, 3), 2904 2905 BitField("idDigit2_1", None, 4), # optional 2906 BitField("idDigit2", None, 4), 2907 2908 BitField("idDigit3_1", None, 4), 2909 BitField("idDigit3", None, 4), 2910 2911 BitField("idDigit4_1", None, 4), 2912 BitField("idDigit4", None, 4), 2913 2914 BitField("idDigit5_1", None, 4), 2915 BitField("idDigit5", None, 4), 2916 2917 BitField("idDigit6_1", None, 4), 2918 BitField("idDigit6", None, 4), 2919 BitField("idDigit7_1", None, 4), 2920 BitField("idDigit7", None, 4), 2921 BitField("idDigit8_1", None, 4), 2922 BitField("idDigit8", None, 4), 2923 BitField("idDigit9_1", None, 4), 2924 BitField("idDigit9", None, 4), 2925 ] 2926 2927 def post_build(self, p, pay): 2928 # this list holds the values of the variables, the 2929 # INTERESTING value! 2930 a = [getattr(self, fld.name, None) for fld in self.fields_desc] 2931 res = adapt(3, 11, a, self.fields_desc) 2932 if self.lengthMI is None: 2933 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 2934 if res[0] != 0: 2935 p = p[:-res[0]] 2936 return p + pay 2937 2938 2939class MobileStationClassmark1Hdr(Packet): 2940 """ Mobile Station Classmark 1 Section 10.5.1.5 """ 2941 name = "Mobile Station Classmark 1" 2942 fields_desc = [ 2943 BitField("eightBitiMSC1", None, 1), 2944 XBitField("ieiMSC1", None, 7), 2945 BitField("spare", 0x0, 1), 2946 BitField("revisionLvl", 0x0, 2), 2947 BitField("esInd", 0x0, 1), 2948 BitField("a51", 0x0, 1), 2949 BitField("rfPowerCap", 0x0, 3) 2950 ] 2951 2952 2953class MobileStationClassmark2Hdr(Packet): 2954 """ Mobile Station Classmark 2 Section 10.5.1.6 """ 2955 name = "Mobile Station Classmark 2" 2956 fields_desc = [ 2957 BitField("eightBitMSC2", None, 1), 2958 XBitField("ieiMSC2", None, 7), 2959 XByteField("lengthMSC2", 0x3), 2960 BitField("spare", 0x0, 1), 2961 BitField("revisionLvl", 0x0, 2), 2962 BitField("esInd", 0x0, 1), 2963 BitField("a51", 0x0, 1), 2964 BitField("rfPowerCap", 0x0, 3), 2965 BitField("spare1", 0x0, 1), 2966 BitField("psCap", 0x0, 1), 2967 BitField("ssScreenInd", 0x0, 2), 2968 BitField("smCaPabi", 0x0, 1), 2969 BitField("vbs", 0x0, 1), 2970 BitField("vgcs", 0x0, 1), 2971 BitField("fc", 0x0, 1), 2972 BitField("cm3", 0x0, 1), 2973 BitField("spare2", 0x0, 1), 2974 BitField("lcsvaCap", 0x0, 1), 2975 BitField("spare3", 0x0, 1), 2976 BitField("soLsa", 0x0, 1), 2977 BitField("cmsp", 0x0, 1), 2978 BitField("a53", 0x0, 1), 2979 BitField("a52", 0x0, 1) 2980 ] 2981 2982 2983# len max 14 2984class MobileStationClassmark3(Packet): 2985 """ Mobile Station Classmark 3 Section 10.5.1.7 """ 2986 name = "Mobile Station Classmark 3" 2987 fields_desc = [ 2988 # FIXME 2989 ByteField("ieiMSC3", 0x0), 2990 ByteField("byte2", 0x0), 2991 ByteField("byte3", 0x0), 2992 ByteField("byte4", 0x0), 2993 ByteField("byte5", 0x0), 2994 ByteField("byte6", 0x0), 2995 ByteField("byte7", 0x0), 2996 ByteField("byte8", 0x0), 2997 ByteField("byte9", 0x0), 2998 ByteField("byte10", 0x0), 2999 ByteField("byte11", 0x0), 3000 ByteField("byte12", 0x0), 3001 ByteField("byte13", 0x0), 3002 ByteField("byte14", 0x0) 3003 ] 3004 3005 3006class SpareHalfOctets(Packet): 3007 """ Spare Half Octet Section 10.5.1.8 """ 3008 name = "Spare Half Octet" 3009 fields_desc = [ 3010 BitField("filler", None, 4), 3011 BitField("spareHalfOctets", 0x0, 4) 3012 ] 3013 3014 3015class DescriptiveGroupOrBroadcastCallReferenceHdr(Packet): 3016 """ Descriptive group or broadcast call reference Section 10.5.1.9 """ 3017 name = "Descriptive Group or Broadcast Call Reference" 3018 fields_desc = [ 3019 BitField("eightBitDGOBCR", None, 1), 3020 XBitField("ieiDGOBCR", None, 7), 3021 BitField("binCallRef", 0x0, 27), 3022 BitField("sf", 0x0, 1), 3023 BitField("fa", 0x0, 1), 3024 BitField("callPrio", 0x0, 3), 3025 BitField("cipherInfo", 0x0, 4), 3026 BitField("spare1", 0x0, 1), 3027 BitField("spare2", 0x0, 1), 3028 BitField("spare3", 0x0, 1), 3029 BitField("spare4", 0x0, 1) 3030 ] 3031 3032 3033class GroupCipherKeyNumber(Packet): 3034 """ Group Cipher Key Number reference Section 10.5.1.10 """ 3035 name = "Group Cipher Key Number" 3036 fields_desc = [ 3037 XBitField("ieiGCKN", None, 4), 3038 BitField("groupCipher", 0x0, 4) 3039 ] 3040 3041 3042class PdAndSapiHdr(Packet): 3043 """ PD and SAPI $(CCBS)$ Section 10.5.1.10a """ 3044 name = "PD and SAPI $(CCBS)$" 3045 fields_desc = [ 3046 BitField("eightBitPAS", None, 1), 3047 XBitField("ieiPAS", None, 7), 3048 BitField("spare", 0x0, 1), 3049 BitField("spare1", 0x0, 1), 3050 BitField("sapi", 0x0, 2), 3051 BitField("pd", 0x0, 4) 3052 ] 3053 3054 3055class PriorityLevelHdr(Packet): 3056 """ Priority Level Section 10.5.1.11 """ 3057 name = "Priority Level" 3058 fields_desc = [ 3059 XBitField("ieiPL", None, 4), 3060 BitField("spare", 0x0, 1), 3061 BitField("callPrio", 0x0, 3) 3062 ] 3063 3064# 3065# Radio Resource management information elements 3066# 3067 3068 3069# len 6 to max for L3 message (251) 3070class BaRangeHdr(Packet): 3071 """ BA Range Section 10.5.2.1a """ 3072 name = "BA Range" 3073 fields_desc = [ 3074 BitField("eightBitBR", None, 1), 3075 XBitField("ieiBR", None, 7), 3076 3077 XByteField("lengthBR", None), 3078#error: byte format requires -128 <= number <= 127 3079 ByteField("nrOfRanges", 0x0), 3080# # rX = range X 3081# # L o = Lower H i = higher 3082# # H p = high Part Lp = low Part 3083 ByteField("r1LoHp", 0x0), 3084 3085 BitField("r1LoLp", 0x0, 3), 3086 BitField("r1HiHp", 0x0, 5), 3087 3088 BitField("r1HiLp", 0x0, 4), 3089 BitField("r2LoHp", 0x0, 4), 3090 # optional 3091 BitField("r2LoLp", None, 5), 3092 BitField("r2HiHp", None, 3), 3093 3094 ByteField("r2HiLp", None), 3095 ByteField("r3LoHp", None), 3096 3097 BitField("r3LoLp", None, 5), 3098 BitField("r3HiHp", None, 3), 3099 3100 ByteField("r3HiLp", None), 3101 ByteField("r4LoHp", None), 3102 3103 BitField("r4LoLp", None, 5), 3104 BitField("r4HiHp", None, 3), 3105 ByteField("r4HiLp", None), 3106 ByteField("r5LoHp", None), 3107 3108 BitField("r5LoLp", None, 5), 3109 BitField("r5HiHp", None, 3), 3110 ByteField("r5HiLp", None), 3111 ByteField("r6LoHp", None), 3112 3113 BitField("r6LoLp", None, 5), 3114 BitField("r6HiHp", None, 3), 3115 ByteField("r6HiLp", None), 3116 ByteField("r7LoHp", None), 3117 3118 BitField("r7LoLp", None, 5), 3119 BitField("r7HiHp", None, 3), 3120 ByteField("r7HiLp", None), 3121 ByteField("r8LoHp", None), 3122 3123 BitField("r8LoLp", None, 5), 3124 BitField("r8HiHp", None, 3), 3125 ByteField("r8HiLp", None), 3126 ByteField("r9LoHp", None), 3127 3128 BitField("r9LoLp", None, 5), 3129 BitField("r9HiHp", None, 3), 3130 ByteField("r9HiLp", None), 3131 ByteField("r10LoHp", None), 3132 3133 BitField("r10LoLp", None, 5), 3134 BitField("r10HiHp", None, 3), 3135 ByteField("r10HiLp", None), 3136 ByteField("r11LoHp", None), 3137 3138 BitField("r11LoLp", None, 5), 3139 BitField("r11HiHp", None, 3), 3140 ByteField("r11HiLp", None), 3141 ByteField("r12LoHp", None), 3142 3143 BitField("r12LoLp", None, 5), 3144 BitField("r12HiHp", None, 3), 3145 ByteField("r12HiLp", None), 3146 ByteField("r13LoHp", None), 3147 3148 BitField("r13LoLp", None, 5), 3149 BitField("r13HiHp", None, 3), 3150 ByteField("r13HiLp", None), 3151 ByteField("r14LoHp", None), 3152 3153 BitField("r14LoLp", None, 5), 3154 BitField("r14HiHp", None, 3), 3155 ByteField("r14HiLp", None), 3156 ByteField("r15LoHp", None), 3157 3158 BitField("r15LoLp", None, 5), 3159 BitField("r15HiHp", None, 3), 3160 ByteField("r15HiLp", None), 3161 ByteField("r16LoHp", None), 3162 3163 BitField("r16LoLp", None, 5), 3164 BitField("r16HiHp", None, 3), 3165 ByteField("r16HiLp", None), 3166 ByteField("r17LoHp", None), 3167 3168 BitField("r17LoLp", None, 5), 3169 BitField("r17HiHp", None, 3), 3170 ByteField("r17HiLp", None), 3171 ByteField("r18LoHp", None), 3172 3173 BitField("r18LoLp", None, 5), 3174 BitField("r18HiHp", None, 3), 3175 ByteField("r18HiLp", None), 3176 ByteField("r19LoHp", None), 3177 3178 BitField("r19LoLp", None, 5), 3179 BitField("r19HiHp", None, 3), 3180 ByteField("r19HiLp", None), 3181 ByteField("r20LoHp", None), 3182 3183 BitField("r20LoLp", None, 5), 3184 BitField("r20HiHp", None, 3), 3185 ByteField("r20HiLp", None), 3186 ByteField("r21LoHp", None), 3187 3188 BitField("r21LoLp", None, 5), 3189 BitField("r21HiHp", None, 3), 3190 ByteField("r21HiLp", None), 3191 ByteField("r22LoHp", None), 3192 3193 BitField("r22LoLp", None, 5), 3194 BitField("r22HiHp", None, 3), 3195 ByteField("r22HiLp", None), 3196 ByteField("r23LoHp", None), 3197 3198 BitField("r23LoLp", None, 5), 3199 BitField("r23HiHp", None, 3), 3200 ByteField("r23HiLp", None), 3201 ByteField("r24LoHp", None), 3202 3203 BitField("r24LoLp", None, 5), 3204 BitField("r24HiHp", None, 3), 3205 ByteField("r24HiLp", None), 3206 ByteField("r25LoHp", None), 3207 3208 BitField("r25LoLp", None, 5), 3209 BitField("r25HiHp", None, 3), 3210 ByteField("r25HiLp", None), 3211 ByteField("r26LoHp", None), 3212 3213 BitField("r26LoLp", None, 5), 3214 BitField("r26HiHp", None, 3), 3215 ByteField("r26HiLp", None), 3216 ByteField("r27LoHp", None), 3217 3218 BitField("r27LoLp", None, 5), 3219 BitField("r27HiHp", None, 3), 3220 ByteField("r27HiLp", None), 3221 ByteField("r28LoHp", None), 3222 3223 BitField("r28LoLp", None, 5), 3224 BitField("r28HiHp", None, 3), 3225 ByteField("r28HiLp", None), 3226 ByteField("r29LoHp", None), 3227 3228 BitField("r29LoLp", None, 5), 3229 BitField("r29HiHp", None, 3), 3230 ByteField("r29HiLp", None), 3231 ByteField("r30LoHp", None), 3232 3233 BitField("r30LoLp", None, 5), 3234 BitField("r30HiHp", None, 3), 3235 ByteField("r30HiLp", None), 3236 ByteField("r31LoHp", None), 3237 3238 BitField("r31LoLp", None, 5), 3239 BitField("r31HiHp", None, 3), 3240 ByteField("r31HiLp", None), 3241 ByteField("r32LoHp", None), 3242 3243 BitField("r32LoLp", None, 5), 3244 BitField("r32HiHp", None, 3), 3245 ByteField("r32HiLp", None), 3246 ByteField("r33LoHp", None), 3247 3248 BitField("r33LoLp", None, 5), 3249 BitField("r33HiHp", None, 3), 3250 ByteField("r33HiLp", None), 3251 ByteField("r34LoHp", None), 3252 3253 BitField("r34LoLp", None, 5), 3254 BitField("r34HiHp", None, 3), 3255 ByteField("r34HiLp", None), 3256 ByteField("r35LoHp", None), 3257 3258 BitField("r35LoLp", None, 5), 3259 BitField("r35HiHp", None, 3), 3260 ByteField("r35HiLp", None), 3261 ByteField("r36LoHp", None), 3262 3263 BitField("r36LoLp", None, 5), 3264 BitField("r36HiHp", None, 3), 3265 ByteField("r36HiLp", None), 3266 ByteField("r37LoHp", None), 3267 3268 BitField("r37LoLp", None, 5), 3269 BitField("r37HiHp", None, 3), 3270 ByteField("r37HiLp", None), 3271 ByteField("r38LoHp", None), 3272 3273 BitField("r38LoLp", None, 5), 3274 BitField("r38HiHp", None, 3), 3275 ByteField("r38HiLp", None), 3276 ByteField("r39LoHp", None), 3277 3278 BitField("r39LoLp", None, 5), 3279 BitField("r39HiHp", None, 3), 3280 ByteField("r39HiLp", None), 3281 ByteField("r40LoHp", None), 3282 3283 BitField("r40LoLp", None, 5), 3284 BitField("r40HiHp", None, 3), 3285 ByteField("r40HiLp", None), 3286 ByteField("r41LoHp", None), 3287 3288 BitField("r41LoLp", None, 5), 3289 BitField("r41HiHp", None, 3), 3290 ByteField("r41HiLp", None), 3291 ByteField("r42LoHp", None), 3292 3293 BitField("r42LoLp", None, 5), 3294 BitField("r42HiHp", None, 3), 3295 ByteField("r42HiLp", None), 3296 ByteField("r43LoHp", None), 3297 3298 BitField("r43LoLp", None, 5), 3299 BitField("r43HiHp", None, 3), 3300 ByteField("r43HiLp", None), 3301 ByteField("r44LoHp", None), 3302 3303 BitField("r44LoLp", None, 5), 3304 BitField("r44HiHp", None, 3), 3305 ByteField("r44HiLp", None), 3306 ByteField("r45LoHp", None), 3307 3308 BitField("r45LoLp", None, 5), 3309 BitField("r45HiHp", None, 3), 3310 ByteField("r45HiLp", None), 3311 ByteField("r46LoHp", None), 3312 3313 BitField("r46LoLp", None, 5), 3314 BitField("r46HiHp", None, 3), 3315 ByteField("r46HiLp", None), 3316 ByteField("r47LoHp", None), 3317 3318 BitField("r47LoLp", None, 5), 3319 BitField("r47HiHp", None, 3), 3320 ByteField("r47HiLp", None), 3321 ByteField("r48LoHp", None), 3322 3323 BitField("r48LoLp", None, 5), 3324 BitField("r48HiHp", None, 3), 3325 ByteField("r48HiLp", None), 3326 ByteField("r49LoHp", None), 3327 3328 BitField("r49LoLp", None, 5), 3329 BitField("r49HiHp", None, 3), 3330 ByteField("r49HiLp", None), 3331 ByteField("r50LoHp", None), 3332 3333 BitField("r50LoLp", None, 5), 3334 BitField("r50HiHp", None, 3), 3335 ByteField("r50HiLp", None), 3336 ByteField("r51LoHp", None), 3337 3338 BitField("r51LoLp", None, 5), 3339 BitField("r51HiHp", None, 3), 3340 ByteField("r51HiLp", None), 3341 ByteField("r52LoHp", None), 3342 3343 BitField("r52LoLp", None, 5), 3344 BitField("r52HiHp", None, 3), 3345 ByteField("r52HiLp", None), 3346 ByteField("r53LoHp", None), 3347 3348 BitField("r53LoLp", None, 5), 3349 BitField("r53HiHp", None, 3), 3350 ByteField("r53HiLp", None), 3351 ByteField("r54LoHp", None), 3352 3353 BitField("r54LoLp", None, 5), 3354 BitField("r54HiHp", None, 3), 3355 ByteField("r54HiLp", None), 3356 ByteField("r55LoHp", None), 3357 3358 BitField("r55LoLp", None, 5), 3359 BitField("r55HiHp", None, 3), 3360 ByteField("r55HiLp", None), 3361 ByteField("r56LoHp", None), 3362 3363 BitField("r56LoLp", None, 5), 3364 BitField("r56HiHp", None, 3), 3365 ByteField("r56HiLp", None), 3366 ByteField("r57LoHp", None), 3367 3368 BitField("r57LoLp", None, 5), 3369 BitField("r57HiHp", None, 3), 3370 ByteField("r57HiLp", None), 3371 ByteField("r58LoHp", None), 3372 3373 BitField("r58LoLp", None, 5), 3374 BitField("r58HiHp", None, 3), 3375 ByteField("r58HiLp", None), 3376 ByteField("r59LoHp", None), 3377 3378 BitField("r59LoLp", None, 5), 3379 BitField("r59HiHp", None, 3), 3380 ByteField("r59HiLp", None), 3381 ByteField("r60LoHp", None), 3382 3383 BitField("r60LoLp", None, 5), 3384 BitField("r60HiHp", None, 3), 3385 ByteField("r60HiLp", None), 3386 ByteField("r61LoHp", None), 3387 3388 BitField("r61LoLp", None, 5), 3389 BitField("r61HiHp", None, 3), 3390 ByteField("r61HiLp", None), 3391 ByteField("r62LoHp", None), 3392 3393 BitField("r62LoLp", None, 5), 3394 BitField("r62HiHp", None, 3), 3395 ByteField("r62HiLp", None), 3396 ByteField("r63LoHp", None), 3397 3398 BitField("r63LoLp", None, 5), 3399 BitField("r63HiHp", None, 3), 3400 ByteField("r63HiLp", None), 3401 ByteField("r64LoHp", None), 3402 3403 BitField("r64LoLp", None, 5), 3404 BitField("r64HiHp", None, 3), 3405 ByteField("r64HiLp", None), 3406 ByteField("r65LoHp", None), 3407 3408 BitField("r65LoLp", None, 5), 3409 BitField("r65HiHp", None, 3), 3410 ByteField("r65HiLp", None), 3411 ByteField("r66LoHp", None), 3412 3413 BitField("r66LoLp", None, 5), 3414 BitField("r66HiHp", None, 3), 3415 ByteField("r66HiLp", None), 3416 ByteField("r67LoHp", None), 3417 3418 BitField("r67LoLp", None, 5), 3419 BitField("r67HiHp", None, 3), 3420 ByteField("r67HiLp", None), 3421 ByteField("r68LoHp", None), 3422 3423 BitField("r68LoLp", None, 5), 3424 BitField("r68HiHp", None, 3), 3425 ByteField("r68HiLp", None), 3426 ByteField("r69LoHp", None), 3427 3428 BitField("r69LoLp", None, 5), 3429 BitField("r69HiHp", None, 3), 3430 ByteField("r69HiLp", None), 3431 ByteField("r70LoHp", None), 3432 3433 BitField("r70LoLp", None, 5), 3434 BitField("r70HiHp", None, 3), 3435 ByteField("r70HiLp", None), 3436 ByteField("r71LoHp", None), 3437 3438 BitField("r71LoLp", None, 5), 3439 BitField("r71HiHp", None, 3), 3440 ByteField("r71HiLp", None), 3441 ByteField("r72LoHp", None), 3442 3443 BitField("r72LoLp", None, 5), 3444 BitField("r72HiHp", None, 3), 3445 ByteField("r72HiLp", None), 3446 ByteField("r73LoHp", None), 3447 3448 BitField("r73LoLp", None, 5), 3449 BitField("r73HiHp", None, 3), 3450 ByteField("r73HiLp", None), 3451 ByteField("r74LoHp", None), 3452 3453 BitField("r74LoLp", None, 5), 3454 BitField("r74HiHp", None, 3), 3455 ByteField("r74HiLp", None), 3456 ByteField("r75LoHp", None), 3457 3458 BitField("r75LoLp", None, 5), 3459 BitField("r75HiHp", None, 3), 3460 ByteField("r75HiLp", None), 3461 ByteField("r76LoHp", None), 3462 3463 BitField("r76LoLp", None, 5), 3464 BitField("r76HiHp", None, 3), 3465 ByteField("r76HiLp", None), 3466 ByteField("r77LoHp", None), 3467 3468 BitField("r77LoLp", None, 5), 3469 BitField("r77HiHp", None, 3), 3470 ByteField("r77HiLp", None), 3471 ByteField("r78LoHp", None), 3472 3473 BitField("r78LoLp", None, 5), 3474 BitField("r78HiHp", None, 3), 3475 ByteField("r78HiLp", None), 3476 ByteField("r79LoHp", None), 3477 3478 BitField("r79LoLp", None, 5), 3479 BitField("r79HiHp", None, 3), 3480 ByteField("r79HiLp", None), 3481 ByteField("r80LoHp", None), 3482 3483 BitField("r80LoLp", None, 5), 3484 BitField("r80HiHp", None, 3), 3485 ByteField("r80HiLp", None), 3486 ByteField("r81LoHp", None), 3487 3488 BitField("r81LoLp", None, 5), 3489 BitField("r81HiHp", None, 3), 3490 ByteField("r81HiLp", None), 3491 ByteField("r82LoHp", None), 3492 3493 BitField("r82LoLp", None, 5), 3494 BitField("r82HiHp", None, 3), 3495 ByteField("r82HiLp", None), 3496 ByteField("r83LoHp", None), 3497 3498 BitField("r83LoLp", None, 5), 3499 BitField("r83HiHp", None, 3), 3500 ByteField("r83HiLp", None), 3501 ByteField("r84LoHp", None), 3502 3503 BitField("r84LoLp", None, 5), 3504 BitField("r84HiHp", None, 3), 3505 ByteField("r84HiLp", None) 3506 ] 3507 3508 def post_build(self, p, pay): 3509 a = [getattr(self, fld.name) for fld in self.fields_desc] 3510 res = adapt(6, 251, a, self.fields_desc) 3511 if self.lengthBR is None: 3512 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 3513 if res[0] != 0: 3514 p = p[:-res[0]] 3515 return p + pay 3516 3517 3518# len 3 to max for L3 message (251) 3519class BaListPrefHdr(Packet): 3520 """ BA List Pref Section 10.5.2.1c """ 3521 name = "BA List Pref" 3522 fields_desc = [ 3523 # FIXME dynamic 3524 BitField("eightBitBLP", None, 1), 3525 XBitField("ieiBLP", None, 7), 3526 3527 XByteField("lengthBLP", None), 3528 3529 BitField("fixBit", 0x0, 1), 3530 BitField("rangeLower", 0x0, 10), 3531 BitField("fixBit2", 0x0, 1), 3532 BitField("rangeUpper", 0x0, 10), 3533 BitField("baFreq", 0x0, 10), 3534 BitField("sparePad", 0x0, 8) 3535 ] 3536 3537 3538# len 17 || Have a look at the specs for the field format 3539# Bit map 0 format 3540# Range 1024 format 3541# Range 512 format 3542# Range 256 format 3543# Range 128 format 3544# Variable bit map format 3545class CellChannelDescriptionHdr(Packet): 3546 """ Cell Channel Description Section 10.5.2.1b """ 3547 name = "Cell Channel Description " 3548 fields_desc = [ 3549 BitField("eightBitCCD", None, 1), 3550 XBitField("ieiCCD", None, 7), 3551 BitField("bit128", 0x0, 1), 3552 BitField("bit127", 0x0, 1), 3553 BitField("spare1", 0x0, 1), 3554 BitField("spare2", 0x0, 1), 3555 BitField("bit124", 0x0, 1), 3556 BitField("bit123", 0x0, 1), 3557 BitField("bit122", 0x0, 1), 3558 BitField("bit121", 0x0, 1), 3559 ByteField("bit120", 0x0), 3560 ByteField("bit112", 0x0), 3561 ByteField("bit104", 0x0), 3562 ByteField("bit96", 0x0), 3563 ByteField("bit88", 0x0), 3564 ByteField("bit80", 0x0), 3565 ByteField("bit72", 0x0), 3566 ByteField("bit64", 0x0), 3567 ByteField("bit56", 0x0), 3568 ByteField("bit48", 0x0), 3569 ByteField("bit40", 0x0), 3570 ByteField("bit32", 0x0), 3571 ByteField("bit24", 0x0), 3572 ByteField("bit16", 0x0), 3573 ByteField("bit8", 0x0) 3574 ] 3575 3576 3577class CellDescriptionHdr(Packet): 3578 """ Cell Description Section 10.5.2.2 """ 3579 name = "Cell Description" 3580 fields_desc = [ 3581 BitField("eightBitCD", None, 1), 3582 XBitField("ieiCD", None, 7), 3583 BitField("bcchHigh", 0x0, 2), 3584 BitField("ncc", 0x0, 3), 3585 BitField("bcc", 0x0, 3), 3586 ByteField("bcchLow", 0x0) 3587 ] 3588 3589 3590class CellOptionsBCCHHdr(Packet): 3591 """ Cell Options (BCCH) Section 10.5.2.3 """ 3592 name = "Cell Options (BCCH)" 3593 fields_desc = [ 3594 BitField("eightBitCOB", None, 1), 3595 XBitField("ieiCOB", None, 7), 3596 BitField("spare", 0x0, 1), 3597 BitField("pwrc", 0x0, 1), 3598 BitField("dtx", 0x0, 2), 3599 BitField("rLinkTout", 0x0, 4) 3600 ] 3601 3602 3603class CellOptionsSACCHHdr(Packet): 3604 """ Cell Options (SACCH) Section 10.5.2.3a """ 3605 name = "Cell Options (SACCH)" 3606 fields_desc = [ 3607 BitField("eightBitCOS", None, 1), 3608 XBitField("ieiCOS", None, 7), 3609 BitField("dtx", 0x0, 1), 3610 BitField("pwrc", 0x0, 1), 3611 BitField("dtx", 0x0, 1), 3612 BitField("rLinkTout", 0x0, 4) 3613 ] 3614 3615 3616class CellSelectionParametersHdr(Packet): 3617 """ Cell Selection Parameters Section 10.5.2.4 """ 3618 name = "Cell Selection Parameters" 3619 fields_desc = [ 3620 BitField("eightBitCSP", None, 1), 3621 XBitField("ieiCSP", None, 7), 3622 BitField("cellReselect", 0x0, 3), 3623 BitField("msTxPwrMax", 0x0, 5), 3624 BitField("acs", None, 1), 3625 BitField("neci", None, 1), 3626 BitField("rxlenAccMin", None, 6) 3627 ] 3628 3629 3630class MacModeAndChannelCodingRequestHdr(Packet): 3631 """ MAC Mode and Channel Coding Requested Section 10.5.2.4a """ 3632 name = "MAC Mode and Channel Coding Requested" 3633 fields_desc = [ 3634 XBitField("ieiMMACCR", None, 4), 3635 BitField("macMode", 0x0, 2), 3636 BitField("cs", 0x0, 2) 3637 ] 3638 3639 3640class ChannelDescriptionHdr(Packet): 3641 """ Channel Description Section 10.5.2.5 """ 3642 name = "Channel Description" 3643 fields_desc = [ 3644 BitField("eightBitCD", None, 1), 3645 XBitField("ieiCD", None, 7), 3646 3647 BitField("channelTyp", 0x0, 5), 3648 BitField("tn", 0x0, 3), 3649 3650 BitField("tsc", 0x0, 3), 3651 BitField("h", 0x1, 1), 3652 # if h=1 maybe we find a better solution here... 3653 BitField("maioHi", 0x0, 4), 3654 3655 BitField("maioLo", 0x0, 2), 3656 BitField("hsn", 0x0, 6) 3657 #BitField("spare", 0x0, 2), 3658 #BitField("arfcnHigh", 0x0, 2), 3659 #ByteField("arfcnLow", 0x0) 3660 ] 3661 3662 3663class ChannelDescription2Hdr(Packet): 3664 """ Channel Description 2 Section 10.5.2.5a """ 3665 name = "Channel Description 2" 3666 fields_desc = [ 3667 BitField("eightBitCD2", None, 1), 3668 XBitField("ieiCD2", None, 7), 3669 BitField("channelTyp", 0x0, 5), 3670 BitField("tn", 0x0, 3), 3671 BitField("tsc", 0x0, 3), 3672 BitField("h", 0x0, 1), 3673 # if h=1 3674 # BitField("maioHi", 0x0, 4), 3675 # BitField("maioLo", 0x0, 2), 3676 # BitField("hsn", 0x0, 6) 3677 BitField("spare", 0x0, 2), 3678 BitField("arfcnHigh", 0x0, 2), 3679 ByteField("arfcnLow", 0x0) 3680 ] 3681 3682 3683class ChannelModeHdr(Packet): 3684 """ Channel Mode Section 10.5.2.6 """ 3685 name = "Channel Mode" 3686 fields_desc = [ 3687 BitField("eightBitCM", None, 1), 3688 XBitField("ieiCM", None, 7), 3689 ByteField("mode", 0x0) 3690 ] 3691 3692 3693class ChannelMode2Hdr(Packet): 3694 """ Channel Mode 2 Section 10.5.2.7 """ 3695 name = "Channel Mode 2" 3696 fields_desc = [ 3697 BitField("eightBitCM2", None, 1), 3698 XBitField("ieiCM2", None, 7), 3699 ByteField("mode", 0x0) 3700 ] 3701 3702 3703class ChannelNeededHdr(Packet): 3704 """ Channel Needed Section 10.5.2.8 """ 3705 name = "Channel Needed" 3706 fields_desc = [ 3707 XBitField("ieiCN", None, 4), 3708 BitField("channel2", 0x0, 2), 3709 BitField("channel1", 0x0, 2), 3710 ] 3711 3712 3713class ChannelRequestDescriptionHdr(Packet): 3714 """Channel Request Description Section 10.5.2.8a """ 3715 name = "Channel Request Description" 3716 fields_desc = [ 3717 BitField("eightBitCRD", None, 1), 3718 XBitField("ieiCRD", None, 7), 3719 BitField("mt", 0x0, 1), 3720 ConditionalField(BitField("spare", 0x0, 39), 3721 lambda pkt: pkt.mt == 0), 3722 ConditionalField(BitField("spare", 0x0, 3), 3723 lambda pkt: pkt.mt == 1), 3724 ConditionalField(BitField("priority", 0x0, 2), 3725 lambda pkt: pkt.mt == 1), 3726 ConditionalField(BitField("rlcMode", 0x0, 1), 3727 lambda pkt: pkt.mt == 1), 3728 ConditionalField(BitField("llcFrame", 0x1, 1), 3729 lambda pkt: pkt.mt == 1), 3730 ConditionalField(ByteField("reqBandMsb", 0x0), 3731 lambda pkt: pkt.mt == 1), 3732 ConditionalField(ByteField("reqBandLsb", 0x0), 3733 lambda pkt: pkt.mt == 1), 3734 ConditionalField(ByteField("rlcMsb", 0x0), 3735 lambda pkt: pkt.mt == 1), 3736 ConditionalField(ByteField("rlcLsb", 0x0), 3737 lambda pkt: pkt.mt == 1) 3738 ] 3739 3740 3741class CipherModeSettingHdr(Packet): 3742 """Cipher Mode Setting Section 10.5.2.9 """ 3743 name = "Cipher Mode Setting" 3744 fields_desc = [ 3745 XBitField("ieiCMS", None, 4), 3746 BitField("algoId", 0x0, 3), 3747 BitField("sc", 0x0, 1), 3748 ] 3749 3750 3751class CipherResponseHdr(Packet): 3752 """Cipher Response Section 10.5.2.10 """ 3753 name = "Cipher Response" 3754 fields_desc = [ 3755 XBitField("ieiCR", None, 4), 3756 BitField("spare", 0x0, 3), 3757 BitField("cr", 0x0, 1), 3758 ] 3759 3760 3761# This packet fixes the problem with the 1/2 Byte length. Concatenation 3762# of cipherModeSetting and cipherResponse 3763class CipherModeSettingAndcipherResponse(Packet): 3764 name = "Cipher Mode Setting And Cipher Response" 3765 fields_desc = [ 3766 BitField("algoId", 0x0, 3), 3767 BitField("sc", 0x0, 1), 3768 BitField("spare", 0x0, 3), 3769 BitField("cr", 0x0, 1) 3770 ] 3771 3772 3773class ControlChannelDescriptionHdr(Packet): 3774 """Control Channel Description Section 10.5.2.11 """ 3775 name = "Control Channel Description" 3776 fields_desc = [ 3777 BitField("eightBitCCD", None, 1), 3778 XBitField("ieiCCD", None, 7), 3779 3780 BitField("spare", 0x0, 1), 3781 BitField("att", 0x0, 1), 3782 BitField("bsAgBlksRes", 0x0, 3), 3783 BitField("ccchConf", 0x0, 3), 3784 3785 BitField("spare", 0x0, 1), 3786 BitField("spare1", 0x0, 1), 3787 BitField("spare2", 0x0, 1), 3788 BitField("spare3", 0x0, 1), 3789 BitField("spare4", 0x0, 1), 3790 BitField("bsPaMfrms", 0x0, 3), 3791 3792 ByteField("t3212", 0x0) 3793 ] 3794 3795 3796class FrequencyChannelSequenceHdr(Packet): 3797 """Frequency Channel Sequence Section 10.5.2.12""" 3798 name = "Frequency Channel Sequence" 3799 fields_desc = [ 3800 BitField("eightBitFCS", None, 1), 3801 XBitField("ieiFCS", None, 7), 3802 BitField("spare", 0x0, 1), 3803 BitField("lowestArfcn", 0x0, 7), 3804 BitField("skipArfcn01", 0x0, 4), 3805 BitField("skipArfcn02", 0x0, 4), 3806 BitField("skipArfcn03", 0x0, 4), 3807 BitField("skipArfcn04", 0x0, 4), 3808 BitField("skipArfcn05", 0x0, 4), 3809 BitField("skipArfcn06", 0x0, 4), 3810 BitField("skipArfcn07", 0x0, 4), 3811 BitField("skipArfcn08", 0x0, 4), 3812 BitField("skipArfcn09", 0x0, 4), 3813 BitField("skipArfcn10", 0x0, 4), 3814 BitField("skipArfcn11", 0x0, 4), 3815 BitField("skipArfcn12", 0x0, 4), 3816 BitField("skipArfcn13", 0x0, 4), 3817 BitField("skipArfcn14", 0x0, 4), 3818 BitField("skipArfcn15", 0x0, 4), 3819 BitField("skipArfcn16", 0x0, 4) 3820 ] 3821 3822 3823class FrequencyListHdr(Packet): 3824 """Frequency List Section 10.5.2.13""" 3825 name = "Frequency List" 3826 # Problem: 3827 # There are several formats for the Frequency List information 3828 # element, distinguished by the "format indicator" subfield. 3829 # Some formats are frequency bit maps, the others use a special encoding 3830 # scheme. 3831 fields_desc = [ 3832 BitField("eightBitFL", None, 1), 3833 XBitField("ieiFL", None, 7), 3834 XByteField("lengthFL", None), 3835 3836 BitField("formatID", 0x0, 2), 3837 BitField("spare", 0x0, 2), 3838 BitField("arfcn124", 0x0, 1), 3839 BitField("arfcn123", 0x0, 1), 3840 BitField("arfcn122", 0x0, 1), 3841 BitField("arfcn121", 0x0, 1), 3842 3843 ByteField("arfcn120", 0x0), 3844 ByteField("arfcn112", 0x0), 3845 ByteField("arfcn104", 0x0), 3846 ByteField("arfcn96", 0x0), 3847 ByteField("arfcn88", 0x0), 3848 ByteField("arfcn80", 0x0), 3849 ByteField("arfcn72", 0x0), 3850 ByteField("arfcn64", 0x0), 3851 ByteField("arfcn56", 0x0), 3852 ByteField("arfcn48", 0x0), 3853 ByteField("arfcn40", 0x0), 3854 ByteField("arfcn32", 0x0), 3855 ByteField("arfcn24", 0x0), 3856 ByteField("arfcn16", 0x0), 3857 ByteField("arfcn8", 0x0) 3858 ] 3859 3860 3861class FrequencyShortListHdr(Packet): 3862 """Frequency Short List Section 10.5.2.14""" 3863 name = "Frequency Short List" 3864# len is 10 3865#This element is encoded exactly as the Frequency List information element, 3866#except that it has a fixed length instead of a 3867#variable length and does not contain a length indicator and that it 3868#shall not be encoded in bitmap 0 format. 3869 fields_desc = [ 3870 ByteField("ieiFSL", 0x0), 3871 ByteField("byte2", 0x0), 3872 ByteField("byte3", 0x0), 3873 ByteField("byte4", 0x0), 3874 ByteField("byte5", 0x0), 3875 ByteField("byte6", 0x0), 3876 ByteField("byte7", 0x0), 3877 ByteField("byte8", 0x0), 3878 ByteField("byte9", 0x0), 3879 ByteField("byte10", 0x0) 3880 ] 3881 3882 3883class FrequencyShortListHdr2(Packet): 3884 """Frequency Short List2 Section 10.5.2.14a""" 3885 name = "Frequency Short List 2" 3886 fields_desc = [ 3887 ByteField("byte1", 0x0), 3888 ByteField("byte2", 0x0), 3889 ByteField("byte3", 0x0), 3890 ByteField("byte4", 0x0), 3891 ByteField("byte5", 0x0), 3892 ByteField("byte6", 0x0), 3893 ByteField("byte7", 0x0), 3894 ByteField("byte8", 0x0) 3895 ] 3896 3897 3898# len 4 to 13 3899class GroupChannelDescriptionHdr(Packet): 3900 """Group Channel Description Section 10.5.2.14b""" 3901 name = "Group Channel Description" 3902 fields_desc = [ 3903 BitField("eightBitGCD", None, 1), 3904 XBitField("ieiGCD", None, 7), 3905 3906 XByteField("lengthGCD", None), 3907 3908 BitField("channelType", 0x0, 5), 3909 BitField("tn", 0x0, 3), 3910 3911 BitField("tsc", 0x0, 3), 3912 BitField("h", 0x0, 1), 3913 # if h == 0 the packet looks the following way: 3914 ConditionalField(BitField("spare", 0x0, 2), 3915 lambda pkt: pkt. h == 0x0), 3916 ConditionalField(BitField("arfcnHi", 0x0, 2), 3917 lambda pkt: pkt. h == 0x0), 3918 ConditionalField(ByteField("arfcnLo", None), 3919 lambda pkt: pkt. h == 0x0), 3920 # if h == 1 the packet looks the following way: 3921 ConditionalField(BitField("maioHi", 0x0, 4), 3922 lambda pkt: pkt. h == 0x1), 3923 ConditionalField(BitField("maioLo", None, 2), 3924 lambda pkt: pkt. h == 0x1), 3925 ConditionalField(BitField("hsn", None, 6), 3926 lambda pkt: pkt. h == 0x1), 3927 # finished with conditional fields 3928 ByteField("maC6", None), 3929 ByteField("maC7", None), 3930 ByteField("maC8", None), 3931 ByteField("maC9", None), 3932 ByteField("maC10", None), 3933 ByteField("maC11", None), 3934 ByteField("maC12", None), 3935 ByteField("maC13", None), 3936 ByteField("maC14", None) 3937 ] 3938 3939 def post_build(self, p, pay): 3940 a = [getattr(self, fld.name) for fld in self.fields_desc] 3941 res = adapt(4, 13, a, self.fields_desc) 3942 if self.lengthGCD is None: 3943 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 3944 if res[0] != 0: 3945 p = p[:-res[0]] 3946 return p + pay 3947 3948 3949class GprsResumptionHdr(Packet): 3950 """GPRS Resumption Section 10.5.2.14c""" 3951 name = "GPRS Resumption" 3952 fields_desc = [ 3953 XBitField("ieiGR", None, 4), 3954 BitField("spare", 0x0, 3), 3955 BitField("ack", 0x0, 1) 3956 ] 3957 3958 3959class HandoverReferenceHdr(Packet): 3960 """Handover Reference Section 10.5.2.15""" 3961 name = "Handover Reference" 3962 fields_desc = [ 3963 BitField("eightBitHR", None, 1), 3964 XBitField("ieiHR", None, 7), 3965 ByteField("handoverRef", 0x0) 3966 ] 3967 3968 3969# len 1-12 3970class IaRestOctets(Packet): 3971 """IA Rest Octets Section 10.5.2.16""" 3972 name = "IA Rest Octets" 3973 fields_desc = [ 3974 ByteField("ieiIRO", 0x0), 3975 # FIXME brainfuck packet 3976 XByteField("lengthIRO", None), 3977 ByteField("byte2", None), 3978 ByteField("byte3", None), 3979 ByteField("byte4", None), 3980 ByteField("byte5", None), 3981 ByteField("byte6", None), 3982 ByteField("byte7", None), 3983 ByteField("byte8", None), 3984 ByteField("byte9", None), 3985 ByteField("byte10", None), 3986 ByteField("byte11", None) 3987 ] 3988 3989 def post_build(self, p, pay): 3990 a = [getattr(self, fld.name) for fld in self.fields_desc] 3991 res = adapt(1, 12, a, self.fields_desc) 3992 if self.lengthIRO is None: 3993 if res[1] < 0: # FIXME better fix 3994 res[1] = 0 3995 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 3996 if res[0] != 0: 3997 p = p[:-res[0]] 3998 return p + pay 3999 4000 4001class IraRestOctetsHdr(Packet): 4002 """IAR Rest Octets Section 10.5.2.17""" 4003 name = "IAR Rest Octets" 4004 fields_desc = [ 4005 BitField("eightBitIRO", None, 1), 4006 XBitField("ieiIRO", None, 7), 4007 BitField("spare01", 0x0, 1), 4008 BitField("spare02", 0x0, 1), 4009 BitField("spare03", 0x1, 1), 4010 BitField("spare04", 0x0, 1), 4011 BitField("spare05", 0x1, 1), 4012 BitField("spare06", 0x0, 1), 4013 BitField("spare07", 0x1, 1), 4014 BitField("spare08", 0x1, 1), 4015 BitField("spare09", 0x0, 1), 4016 BitField("spare10", 0x0, 1), 4017 BitField("spare11", 0x1, 1), 4018 BitField("spare12", 0x0, 1), 4019 BitField("spare13", 0x1, 1), 4020 BitField("spare14", 0x0, 1), 4021 BitField("spare15", 0x1, 1), 4022 BitField("spare16", 0x1, 1), 4023 BitField("spare17", 0x0, 1), 4024 BitField("spare18", 0x0, 1), 4025 BitField("spare19", 0x1, 1), 4026 BitField("spare20", 0x0, 1), 4027 BitField("spare21", 0x1, 1), 4028 BitField("spare22", 0x0, 1), 4029 BitField("spare23", 0x1, 1), 4030 BitField("spare24", 0x1, 1) 4031 ] 4032 4033 4034# len is 1 to 5 what do we do with the variable size? no length 4035# field?! WTF 4036class IaxRestOctetsHdr(Packet): 4037 """IAX Rest Octets Section 10.5.2.18""" 4038 name = "IAX Rest Octets" 4039 fields_desc = [ 4040 BitField("eightBitIRO", None, 1), 4041 XBitField("ieiIRO", None, 7), 4042 BitField("spare01", 0x0, 1), 4043 BitField("spare02", 0x0, 1), 4044 BitField("spare03", 0x1, 1), 4045 BitField("spare04", 0x0, 1), 4046 BitField("spare05", 0x1, 1), 4047 BitField("spare06", 0x0, 1), 4048 BitField("spare07", 0x1, 1), 4049 BitField("spare08", 0x1, 1), 4050 ByteField("spareB1", None), 4051 ByteField("spareB2", None), 4052 ByteField("spareB3", None) 4053 ] 4054 4055 4056class L2PseudoLengthHdr(Packet): 4057 """L2 Pseudo Length Section 10.5.2.19""" 4058 name = "L2 Pseudo Length" 4059 fields_desc = [ 4060 BitField("eightBitPL", None, 1), 4061 XBitField("ieiPL", None, 7), 4062 BitField("l2pLength", None, 6), 4063 BitField("bit2", 0x0, 1), 4064 BitField("bit1", 0x1, 1) 4065 ] 4066 4067 4068class MeasurementResultsHdr(Packet): 4069 """Measurement Results Section 10.5.2.20""" 4070 name = "Measurement Results" 4071 fields_desc = [ 4072 BitField("eightBitMR", None, 1), 4073 XBitField("ieiMR", None, 7), 4074 BitField("baUsed", 0x0, 1), 4075 BitField("dtxUsed", 0x0, 1), 4076 BitField("rxLevFull", 0x0, 6), 4077 BitField("spare", 0x0, 1), 4078 BitField("measValid", 0x0, 1), 4079 BitField("rxLevSub", 0x0, 6), 4080 BitField("spare0", 0x0, 1), 4081 BitField("rxqualFull", 0x0, 3), 4082 BitField("rxqualSub", 0x0, 3), 4083 BitField("noNcellHi", 0x0, 1), 4084 BitField("noNcellLo", 0x0, 2), 4085 BitField("rxlevC1", 0x0, 6), 4086 BitField("bcchC1", 0x0, 5), 4087 BitField("bsicC1Hi", 0x0, 3), 4088 BitField("bsicC1Lo", 0x0, 3), 4089 BitField("rxlevC2", 0x0, 5), 4090 BitField("rxlevC2Lo", 0x0, 1), 4091 BitField("bcchC2", 0x0, 5), 4092 BitField("bsicC1Hi", 0x0, 2), 4093 BitField("bscicC2Lo", 0x0, 4), 4094 BitField("bscicC2Hi", 0x0, 4), 4095 4096 BitField("rxlevC3Lo", 0x0, 2), 4097 BitField("bcchC3", 0x0, 5), 4098 BitField("rxlevC3Hi", 0x0, 1), 4099 4100 BitField("bsicC3Lo", 0x0, 5), 4101 BitField("bsicC3Hi", 0x0, 3), 4102 4103 BitField("rxlevC4Lo", 0x0, 3), 4104 BitField("bcchC4", 0x0, 5), 4105 4106 BitField("bsicC4", 0x0, 6), 4107 BitField("rxlevC5Hi", 0x0, 2), 4108 4109 BitField("rxlevC5Lo", 0x0, 4), 4110 BitField("bcchC5Hi", 0x0, 4), 4111 4112 BitField("bcchC5Lo", 0x0, 1), 4113 BitField("bsicC5", 0x0, 6), 4114 BitField("rxlevC6", 0x0, 1), 4115 4116 BitField("rxlevC6Lo", 0x0, 5), 4117 BitField("bcchC6Hi", 0x0, 3), 4118 4119 BitField("bcchC6Lo", 0x0, 3), 4120 BitField("bsicC6", 0x0, 5) 4121 ] 4122 4123 4124class GprsMeasurementResultsHdr(Packet): 4125 """GPRS Measurement Results Section 10.5.2.20a""" 4126 name = "GPRS Measurement Results" 4127 fields_desc = [ 4128 BitField("eightBitGMR", None, 1), 4129 XBitField("ieiGMR", None, 7), 4130 BitField("cValue", 0x0, 6), 4131 BitField("rxqualHi", 0x0, 2), 4132 BitField("rxqL", 0x0, 1), 4133 BitField("spare", 0x0, 1), 4134 BitField("signVar", 0x0, 6) 4135 ] 4136 4137 4138# len 3 to 10 4139class MobileAllocationHdr(Packet): 4140 """Mobile Allocation Section 10.5.2.21""" 4141 name = "Mobile Allocation" 4142 fields_desc = [ 4143 BitField("eightBitMA", None, 1), 4144 XBitField("ieiMA", None, 7), 4145 XByteField("lengthMA", None), 4146 ByteField("maC64", 0x12), 4147 ByteField("maC56", None), # optional fields start here 4148 ByteField("maC48", None), 4149 ByteField("maC40", None), 4150 ByteField("maC32", None), 4151 ByteField("maC24", None), 4152 ByteField("maC16", None), 4153 ByteField("maC8", None) 4154 ] 4155 4156 def post_build(self, p, pay): 4157 a = [getattr(self, fld.name) for fld in self.fields_desc] 4158 res = adapt(3, 10, a, self.fields_desc) 4159 if self.lengthMA is None: 4160 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 4161 if res[0] != 0: 4162 p = p[:-res[0]] 4163 return p + pay 4164 4165 4166class MobileTimeDifferenceHdr(Packet): 4167 """Mobile Time Difference Section 10.5.2.21a""" 4168 name = "Mobile Time Difference" 4169 fields_desc = [ 4170 BitField("eightBitMTD", None, 1), 4171 XBitField("ieiMTD", None, 7), 4172 XByteField("lengthMTD", 0x5), 4173 ByteField("valueHi", 0x0), 4174 ByteField("valueCnt", 0x0), 4175 BitField("valueLow", 0x0, 5), 4176 BitField("spare", 0x0, 1), 4177 BitField("spare1", 0x0, 1), 4178 BitField("spare2", 0x0, 1) 4179 ] 4180 4181 4182# min 4 octets max 8 4183class MultiRateConfigurationHdr(Packet): 4184 """ MultiRate configuration Section 10.5.2.21aa""" 4185 name = "MultiRate Configuration" 4186 fields_desc = [ 4187 BitField("eightBitMRC", None, 1), 4188 XBitField("ieiMRC", None, 7), 4189 4190 XByteField("lengthMRC", None), 4191 4192 BitField("mrVersion", 0x0, 3), 4193 BitField("spare", 0x0, 1), 4194 BitField("icmi", 0x0, 1), 4195 BitField("spare", 0x0, 1), 4196 BitField("startMode", 0x0, 2), 4197 4198 ByteField("amrCodec", 0x0), 4199 4200 BitField("spare", None, 2), 4201 BitField("threshold1", None, 6), 4202 4203 BitField("hysteresis1", None, 4), 4204 BitField("threshold2", None, 4), 4205 4206 BitField("threshold2cnt", None, 2), 4207 BitField("hysteresis2", None, 4), 4208 BitField("threshold3", None, 2), 4209 4210 BitField("threshold3cnt", None, 4), 4211 BitField("hysteresis3", None, 4) 4212 ] 4213 4214 def post_build(self, p, pay): 4215 a = [getattr(self, fld.name) for fld in self.fields_desc] 4216 res = adapt(4, 8, a, self.fields_desc) 4217 if self.lengthMRC is None: 4218 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 4219 if res[0] != 0: 4220 p = p[:-res[0]] 4221 return p + pay 4222 4223 4224# len 3 to 12 4225class MultislotAllocationHdr(Packet): 4226 """Multislot Allocation Section 10.5.2.21b""" 4227 name = "Multislot Allocation" 4228 fields_desc = [ 4229 BitField("eightBitMSA", None, 1), 4230 XBitField("ieiMSA", None, 7), 4231 XByteField("lengthMSA", None), 4232 BitField("ext0", 0x1, 1), 4233 BitField("da", 0x0, 7), 4234 ConditionalField(BitField("ext1", 0x1, 1), # optional 4235 lambda pkt: pkt.ext0 == 0), 4236 ConditionalField(BitField("ua", 0x0, 7), 4237 lambda pkt: pkt.ext0 == 0), 4238 ByteField("chan1", None), 4239 ByteField("chan2", None), 4240 ByteField("chan3", None), 4241 ByteField("chan4", None), 4242 ByteField("chan5", None), 4243 ByteField("chan6", None), 4244 ByteField("chan7", None), 4245 ByteField("chan8", None) 4246 ] 4247 4248 def post_build(self, p, pay): 4249 a = [getattr(self, fld.name) for fld in self.fields_desc] 4250 res = adapt(3, 12, a, self.fields_desc) 4251 if res[0] != 0: 4252 p = p[:-res[0]] 4253 if self.lengthMSA is None: 4254 p = p[:1] + struct.pack(">B", len(p)-2) + p[2:] 4255 return p + pay 4256 4257 4258class NcModeHdr(Packet): 4259 """NC mode Section 10.5.2.21c""" 4260 name = "NC Mode" 4261 fields_desc = [ 4262 XBitField("ieiNM", None, 4), 4263 BitField("spare", 0x0, 2), 4264 BitField("ncMode", 0x0, 2) 4265 ] 4266 4267 4268# Fix for len problem 4269# concatenation NC Mode And Spare Half Octets 4270class NcModeAndSpareHalfOctets(Packet): 4271 name = "NC Mode And Spare Half Octets" 4272 fields_desc = [ 4273 BitField("spare", 0x0, 2), 4274 BitField("ncMode", 0x0, 2), 4275 BitField("spareHalfOctets", 0x0, 4) 4276 ] 4277 4278 4279class NeighbourCellsDescriptionHdr(Packet): 4280 """Neighbour Cells Description Section 10.5.2.22""" 4281 name = "Neighbour Cells Description" 4282 fields_desc = [ 4283 BitField("eightBitNCD", None, 1), 4284 XBitField("ieiNCD", None, 7), 4285 BitField("bit128", 0x0, 1), 4286 BitField("bit127", 0x0, 1), 4287 BitField("extInd", 0x0, 1), 4288 BitField("baInd", 0x0, 1), 4289 BitField("bit124", 0x0, 1), 4290 BitField("bit123", 0x0, 1), 4291 BitField("bit122", 0x0, 1), 4292 BitField("bit121", 0x0, 1), 4293 BitField("120bits", 0x0, 120) 4294 ] 4295 4296 4297class NeighbourCellsDescription2Hdr(Packet): 4298 """Neighbour Cells Description 2 Section 10.5.2.22a""" 4299 name = "Neighbour Cells Description 2" 4300 fields_desc = [ 4301 BitField("eightBitNCD2", None, 1), 4302 XBitField("ieiNCD2", None, 7), 4303 BitField("bit128", 0x0, 1), 4304 BitField("multiband", 0x0, 2), 4305 BitField("baInd", 0x0, 1), 4306 BitField("bit124", 0x0, 1), 4307 BitField("bit123", 0x0, 1), 4308 BitField("bit122", 0x0, 1), 4309 BitField("bit121", 0x0, 1), 4310 BitField("120bits", 0x0, 120) 4311 ] 4312 4313 4314class NtNRestOctets(Packet): 4315 """NT/N Rest Octets Section 10.5.2.22c""" 4316 name = "NT/N Rest Octets" 4317 fields_desc = [ 4318 BitField("nln", 0x0, 2), 4319 BitField("ncnInfo", 0x0, 4), 4320 BitField("spare", 0x0, 2) 4321 ] 4322 4323 4324# 4325# The following packet has no length info! 4326# 4327# len 1-18 4328class P1RestOctets(Packet): 4329 """P1 Rest Octets Section 10.5.2.23""" 4330 name = "P1 Rest Octets" 4331 fields_desc = [ 4332 BitField("nln", 0x0, 2), 4333 BitField("nlnStatus", 0x0, 1), 4334 BitField("prio1", 0x0, 3), 4335 BitField("prio2", 0x0, 3), 4336 # optional 4337 BitField("pageIndication1", 0x0, 1), 4338 BitField("pageIndication2", 0x0, 1), 4339 BitField("spare", 0x0, 5), 4340 ByteField("spareB1", None), 4341 ByteField("spareB2", None), 4342 ByteField("spareB3", None), 4343 ByteField("spareB4", None), 4344 ByteField("spareB5", None), 4345 ByteField("spareB6", None), 4346 ByteField("spareB7", None), 4347 ByteField("spareB8", None), 4348 ByteField("spareB9", None), 4349 ByteField("spareB10", None), 4350 ByteField("spareB11", None), 4351 ByteField("spareB12", None), 4352 ByteField("spareB13", None), 4353 ByteField("spareB14", None), 4354 ByteField("spareB15", None), 4355 ByteField("spareB16", None), 4356 ] 4357 4358 4359# len 2-12 4360class P2RestOctets(Packet): 4361 """P2 Rest Octets Section 10.5.2.24""" 4362 name = "P2 Rest Octets" 4363 fields_desc = [ 4364 BitField("cn3", 0x0, 2), 4365 BitField("nln", 0x0, 2), 4366 BitField("nlnStatus", 0x0, 1), 4367 BitField("prio1", 0x0, 3), 4368 4369 BitField("prio2", 0x0, 3), 4370 BitField("prio3", 0x0, 3), 4371 BitField("pageIndication3", 0x0, 1), 4372 BitField("spare", 0x0, 1), 4373 4374 # optinal (No length field!) 4375 ByteField("spareB1", None), 4376 ByteField("spareB2", None), 4377 ByteField("spareB3", None), 4378 ByteField("spareB4", None), 4379 4380 ByteField("spareB5", None), 4381 ByteField("spareB6", None), 4382 ByteField("spareB7", None), 4383 ByteField("spareB8", None), 4384 4385 ByteField("spareB9", None), 4386 ByteField("spareB10", None) 4387 ] 4388 4389 4390# len 4 4391class P3RestOctets(Packet): 4392 """P3 Rest Octets Section 10.5.2.25""" 4393 name = "P3 Rest Octets" 4394 fields_desc = [ 4395 BitField("cn3", 0x0, 2), 4396 BitField("cn4", 0x0, 2), 4397 BitField("nln", 0x0, 2), 4398 BitField("nlnStatus", 0x0, 1), 4399 BitField("prio1", 0x0, 3), 4400 BitField("prio2", 0x0, 3), 4401 BitField("prio3", 0x0, 3), 4402 BitField("prio4", 0x0, 3), 4403 BitField("spare", 0x0, 5) 4404 ] 4405 4406 4407# len 4 4408# strange packet, lots of valid formats 4409 4410# ideas for the dynamic packets: 4411# 1] for user interaction: Create an interactive "builder" based on a 4412# Q/A process (not very scapy like) 4413# 2] for usage in scripts, create an alternative packet for every 4414# possible packet layout 4415# 4416 4417 4418class PacketChannelDescription(Packet): 4419 """Packet Channel Description Section 10.5.2.25a""" 4420 name = "Packet Channel Description" 4421 fields_desc = [ 4422 ByteField("ieiPCD", None), 4423 BitField("chanType", 0x0, 5), # This packet has multiple 4424 # possible layouts. I moddeled the first one 4425 BitField("tn", 0x0, 3), # maybe build an 4426 #"interactive" builder. Like 4427 # a Q/A then propose a 4428 # packet? 4429 BitField("tsc", 0x0, 3), 4430 BitField("chooser1", 0x0, 1), 4431 BitField("chooser2", 0x0, 1), 4432 BitField("spare1", 0x0, 1), 4433 BitField("arfcn", 0x0, 10), 4434 ] 4435 4436 4437class DedicatedModeOrTBFHdr(Packet): 4438 """Dedicated mode or TBF Section 10.5.2.25b""" 4439 name = "Dedicated Mode or TBF" 4440 fields_desc = [ 4441 XBitField("ieiDMOT", None, 4), 4442 BitField("spare", 0x0, 1), 4443 BitField("tma", 0x0, 1), 4444 BitField("downlink", 0x0, 1), 4445 BitField("td", 0x0, 1) 4446 ] 4447 4448 4449# FIXME add implementation 4450class RrPacketUplinkAssignment(Packet): 4451 """RR Packet Uplink Assignment Section 10.5.2.25c""" 4452 name = "RR Packet Uplink Assignment" 4453 fields_desc = [ 4454 # Fill me 4455 ] 4456 4457 4458class PageModeHdr(Packet): 4459 """Page Mode Section 10.5.2.26""" 4460 name = "Page Mode" 4461 fields_desc = [ 4462 XBitField("ieiPM", None, 4), 4463 BitField("spare", 0x0, 1), 4464 BitField("spare1", 0x0, 1), 4465 BitField("pm", 0x0, 2) 4466 ] 4467 4468 4469# Fix for 1/2 len problem 4470# concatenation: pageMode and dedicatedModeOrTBF 4471class PageModeAndDedicatedModeOrTBF(Packet): 4472 name = "Page Mode and Dedicated Mode Or TBF" 4473 fields_desc = [ 4474 BitField("spare", 0x0, 1), 4475 BitField("spare1", 0x0, 1), 4476 BitField("pm", 0x0, 2), 4477 BitField("spare", 0x0, 1), 4478 BitField("tma", 0x0, 1), 4479 BitField("downlink", 0x0, 1), 4480 BitField("td", 0x0, 1) 4481 ] 4482 4483 4484# Fix for 1/2 len problem 4485# concatenation: pageMode and spareHalfOctets 4486class PageModeAndSpareHalfOctets(Packet): 4487 name = "Page Mode and Spare Half Octets" 4488 fields_desc = [ 4489 BitField("spare", 0x0, 1), 4490 BitField("spare1", 0x0, 1), 4491 BitField("pm", 0x0, 2), 4492 BitField("spareHalfOctets", 0x0, 4) 4493 ] 4494 4495 4496# Fix for 1/2 len problem 4497# concatenation: pageMode and Channel Needed 4498class PageModeAndChannelNeeded(Packet): 4499 name = "Page Mode and Channel Needed" 4500 fields_desc = [ 4501 BitField("spare", 0x0, 1), 4502 BitField("spare1", 0x0, 1), 4503 BitField("pm", 0x0, 2), 4504 BitField("channel2", 0x0, 2), 4505 BitField("channel1", 0x0, 2) 4506 ] 4507 4508 4509class NccPermittedHdr(Packet): 4510 """NCC Permitted Section 10.5.2.27""" 4511 name = "NCC Permitted" 4512 fields_desc = [ 4513 BitField("eightBitNP", None, 1), 4514 XBitField("ieiNP", None, 7), 4515 ByteField("nccPerm", 0x0) 4516 ] 4517 4518 4519class PowerCommandHdr(Packet): 4520 """Power Command Section 10.5.2.28""" 4521 name = "Power Command" 4522 fields_desc = [ 4523 BitField("eightBitPC", None, 1), 4524 XBitField("ieiPC", None, 7), 4525 BitField("spare", 0x0, 1), 4526 BitField("spare1", 0x0, 1), 4527 BitField("spare2", 0x0, 1), 4528 BitField("powerLvl", 0x0, 5) 4529 ] 4530 4531 4532class PowerCommandAndAccessTypeHdr(Packet): 4533 """Power Command and access type Section 10.5.2.28a""" 4534 name = "Power Command and Access Type" 4535 fields_desc = [ 4536 BitField("eightBitPCAAT", None, 1), 4537 XBitField("ieiPCAAT", None, 7), 4538 BitField("atc", 0x0, 1), 4539 BitField("spare", 0x0, 1), 4540 BitField("spare1", 0x0, 1), 4541 BitField("powerLvl", 0x0, 5) 4542 ] 4543 4544 4545class RachControlParametersHdr(Packet): 4546 """RACH Control Parameters Section 10.5.2.29""" 4547 name = "RACH Control Parameters" 4548 fields_desc = [ 4549 BitField("eightBitRCP", None, 1), 4550 XBitField("ieiRCP", None, 7), 4551 BitField("maxRetrans", 0x0, 2), 4552 BitField("txInteger", 0x0, 4), 4553 BitField("cellBarrAccess", 0x0, 1), 4554 BitField("re", 0x0, 1), 4555 BitField("ACC15", 0x0, 1), 4556 BitField("ACC14", 0x0, 1), 4557 BitField("ACC13", 0x0, 1), 4558 BitField("ACC12", 0x0, 1), 4559 BitField("ACC11", 0x0, 1), 4560 BitField("ACC10", 0x0, 1), 4561 BitField("ACC09", 0x0, 1), 4562 BitField("ACC08", 0x0, 1), 4563 BitField("ACC07", 0x0, 1), 4564 BitField("ACC06", 0x0, 1), 4565 BitField("ACC05", 0x0, 1), 4566 BitField("ACC04", 0x0, 1), 4567 BitField("ACC03", 0x0, 1), 4568 BitField("ACC02", 0x0, 1), 4569 BitField("ACC01", 0x0, 1), 4570 BitField("ACC00", 0x0, 1), 4571 ] 4572 4573 4574class RequestReferenceHdr(Packet): 4575 """Request Reference Section 10.5.2.30""" 4576 name = "Request Reference" 4577 fields_desc = [ 4578 BitField("eightBitRR", None, 1), 4579 XBitField("ieiRR", None, 7), 4580 ByteField("ra", 0x0), 4581 BitField("t1", 0x0, 5), 4582 BitField("t3Hi", 0x0, 3), 4583 BitField("t3Lo", 0x0, 3), 4584 BitField("t2", 0x0, 5) 4585 ] 4586 4587 4588class RrCauseHdr(Packet): 4589 """RR Cause Section 10.5.2.31""" 4590 name = "RR Cause" 4591 fields_desc = [ 4592 BitField("eightBitRC", None, 1), 4593 XBitField("ieiRC", None, 7), 4594 ByteField("rrCause", 0x0) 4595 ] 4596 4597 4598class Si1RestOctets(Packet): 4599 """SI 1 Rest Octets Section 10.5.2.32""" 4600 name = "SI 1 Rest Octets" 4601 fields_desc = [ 4602 ByteField("nchPos", 0x0) 4603 ] 4604 4605 4606class Si2bisRestOctets(Packet): 4607 """SI 2bis Rest Octets Section 10.5.2.33""" 4608 name = "SI 2bis Rest Octets" 4609 fields_desc = [ 4610 ByteField("spare", 0x0) 4611 ] 4612 4613 4614class Si2terRestOctets(Packet): 4615 """SI 2ter Rest Octets Section 10.5.2.33a""" 4616 name = "SI 2ter Rest Octets" 4617 fields_desc = [ 4618 ByteField("spare1", 0x0), 4619 ByteField("spare2", 0x0), 4620 ByteField("spare3", 0x0), 4621 ByteField("spare4", 0x0) 4622 ] 4623 4624 4625# len 5 4626class Si3RestOctets(Packet): 4627 """SI 3 Rest Octets Section 10.5.2.34""" 4628 name = "SI 3 Rest Octets" 4629 fields_desc = [ 4630 ByteField("byte1", 0x0), 4631 ByteField("byte2", 0x0), 4632 ByteField("byte3", 0x0), 4633 ByteField("byte4", 0x0), 4634 ByteField("byte5", 0x0) 4635 ] 4636 4637 4638# len 1 to 11 4639class Si4RestOctets(Packet): 4640 """SI 4 Rest Octets Section 10.5.2.35""" 4641 name = "SI 4 Rest Octets" 4642 fields_desc = [ 4643 XByteField("lengthSI4", None), 4644 ByteField("byte2", None), 4645 ByteField("byte3", None), 4646 ByteField("byte4", None), 4647 ByteField("byte5", None), 4648 ByteField("byte6", None), 4649 ByteField("byte7", None), 4650 ByteField("byte8", None), 4651 ByteField("byte9", None), 4652 ByteField("byte10", None), 4653 ByteField("byte11", None) 4654 ] 4655 4656 def post_build(self, p, pay): 4657 a = [getattr(self, fld.name) for fld in self.fields_desc] 4658 res = adapt(1, 11, a, self.fields_desc, 1) 4659 if self.lengthSI4 is None: 4660 p = struct.pack(">B", res[1]) + p[1:] 4661 if res[0] != 0: 4662 p = p[:-res[0]] 4663 if len(p) is 1: # length of this packet can be 0, but packet is 4664 p = '' # but the IE is manadatory 0_o 4665 return p + pay 4666 4667 4668class Si6RestOctets(Packet): 4669 """SI 6 Rest Octets Section 10.5.2.35a""" 4670 name = "SI 4 Rest Octets" 4671 fields_desc = [ 4672 # FIXME 4673 ] 4674 4675 4676# len 21 4677class Si7RestOctets(Packet): 4678 """SI 7 Rest Octets Section 10.5.2.36""" 4679 name = "SI 7 Rest Octets" 4680 fields_desc = [ 4681 # FIXME 4682 XByteField("lengthSI7", 0x15), 4683 ByteField("byte2", 0x0), 4684 ByteField("byte3", 0x0), 4685 ByteField("byte4", 0x0), 4686 ByteField("byte5", 0x0), 4687 ByteField("byte6", 0x0), 4688 ByteField("byte7", 0x0), 4689 ByteField("byte8", 0x0), 4690 ByteField("byte9", 0x0), 4691 ByteField("byte10", 0x0), 4692 ByteField("byte11", 0x0), 4693 ByteField("byte12", 0x0), 4694 ByteField("byte13", 0x0), 4695 ByteField("byte14", 0x0), 4696 ByteField("byte15", 0x0), 4697 ByteField("byte16", 0x0), 4698 ByteField("byte17", 0x0), 4699 ByteField("byte18", 0x0), 4700 ByteField("byte19", 0x0), 4701 ByteField("byte20", 0x0), 4702 ByteField("byte21", 0x0) 4703 ] 4704 4705 4706# len 21 4707class Si8RestOctets(Packet): 4708 """SI 8 Rest Octets Section 10.5.2.37""" 4709 name = "SI 8 Rest Octets" 4710 fields_desc = [ 4711 # FIXME 4712 XByteField("lengthSI8", 0x15), 4713 ByteField("byte2", 0x0), 4714 ByteField("byte3", 0x0), 4715 ByteField("byte4", 0x0), 4716 ByteField("byte5", 0x0), 4717 ByteField("byte6", 0x0), 4718 ByteField("byte7", 0x0), 4719 ByteField("byte8", 0x0), 4720 ByteField("byte9", 0x0), 4721 ByteField("byte10", 0x0), 4722 ByteField("byte11", 0x0), 4723 ByteField("byte12", 0x0), 4724 ByteField("byte13", 0x0), 4725 ByteField("byte14", 0x0), 4726 ByteField("byte15", 0x0), 4727 ByteField("byte16", 0x0), 4728 ByteField("byte17", 0x0), 4729 ByteField("byte18", 0x0), 4730 ByteField("byte19", 0x0), 4731 ByteField("byte20", 0x0), 4732 ByteField("byte21", 0x0) 4733 ] 4734 4735 4736#len 17 4737class Si9RestOctets(Packet): 4738 """SI 9 Rest Octets Section 10.5.2.37a""" 4739 name = "SI 9 Rest Octets" 4740 fields_desc = [ 4741 # FIXME 4742 XByteField("lengthSI9", 0x11), 4743 ByteField("byte2", 0x0), 4744 ByteField("byte3", 0x0), 4745 ByteField("byte4", 0x0), 4746 ByteField("byte5", 0x0), 4747 ByteField("byte6", 0x0), 4748 ByteField("byte7", 0x0), 4749 ByteField("byte8", 0x0), 4750 ByteField("byte9", 0x0), 4751 ByteField("byte10", 0x0), 4752 ByteField("byte11", 0x0), 4753 ByteField("byte12", 0x0), 4754 ByteField("byte13", 0x0), 4755 ByteField("byte14", 0x0), 4756 ByteField("byte15", 0x0), 4757 ByteField("byte16", 0x0), 4758 ByteField("byte17", 0x0) 4759 ] 4760 4761 4762# len 21 4763class Si13RestOctets(Packet): 4764 """SI 13 Rest Octets Section 10.5.2.37b""" 4765 name = "SI 13 Rest Octets" 4766 fields_desc = [ 4767 # FIXME 4768 XByteField("lengthSI3", 0x15), 4769 ByteField("byte2", 0x0), 4770 ByteField("byte3", 0x0), 4771 ByteField("byte4", 0x0), 4772 ByteField("byte5", 0x0), 4773 ByteField("byte6", 0x0), 4774 ByteField("byte7", 0x0), 4775 ByteField("byte8", 0x0), 4776 ByteField("byte9", 0x0), 4777 ByteField("byte10", 0x0), 4778 ByteField("byte11", 0x0), 4779 ByteField("byte12", 0x0), 4780 ByteField("byte13", 0x0), 4781 ByteField("byte14", 0x0), 4782 ByteField("byte15", 0x0), 4783 ByteField("byte16", 0x0), 4784 ByteField("byte17", 0x0), 4785 ByteField("byte18", 0x0), 4786 ByteField("byte19", 0x0), 4787 ByteField("byte20", 0x0), 4788 ByteField("byte21", 0x0) 4789 ] 4790 4791 4792# 10.5.2.37c [spare] 4793# 10.5.2.37d [spare] 4794 4795 4796# len 21 4797class Si16RestOctets(Packet): 4798 """SI 16 Rest Octets Section 10.5.2.37e""" 4799 name = "SI 16 Rest Octets" 4800 fields_desc = [ 4801 # FIXME 4802 XByteField("lengthSI16", 0x15), 4803 ByteField("byte2", 0x0), 4804 ByteField("byte3", 0x0), 4805 ByteField("byte4", 0x0), 4806 ByteField("byte5", 0x0), 4807 ByteField("byte6", 0x0), 4808 ByteField("byte7", 0x0), 4809 ByteField("byte8", 0x0), 4810 ByteField("byte9", 0x0), 4811 ByteField("byte10", 0x0), 4812 ByteField("byte11", 0x0), 4813 ByteField("byte12", 0x0), 4814 ByteField("byte13", 0x0), 4815 ByteField("byte14", 0x0), 4816 ByteField("byte15", 0x0), 4817 ByteField("byte16", 0x0), 4818 ByteField("byte17", 0x0), 4819 ByteField("byte18", 0x0), 4820 ByteField("byte19", 0x0), 4821 ByteField("byte20", 0x0), 4822 ByteField("byte21", 0x0) 4823 ] 4824 4825 4826# len 21 4827class Si17RestOctets(Packet): 4828 """SI 17 Rest Octets Section 10.5.2.37f""" 4829 name = "SI 17 Rest Octets" 4830 fields_desc = [ 4831 # FIXME 4832 XByteField("lengthSI17", 0x15), 4833 ByteField("byte2", 0x0), 4834 ByteField("byte3", 0x0), 4835 ByteField("byte4", 0x0), 4836 ByteField("byte5", 0x0), 4837 ByteField("byte6", 0x0), 4838 ByteField("byte7", 0x0), 4839 ByteField("byte8", 0x0), 4840 ByteField("byte9", 0x0), 4841 ByteField("byte10", 0x0), 4842 ByteField("byte11", 0x0), 4843 ByteField("byte12", 0x0), 4844 ByteField("byte13", 0x0), 4845 ByteField("byte14", 0x0), 4846 ByteField("byte15", 0x0), 4847 ByteField("byte16", 0x0), 4848 ByteField("byte17", 0x0), 4849 ByteField("byte18", 0x0), 4850 ByteField("byte19", 0x0), 4851 ByteField("byte20", 0x0), 4852 ByteField("byte21", 0x0) 4853 ] 4854 4855 4856class StartingTimeHdr(Packet): 4857 """Starting Time Section 10.5.2.38""" 4858 name = "Starting Time" 4859 fields_desc = [ 4860 BitField("eightBitST", None, 1), 4861 XBitField("ieiST", None, 7), 4862 ByteField("ra", 0x0), 4863 BitField("t1", 0x0, 5), 4864 BitField("t3Hi", 0x0, 3), 4865 BitField("t3Lo", 0x0, 3), 4866 BitField("t2", 0x0, 5) 4867 ] 4868 4869 4870class SynchronizationIndicationHdr(Packet): 4871 """Synchronization Indication Section 10.5.2.39""" 4872 name = "Synchronization Indication" 4873 fields_desc = [ 4874 XBitField("ieiSI", None, 4), 4875 BitField("nci", 0x0, 1), 4876 BitField("rot", 0x0, 1), 4877 BitField("si", 0x0, 2) 4878 ] 4879 4880 4881class TimingAdvanceHdr(Packet): 4882 """Timing Advance Section 10.5.2.40""" 4883 name = "Timing Advance" 4884 fields_desc = [ 4885 BitField("eightBitTA", None, 1), 4886 XBitField("ieiTA", None, 7), 4887 BitField("spare", 0x0, 1), 4888 BitField("spare1", 0x0, 1), 4889 BitField("timingVal", 0x0, 6) 4890 ] 4891 4892 4893class TimeDifferenceHdr(Packet): 4894 """ Time Difference Section 10.5.2.41""" 4895 name = "Time Difference" 4896 fields_desc = [ 4897 BitField("eightBitTD", None, 1), 4898 XBitField("ieiTD", None, 7), 4899 XByteField("lengthTD", 0x3), 4900 ByteField("timeValue", 0x0) 4901 ] 4902 4903 4904class TlliHdr(Packet): 4905 """ TLLI Section Section 10.5.2.41a""" 4906 name = "TLLI" 4907 fields_desc = [ 4908 BitField("eightBitT", None, 1), 4909 XBitField("ieiT", None, 7), 4910 ByteField("value", 0x0), 4911 ByteField("value1", 0x0), 4912 ByteField("value2", 0x0), 4913 ByteField("value3", 0x0) 4914 ] 4915 4916 4917class TmsiPTmsiHdr(Packet): 4918 """ TMSI/P-TMSI Section 10.5.2.42""" 4919 name = "TMSI/P-TMSI" 4920 fields_desc = [ 4921 BitField("eightBitTPT", None, 1), 4922 XBitField("ieiTPT", None, 7), 4923 ByteField("value", 0x0), 4924 ByteField("value1", 0x0), 4925 ByteField("value2", 0x0), 4926 ByteField("value3", 0x0) 4927 ] 4928 4929 4930class VgcsTargetModeIdenticationHdr(Packet): 4931 """ VGCS target Mode Indication 10.5.2.42a""" 4932 name = "VGCS Target Mode Indication" 4933 fields_desc = [ 4934 BitField("eightBitVTMI", None, 1), 4935 XBitField("ieiVTMI", None, 7), 4936 XByteField("lengthVTMI", 0x2), 4937 BitField("targerMode", 0x0, 2), 4938 BitField("cipherKeyNb", 0x0, 4), 4939 BitField("spare", 0x0, 1), 4940 BitField("spare1", 0x0, 1) 4941 ] 4942 4943 4944class WaitIndicationHdr(Packet): 4945 """ Wait Indication Section 10.5.2.43""" 4946 name = "Wait Indication" 4947 fields_desc = [ # asciiart of specs strange 4948 BitField("eightBitWI", None, 1), 4949 XBitField("ieiWI", None, 7), 4950 ByteField("timeoutVal", 0x0) 4951 ] 4952 4953 4954# len 17 4955class ExtendedMeasurementResultsHdr(Packet): 4956 """EXTENDED MEASUREMENT RESULTS Section 10.5.2.45""" 4957 name = "Extended Measurement Results" 4958 fields_desc = [ 4959 BitField("eightBitEMR", None, 1), 4960 XBitField("ieiEMR", None, 7), 4961 4962 BitField("scUsed", None, 1), 4963 BitField("dtxUsed", None, 1), 4964 BitField("rxLevC0", None, 6), 4965 4966 BitField("rxLevC1", None, 6), 4967 BitField("rxLevC2Hi", None, 2), 4968 4969 BitField("rxLevC2Lo", None, 4), 4970 BitField("rxLevC3Hi", None, 4), 4971 4972 BitField("rxLevC3Lo", None, 3), 4973 BitField("rxLevC4", None, 5), 4974 4975 BitField("rxLevC5", None, 6), 4976 BitField("rxLevC6Hi", None, 2), 4977 4978 BitField("rxLevC6Lo", None, 4), 4979 BitField("rxLevC7Hi", None, 4), 4980 4981 BitField("rxLevC7Lo", None, 2), 4982 BitField("rxLevC8", None, 6), 4983 4984 BitField("rxLevC9", None, 6), 4985 BitField("rxLevC10Hi", None, 2), 4986 4987 BitField("rxLevC10Lo", None, 4), 4988 BitField("rxLevC11Hi", None, 4), 4989 4990 BitField("rxLevC13Lo", None, 2), 4991 BitField("rxLevC12", None, 6), 4992 4993 BitField("rxLevC13", None, 6), 4994 BitField("rxLevC14Hi", None, 2), 4995 4996 BitField("rxLevC14Lo", None, 4), 4997 BitField("rxLevC15Hi", None, 4), 4998 4999 BitField("rxLevC15Lo", None, 2), 5000 BitField("rxLevC16", None, 6), 5001 5002 5003 BitField("rxLevC17", None, 6), 5004 BitField("rxLevC18Hi", None, 2), 5005 5006 BitField("rxLevC18Lo", None, 4), 5007 BitField("rxLevC19Hi", None, 4), 5008 5009 BitField("rxLevC19Lo", None, 2), 5010 BitField("rxLevC20", None, 6) 5011 ] 5012 5013 5014# len 17 5015class ExtendedMeasurementFrequencyListHdr(Packet): 5016 """Extended Measurement Frequency List Section 10.5.2.46""" 5017 name = "Extended Measurement Frequency List" 5018 fields_desc = [ 5019 BitField("eightBitEMFL", None, 1), 5020 XBitField("ieiEMFL", None, 7), 5021 5022 BitField("bit128", 0x0, 1), 5023 BitField("bit127", 0x0, 1), 5024 BitField("spare", 0x0, 1), 5025 BitField("seqCode", 0x0, 1), 5026 BitField("bit124", 0x0, 1), 5027 BitField("bit123", 0x0, 1), 5028 BitField("bit122", 0x0, 1), 5029 BitField("bit121", 0x0, 1), 5030 5031 BitField("bitsRest", 0x0, 128) 5032 ] 5033 5034 5035class SuspensionCauseHdr(Packet): 5036 """Suspension Cause Section 10.5.2.47""" 5037 name = "Suspension Cause" 5038 fields_desc = [ 5039 BitField("eightBitSC", None, 1), 5040 XBitField("ieiSC", None, 7), 5041 ByteField("suspVal", 0x0) 5042 ] 5043 5044 5045class ApduIDHdr(Packet): 5046 """APDU Flags Section 10.5.2.48""" 5047 name = "Apdu Id" 5048 fields_desc = [ 5049 XBitField("ieiAI", None, 4), 5050 BitField("id", None, 4) 5051 ] 5052 5053 5054class ApduFlagsHdr(Packet): 5055 """APDU Flags Section 10.5.2.49""" 5056 name = "Apdu Flags" 5057 fields_desc = [ 5058 XBitField("iei", None, 4), 5059 BitField("spare", 0x0, 1), 5060 BitField("cr", 0x0, 1), 5061 BitField("firstSeg", 0x0, 1), 5062 BitField("lastSeg", 0x0, 1) 5063 ] 5064 5065 5066# Fix 1/2 len problem 5067class ApduIDAndApduFlags(Packet): 5068 name = "Apu Id and Apdu Flags" 5069 fields_desc = [ 5070 BitField("id", None, 4), 5071 BitField("spare", 0x0, 1), 5072 BitField("cr", 0x0, 1), 5073 BitField("firstSeg", 0x0, 1), 5074 BitField("lastSeg", 0x0, 1) 5075 ] 5076 5077 5078# len 2 to max L3 (251) (done) 5079class ApduDataHdr(Packet): 5080 """APDU Data Section 10.5.2.50""" 5081 name = "Apdu Data" 5082 fields_desc = [ 5083 BitField("eightBitAD", None, 1), 5084 XBitField("ieiAD", None, 7), 5085 XByteField("lengthAD", None), 5086 #optional 5087 ByteField("apuInfo1", None), 5088 ByteField("apuInfo2", None), 5089 ByteField("apuInfo3", None), 5090 ByteField("apuInfo4", None), 5091 ByteField("apuInfo5", None), 5092 ByteField("apuInfo6", None), 5093 ByteField("apuInfo7", None), 5094 ByteField("apuInfo8", None), 5095 ByteField("apuInfo9", None), 5096 ByteField("apuInfo10", None), 5097 ByteField("apuInfo11", None), 5098 ByteField("apuInfo12", None), 5099 ByteField("apuInfo13", None), 5100 ByteField("apuInfo14", None), 5101 ByteField("apuInfo15", None), 5102 ByteField("apuInfo16", None), 5103 ByteField("apuInfo17", None), 5104 ByteField("apuInfo18", None), 5105 ByteField("apuInfo19", None), 5106 ByteField("apuInfo20", None), 5107 ByteField("apuInfo21", None), 5108 ByteField("apuInfo22", None), 5109 ByteField("apuInfo23", None), 5110 ByteField("apuInfo24", None), 5111 ByteField("apuInfo25", None), 5112 ByteField("apuInfo26", None), 5113 ByteField("apuInfo27", None), 5114 ByteField("apuInfo28", None), 5115 ByteField("apuInfo29", None), 5116 ByteField("apuInfo30", None), 5117 ByteField("apuInfo31", None), 5118 ByteField("apuInfo32", None), 5119 ByteField("apuInfo33", None), 5120 ByteField("apuInfo34", None), 5121 ByteField("apuInfo35", None), 5122 ByteField("apuInfo36", None), 5123 ByteField("apuInfo37", None), 5124 ByteField("apuInfo38", None), 5125 ByteField("apuInfo39", None), 5126 ByteField("apuInfo40", None), 5127 ByteField("apuInfo41", None), 5128 ByteField("apuInfo42", None), 5129 ByteField("apuInfo43", None), 5130 ByteField("apuInfo44", None), 5131 ByteField("apuInfo45", None), 5132 ByteField("apuInfo46", None), 5133 ByteField("apuInfo47", None), 5134 ByteField("apuInfo48", None), 5135 ByteField("apuInfo49", None), 5136 ByteField("apuInfo50", None), 5137 ByteField("apuInfo51", None), 5138 ByteField("apuInfo52", None), 5139 ByteField("apuInfo53", None), 5140 ByteField("apuInfo54", None), 5141 ByteField("apuInfo55", None), 5142 ByteField("apuInfo56", None), 5143 ByteField("apuInfo57", None), 5144 ByteField("apuInfo58", None), 5145 ByteField("apuInfo59", None), 5146 ByteField("apuInfo60", None), 5147 ByteField("apuInfo61", None), 5148 ByteField("apuInfo62", None), 5149 ByteField("apuInfo63", None), 5150 ByteField("apuInfo64", None), 5151 ByteField("apuInfo65", None), 5152 ByteField("apuInfo66", None), 5153 ByteField("apuInfo67", None), 5154 ByteField("apuInfo68", None), 5155 ByteField("apuInfo69", None), 5156 ByteField("apuInfo70", None), 5157 ByteField("apuInfo71", None), 5158 ByteField("apuInfo72", None), 5159 ByteField("apuInfo73", None), 5160 ByteField("apuInfo74", None), 5161 ByteField("apuInfo75", None), 5162 ByteField("apuInfo76", None), 5163 ByteField("apuInfo77", None), 5164 ByteField("apuInfo78", None), 5165 ByteField("apuInfo79", None), 5166 ByteField("apuInfo80", None), 5167 ByteField("apuInfo81", None), 5168 ByteField("apuInfo82", None), 5169 ByteField("apuInfo83", None), 5170 ByteField("apuInfo84", None), 5171 ByteField("apuInfo85", None), 5172 ByteField("apuInfo86", None), 5173 ByteField("apuInfo87", None), 5174 ByteField("apuInfo88", None), 5175 ByteField("apuInfo89", None), 5176 ByteField("apuInfo90", None), 5177 ByteField("apuInfo91", None), 5178 ByteField("apuInfo92", None), 5179 ByteField("apuInfo93", None), 5180 ByteField("apuInfo94", None), 5181 ByteField("apuInfo95", None), 5182 ByteField("apuInfo96", None), 5183 ByteField("apuInfo97", None), 5184 ByteField("apuInfo98", None), 5185 ByteField("apuInfo99", None), 5186 ByteField("apuInfo100", None), 5187 ByteField("apuInfo101", None), 5188 ByteField("apuInfo102", None), 5189 ByteField("apuInfo103", None), 5190 ByteField("apuInfo104", None), 5191 ByteField("apuInfo105", None), 5192 ByteField("apuInfo106", None), 5193 ByteField("apuInfo107", None), 5194 ByteField("apuInfo108", None), 5195 ByteField("apuInfo109", None), 5196 ByteField("apuInfo110", None), 5197 ByteField("apuInfo111", None), 5198 ByteField("apuInfo112", None), 5199 ByteField("apuInfo113", None), 5200 ByteField("apuInfo114", None), 5201 ByteField("apuInfo115", None), 5202 ByteField("apuInfo116", None), 5203 ByteField("apuInfo117", None), 5204 ByteField("apuInfo118", None), 5205 ByteField("apuInfo119", None), 5206 ByteField("apuInfo120", None), 5207 ByteField("apuInfo121", None), 5208 ByteField("apuInfo122", None), 5209 ByteField("apuInfo123", None), 5210 ByteField("apuInfo124", None), 5211 ByteField("apuInfo125", None), 5212 ByteField("apuInfo126", None), 5213 ByteField("apuInfo127", None), 5214 ByteField("apuInfo128", None), 5215 ByteField("apuInfo129", None), 5216 ByteField("apuInfo130", None), 5217 ByteField("apuInfo131", None), 5218 ByteField("apuInfo132", None), 5219 ByteField("apuInfo133", None), 5220 ByteField("apuInfo134", None), 5221 ByteField("apuInfo135", None), 5222 ByteField("apuInfo136", None), 5223 ByteField("apuInfo137", None), 5224 ByteField("apuInfo138", None), 5225 ByteField("apuInfo139", None), 5226 ByteField("apuInfo140", None), 5227 ByteField("apuInfo141", None), 5228 ByteField("apuInfo142", None), 5229 ByteField("apuInfo143", None), 5230 ByteField("apuInfo144", None), 5231 ByteField("apuInfo145", None), 5232 ByteField("apuInfo146", None), 5233 ByteField("apuInfo147", None), 5234 ByteField("apuInfo148", None), 5235 ByteField("apuInfo149", None), 5236 ByteField("apuInfo150", None), 5237 ByteField("apuInfo151", None), 5238 ByteField("apuInfo152", None), 5239 ByteField("apuInfo153", None), 5240 ByteField("apuInfo154", None), 5241 ByteField("apuInfo155", None), 5242 ByteField("apuInfo156", None), 5243 ByteField("apuInfo157", None), 5244 ByteField("apuInfo158", None), 5245 ByteField("apuInfo159", None), 5246 ByteField("apuInfo160", None), 5247 ByteField("apuInfo161", None), 5248 ByteField("apuInfo162", None), 5249 ByteField("apuInfo163", None), 5250 ByteField("apuInfo164", None), 5251 ByteField("apuInfo165", None), 5252 ByteField("apuInfo166", None), 5253 ByteField("apuInfo167", None), 5254 ByteField("apuInfo168", None), 5255 ByteField("apuInfo169", None), 5256 ByteField("apuInfo170", None), 5257 ByteField("apuInfo171", None), 5258 ByteField("apuInfo172", None), 5259 ByteField("apuInfo173", None), 5260 ByteField("apuInfo174", None), 5261 ByteField("apuInfo175", None), 5262 ByteField("apuInfo176", None), 5263 ByteField("apuInfo177", None), 5264 ByteField("apuInfo178", None), 5265 ByteField("apuInfo179", None), 5266 ByteField("apuInfo180", None), 5267 ByteField("apuInfo181", None), 5268 ByteField("apuInfo182", None), 5269 ByteField("apuInfo183", None), 5270 ByteField("apuInfo184", None), 5271 ByteField("apuInfo185", None), 5272 ByteField("apuInfo186", None), 5273 ByteField("apuInfo187", None), 5274 ByteField("apuInfo188", None), 5275 ByteField("apuInfo189", None), 5276 ByteField("apuInfo190", None), 5277 ByteField("apuInfo191", None), 5278 ByteField("apuInfo192", None), 5279 ByteField("apuInfo193", None), 5280 ByteField("apuInfo194", None), 5281 ByteField("apuInfo195", None), 5282 ByteField("apuInfo196", None), 5283 ByteField("apuInfo197", None), 5284 ByteField("apuInfo198", None), 5285 ByteField("apuInfo199", None), 5286 ByteField("apuInfo200", None), 5287 ByteField("apuInfo201", None), 5288 ByteField("apuInfo202", None), 5289 ByteField("apuInfo203", None), 5290 ByteField("apuInfo204", None), 5291 ByteField("apuInfo205", None), 5292 ByteField("apuInfo206", None), 5293 ByteField("apuInfo207", None), 5294 ByteField("apuInfo208", None), 5295 ByteField("apuInfo209", None), 5296 ByteField("apuInfo210", None), 5297 ByteField("apuInfo211", None), 5298 ByteField("apuInfo212", None), 5299 ByteField("apuInfo213", None), 5300 ByteField("apuInfo214", None), 5301 ByteField("apuInfo215", None), 5302 ByteField("apuInfo216", None), 5303 ByteField("apuInfo217", None), 5304 ByteField("apuInfo218", None), 5305 ByteField("apuInfo219", None), 5306 ByteField("apuInfo220", None), 5307 ByteField("apuInfo221", None), 5308 ByteField("apuInfo222", None), 5309 ByteField("apuInfo223", None), 5310 ByteField("apuInfo224", None), 5311 ByteField("apuInfo225", None), 5312 ByteField("apuInfo226", None), 5313 ByteField("apuInfo227", None), 5314 ByteField("apuInfo228", None), 5315 ByteField("apuInfo229", None), 5316 ByteField("apuInfo230", None), 5317 ByteField("apuInfo231", None), 5318 ByteField("apuInfo232", None), 5319 ByteField("apuInfo233", None), 5320 ByteField("apuInfo234", None), 5321 ByteField("apuInfo235", None), 5322 ByteField("apuInfo236", None), 5323 ByteField("apuInfo237", None), 5324 ByteField("apuInfo238", None), 5325 ByteField("apuInfo239", None), 5326 ByteField("apuInfo240", None), 5327 ByteField("apuInfo241", None), 5328 ByteField("apuInfo242", None), 5329 ByteField("apuInfo243", None), 5330 ByteField("apuInfo244", None), 5331 ByteField("apuInfo245", None), 5332 ByteField("apuInfo246", None), 5333 ByteField("apuInfo247", None), 5334 ByteField("apuInfo248", None), 5335 ByteField("apuInfo249", None) 5336 ] 5337 5338 def post_build(self, p, pay): 5339 a = [getattr(self, fld.name) for fld in self.fields_desc] 5340 res = adapt(2, 251, a, self.fields_desc) 5341 if self.lengthAD is None: 5342 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 5343 if res[0] != 0: 5344 p = p[:-res[0]] 5345 return p + pay 5346 5347# 5348# 10.5.3 Mobility management information elements 5349# 5350 5351 5352class AuthenticationParameterRAND(Packet): 5353 """Authentication parameter RAND Section 10.5.3.1""" 5354 name = "Authentication Parameter Rand" 5355 fields_desc = [ 5356 ByteField("ieiAPR", None), 5357 BitField("randValue", 0x0, 128) 5358 ] 5359 5360 5361class AuthenticationParameterSRES(Packet): 5362 """Authentication parameter SRES Section 10.5.3.2""" 5363 name = "Authentication Parameter Sres" 5364 fields_desc = [ 5365 ByteField("ieiAPS", None), 5366 BitField("sresValue", 0x0, 40) 5367 ] 5368 5369 5370class CmServiceType(Packet): 5371 """CM service type Section 10.5.3.3""" 5372 name = "CM Service Type" 5373 fields_desc = [ 5374 XBitField("ieiCST", 0x0, 4), 5375 BitField("serviceType", 0x0, 4) 5376 ] 5377 5378 5379class CmServiceTypeAndCiphKeySeqNr(Packet): 5380 name = "CM Service Type and Cipher Key Sequence Number" 5381 fields_desc = [ 5382 BitField("keySeq", 0x0, 3), 5383 BitField("spare", 0x0, 1), 5384 BitField("serviceType", 0x0, 4) 5385 ] 5386 5387 5388class IdentityType(Packet): 5389 """Identity type Section 10.5.3.4""" 5390 name = "Identity Type" 5391 fields_desc = [ 5392 XBitField("ieiIT", 0x0, 4), 5393 BitField("spare", 0x0, 1), 5394 BitField("idType", 0x1, 3) 5395 ] 5396 5397 5398# Fix 1/2 len problem 5399class IdentityTypeAndSpareHalfOctet(Packet): 5400 name = "Identity Type and Spare Half Octet" 5401 fields_desc = [ 5402 BitField("spare", 0x0, 1), 5403 BitField("idType", 0x1, 3), 5404 BitField("spareHalfOctets", 0x0, 4) 5405 ] 5406 5407 5408class LocationUpdatingType(Packet): 5409 """Location updating type Section 10.5.3.5""" 5410 name = "Location Updating Type" 5411 fields_desc = [ 5412 XBitField("ieiLUT", 0x0, 4), 5413 BitField("for", 0x0, 1), 5414 BitField("spare", 0x0, 1), 5415 BitField("lut", 0x0, 2) 5416 ] 5417 5418 5419class LocationUpdatingTypeAndCiphKeySeqNr(Packet): 5420 name = "Location Updating Type and Cipher Key Sequence Number" 5421 fields_desc = [ 5422 BitField("for", 0x0, 1), 5423 BitField("spare", 0x0, 1), 5424 BitField("lut", 0x0, 2), 5425 BitField("spare", 0x0, 1), 5426 BitField("keySeq", 0x0, 3) 5427 ] 5428 5429 5430# len 3 to L3 max (251) (done) 5431class NetworkNameHdr(Packet): 5432 """Network Name Section 10.5.3.5a""" 5433 name = "Network Name" 5434 fields_desc = [ 5435 BitField("eightBitNN", None, 1), 5436 XBitField("ieiNN", None, 7), 5437 5438 XByteField("lengthNN", None), 5439 5440 BitField("ext1", 0x1, 1), 5441 BitField("codingScheme", 0x0, 3), 5442 BitField("addCi", 0x0, 1), 5443 BitField("nbSpare", 0x0, 3), 5444 # optional 5445 ByteField("txtString1", None), 5446 ByteField("txtString2", None), 5447 ByteField("txtString3", None), 5448 ByteField("txtString4", None), 5449 ByteField("txtString5", None), 5450 ByteField("txtString6", None), 5451 ByteField("txtString7", None), 5452 ByteField("txtString8", None), 5453 ByteField("txtString9", None), 5454 ByteField("txtString10", None), 5455 ByteField("txtString11", None), 5456 ByteField("txtString12", None), 5457 ByteField("txtString13", None), 5458 ByteField("txtString14", None), 5459 ByteField("txtString15", None), 5460 ByteField("txtString16", None), 5461 ByteField("txtString17", None), 5462 ByteField("txtString18", None), 5463 ByteField("txtString19", None), 5464 ByteField("txtString20", None), 5465 ByteField("txtString21", None), 5466 ByteField("txtString22", None), 5467 ByteField("txtString23", None), 5468 ByteField("txtString24", None), 5469 ByteField("txtString25", None), 5470 ByteField("txtString26", None), 5471 ByteField("txtString27", None), 5472 ByteField("txtString28", None), 5473 ByteField("txtString29", None), 5474 ByteField("txtString30", None), 5475 ByteField("txtString31", None), 5476 ByteField("txtString32", None), 5477 ByteField("txtString33", None), 5478 ByteField("txtString34", None), 5479 ByteField("txtString35", None), 5480 ByteField("txtString36", None), 5481 ByteField("txtString37", None), 5482 ByteField("txtString38", None), 5483 ByteField("txtString39", None), 5484 ByteField("txtString40", None), 5485 ByteField("txtString41", None), 5486 ByteField("txtString42", None), 5487 ByteField("txtString43", None), 5488 ByteField("txtString44", None), 5489 ByteField("txtString45", None), 5490 ByteField("txtString46", None), 5491 ByteField("txtString47", None), 5492 ByteField("txtString48", None), 5493 ByteField("txtString49", None), 5494 ByteField("txtString50", None), 5495 ByteField("txtString51", None), 5496 ByteField("txtString52", None), 5497 ByteField("txtString53", None), 5498 ByteField("txtString54", None), 5499 ByteField("txtString55", None), 5500 ByteField("txtString56", None), 5501 ByteField("txtString57", None), 5502 ByteField("txtString58", None), 5503 ByteField("txtString59", None), 5504 ByteField("txtString60", None), 5505 ByteField("txtString61", None), 5506 ByteField("txtString62", None), 5507 ByteField("txtString63", None), 5508 ByteField("txtString64", None), 5509 ByteField("txtString65", None), 5510 ByteField("txtString66", None), 5511 ByteField("txtString67", None), 5512 ByteField("txtString68", None), 5513 ByteField("txtString69", None), 5514 ByteField("txtString70", None), 5515 ByteField("txtString71", None), 5516 ByteField("txtString72", None), 5517 ByteField("txtString73", None), 5518 ByteField("txtString74", None), 5519 ByteField("txtString75", None), 5520 ByteField("txtString76", None), 5521 ByteField("txtString77", None), 5522 ByteField("txtString78", None), 5523 ByteField("txtString79", None), 5524 ByteField("txtString80", None), 5525 ByteField("txtString81", None), 5526 ByteField("txtString82", None), 5527 ByteField("txtString83", None), 5528 ByteField("txtString84", None), 5529 ByteField("txtString85", None), 5530 ByteField("txtString86", None), 5531 ByteField("txtString87", None), 5532 ByteField("txtString88", None), 5533 ByteField("txtString89", None), 5534 ByteField("txtString90", None), 5535 ByteField("txtString91", None), 5536 ByteField("txtString92", None), 5537 ByteField("txtString93", None), 5538 ByteField("txtString94", None), 5539 ByteField("txtString95", None), 5540 ByteField("txtString96", None), 5541 ByteField("txtString97", None), 5542 ByteField("txtString98", None), 5543 ByteField("txtString99", None), 5544 ByteField("txtString100", None), 5545 ByteField("txtString101", None), 5546 ByteField("txtString102", None), 5547 ByteField("txtString103", None), 5548 ByteField("txtString104", None), 5549 ByteField("txtString105", None), 5550 ByteField("txtString106", None), 5551 ByteField("txtString107", None), 5552 ByteField("txtString108", None), 5553 ByteField("txtString109", None), 5554 ByteField("txtString110", None), 5555 ByteField("txtString111", None), 5556 ByteField("txtString112", None), 5557 ByteField("txtString113", None), 5558 ByteField("txtString114", None), 5559 ByteField("txtString115", None), 5560 ByteField("txtString116", None), 5561 ByteField("txtString117", None), 5562 ByteField("txtString118", None), 5563 ByteField("txtString119", None), 5564 ByteField("txtString120", None), 5565 ByteField("txtString121", None), 5566 ByteField("txtString122", None), 5567 ByteField("txtString123", None), 5568 ByteField("txtString124", None), 5569 ByteField("txtString125", None), 5570 ByteField("txtString126", None), 5571 ByteField("txtString127", None), 5572 ByteField("txtString128", None), 5573 ByteField("txtString129", None), 5574 ByteField("txtString130", None), 5575 ByteField("txtString131", None), 5576 ByteField("txtString132", None), 5577 ByteField("txtString133", None), 5578 ByteField("txtString134", None), 5579 ByteField("txtString135", None), 5580 ByteField("txtString136", None), 5581 ByteField("txtString137", None), 5582 ByteField("txtString138", None), 5583 ByteField("txtString139", None), 5584 ByteField("txtString140", None), 5585 ByteField("txtString141", None), 5586 ByteField("txtString142", None), 5587 ByteField("txtString143", None), 5588 ByteField("txtString144", None), 5589 ByteField("txtString145", None), 5590 ByteField("txtString146", None), 5591 ByteField("txtString147", None), 5592 ByteField("txtString148", None), 5593 ByteField("txtString149", None), 5594 ByteField("txtString150", None), 5595 ByteField("txtString151", None), 5596 ByteField("txtString152", None), 5597 ByteField("txtString153", None), 5598 ByteField("txtString154", None), 5599 ByteField("txtString155", None), 5600 ByteField("txtString156", None), 5601 ByteField("txtString157", None), 5602 ByteField("txtString158", None), 5603 ByteField("txtString159", None), 5604 ByteField("txtString160", None), 5605 ByteField("txtString161", None), 5606 ByteField("txtString162", None), 5607 ByteField("txtString163", None), 5608 ByteField("txtString164", None), 5609 ByteField("txtString165", None), 5610 ByteField("txtString166", None), 5611 ByteField("txtString167", None), 5612 ByteField("txtString168", None), 5613 ByteField("txtString169", None), 5614 ByteField("txtString170", None), 5615 ByteField("txtString171", None), 5616 ByteField("txtString172", None), 5617 ByteField("txtString173", None), 5618 ByteField("txtString174", None), 5619 ByteField("txtString175", None), 5620 ByteField("txtString176", None), 5621 ByteField("txtString177", None), 5622 ByteField("txtString178", None), 5623 ByteField("txtString179", None), 5624 ByteField("txtString180", None), 5625 ByteField("txtString181", None), 5626 ByteField("txtString182", None), 5627 ByteField("txtString183", None), 5628 ByteField("txtString184", None), 5629 ByteField("txtString185", None), 5630 ByteField("txtString186", None), 5631 ByteField("txtString187", None), 5632 ByteField("txtString188", None), 5633 ByteField("txtString189", None), 5634 ByteField("txtString190", None), 5635 ByteField("txtString191", None), 5636 ByteField("txtString192", None), 5637 ByteField("txtString193", None), 5638 ByteField("txtString194", None), 5639 ByteField("txtString195", None), 5640 ByteField("txtString196", None), 5641 ByteField("txtString197", None), 5642 ByteField("txtString198", None), 5643 ByteField("txtString199", None), 5644 ByteField("txtString200", None), 5645 ByteField("txtString201", None), 5646 ByteField("txtString202", None), 5647 ByteField("txtString203", None), 5648 ByteField("txtString204", None), 5649 ByteField("txtString205", None), 5650 ByteField("txtString206", None), 5651 ByteField("txtString207", None), 5652 ByteField("txtString208", None), 5653 ByteField("txtString209", None), 5654 ByteField("txtString210", None), 5655 ByteField("txtString211", None), 5656 ByteField("txtString212", None), 5657 ByteField("txtString213", None), 5658 ByteField("txtString214", None), 5659 ByteField("txtString215", None), 5660 ByteField("txtString216", None), 5661 ByteField("txtString217", None), 5662 ByteField("txtString218", None), 5663 ByteField("txtString219", None), 5664 ByteField("txtString220", None), 5665 ByteField("txtString221", None), 5666 ByteField("txtString222", None), 5667 ByteField("txtString223", None), 5668 ByteField("txtString224", None), 5669 ByteField("txtString225", None), 5670 ByteField("txtString226", None), 5671 ByteField("txtString227", None), 5672 ByteField("txtString228", None), 5673 ByteField("txtString229", None), 5674 ByteField("txtString230", None), 5675 ByteField("txtString231", None), 5676 ByteField("txtString232", None), 5677 ByteField("txtString233", None), 5678 ByteField("txtString234", None), 5679 ByteField("txtString235", None), 5680 ByteField("txtString236", None), 5681 ByteField("txtString237", None), 5682 ByteField("txtString238", None), 5683 ByteField("txtString239", None), 5684 ByteField("txtString240", None), 5685 ByteField("txtString241", None), 5686 ByteField("txtString242", None), 5687 ByteField("txtString243", None), 5688 ByteField("txtString244", None), 5689 ByteField("txtString245", None), 5690 ByteField("txtString246", None), 5691 ByteField("txtString247", None), 5692 ByteField("txtString248", None) 5693 ] 5694 5695 def post_build(self, p, pay): 5696 a = [getattr(self, fld.name) for fld in self.fields_desc] 5697 res = adapt(3, 251, a, self.fields_desc) 5698 if self.lengthNN is None: 5699 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 5700 if res[0] != 0: 5701 p = p[:-res[0]] 5702 return p + pay 5703 5704 5705class RejectCause(Packet): 5706 """Reject cause Section 10.5.3.6""" 5707 name = "Reject Cause" 5708 fields_desc = [ 5709 ByteField("ieiRC", 0x0), 5710 ByteField("rejCause", 0x0) 5711 ] 5712 5713 5714class FollowOnProceed(Packet): 5715 """Follow-on Proceed Section 10.5.3.7""" 5716 name = "Follow-on Proceed" 5717 fields_desc = [ 5718 ByteField("ieiFOP", 0x0), 5719 ] 5720 5721 5722class TimeZoneHdr(Packet): 5723 """Time Zone Section 10.5.3.8""" 5724 name = "Time Zone" 5725 fields_desc = [ 5726 BitField("eightBitTZ", None, 1), 5727 XBitField("ieiTZ", None, 7), 5728 ByteField("timeZone", 0x0), 5729 ] 5730 5731 5732class TimeZoneAndTimeHdr(Packet): 5733 """Time Zone and Time Section 10.5.3.9""" 5734 name = "Time Zone and Time" 5735 fields_desc = [ 5736 BitField("eightBitTZAT", None, 1), 5737 XBitField("ieiTZAT", None, 7), 5738 ByteField("year", 0x0), 5739 ByteField("month", 0x0), 5740 ByteField("day", 0x0), 5741 ByteField("hour", 0x0), 5742 ByteField("minute", 0x0), 5743 ByteField("second", 0x0), 5744 ByteField("timeZone", 0x0) 5745 ] 5746 5747 5748class CtsPermissionHdr(Packet): 5749 """CTS permission Section 10.5.3.10""" 5750 name = "Cts Permission" 5751 fields_desc = [ 5752 BitField("eightBitCP", None, 1), 5753 XBitField("ieiCP", None, 7), 5754 ] 5755 5756 5757class LsaIdentifierHdr(Packet): 5758 """LSA Identifier Section 10.5.3.11""" 5759 name = "Lsa Identifier" 5760 fields_desc = [ 5761 BitField("eightBitLI", None, 1), 5762 XBitField("ieiLI", None, 7), 5763 ByteField("lsaID", 0x0), 5764 ByteField("lsaID1", 0x0), 5765 ByteField("lsaID2", 0x0) 5766 ] 5767 5768 5769# 5770# 10.5.4 Call control information elements 5771# 5772 5773#10.5.4.1 Extensions of codesets 5774# This is only text and no packet 5775 5776class LockingShiftProcedureHdr(Packet): 5777 """Locking shift procedure Section 10.5.4.2""" 5778 name = "Locking Shift Procedure" 5779 fields_desc = [ 5780 XBitField("ieiLSP", None, 4), 5781 BitField("lockShift", 0x0, 1), 5782 BitField("codesetId", 0x0, 3) 5783 ] 5784 5785 5786class NonLockingShiftProcedureHdr(Packet): 5787 """Non-locking shift procedure Section 10.5.4.3""" 5788 name = "Non-locking Shift Procedure" 5789 fields_desc = [ 5790 XBitField("ieiNLSP", None, 4), 5791 BitField("nonLockShift", 0x1, 1), 5792 BitField("codesetId", 0x0, 3) 5793 ] 5794 5795 5796class AuxiliaryStatesHdr(Packet): 5797 """Auxiliary states Section 10.5.4.4""" 5798 name = "Auxiliary States" 5799 fields_desc = [ 5800 BitField("eightBitAS", None, 1), 5801 XBitField("ieiAS", None, 7), 5802 XByteField("lengthAS", 0x3), 5803 BitField("ext", 0x1, 1), 5804 BitField("spare", 0x0, 3), 5805 BitField("holdState", 0x0, 2), 5806 BitField("mptyState", 0x0, 2) 5807 ] 5808 5809 5810# len 3 to 15 5811class BearerCapabilityHdr(Packet): 5812 """Bearer capability Section 10.5.4.5""" 5813 name = "Bearer Capability" 5814 fields_desc = [ 5815 BitField("eightBitBC", None, 1), 5816 XBitField("ieiBC", None, 7), 5817 5818 XByteField("lengthBC", None), 5819 5820 BitField("ext0", 0x1, 1), 5821 BitField("radioChReq", 0x1, 2), 5822 BitField("codingStd", 0x0, 1), 5823 BitField("transMode", 0x0, 1), 5824 BitField("infoTransCa", 0x0, 3), 5825 # optional 5826 ConditionalField(BitField("ext1", 0x1, 1), 5827 lambda pkt: pkt.ext0 == 0), 5828 ConditionalField(BitField("coding", None, 1), 5829 lambda pkt: pkt.ext0 == 0), 5830 ConditionalField(BitField("spare", None, 2), 5831 lambda pkt: pkt.ext0 == 0), 5832 ConditionalField(BitField("speechVers", 0x0, 4), 5833 lambda pkt: pkt.ext0 == 0), 5834 5835 ConditionalField(BitField("ext2", 0x1, 1), 5836 lambda pkt: pkt.ext1 == 0), 5837 ConditionalField(BitField("compress", None, 1), 5838 lambda pkt: pkt.ext1 == 0), 5839 ConditionalField(BitField("structure", None, 2), 5840 lambda pkt: pkt.ext1 == 0), 5841 ConditionalField(BitField("dupMode", None, 1), 5842 lambda pkt: pkt.ext1 == 0), 5843 ConditionalField(BitField("config", None, 1), 5844 lambda pkt: pkt.ext1 == 0), 5845 ConditionalField(BitField("nirr", None, 1), 5846 lambda pkt: pkt.ext1 == 0), 5847 ConditionalField(BitField("establi", 0x0, 1), 5848 lambda pkt: pkt.ext1 == 0), 5849 5850 BitField("ext3", None, 1), 5851 BitField("accessId", None, 2), 5852 BitField("rateAda", None, 2), 5853 BitField("signaling", None, 3), 5854 5855 ConditionalField(BitField("ext4", None, 1), 5856 lambda pkt: pkt.ext3 == 0), 5857 ConditionalField(BitField("otherITC", None, 2), 5858 lambda pkt: pkt.ext3 == 0), 5859 ConditionalField(BitField("otherRate", None, 2), 5860 lambda pkt: pkt.ext3 == 0), 5861 ConditionalField(BitField("spare1", 0x0, 3), 5862 lambda pkt: pkt.ext3 == 0), 5863 5864 ConditionalField(BitField("ext5", 0x1, 1), 5865 lambda pkt: pkt.ext4 == 0), 5866 ConditionalField(BitField("hdr", None, 1), 5867 lambda pkt: pkt.ext4 == 0), 5868 ConditionalField(BitField("multiFr", None, 1), 5869 lambda pkt: pkt.ext4 == 0), 5870 ConditionalField(BitField("mode", None, 1), 5871 lambda pkt: pkt.ext4 == 0), 5872 ConditionalField(BitField("lli", None, 1), 5873 lambda pkt: pkt.ext4 == 0), 5874 ConditionalField(BitField("assig", None, 1), 5875 lambda pkt: pkt.ext4 == 0), 5876 ConditionalField(BitField("inbNeg", None, 1), 5877 lambda pkt: pkt.ext4 == 0), 5878 ConditionalField(BitField("spare2", 0x0, 1), 5879 lambda pkt: pkt.ext4 == 0), 5880 5881 BitField("ext6", None, 1), 5882 BitField("layer1Id", None, 2), 5883 BitField("userInf", None, 4), 5884 BitField("sync", None, 1), 5885 5886 ConditionalField(BitField("ext7", None, 1), 5887 lambda pkt: pkt.ext6 == 0), 5888 ConditionalField(BitField("stopBit", None, 1), 5889 lambda pkt: pkt.ext6 == 0), 5890 ConditionalField(BitField("negoc", None, 1), 5891 lambda pkt: pkt.ext6 == 0), 5892 ConditionalField(BitField("nbDataBit", None, 1), 5893 lambda pkt: pkt.ext6 == 0), 5894 ConditionalField(BitField("userRate", None, 4), 5895 lambda pkt: pkt.ext6 == 0), 5896 5897 ConditionalField(BitField("ext8", None, 1), 5898 lambda pkt: pkt.ext7 == 0), 5899 ConditionalField(BitField("interRate", None, 2), 5900 lambda pkt: pkt.ext7 == 0), 5901 ConditionalField(BitField("nicTX", None, 1), 5902 lambda pkt: pkt.ext7 == 0), 5903 ConditionalField(BitField("nicRX", None, 1), 5904 lambda pkt: pkt.ext7 == 0), 5905 ConditionalField(BitField("parity", None, 3), 5906 lambda pkt: pkt.ext7 == 0), 5907 5908 ConditionalField(BitField("ext9", None, 1), 5909 lambda pkt: pkt.ext8 == 0), 5910 ConditionalField(BitField("connEle", None, 2), 5911 lambda pkt: pkt.ext8 == 0), 5912 ConditionalField(BitField("modemType", None, 5), 5913 lambda pkt: pkt.ext8 == 0), 5914 5915 ConditionalField(BitField("ext10", None, 1), 5916 lambda pkt: pkt.ext9 == 0), 5917 ConditionalField(BitField("otherModemType", None, 2), 5918 lambda pkt: pkt.ext9 == 0), 5919 ConditionalField(BitField("netUserRate", None, 5), 5920 lambda pkt: pkt.ext9 == 0), 5921 5922 ConditionalField(BitField("ext11", None, 1), 5923 lambda pkt: pkt.ext10 == 0), 5924 ConditionalField(BitField("chanCoding", None, 4), 5925 lambda pkt: pkt.ext10 == 0), 5926 ConditionalField(BitField("maxTrafficChan", None, 3), 5927 lambda pkt: pkt.ext10 == 0), 5928 5929 ConditionalField(BitField("ext12", None, 1), 5930 lambda pkt: pkt.ext11 == 0), 5931 ConditionalField(BitField("uimi", None, 3), 5932 lambda pkt: pkt.ext11 == 0), 5933 ConditionalField(BitField("airInterfaceUserRate", None, 4), 5934 lambda pkt: pkt.ext11 == 0), 5935 5936 ConditionalField(BitField("ext13", 0x1, 1), 5937 lambda pkt: pkt.ext12 == 0), 5938 ConditionalField(BitField("layer2Ch", None, 2), 5939 lambda pkt: pkt.ext12 == 0), 5940 ConditionalField(BitField("userInfoL2", 0x0, 5), 5941 lambda pkt: pkt.ext12 == 0) 5942 ] 5943 5944 # We have a bug here. packet is not working if used in message 5945 def post_build(self, p, pay): 5946 a = [getattr(self, fld.name) for fld in self.fields_desc] 5947 res = adapt(3, 15, a, self.fields_desc) 5948 if res[0] != 0: 5949 p = p[:-res[0]] 5950 # avoids a bug. find better way 5951 if len(p) is 5: 5952 p = p[:-2] 5953 if self.lengthBC is None: 5954 p = p[:1] + struct.pack(">B", len(p)-3) + p[2:] 5955 return p + pay 5956 5957 5958class CallControlCapabilitiesHdr(Packet): 5959 """Call Control Capabilities Section 10.5.4.5a""" 5960 name = "Call Control Capabilities" 5961 fields_desc = [ 5962 BitField("eightBitCCC", None, 1), 5963 XBitField("ieiCCC", None, 7), 5964 XByteField("lengthCCC", 0x3), 5965 BitField("spare", 0x0, 6), 5966 BitField("pcp", 0x0, 1), 5967 BitField("dtmf", 0x0, 1) 5968 ] 5969 5970 5971class CallStateHdr(Packet): 5972 """Call State Section 10.5.4.6""" 5973 name = "Call State" 5974 fields_desc = [ 5975 BitField("eightBitCS", None, 1), 5976 XBitField("ieiCS", None, 7), 5977 BitField("codingStd", 0x0, 2), 5978 BitField("stateValue", 0x0, 6) 5979 ] 5980 5981 5982# len 3 to 43 5983class CalledPartyBcdNumberHdr(Packet): 5984 """Called party BCD number Section 10.5.4.7""" 5985 name = "Called Party BCD Number" 5986 fields_desc = [ 5987 BitField("eightBitCPBN", None, 1), 5988 XBitField("ieiCPBN", None, 7), 5989 XByteField("lengthCPBN", None), 5990 BitField("ext", 0x1, 1), 5991 BitField("typeNb", 0x0, 3), 5992 BitField("nbPlanId", 0x0, 4), 5993 # optional 5994 BitField("nbDigit2", None, 4), 5995 BitField("nbDigit1", None, 4), 5996 BitField("nbDigit4", None, 4), 5997 BitField("nbDigit3", None, 4), 5998 5999 BitField("nbDigit6", None, 4), 6000 BitField("nbDigit5", None, 4), 6001 BitField("nbDigit8", None, 4), 6002 BitField("nbDigit7", None, 4), 6003 6004 BitField("nbDigit10", None, 4), 6005 BitField("nbDigit9", None, 4), 6006 BitField("nbDigit12", None, 4), 6007 BitField("nbDigit11", None, 4), 6008 6009 BitField("nbDigit14", None, 4), 6010 BitField("nbDigit13", None, 4), 6011 BitField("nbDigit16", None, 4), 6012 BitField("nbDigit15", None, 4), 6013 6014 BitField("nbDigit18", None, 4), 6015 BitField("nbDigit17", None, 4), 6016 BitField("nbDigit20", None, 4), 6017 BitField("nbDigit19", None, 4), 6018 6019 BitField("nbDigit22", None, 4), 6020 BitField("nbDigit21", None, 4), 6021 BitField("nbDigit24", None, 4), 6022 BitField("nbDigit23", None, 4), 6023 6024 BitField("nbDigit26", None, 4), 6025 BitField("nbDigit25", None, 4), 6026 BitField("nbDigit28", None, 4), 6027 BitField("nbDigit27", None, 4), 6028 6029 BitField("nbDigit30", None, 4), 6030 BitField("nbDigit29", None, 4), 6031 BitField("nbDigit32", None, 4), 6032 BitField("nbDigit31", None, 4), 6033 6034 BitField("nbDigit34", None, 4), 6035 BitField("nbDigit33", None, 4), 6036 BitField("nbDigit36", None, 4), 6037 BitField("nbDigit35", None, 4), 6038 6039 BitField("nbDigit38", None, 4), 6040 BitField("nbDigit37", None, 4), 6041 BitField("nbDigit40", None, 4), 6042 BitField("nbDigit39", None, 4), 6043# ^^^^^^ 20 first optional bytes ^^^^^^^^^^^^^^^ 6044 BitField("nbDigit42", None, 4), 6045 BitField("nbDigit41", None, 4), 6046 BitField("nbDigit44", None, 4), 6047 BitField("nbDigit43", None, 4), 6048 6049 BitField("nbDigit46", None, 4), 6050 BitField("nbDigit45", None, 4), 6051 BitField("nbDigit48", None, 4), 6052 BitField("nbDigit47", None, 4), 6053 6054 BitField("nbDigit50", None, 4), 6055 BitField("nbDigit49", None, 4), 6056 BitField("nbDigit52", None, 4), 6057 BitField("nbDigit51", None, 4), 6058 6059 BitField("nbDigit54", None, 4), 6060 BitField("nbDigit53", None, 4), 6061 BitField("nbDigit56", None, 4), 6062 BitField("nbDigit55", None, 4), 6063 6064 BitField("nbDigit58", None, 4), 6065 BitField("nbDigit57", None, 4), 6066 BitField("nbDigit60", None, 4), 6067 BitField("nbDigit59", None, 4), 6068 6069 BitField("nbDigit62", None, 4), 6070 BitField("nbDigit61", None, 4), 6071 BitField("nbDigit64", None, 4), 6072 BitField("nbDigit63", None, 4), 6073 6074 BitField("nbDigit66", None, 4), 6075 BitField("nbDigit65", None, 4), 6076 BitField("nbDigit68", None, 4), 6077 BitField("nbDigit67", None, 4), 6078 6079 BitField("nbDigit70", None, 4), 6080 BitField("nbDigit69", None, 4), 6081 BitField("nbDigit72", None, 4), 6082 BitField("nbDigit71", None, 4), 6083 6084 BitField("nbDigit74", None, 4), 6085 BitField("nbDigit73", None, 4), 6086 BitField("nbDigit76", None, 4), 6087 BitField("nbDigit75", None, 4), 6088 6089 BitField("nbDigit78", None, 4), 6090 BitField("nbDigit77", None, 4), 6091 BitField("nbDigit80", None, 4), 6092 BitField("nbDigit79", None, 4), 6093 ] 6094 6095 def post_build(self, p, pay): 6096 a = [getattr(self, fld.name) for fld in self.fields_desc] 6097 res = adapt(3, 43, a, self.fields_desc, 2) 6098 if self.lengthCPBN is None: 6099 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 6100 if res[0] != 0: 6101 p = p[:-res[0]] 6102 return p + pay 6103 6104 6105# len 2 to 23 6106class CalledPartySubaddressHdr(Packet): 6107 """Called party subaddress Section 10.5.4.8""" 6108 name = "Called Party Subaddress" 6109 fields_desc = [ 6110 BitField("eightBitCPS", None, 1), 6111 XBitField("ieiCPS", None, 7), 6112 XByteField("lengthCPS", None), 6113 # optional 6114 BitField("ext", None, 1), 6115 BitField("subAddr", None, 3), 6116 BitField("oddEven", None, 1), 6117 BitField("spare", None, 3), 6118 6119 ByteField("subInfo0", None), 6120 ByteField("subInfo1", None), 6121 ByteField("subInfo2", None), 6122 ByteField("subInfo3", None), 6123 ByteField("subInfo4", None), 6124 ByteField("subInfo5", None), 6125 ByteField("subInfo6", None), 6126 ByteField("subInfo7", None), 6127 ByteField("subInfo8", None), 6128 ByteField("subInfo9", None), 6129 ByteField("subInfo10", None), 6130 ByteField("subInfo11", None), 6131 ByteField("subInfo12", None), 6132 ByteField("subInfo13", None), 6133 ByteField("subInfo14", None), 6134 ByteField("subInfo15", None), 6135 ByteField("subInfo16", None), 6136 ByteField("subInfo17", None), 6137 ByteField("subInfo18", None), 6138 ByteField("subInfo19", None) 6139 ] 6140 6141 def post_build(self, p, pay): 6142 a = [getattr(self, fld.name) for fld in self.fields_desc] 6143 res = adapt(2, 23, a, self.fields_desc) 6144 if self.lengthCPS is None: 6145 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 6146 if res[0] != 0: 6147 p = p[:-res[0]] 6148 return p + pay 6149 6150 6151# len 3 to 14 6152class CallingPartyBcdNumberHdr(Packet): 6153 """Called party subaddress Section 10.5.4.9""" 6154 name = "Called Party Subaddress" 6155 fields_desc = [ 6156 BitField("eightBitCPBN", None, 1), 6157 XBitField("ieiCPBN", None, 7), 6158 XByteField("lengthCPBN", None), 6159 BitField("ext", 0x1, 1), 6160 BitField("typeNb", 0x0, 3), 6161 BitField("nbPlanId", 0x0, 4), 6162 # optional 6163 ConditionalField(BitField("ext1", 0x1, 1), 6164 lambda pkt: pkt.ext == 0), 6165 ConditionalField(BitField("presId", None, 2), 6166 lambda pkt: pkt.ext == 0), 6167 ConditionalField(BitField("spare", None, 3), 6168 lambda pkt: pkt.ext == 0), 6169 ConditionalField(BitField("screenId", 0x0, 2), 6170 lambda pkt: pkt.ext == 0), 6171 6172 BitField("nbDigit2", None, 4), 6173 BitField("nbDigit1", None, 4), 6174 6175 BitField("nbDigit4", None, 4), 6176 BitField("nbDigit3", None, 4), 6177 6178 BitField("nbDigit6", None, 4), 6179 BitField("nbDigit5", None, 4), 6180 6181 BitField("nbDigit8", None, 4), 6182 BitField("nbDigit7", None, 4), 6183 6184 BitField("nbDigit10", None, 4), 6185 BitField("nbDigit9", None, 4), 6186 6187 BitField("nbDigit12", None, 4), 6188 BitField("nbDigit11", None, 4), 6189 6190 BitField("nbDigit14", None, 4), 6191 BitField("nbDigit13", None, 4), 6192 6193 BitField("nbDigit16", None, 4), 6194 BitField("nbDigit15", None, 4), 6195 6196 BitField("nbDigit18", None, 4), 6197 BitField("nbDigit17", None, 4), 6198 6199 BitField("nbDigit20", None, 4), 6200 BitField("nbDigit19", None, 4), 6201 ] 6202 6203 def post_build(self, p, pay): 6204 a = [getattr(self, fld.name) for fld in self.fields_desc] 6205 res = adapt(4, 14, a, self.fields_desc) 6206 if res[0] != 0: 6207 p = p[:-res[0]] 6208 if self.lengthCPBN is None: 6209 p = p[:1] + struct.pack(">B", len(p)-2) + p[2:] 6210 return p + pay 6211 6212 6213# len 2 to 23 6214class CallingPartySubaddressHdr(Packet): 6215 """Calling party subaddress Section 10.5.4.10""" 6216 name = "Calling Party Subaddress" 6217 fields_desc = [ 6218 BitField("eightBitCPS", None, 1), 6219 XBitField("ieiCPS", None, 7), 6220 XByteField("lengthCPS", None), 6221 # optional 6222 BitField("ext1", None, 1), 6223 BitField("typeAddr", None, 3), 6224 BitField("oddEven", None, 1), 6225 BitField("spare", None, 3), 6226 6227 ByteField("subInfo0", None), 6228 ByteField("subInfo1", None), 6229 ByteField("subInfo2", None), 6230 ByteField("subInfo3", None), 6231 ByteField("subInfo4", None), 6232 ByteField("subInfo5", None), 6233 ByteField("subInfo6", None), 6234 ByteField("subInfo7", None), 6235 ByteField("subInfo8", None), 6236 ByteField("subInfo9", None), 6237 ByteField("subInfo10", None), 6238 ByteField("subInfo11", None), 6239 ByteField("subInfo12", None), 6240 ByteField("subInfo13", None), 6241 ByteField("subInfo14", None), 6242 ByteField("subInfo15", None), 6243 ByteField("subInfo16", None), 6244 ByteField("subInfo17", None), 6245 ByteField("subInfo18", None), 6246 ByteField("subInfo19", None) 6247 ] 6248 6249 def post_build(self, p, pay): 6250 a = [getattr(self, fld.name) for fld in self.fields_desc] 6251 res = adapt(2, 23, a, self.fields_desc) 6252 if self.lengthCPS is None: 6253 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 6254 if res[0] != 0: 6255 p = p[:-res[0]] 6256 return p + pay 6257 6258 6259# len 4 to 32 6260class CauseHdr(Packet): 6261 """Cause Section 10.5.4.11""" 6262 name = "Cause" 6263 fields_desc = [ 6264 BitField("eightBitC", None, 1), 6265 XBitField("ieiC", None, 7), 6266 6267 XByteField("lengthC", None), 6268 6269 BitField("ext", 0x1, 1), 6270 BitField("codingStd", 0x0, 2), 6271 BitField("spare", 0x0, 1), 6272 BitField("location", 0x0, 4), 6273 6274 ConditionalField(BitField("ext1", 0x1, 1), 6275 lambda pkt: pkt.ext == 0), 6276 ConditionalField(BitField("recommendation", 0x0, 7), 6277 lambda pkt: pkt.ext == 0), 6278 # optional 6279 BitField("ext2", None, 1), 6280 BitField("causeValue", None, 7), 6281 6282 ByteField("diagnositc0", None), 6283 ByteField("diagnositc1", None), 6284 ByteField("diagnositc2", None), 6285 ByteField("diagnositc3", None), 6286 ByteField("diagnositc4", None), 6287 ByteField("diagnositc5", None), 6288 ByteField("diagnositc6", None), 6289 ByteField("diagnositc7", None), 6290 ByteField("diagnositc8", None), 6291 ByteField("diagnositc9", None), 6292 ByteField("diagnositc10", None), 6293 ByteField("diagnositc11", None), 6294 ByteField("diagnositc12", None), 6295 ByteField("diagnositc13", None), 6296 ByteField("diagnositc14", None), 6297 ByteField("diagnositc15", None), 6298 ByteField("diagnositc16", None), 6299 ByteField("diagnositc17", None), 6300 ByteField("diagnositc18", None), 6301 ByteField("diagnositc19", None), 6302 ByteField("diagnositc20", None), 6303 ByteField("diagnositc21", None), 6304 ByteField("diagnositc22", None), 6305 ByteField("diagnositc23", None), 6306 ByteField("diagnositc24", None), 6307 ByteField("diagnositc25", None), 6308 ByteField("diagnositc26", None), 6309 ] 6310 6311 def post_build(self, p, pay): 6312 a = [getattr(self, fld.name) for fld in self.fields_desc] 6313 res = adapt(4, 32, a, self.fields_desc) 6314 if res[0] != 0: 6315 p = p[:-res[0]] 6316 if self.lengthC is None: 6317 p = p[:1] + struct.pack(">B", len(p)-2) + p[2:] 6318 return p + pay 6319 6320 6321class ClirSuppressionHdr(Packet): 6322 """CLIR suppression Section 10.5.4.11a""" 6323 name = "Clir Suppression" 6324 fields_desc = [ 6325 BitField("eightBitCS", None, 1), 6326 XBitField("ieiCS", None, 7), 6327 ] 6328 6329 6330class ClirInvocationHdr(Packet): 6331 """CLIR invocation Section 10.5.4.11b""" 6332 name = "Clir Invocation" 6333 fields_desc = [ 6334 BitField("eightBitCI", None, 1), 6335 XBitField("ieiCI", None, 7), 6336 ] 6337 6338 6339class CongestionLevelHdr(Packet): 6340 """Congestion level Section 10.5.4.12""" 6341 name = "Congestion Level" 6342 fields_desc = [ 6343 XBitField("ieiCL", None, 4), 6344 BitField("notDef", 0x0, 4) 6345 ] 6346 6347 6348# Fix 1/2 len problem 6349class CongestionLevelAndSpareHalfOctets(Packet): 6350 name = "Congestion Level and Spare Half Octets" 6351 fields_desc = [ 6352 BitField("ieiCL", 0x0, 4), 6353 BitField("spareHalfOctets", 0x0, 4) 6354 ] 6355 6356 6357# len 3 to 14 6358class ConnectedNumberHdr(Packet): 6359 """Connected number Section 10.5.4.13""" 6360 name = "Connected Number" 6361 fields_desc = [ 6362 BitField("eightBitCN", None, 1), 6363 XBitField("ieiCN", None, 7), 6364 6365 XByteField("lengthCN", None), 6366 6367 BitField("ext", 0x1, 1), 6368 BitField("typeNb", 0x0, 3), 6369 BitField("typePlanId", 0x0, 4), 6370 # optional 6371 ConditionalField(BitField("ext1", 0x1, 1), 6372 lambda pkt: pkt.ext == 0), 6373 ConditionalField(BitField("presId", None, 2), 6374 lambda pkt: pkt.ext == 0), 6375 ConditionalField(BitField("spare", None, 3), 6376 lambda pkt: pkt.ext == 0), 6377 ConditionalField(BitField("screenId", None, 2), 6378 lambda pkt: pkt.ext == 0), 6379 6380 BitField("nbDigit2", None, 4), 6381 BitField("nbDigit1", None, 4), 6382 6383 BitField("nbDigit4", None, 4), 6384 BitField("nbDigit3", None, 4), 6385 6386 BitField("nbDigit6", None, 4), 6387 BitField("nbDigit5", None, 4), 6388 6389 BitField("nbDigit8", None, 4), 6390 BitField("nbDigit7", None, 4), 6391 6392 BitField("nbDigit10", None, 4), 6393 BitField("nbDigit9", None, 4), 6394 6395 BitField("nbDigit12", None, 4), 6396 BitField("nbDigit11", None, 4), 6397 6398 BitField("nbDigit14", None, 4), 6399 BitField("nbDigit13", None, 4), 6400 6401 BitField("nbDigit16", None, 4), 6402 BitField("nbDigit15", None, 4), 6403 6404 BitField("nbDigit18", None, 4), 6405 BitField("nbDigit17", None, 4), 6406 6407 BitField("nbDigit20", None, 4), 6408 BitField("nbDigit19", None, 4) 6409 ] 6410 6411 def post_build(self, p, pay): 6412 a = [getattr(self, fld.name) for fld in self.fields_desc] 6413 res = adapt(3, 14, a, self.fields_desc) 6414 if res[0] != 0: 6415 p = p[:-res[0]] 6416 if self.lengthCN is None: 6417 p = p[:1] + struct.pack(">B", len(p)-2) + p[2:] 6418 return p + pay 6419 6420 6421# len 2 to 23 6422class ConnectedSubaddressHdr(Packet): 6423 """Connected subaddress Section 10.5.4.14""" 6424 name = "Connected Subaddress" 6425 fields_desc = [ 6426 BitField("eightBitCS", None, 1), 6427 XBitField("ieiCS", None, 7), 6428 6429 XByteField("lengthCS", None), 6430 # optional 6431 BitField("ext", None, 1), 6432 BitField("typeOfSub", None, 3), 6433 BitField("oddEven", None, 1), 6434 BitField("spare", None, 3), 6435 6436 ByteField("subInfo0", None), 6437 ByteField("subInfo1", None), 6438 ByteField("subInfo2", None), 6439 ByteField("subInfo3", None), 6440 ByteField("subInfo4", None), 6441 ByteField("subInfo5", None), 6442 ByteField("subInfo6", None), 6443 ByteField("subInfo7", None), 6444 ByteField("subInfo8", None), 6445 ByteField("subInfo9", None), 6446 ByteField("subInfo10", None), 6447 ByteField("subInfo11", None), 6448 ByteField("subInfo12", None), 6449 ByteField("subInfo13", None), 6450 ByteField("subInfo14", None), 6451 ByteField("subInfo15", None), 6452 ByteField("subInfo16", None), 6453 ByteField("subInfo17", None), 6454 ByteField("subInfo18", None), 6455 ByteField("subInfo19", None) 6456 ] 6457 6458 def post_build(self, p, pay): 6459 a = [getattr(self, fld.name) for fld in self.fields_desc] 6460 res = adapt(2, 23, a, self.fields_desc) 6461 if self.lengthCS is None: 6462 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 6463 if res[0] != 0: 6464 p = p[:-res[0]] 6465 return p + pay 6466 6467 6468# len 2 to L3 (251) (done) 6469class FacilityHdr(Packet): 6470 """Facility Section 10.5.4.15""" 6471 name = "Facility" 6472 fields_desc = [ 6473 BitField("eightBitF", None, 1), 6474 XBitField("ieiF", None, 7), 6475 XByteField("lengthF", None), 6476 # optional 6477 ByteField("facilityInfo1", None), 6478 ByteField("facilityInfo2", None), 6479 ByteField("facilityInfo3", None), 6480 ByteField("facilityInfo4", None), 6481 ByteField("facilityInfo5", None), 6482 ByteField("facilityInfo6", None), 6483 ByteField("facilityInfo7", None), 6484 ByteField("facilityInfo8", None), 6485 ByteField("facilityInfo9", None), 6486 ByteField("facilityInfo10", None), 6487 ByteField("facilityInfo11", None), 6488 ByteField("facilityInfo12", None), 6489 ByteField("facilityInfo13", None), 6490 ByteField("facilityInfo14", None), 6491 ByteField("facilityInfo15", None), 6492 ByteField("facilityInfo16", None), 6493 ByteField("facilityInfo17", None), 6494 ByteField("facilityInfo18", None), 6495 ByteField("facilityInfo19", None), 6496 ByteField("facilityInfo20", None), 6497 ByteField("facilityInfo21", None), 6498 ByteField("facilityInfo22", None), 6499 ByteField("facilityInfo23", None), 6500 ByteField("facilityInfo24", None), 6501 ByteField("facilityInfo25", None), 6502 ByteField("facilityInfo26", None), 6503 ByteField("facilityInfo27", None), 6504 ByteField("facilityInfo28", None), 6505 ByteField("facilityInfo29", None), 6506 ByteField("facilityInfo30", None), 6507 ByteField("facilityInfo31", None), 6508 ByteField("facilityInfo32", None), 6509 ByteField("facilityInfo33", None), 6510 ByteField("facilityInfo34", None), 6511 ByteField("facilityInfo35", None), 6512 ByteField("facilityInfo36", None), 6513 ByteField("facilityInfo37", None), 6514 ByteField("facilityInfo38", None), 6515 ByteField("facilityInfo39", None), 6516 ByteField("facilityInfo40", None), 6517 ByteField("facilityInfo41", None), 6518 ByteField("facilityInfo42", None), 6519 ByteField("facilityInfo43", None), 6520 ByteField("facilityInfo44", None), 6521 ByteField("facilityInfo45", None), 6522 ByteField("facilityInfo46", None), 6523 ByteField("facilityInfo47", None), 6524 ByteField("facilityInfo48", None), 6525 ByteField("facilityInfo49", None), 6526 ByteField("facilityInfo50", None), 6527 ByteField("facilityInfo51", None), 6528 ByteField("facilityInfo52", None), 6529 ByteField("facilityInfo53", None), 6530 ByteField("facilityInfo54", None), 6531 ByteField("facilityInfo55", None), 6532 ByteField("facilityInfo56", None), 6533 ByteField("facilityInfo57", None), 6534 ByteField("facilityInfo58", None), 6535 ByteField("facilityInfo59", None), 6536 ByteField("facilityInfo60", None), 6537 ByteField("facilityInfo61", None), 6538 ByteField("facilityInfo62", None), 6539 ByteField("facilityInfo63", None), 6540 ByteField("facilityInfo64", None), 6541 ByteField("facilityInfo65", None), 6542 ByteField("facilityInfo66", None), 6543 ByteField("facilityInfo67", None), 6544 ByteField("facilityInfo68", None), 6545 ByteField("facilityInfo69", None), 6546 ByteField("facilityInfo70", None), 6547 ByteField("facilityInfo71", None), 6548 ByteField("facilityInfo72", None), 6549 ByteField("facilityInfo73", None), 6550 ByteField("facilityInfo74", None), 6551 ByteField("facilityInfo75", None), 6552 ByteField("facilityInfo76", None), 6553 ByteField("facilityInfo77", None), 6554 ByteField("facilityInfo78", None), 6555 ByteField("facilityInfo79", None), 6556 ByteField("facilityInfo80", None), 6557 ByteField("facilityInfo81", None), 6558 ByteField("facilityInfo82", None), 6559 ByteField("facilityInfo83", None), 6560 ByteField("facilityInfo84", None), 6561 ByteField("facilityInfo85", None), 6562 ByteField("facilityInfo86", None), 6563 ByteField("facilityInfo87", None), 6564 ByteField("facilityInfo88", None), 6565 ByteField("facilityInfo89", None), 6566 ByteField("facilityInfo90", None), 6567 ByteField("facilityInfo91", None), 6568 ByteField("facilityInfo92", None), 6569 ByteField("facilityInfo93", None), 6570 ByteField("facilityInfo94", None), 6571 ByteField("facilityInfo95", None), 6572 ByteField("facilityInfo96", None), 6573 ByteField("facilityInfo97", None), 6574 ByteField("facilityInfo98", None), 6575 ByteField("facilityInfo99", None), 6576 ByteField("facilityInfo100", None), 6577 ByteField("facilityInfo101", None), 6578 ByteField("facilityInfo102", None), 6579 ByteField("facilityInfo103", None), 6580 ByteField("facilityInfo104", None), 6581 ByteField("facilityInfo105", None), 6582 ByteField("facilityInfo106", None), 6583 ByteField("facilityInfo107", None), 6584 ByteField("facilityInfo108", None), 6585 ByteField("facilityInfo109", None), 6586 ByteField("facilityInfo110", None), 6587 ByteField("facilityInfo111", None), 6588 ByteField("facilityInfo112", None), 6589 ByteField("facilityInfo113", None), 6590 ByteField("facilityInfo114", None), 6591 ByteField("facilityInfo115", None), 6592 ByteField("facilityInfo116", None), 6593 ByteField("facilityInfo117", None), 6594 ByteField("facilityInfo118", None), 6595 ByteField("facilityInfo119", None), 6596 ByteField("facilityInfo120", None), 6597 ByteField("facilityInfo121", None), 6598 ByteField("facilityInfo122", None), 6599 ByteField("facilityInfo123", None), 6600 ByteField("facilityInfo124", None), 6601 ByteField("facilityInfo125", None), 6602 ByteField("facilityInfo126", None), 6603 ByteField("facilityInfo127", None), 6604 ByteField("facilityInfo128", None), 6605 ByteField("facilityInfo129", None), 6606 ByteField("facilityInfo130", None), 6607 ByteField("facilityInfo131", None), 6608 ByteField("facilityInfo132", None), 6609 ByteField("facilityInfo133", None), 6610 ByteField("facilityInfo134", None), 6611 ByteField("facilityInfo135", None), 6612 ByteField("facilityInfo136", None), 6613 ByteField("facilityInfo137", None), 6614 ByteField("facilityInfo138", None), 6615 ByteField("facilityInfo139", None), 6616 ByteField("facilityInfo140", None), 6617 ByteField("facilityInfo141", None), 6618 ByteField("facilityInfo142", None), 6619 ByteField("facilityInfo143", None), 6620 ByteField("facilityInfo144", None), 6621 ByteField("facilityInfo145", None), 6622 ByteField("facilityInfo146", None), 6623 ByteField("facilityInfo147", None), 6624 ByteField("facilityInfo148", None), 6625 ByteField("facilityInfo149", None), 6626 ByteField("facilityInfo150", None), 6627 ByteField("facilityInfo151", None), 6628 ByteField("facilityInfo152", None), 6629 ByteField("facilityInfo153", None), 6630 ByteField("facilityInfo154", None), 6631 ByteField("facilityInfo155", None), 6632 ByteField("facilityInfo156", None), 6633 ByteField("facilityInfo157", None), 6634 ByteField("facilityInfo158", None), 6635 ByteField("facilityInfo159", None), 6636 ByteField("facilityInfo160", None), 6637 ByteField("facilityInfo161", None), 6638 ByteField("facilityInfo162", None), 6639 ByteField("facilityInfo163", None), 6640 ByteField("facilityInfo164", None), 6641 ByteField("facilityInfo165", None), 6642 ByteField("facilityInfo166", None), 6643 ByteField("facilityInfo167", None), 6644 ByteField("facilityInfo168", None), 6645 ByteField("facilityInfo169", None), 6646 ByteField("facilityInfo170", None), 6647 ByteField("facilityInfo171", None), 6648 ByteField("facilityInfo172", None), 6649 ByteField("facilityInfo173", None), 6650 ByteField("facilityInfo174", None), 6651 ByteField("facilityInfo175", None), 6652 ByteField("facilityInfo176", None), 6653 ByteField("facilityInfo177", None), 6654 ByteField("facilityInfo178", None), 6655 ByteField("facilityInfo179", None), 6656 ByteField("facilityInfo180", None), 6657 ByteField("facilityInfo181", None), 6658 ByteField("facilityInfo182", None), 6659 ByteField("facilityInfo183", None), 6660 ByteField("facilityInfo184", None), 6661 ByteField("facilityInfo185", None), 6662 ByteField("facilityInfo186", None), 6663 ByteField("facilityInfo187", None), 6664 ByteField("facilityInfo188", None), 6665 ByteField("facilityInfo189", None), 6666 ByteField("facilityInfo190", None), 6667 ByteField("facilityInfo191", None), 6668 ByteField("facilityInfo192", None), 6669 ByteField("facilityInfo193", None), 6670 ByteField("facilityInfo194", None), 6671 ByteField("facilityInfo195", None), 6672 ByteField("facilityInfo196", None), 6673 ByteField("facilityInfo197", None), 6674 ByteField("facilityInfo198", None), 6675 ByteField("facilityInfo199", None), 6676 ByteField("facilityInfo200", None), 6677 ByteField("facilityInfo201", None), 6678 ByteField("facilityInfo202", None), 6679 ByteField("facilityInfo203", None), 6680 ByteField("facilityInfo204", None), 6681 ByteField("facilityInfo205", None), 6682 ByteField("facilityInfo206", None), 6683 ByteField("facilityInfo207", None), 6684 ByteField("facilityInfo208", None), 6685 ByteField("facilityInfo209", None), 6686 ByteField("facilityInfo210", None), 6687 ByteField("facilityInfo211", None), 6688 ByteField("facilityInfo212", None), 6689 ByteField("facilityInfo213", None), 6690 ByteField("facilityInfo214", None), 6691 ByteField("facilityInfo215", None), 6692 ByteField("facilityInfo216", None), 6693 ByteField("facilityInfo217", None), 6694 ByteField("facilityInfo218", None), 6695 ByteField("facilityInfo219", None), 6696 ByteField("facilityInfo220", None), 6697 ByteField("facilityInfo221", None), 6698 ByteField("facilityInfo222", None), 6699 ByteField("facilityInfo223", None), 6700 ByteField("facilityInfo224", None), 6701 ByteField("facilityInfo225", None), 6702 ByteField("facilityInfo226", None), 6703 ByteField("facilityInfo227", None), 6704 ByteField("facilityInfo228", None), 6705 ByteField("facilityInfo229", None), 6706 ByteField("facilityInfo230", None), 6707 ByteField("facilityInfo231", None), 6708 ByteField("facilityInfo232", None), 6709 ByteField("facilityInfo233", None), 6710 ByteField("facilityInfo234", None), 6711 ByteField("facilityInfo235", None), 6712 ByteField("facilityInfo236", None), 6713 ByteField("facilityInfo237", None), 6714 ByteField("facilityInfo238", None), 6715 ByteField("facilityInfo239", None), 6716 ByteField("facilityInfo240", None), 6717 ByteField("facilityInfo241", None), 6718 ByteField("facilityInfo242", None), 6719 ByteField("facilityInfo243", None), 6720 ByteField("facilityInfo244", None), 6721 ByteField("facilityInfo245", None), 6722 ByteField("facilityInfo246", None), 6723 ByteField("facilityInfo247", None), 6724 ByteField("facilityInfo248", None), 6725 ByteField("facilityInfo249", None) 6726 ] 6727 6728 def post_build(self, p, pay): 6729 a = [getattr(self, fld.name) for fld in self.fields_desc] 6730 res = adapt(2, 251, a, self.fields_desc) 6731 if self.lengthF is None: 6732 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 6733 if res[0] != 0: 6734 p = p[:-res[0]] 6735 return p + pay 6736 6737 6738#len 2 to 5 6739class HighLayerCompatibilityHdr(Packet): 6740 """High layer compatibility Section 10.5.4.16""" 6741 name = "High Layer Compatibility" 6742 fields_desc = [ 6743 BitField("eightBitHLC", None, 1), 6744 XBitField("ieiHLC", None, 7), 6745 6746 XByteField("lengthHLC", None), 6747 # optional 6748 BitField("ext", None, 1), 6749 BitField("codingStd", None, 2), 6750 BitField("interpret", None, 3), 6751 BitField("presMeth", None, 2), 6752 6753 BitField("ext1", None, 1), 6754 BitField("highLayerId", None, 7), 6755 6756 ConditionalField(BitField("ext2", 0x1, 1), 6757 lambda pkt: pkt.ext1 == 0), 6758 ConditionalField(BitField("exHiLayerId", 0x0, 7), 6759 lambda pkt: pkt.ext1 == 0) 6760 ] 6761 6762 def post_build(self, p, pay): 6763 a = [getattr(self, fld.name) for fld in self.fields_desc] 6764 res = adapt(2, 5, a, self.fields_desc) 6765 if res[0] != 0: 6766 p = p[:-res[0]] 6767 if self.lengthHLC is None: 6768 p = p[:1] + struct.pack(">B", len(p)-2) + p[2:] 6769 return p + pay 6770# 6771# 10.5.4.16.1 Static conditions for the high layer 6772# compatibility IE contents 6773# 6774 6775 6776class KeypadFacilityHdr(Packet): 6777 """Keypad facility Section 10.5.4.17""" 6778 name = "Keypad Facility" 6779 fields_desc = [ 6780 BitField("eightBitKF", None, 1), 6781 XBitField("ieiKF", None, 7), 6782 BitField("spare", 0x0, 1), 6783 BitField("keyPadInfo", 0x0, 7) 6784 ] 6785 6786 6787# len 2 to 15 6788class LowLayerCompatibilityHdr(Packet): 6789 """Low layer compatibility Section 10.5.4.18""" 6790 name = "Low Layer Compatibility" 6791 fields_desc = [ 6792 BitField("eightBitLLC", None, 1), 6793 XBitField("ieiLLC", None, 7), 6794 6795 XByteField("lengthLLC", None), 6796 # optional 6797 ByteField("rest0", None), 6798 ByteField("rest1", None), 6799 ByteField("rest2", None), 6800 ByteField("rest3", None), 6801 ByteField("rest4", None), 6802 ByteField("rest5", None), 6803 ByteField("rest6", None), 6804 ByteField("rest7", None), 6805 ByteField("rest8", None), 6806 ByteField("rest9", None), 6807 ByteField("rest10", None), 6808 ByteField("rest11", None), 6809 ByteField("rest12", None) 6810 ] 6811 6812 def post_build(self, p, pay): 6813 a = [getattr(self, fld.name) for fld in self.fields_desc] 6814 res = adapt(2, 15, a, self.fields_desc) 6815 if self.lengthLLC is None: 6816 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 6817 if res[0] != 0: 6818 p = p[:-res[0]] 6819 return p + pay 6820 6821 6822class MoreDataHdr(Packet): 6823 """More data Section 10.5.4.19""" 6824 name = "More Data" 6825 fields_desc = [ 6826 BitField("eightBitMD", None, 1), 6827 XBitField("ieiMD", None, 7), 6828 ] 6829 6830 6831class NotificationIndicatorHdr(Packet): 6832 """Notification indicator Section 10.5.4.20""" 6833 name = "Notification Indicator" 6834 fields_desc = [ 6835 BitField("eightBitNI", None, 1), 6836 XBitField("ieiNI", None, 7), 6837 BitField("ext", 0x1, 1), 6838 BitField("notifDesc", 0x0, 7) 6839 ] 6840 6841 6842class ProgressIndicatorHdr(Packet): 6843 """Progress indicator Section 10.5.4.21""" 6844 name = "Progress Indicator" 6845 fields_desc = [ 6846 BitField("eightBitPI", None, 1), 6847 XBitField("ieiPI", None, 7), 6848 XByteField("lengthPI", 0x2), 6849 BitField("ext", 0x1, 1), 6850 BitField("codingStd", 0x0, 2), 6851 BitField("spare", 0x0, 1), 6852 BitField("location", 0x0, 4), 6853 BitField("ext1", 0x1, 1), 6854 BitField("progressDesc", 0x0, 7) 6855 ] 6856 6857 6858class RecallTypeHdr(Packet): 6859 """Recall type $(CCBS)$ Section 10.5.4.21a""" 6860 name = "Recall Type $(CCBS)$" 6861 fields_desc = [ 6862 BitField("eightBitRT", None, 1), 6863 XBitField("ieiRT", None, 7), 6864 BitField("spare", 0x0, 5), 6865 BitField("recallType", 0x0, 3) 6866 ] 6867 6868 6869# len 3 to 19 6870class RedirectingPartyBcdNumberHdr(Packet): 6871 """Redirecting party BCD number Section 10.5.4.21b""" 6872 name = "Redirecting Party BCD Number" 6873 fields_desc = [ 6874 BitField("eightBitRPBN", None, 1), 6875 XBitField("ieiRPBN", None, 7), 6876 6877 XByteField("lengthRPBN", None), 6878 6879 BitField("ext", 0x1, 1), 6880 BitField("typeNb", 0x0, 3), 6881 BitField("numberingPlan", 0x0, 4), 6882 # optional 6883 ConditionalField(BitField("ext1", 0x1, 1), 6884 lambda pkt: pkt.ext == 0), 6885 ConditionalField(BitField("presId", None, 2), 6886 lambda pkt: pkt.ext == 0), 6887 ConditionalField(BitField("spare", None, 3), 6888 lambda pkt: pkt.ext == 0), 6889 ConditionalField(BitField("screenId", None, 2), 6890 lambda pkt: pkt.ext == 0), 6891 6892 BitField("nbDigit2", None, 4), 6893 BitField("nbDigit1", None, 4), 6894 6895 BitField("nbDigit4", None, 4), 6896 BitField("nbDigit3", None, 4), 6897 6898 BitField("nbDigit6", None, 4), 6899 BitField("nbDigit5", None, 4), 6900 6901 BitField("nbDigit8", None, 4), 6902 BitField("nbDigit7", None, 4), 6903 6904 BitField("nbDigit10", None, 4), 6905 BitField("nbDigit9", None, 4), 6906 6907 BitField("nbDigit12", None, 4), 6908 BitField("nbDigit11", None, 4), 6909 6910 BitField("nbDigit14", None, 4), 6911 BitField("nbDigit13", None, 4), 6912 6913 BitField("nbDigit16", None, 4), 6914 BitField("nbDigit15", None, 4), 6915 6916 BitField("nbDigit18", None, 4), 6917 BitField("nbDigit17", None, 4), 6918 6919 BitField("nbDigit20", None, 4), 6920 BitField("nbDigit19", None, 4), 6921 6922 BitField("nbDigit22", None, 4), 6923 BitField("nbDigit21", None, 4), 6924 6925 BitField("nbDigit24", None, 4), 6926 BitField("nbDigit23", None, 4), 6927 6928 BitField("nbDigit26", None, 4), 6929 BitField("nbDigit25", None, 4), 6930 6931 BitField("nbDigit28", None, 4), 6932 BitField("nbDigit27", None, 4), 6933 6934 BitField("nbDigit30", None, 4), 6935 BitField("nbDigit29", None, 4), 6936 ] 6937 6938 def post_build(self, p, pay): 6939 a = [getattr(self, fld.name) for fld in self.fields_desc] 6940 res = adapt(3, 19, a, self.fields_desc) 6941 if res[0] != 0: 6942 p = p[:-res[0]] 6943 if self.lengthRPBN is None: 6944 p = p[:1] + struct.pack(">B", len(p)-2) + p[2:] 6945 return p + pay 6946 6947 6948# length 2 to 23 6949class RedirectingPartySubaddressHdr(Packet): 6950 """Redirecting party subaddress Section 10.5.4.21c""" 6951 name = "Redirecting Party BCD Number" 6952 fields_desc = [ 6953 BitField("eightBitRPS", None, 1), 6954 XBitField("ieiRPS", None, 7), 6955 6956 XByteField("lengthRPS", None), 6957 # optional 6958 BitField("ext", None, 1), 6959 BitField("typeSub", None, 3), 6960 BitField("oddEven", None, 1), 6961 BitField("spare", None, 3), 6962 6963 ByteField("subInfo0", None), 6964 ByteField("subInfo1", None), 6965 ByteField("subInfo2", None), 6966 ByteField("subInfo3", None), 6967 ByteField("subInfo4", None), 6968 ByteField("subInfo5", None), 6969 ByteField("subInfo6", None), 6970 ByteField("subInfo7", None), 6971 ByteField("subInfo8", None), 6972 ByteField("subInfo9", None), 6973 ByteField("subInfo10", None), 6974 ByteField("subInfo11", None), 6975 ByteField("subInfo12", None), 6976 ByteField("subInfo13", None), 6977 ByteField("subInfo14", None), 6978 ByteField("subInfo15", None), 6979 ByteField("subInfo16", None), 6980 ByteField("subInfo17", None), 6981 ByteField("subInfo18", None), 6982 ByteField("subInfo19", None) 6983 ] 6984 6985 def post_build(self, p, pay): 6986 a = [getattr(self, fld.name) for fld in self.fields_desc] 6987 res = adapt(2, 23, a, self.fields_desc) 6988 if self.lengthRPS is None: 6989 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 6990 if res[0] != 0: 6991 p = p[:-res[0]] 6992 return p + pay 6993 6994 6995class RepeatIndicatorHdr(Packet): 6996 """Repeat indicator Section 10.5.4.22""" 6997 name = "Repeat Indicator" 6998 fields_desc = [ 6999 XBitField("ieiRI", None, 4), 7000 BitField("repeatIndic", 0x0, 4) 7001 ] 7002 7003 7004class ReverseCallSetupDirectionHdr(Packet): 7005 """Reverse call setup direction Section 10.5.4.22a""" 7006 name = "Reverse Call Setup Direction" 7007 fields_desc = [ 7008 ByteField("ieiRCSD", 0x0) 7009 ] 7010 7011 7012# no upper length min 2(max for L3) (251) 7013class SetupContainerHdr(Packet): 7014 """SETUP Container $(CCBS)$ Section 10.5.4.22b""" 7015 name = "Setup Container $(CCBS)$" 7016 fields_desc = [ 7017 BitField("eightBitSC", None, 1), 7018 XBitField("ieiSC", None, 7), 7019 XByteField("lengthSC", None), 7020 # optional 7021 ByteField("mess1", None), 7022 ByteField("mess2", None), 7023 ByteField("mess3", None), 7024 ByteField("mess4", None), 7025 ByteField("mess5", None), 7026 ByteField("mess6", None), 7027 ByteField("mess7", None), 7028 ByteField("mess8", None), 7029 ByteField("mess9", None), 7030 ByteField("mess10", None), 7031 ByteField("mess11", None), 7032 ByteField("mess12", None), 7033 ByteField("mess13", None), 7034 ByteField("mess14", None), 7035 ByteField("mess15", None), 7036 ByteField("mess16", None), 7037 ByteField("mess17", None), 7038 ByteField("mess18", None), 7039 ByteField("mess19", None), 7040 ByteField("mess20", None), 7041 ByteField("mess21", None), 7042 ByteField("mess22", None), 7043 ByteField("mess23", None), 7044 ByteField("mess24", None), 7045 ByteField("mess25", None), 7046 ByteField("mess26", None), 7047 ByteField("mess27", None), 7048 ByteField("mess28", None), 7049 ByteField("mess29", None), 7050 ByteField("mess30", None), 7051 ByteField("mess31", None), 7052 ByteField("mess32", None), 7053 ByteField("mess33", None), 7054 ByteField("mess34", None), 7055 ByteField("mess35", None), 7056 ByteField("mess36", None), 7057 ByteField("mess37", None), 7058 ByteField("mess38", None), 7059 ByteField("mess39", None), 7060 ByteField("mess40", None), 7061 ByteField("mess41", None), 7062 ByteField("mess42", None), 7063 ByteField("mess43", None), 7064 ByteField("mess44", None), 7065 ByteField("mess45", None), 7066 ByteField("mess46", None), 7067 ByteField("mess47", None), 7068 ByteField("mess48", None), 7069 ByteField("mess49", None), 7070 ByteField("mess50", None), 7071 ByteField("mess51", None), 7072 ByteField("mess52", None), 7073 ByteField("mess53", None), 7074 ByteField("mess54", None), 7075 ByteField("mess55", None), 7076 ByteField("mess56", None), 7077 ByteField("mess57", None), 7078 ByteField("mess58", None), 7079 ByteField("mess59", None), 7080 ByteField("mess60", None), 7081 ByteField("mess61", None), 7082 ByteField("mess62", None), 7083 ByteField("mess63", None), 7084 ByteField("mess64", None), 7085 ByteField("mess65", None), 7086 ByteField("mess66", None), 7087 ByteField("mess67", None), 7088 ByteField("mess68", None), 7089 ByteField("mess69", None), 7090 ByteField("mess70", None), 7091 ByteField("mess71", None), 7092 ByteField("mess72", None), 7093 ByteField("mess73", None), 7094 ByteField("mess74", None), 7095 ByteField("mess75", None), 7096 ByteField("mess76", None), 7097 ByteField("mess77", None), 7098 ByteField("mess78", None), 7099 ByteField("mess79", None), 7100 ByteField("mess80", None), 7101 ByteField("mess81", None), 7102 ByteField("mess82", None), 7103 ByteField("mess83", None), 7104 ByteField("mess84", None), 7105 ByteField("mess85", None), 7106 ByteField("mess86", None), 7107 ByteField("mess87", None), 7108 ByteField("mess88", None), 7109 ByteField("mess89", None), 7110 ByteField("mess90", None), 7111 ByteField("mess91", None), 7112 ByteField("mess92", None), 7113 ByteField("mess93", None), 7114 ByteField("mess94", None), 7115 ByteField("mess95", None), 7116 ByteField("mess96", None), 7117 ByteField("mess97", None), 7118 ByteField("mess98", None), 7119 ByteField("mess99", None), 7120 ByteField("mess100", None), 7121 ByteField("mess101", None), 7122 ByteField("mess102", None), 7123 ByteField("mess103", None), 7124 ByteField("mess104", None), 7125 ByteField("mess105", None), 7126 ByteField("mess106", None), 7127 ByteField("mess107", None), 7128 ByteField("mess108", None), 7129 ByteField("mess109", None), 7130 ByteField("mess110", None), 7131 ByteField("mess111", None), 7132 ByteField("mess112", None), 7133 ByteField("mess113", None), 7134 ByteField("mess114", None), 7135 ByteField("mess115", None), 7136 ByteField("mess116", None), 7137 ByteField("mess117", None), 7138 ByteField("mess118", None), 7139 ByteField("mess119", None), 7140 ByteField("mess120", None), 7141 ByteField("mess121", None), 7142 ByteField("mess122", None), 7143 ByteField("mess123", None), 7144 ByteField("mess124", None), 7145 ByteField("mess125", None), 7146 ByteField("mess126", None), 7147 ByteField("mess127", None), 7148 ByteField("mess128", None), 7149 ByteField("mess129", None), 7150 ByteField("mess130", None), 7151 ByteField("mess131", None), 7152 ByteField("mess132", None), 7153 ByteField("mess133", None), 7154 ByteField("mess134", None), 7155 ByteField("mess135", None), 7156 ByteField("mess136", None), 7157 ByteField("mess137", None), 7158 ByteField("mess138", None), 7159 ByteField("mess139", None), 7160 ByteField("mess140", None), 7161 ByteField("mess141", None), 7162 ByteField("mess142", None), 7163 ByteField("mess143", None), 7164 ByteField("mess144", None), 7165 ByteField("mess145", None), 7166 ByteField("mess146", None), 7167 ByteField("mess147", None), 7168 ByteField("mess148", None), 7169 ByteField("mess149", None), 7170 ByteField("mess150", None), 7171 ByteField("mess151", None), 7172 ByteField("mess152", None), 7173 ByteField("mess153", None), 7174 ByteField("mess154", None), 7175 ByteField("mess155", None), 7176 ByteField("mess156", None), 7177 ByteField("mess157", None), 7178 ByteField("mess158", None), 7179 ByteField("mess159", None), 7180 ByteField("mess160", None), 7181 ByteField("mess161", None), 7182 ByteField("mess162", None), 7183 ByteField("mess163", None), 7184 ByteField("mess164", None), 7185 ByteField("mess165", None), 7186 ByteField("mess166", None), 7187 ByteField("mess167", None), 7188 ByteField("mess168", None), 7189 ByteField("mess169", None), 7190 ByteField("mess170", None), 7191 ByteField("mess171", None), 7192 ByteField("mess172", None), 7193 ByteField("mess173", None), 7194 ByteField("mess174", None), 7195 ByteField("mess175", None), 7196 ByteField("mess176", None), 7197 ByteField("mess177", None), 7198 ByteField("mess178", None), 7199 ByteField("mess179", None), 7200 ByteField("mess180", None), 7201 ByteField("mess181", None), 7202 ByteField("mess182", None), 7203 ByteField("mess183", None), 7204 ByteField("mess184", None), 7205 ByteField("mess185", None), 7206 ByteField("mess186", None), 7207 ByteField("mess187", None), 7208 ByteField("mess188", None), 7209 ByteField("mess189", None), 7210 ByteField("mess190", None), 7211 ByteField("mess191", None), 7212 ByteField("mess192", None), 7213 ByteField("mess193", None), 7214 ByteField("mess194", None), 7215 ByteField("mess195", None), 7216 ByteField("mess196", None), 7217 ByteField("mess197", None), 7218 ByteField("mess198", None), 7219 ByteField("mess199", None), 7220 ByteField("mess200", None), 7221 ByteField("mess201", None), 7222 ByteField("mess202", None), 7223 ByteField("mess203", None), 7224 ByteField("mess204", None), 7225 ByteField("mess205", None), 7226 ByteField("mess206", None), 7227 ByteField("mess207", None), 7228 ByteField("mess208", None), 7229 ByteField("mess209", None), 7230 ByteField("mess210", None), 7231 ByteField("mess211", None), 7232 ByteField("mess212", None), 7233 ByteField("mess213", None), 7234 ByteField("mess214", None), 7235 ByteField("mess215", None), 7236 ByteField("mess216", None), 7237 ByteField("mess217", None), 7238 ByteField("mess218", None), 7239 ByteField("mess219", None), 7240 ByteField("mess220", None), 7241 ByteField("mess221", None), 7242 ByteField("mess222", None), 7243 ByteField("mess223", None), 7244 ByteField("mess224", None), 7245 ByteField("mess225", None), 7246 ByteField("mess226", None), 7247 ByteField("mess227", None), 7248 ByteField("mess228", None), 7249 ByteField("mess229", None), 7250 ByteField("mess230", None), 7251 ByteField("mess231", None), 7252 ByteField("mess232", None), 7253 ByteField("mess233", None), 7254 ByteField("mess234", None), 7255 ByteField("mess235", None), 7256 ByteField("mess236", None), 7257 ByteField("mess237", None), 7258 ByteField("mess238", None), 7259 ByteField("mess239", None), 7260 ByteField("mess240", None), 7261 ByteField("mess241", None), 7262 ByteField("mess242", None), 7263 ByteField("mess243", None), 7264 ByteField("mess244", None), 7265 ByteField("mess245", None), 7266 ByteField("mess246", None), 7267 ByteField("mess247", None), 7268 ByteField("mess248", None), 7269 ByteField("mess249", None), 7270 ] 7271 7272 def post_build(self, p, pay): 7273 a = [getattr(self, fld.name) for fld in self.fields_desc] 7274 res = adapt(2, 251, a, self.fields_desc) 7275 if self.lengthSC is None: 7276 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 7277 if res[0] != 0: 7278 p = p[:-res[0]] 7279 return p + pay 7280 7281 7282class SignalHdr(Packet): 7283 """Signal Section 10.5.4.23""" 7284 name = "Signal" 7285 fields_desc = [ 7286 BitField("eightBitS", None, 1), 7287 XBitField("ieiS", None, 7), 7288 ByteField("sigValue", 0x0) 7289 ] 7290 7291 7292# length 2 to max for L3 message (251) 7293class SsVersionIndicatorHdr(Packet): 7294 """SS Version Indicator Section 10.5.4.24""" 7295 name = "SS Version Indicator" 7296 fields_desc = [ 7297 BitField("eightBitSVI", None, 1), 7298 XBitField("ieiSVI", None, 7), 7299 XByteField("lengthSVI", None), 7300 # optional 7301 ByteField("info1", None), 7302 ByteField("info2", None), 7303 ByteField("info3", None), 7304 ByteField("info4", None), 7305 ByteField("info5", None), 7306 ByteField("info6", None), 7307 ByteField("info7", None), 7308 ByteField("info8", None), 7309 ByteField("info9", None), 7310 ByteField("info10", None), 7311 ByteField("info11", None), 7312 ByteField("info12", None), 7313 ByteField("info13", None), 7314 ByteField("info14", None), 7315 ByteField("info15", None), 7316 ByteField("info16", None), 7317 ByteField("info17", None), 7318 ByteField("info18", None), 7319 ByteField("info19", None), 7320 ByteField("info20", None), 7321 ByteField("info21", None), 7322 ByteField("info22", None), 7323 ByteField("info23", None), 7324 ByteField("info24", None), 7325 ByteField("info25", None), 7326 ByteField("info26", None), 7327 ByteField("info27", None), 7328 ByteField("info28", None), 7329 ByteField("info29", None), 7330 ByteField("info30", None), 7331 ByteField("info31", None), 7332 ByteField("info32", None), 7333 ByteField("info33", None), 7334 ByteField("info34", None), 7335 ByteField("info35", None), 7336 ByteField("info36", None), 7337 ByteField("info37", None), 7338 ByteField("info38", None), 7339 ByteField("info39", None), 7340 ByteField("info40", None), 7341 ByteField("info41", None), 7342 ByteField("info42", None), 7343 ByteField("info43", None), 7344 ByteField("info44", None), 7345 ByteField("info45", None), 7346 ByteField("info46", None), 7347 ByteField("info47", None), 7348 ByteField("info48", None), 7349 ByteField("info49", None), 7350 ByteField("info50", None), 7351 ByteField("info51", None), 7352 ByteField("info52", None), 7353 ByteField("info53", None), 7354 ByteField("info54", None), 7355 ByteField("info55", None), 7356 ByteField("info56", None), 7357 ByteField("info57", None), 7358 ByteField("info58", None), 7359 ByteField("info59", None), 7360 ByteField("info60", None), 7361 ByteField("info61", None), 7362 ByteField("info62", None), 7363 ByteField("info63", None), 7364 ByteField("info64", None), 7365 ByteField("info65", None), 7366 ByteField("info66", None), 7367 ByteField("info67", None), 7368 ByteField("info68", None), 7369 ByteField("info69", None), 7370 ByteField("info70", None), 7371 ByteField("info71", None), 7372 ByteField("info72", None), 7373 ByteField("info73", None), 7374 ByteField("info74", None), 7375 ByteField("info75", None), 7376 ByteField("info76", None), 7377 ByteField("info77", None), 7378 ByteField("info78", None), 7379 ByteField("info79", None), 7380 ByteField("info80", None), 7381 ByteField("info81", None), 7382 ByteField("info82", None), 7383 ByteField("info83", None), 7384 ByteField("info84", None), 7385 ByteField("info85", None), 7386 ByteField("info86", None), 7387 ByteField("info87", None), 7388 ByteField("info88", None), 7389 ByteField("info89", None), 7390 ByteField("info90", None), 7391 ByteField("info91", None), 7392 ByteField("info92", None), 7393 ByteField("info93", None), 7394 ByteField("info94", None), 7395 ByteField("info95", None), 7396 ByteField("info96", None), 7397 ByteField("info97", None), 7398 ByteField("info98", None), 7399 ByteField("info99", None), 7400 ByteField("info100", None), 7401 ByteField("info101", None), 7402 ByteField("info102", None), 7403 ByteField("info103", None), 7404 ByteField("info104", None), 7405 ByteField("info105", None), 7406 ByteField("info106", None), 7407 ByteField("info107", None), 7408 ByteField("info108", None), 7409 ByteField("info109", None), 7410 ByteField("info110", None), 7411 ByteField("info111", None), 7412 ByteField("info112", None), 7413 ByteField("info113", None), 7414 ByteField("info114", None), 7415 ByteField("info115", None), 7416 ByteField("info116", None), 7417 ByteField("info117", None), 7418 ByteField("info118", None), 7419 ByteField("info119", None), 7420 ByteField("info120", None), 7421 ByteField("info121", None), 7422 ByteField("info122", None), 7423 ByteField("info123", None), 7424 ByteField("info124", None), 7425 ByteField("info125", None), 7426 ByteField("info126", None), 7427 ByteField("info127", None), 7428 ByteField("info128", None), 7429 ByteField("info129", None), 7430 ByteField("info130", None), 7431 ByteField("info131", None), 7432 ByteField("info132", None), 7433 ByteField("info133", None), 7434 ByteField("info134", None), 7435 ByteField("info135", None), 7436 ByteField("info136", None), 7437 ByteField("info137", None), 7438 ByteField("info138", None), 7439 ByteField("info139", None), 7440 ByteField("info140", None), 7441 ByteField("info141", None), 7442 ByteField("info142", None), 7443 ByteField("info143", None), 7444 ByteField("info144", None), 7445 ByteField("info145", None), 7446 ByteField("info146", None), 7447 ByteField("info147", None), 7448 ByteField("info148", None), 7449 ByteField("info149", None), 7450 ByteField("info150", None), 7451 ByteField("info151", None), 7452 ByteField("info152", None), 7453 ByteField("info153", None), 7454 ByteField("info154", None), 7455 ByteField("info155", None), 7456 ByteField("info156", None), 7457 ByteField("info157", None), 7458 ByteField("info158", None), 7459 ByteField("info159", None), 7460 ByteField("info160", None), 7461 ByteField("info161", None), 7462 ByteField("info162", None), 7463 ByteField("info163", None), 7464 ByteField("info164", None), 7465 ByteField("info165", None), 7466 ByteField("info166", None), 7467 ByteField("info167", None), 7468 ByteField("info168", None), 7469 ByteField("info169", None), 7470 ByteField("info170", None), 7471 ByteField("info171", None), 7472 ByteField("info172", None), 7473 ByteField("info173", None), 7474 ByteField("info174", None), 7475 ByteField("info175", None), 7476 ByteField("info176", None), 7477 ByteField("info177", None), 7478 ByteField("info178", None), 7479 ByteField("info179", None), 7480 ByteField("info180", None), 7481 ByteField("info181", None), 7482 ByteField("info182", None), 7483 ByteField("info183", None), 7484 ByteField("info184", None), 7485 ByteField("info185", None), 7486 ByteField("info186", None), 7487 ByteField("info187", None), 7488 ByteField("info188", None), 7489 ByteField("info189", None), 7490 ByteField("info190", None), 7491 ByteField("info191", None), 7492 ByteField("info192", None), 7493 ByteField("info193", None), 7494 ByteField("info194", None), 7495 ByteField("info195", None), 7496 ByteField("info196", None), 7497 ByteField("info197", None), 7498 ByteField("info198", None), 7499 ByteField("info199", None), 7500 ByteField("info200", None), 7501 ByteField("info201", None), 7502 ByteField("info202", None), 7503 ByteField("info203", None), 7504 ByteField("info204", None), 7505 ByteField("info205", None), 7506 ByteField("info206", None), 7507 ByteField("info207", None), 7508 ByteField("info208", None), 7509 ByteField("info209", None), 7510 ByteField("info210", None), 7511 ByteField("info211", None), 7512 ByteField("info212", None), 7513 ByteField("info213", None), 7514 ByteField("info214", None), 7515 ByteField("info215", None), 7516 ByteField("info216", None), 7517 ByteField("info217", None), 7518 ByteField("info218", None), 7519 ByteField("info219", None), 7520 ByteField("info220", None), 7521 ByteField("info221", None), 7522 ByteField("info222", None), 7523 ByteField("info223", None), 7524 ByteField("info224", None), 7525 ByteField("info225", None), 7526 ByteField("info226", None), 7527 ByteField("info227", None), 7528 ByteField("info228", None), 7529 ByteField("info229", None), 7530 ByteField("info230", None), 7531 ByteField("info231", None), 7532 ByteField("info232", None), 7533 ByteField("info233", None), 7534 ByteField("info234", None), 7535 ByteField("info235", None), 7536 ByteField("info236", None), 7537 ByteField("info237", None), 7538 ByteField("info238", None), 7539 ByteField("info239", None), 7540 ByteField("info240", None), 7541 ByteField("info241", None), 7542 ByteField("info242", None), 7543 ByteField("info243", None), 7544 ByteField("info244", None), 7545 ByteField("info245", None), 7546 ByteField("info246", None), 7547 ByteField("info247", None), 7548 ByteField("info248", None), 7549 ByteField("info249", None), 7550 ] 7551 7552 def post_build(self, p, pay): 7553 a = [getattr(self, fld.name) for fld in self.fields_desc] 7554 res = adapt(2, 251, a, self.fields_desc) 7555 if self.lengthSVI is None: 7556 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 7557 if res[0] != 0: 7558 p = p[:-res[0]] 7559 return p + pay 7560 7561 7562# length 3 to 35 or 131 7563class UserUserHdr(Packet): 7564 """User-user Section 10.5.4.25""" 7565 name = "User-User" 7566 fields_desc = [ 7567 BitField("eightBitUU", None, 1), 7568 XBitField("ieiUU", None, 7), 7569 7570 XByteField("lengthUU", None), # dynamic length of field depending 7571 # of the type of message 7572 # let user decide which length he 7573 # wants to take 7574 # => more fuzzing options 7575 ByteField("userUserPD", 0x0), 7576 # optional 7577 ByteField("userUserInfo1", None), 7578 ByteField("userUserInfo2", None), 7579 ByteField("userUserInfo3", None), 7580 ByteField("userUserInfo4", None), 7581 ByteField("userUserInfo5", None), 7582 ByteField("userUserInfo6", None), 7583 ByteField("userUserInfo7", None), 7584 ByteField("userUserInfo8", None), 7585 ByteField("userUserInfo9", None), 7586 ByteField("userUserInfo10", None), 7587 ByteField("userUserInfo11", None), 7588 ByteField("userUserInfo12", None), 7589 ByteField("userUserInfo13", None), 7590 ByteField("userUserInfo14", None), 7591 ByteField("userUserInfo15", None), 7592 ByteField("userUserInfo16", None), 7593 ByteField("userUserInfo17", None), 7594 ByteField("userUserInfo18", None), 7595 ByteField("userUserInfo19", None), 7596 ByteField("userUserInfo20", None), 7597 ByteField("userUserInfo21", None), 7598 ByteField("userUserInfo22", None), 7599 ByteField("userUserInfo23", None), 7600 ByteField("userUserInfo24", None), 7601 ByteField("userUserInfo25", None), 7602 ByteField("userUserInfo26", None), 7603 ByteField("userUserInfo27", None), 7604 ByteField("userUserInfo28", None), 7605 ByteField("userUserInfo29", None), 7606 ByteField("userUserInfo30", None), 7607 ByteField("userUserInfo31", None), 7608 ByteField("userUserInfo32", None), 7609 # long packet 7610 ByteField("userUserInfo33", None), 7611 ByteField("userUserInfo34", None), 7612 ByteField("userUserInfo35", None), 7613 ByteField("userUserInfo36", None), 7614 ByteField("userUserInfo37", None), 7615 ByteField("userUserInfo38", None), 7616 ByteField("userUserInfo39", None), 7617 ByteField("userUserInfo40", None), 7618 ByteField("userUserInfo41", None), 7619 ByteField("userUserInfo42", None), 7620 ByteField("userUserInfo43", None), 7621 ByteField("userUserInfo44", None), 7622 ByteField("userUserInfo45", None), 7623 ByteField("userUserInfo46", None), 7624 ByteField("userUserInfo47", None), 7625 ByteField("userUserInfo48", None), 7626 ByteField("userUserInfo49", None), 7627 ByteField("userUserInfo50", None), 7628 ByteField("userUserInfo51", None), 7629 ByteField("userUserInfo52", None), 7630 ByteField("userUserInfo53", None), 7631 ByteField("userUserInfo54", None), 7632 ByteField("userUserInfo55", None), 7633 ByteField("userUserInfo56", None), 7634 ByteField("userUserInfo57", None), 7635 ByteField("userUserInfo58", None), 7636 ByteField("userUserInfo59", None), 7637 ByteField("userUserInfo60", None), 7638 ByteField("userUserInfo61", None), 7639 ByteField("userUserInfo62", None), 7640 ByteField("userUserInfo63", None), 7641 ByteField("userUserInfo64", None), 7642 ByteField("userUserInfo65", None), 7643 ByteField("userUserInfo66", None), 7644 ByteField("userUserInfo67", None), 7645 ByteField("userUserInfo68", None), 7646 ByteField("userUserInfo69", None), 7647 ByteField("userUserInfo70", None), 7648 ByteField("userUserInfo71", None), 7649 ByteField("userUserInfo72", None), 7650 ByteField("userUserInfo73", None), 7651 ByteField("userUserInfo74", None), 7652 ByteField("userUserInfo75", None), 7653 ByteField("userUserInfo76", None), 7654 ByteField("userUserInfo77", None), 7655 ByteField("userUserInfo78", None), 7656 ByteField("userUserInfo79", None), 7657 ByteField("userUserInfo80", None), 7658 ByteField("userUserInfo81", None), 7659 ByteField("userUserInfo82", None), 7660 ByteField("userUserInfo83", None), 7661 ByteField("userUserInfo84", None), 7662 ByteField("userUserInfo85", None), 7663 ByteField("userUserInfo86", None), 7664 ByteField("userUserInfo87", None), 7665 ByteField("userUserInfo88", None), 7666 ByteField("userUserInfo89", None), 7667 ByteField("userUserInfo90", None), 7668 ByteField("userUserInfo91", None), 7669 ByteField("userUserInfo92", None), 7670 ByteField("userUserInfo93", None), 7671 ByteField("userUserInfo94", None), 7672 ByteField("userUserInfo95", None), 7673 ByteField("userUserInfo96", None), 7674 ByteField("userUserInfo97", None), 7675 ByteField("userUserInfo98", None), 7676 ByteField("userUserInfo99", None), 7677 ByteField("userUserInfo100", None), 7678 ByteField("userUserInfo101", None), 7679 ByteField("userUserInfo102", None), 7680 ByteField("userUserInfo103", None), 7681 ByteField("userUserInfo104", None), 7682 ByteField("userUserInfo105", None), 7683 ByteField("userUserInfo106", None), 7684 ByteField("userUserInfo107", None), 7685 ByteField("userUserInfo108", None), 7686 ByteField("userUserInfo109", None), 7687 ByteField("userUserInfo110", None), 7688 ByteField("userUserInfo111", None), 7689 ByteField("userUserInfo112", None), 7690 ByteField("userUserInfo113", None), 7691 ByteField("userUserInfo114", None), 7692 ByteField("userUserInfo115", None), 7693 ByteField("userUserInfo116", None), 7694 ByteField("userUserInfo117", None), 7695 ByteField("userUserInfo118", None), 7696 ByteField("userUserInfo119", None), 7697 ByteField("userUserInfo120", None), 7698 ByteField("userUserInfo121", None), 7699 ByteField("userUserInfo122", None), 7700 ByteField("userUserInfo123", None), 7701 ByteField("userUserInfo124", None), 7702 ByteField("userUserInfo125", None), 7703 ByteField("userUserInfo126", None), 7704 ByteField("userUserInfo127", None), 7705 ByteField("userUserInfo128", None), 7706 ByteField("userUserInfo129", None), 7707 ByteField("userUserInfo130", None), 7708 ByteField("userUserInfo131", None) 7709 ] 7710 7711 def post_build(self, p, pay): 7712 a = [getattr(self, fld.name) for fld in self.fields_desc] 7713 res = adapt(3, 131, a, self.fields_desc) 7714 if self.lengthUU is None: 7715 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 7716 if res[0] != 0: 7717 p = p[:-res[0]] 7718 return p + pay 7719 7720 7721class AlertingPatternHdr(Packet): 7722 """Alerting Pattern 10.5.4.26""" 7723 name = "Alerting Pattern" 7724 fields_desc = [ 7725 BitField("eightBitAP", None, 1), 7726 XBitField("ieiAP", None, 7), 7727 XByteField("lengthAP", 0x3), 7728 BitField("spare", 0x0, 4), 7729 BitField("alertingValue", 0x0, 4) 7730 ] 7731 7732 7733class AllowedActionsHdr(Packet): 7734 """Allowed actions $(CCBS)$ Section 10.5.4.26""" 7735 name = "Allowed Actions $(CCBS)$" 7736 fields_desc = [ 7737 BitField("eightBitAA", None, 1), 7738 XBitField("ieiAA", None, 7), 7739 XByteField("lengthAP", 0x3), 7740 BitField("CCBS", 0x0, 1), 7741 BitField("spare", 0x0, 7) 7742 ] 7743 7744 7745# 7746# 10.5.5 GPRS mobility management information elements 7747# 7748 7749class AttachResult(Packet): 7750 """Attach result Section 10.5.5.1""" 7751 name = "Attach Result" 7752 fields_desc = [ 7753 XBitField("ieiAR", 0x0, 4), 7754 BitField("spare", 0x0, 1), 7755 BitField("result", 0x1, 3) 7756 ] 7757 7758 7759class AttachTypeHdr(Packet): 7760 """Attach type Section 10.5.5.2""" 7761 name = "Attach Type" 7762 fields_desc = [ 7763 XBitField("ieiAT", None, 4), 7764 BitField("spare", 0x0, 1), 7765 BitField("type", 0x1, 3) 7766 ] 7767 7768 7769# Fix 1/2 len problem 7770class AttachTypeAndCiphKeySeqNr(Packet): 7771 name = "Attach Type and Cipher Key Sequence Number" 7772 fields_desc = [ 7773 BitField("spare", 0x0, 1), 7774 BitField("type", 0x1, 3), 7775 BitField("spareHalfOctets", 0x0, 4) 7776 ] 7777 7778 7779class CipheringAlgorithm(Packet): 7780 """Ciphering algorithm Section 10.5.5.3""" 7781 name = "Ciphering Algorithm" 7782 fields_desc = [ 7783 XBitField("ieiCA", 0x0, 4), 7784 BitField("spare", 0x0, 1), 7785 BitField("type", 0x1, 3) 7786 ] 7787 7788 7789# Fix 1/2 len problem 7790class CipheringAlgorithmAndImeisvRequest(Packet): 7791 name = "Ciphering Algorithm and Imeisv Request" 7792 fields_desc = [ 7793 BitField("spare", 0x0, 1), 7794 BitField("type", 0x1, 3), 7795 BitField("spare", 0x0, 1), 7796 BitField("imeisvVal", 0x0, 3) 7797 ] 7798 7799 7800# [Spare] 7801class TmsiStatus(Packet): 7802 """[Spare] TMSI status Section 10.5.5.4""" 7803 name = "[Spare] TMSI Status" 7804 fields_desc = [ 7805 XBitField("ieiTS", None, 4), 7806 BitField("spare", 0x0, 3), 7807 BitField("flag", 0x1, 1) 7808 ] 7809 7810 7811class DetachType(Packet): 7812 """Detach type Section 10.5.5.5""" 7813 name = "Detach Type" 7814 fields_desc = [ 7815 XBitField("ieiDT", 0x0, 4), 7816 BitField("poweroff", 0x0, 1), 7817 BitField("type", 0x1, 3) 7818 ] 7819 7820 7821# Fix 1/2 len problem 7822class DetachTypeAndForceToStandby(Packet): 7823 name = "Detach Type and Force To Standby" 7824 fields_desc = [ 7825 BitField("poweroff", 0x0, 1), 7826 BitField("type", 0x1, 3), 7827 BitField("spare", 0x0, 1), 7828 BitField("forceStandby", 0x0, 3) 7829 ] 7830 7831 7832# Fix 1/2 len problem 7833class DetachTypeAndSpareHalfOctets(Packet): 7834 name = "Detach Type and Spare Half Octets" 7835 fields_desc = [ 7836 BitField("poweroff", 0x0, 1), 7837 BitField("type", 0x1, 3), 7838 BitField("spareHalfOctets", 0x0, 4) 7839 ] 7840 7841 7842class DrxParameter(Packet): 7843 """DRX parameter Section 10.5.5.6""" 7844 name = "DRX Parameter" 7845 fields_desc = [ 7846 ByteField("ieiDP", 0x0), 7847 ByteField("splitPG", 0x0), 7848 BitField("spare", 0x0, 4), 7849 BitField("splitCCCH", 0x0, 1), 7850 BitField("NonDrxTimer", 0x1, 3) 7851 ] 7852 7853 7854class ForceToStandby(Packet): 7855 """Force to standby Section 10.5.5.7""" 7856 name = "Force To Standby" 7857 fields_desc = [ 7858 XBitField("ieiFTS", 0x0, 4), 7859 BitField("spare", 0x0, 1), 7860 BitField("forceStandby", 0x0, 3) 7861 ] 7862 7863 7864# Fix 1/2 len problem 7865class ForceToStandbyAndAcReferenceNumber(Packet): 7866 name = "Force To Standby And Ac Reference Number" 7867 fields_desc = [ 7868 BitField("spare", 0x0, 1), 7869 BitField("forceStandby", 0x0, 3), 7870 BitField("acRefVal", 0x0, 4) 7871 ] 7872 7873 7874# Fix 1/2 len problem 7875class ForceToStandbyAndUpdateResult(Packet): 7876 name = "Force To Standby And Update Result" 7877 fields_desc = [ 7878 BitField("spare", 0x0, 1), 7879 BitField("forceStandby", 0x0, 3), 7880 BitField("spare", 0x0, 1), 7881 BitField("updateResVal", 0x0, 3) 7882 ] 7883 7884 7885# Fix 1/2 len problem 7886class ForceToStandbyAndSpareHalfOctets(Packet): 7887 name = "Force To Standby And Spare Half Octets" 7888 fields_desc = [ 7889 BitField("spare", 0x0, 1), 7890 BitField("forceStandby", 0x0, 3), 7891 BitField("spareHalfOctets", 0x0, 4) 7892 ] 7893 7894 7895class PTmsiSignature(Packet): 7896 """P-TMSI signature Section 10.5.5.8""" 7897 name = "P-TMSI Signature" 7898 fields_desc = [ 7899 ByteField("ieiPTS", 0x0), 7900 BitField("signature", 0x0, 24) 7901 ] 7902 7903 7904class IdentityType2(Packet): 7905 """Identity type 2 Section 10.5.5.9""" 7906 name = "Identity Type 2" 7907 fields_desc = [ 7908 XBitField("ieiIT2", 0x0, 4), 7909 BitField("spare", 0x0, 1), 7910 BitField("typeOfIdentity", 0x0, 3) 7911 ] 7912 7913 7914# Fix 1/2 len problem 7915class IdentityType2AndforceToStandby(Packet): 7916 name = "Identity Type 2 and Force to Standby" 7917 fields_desc = [ 7918 BitField("spare", 0x0, 1), 7919 BitField("typeOfIdentity", 0x0, 3), 7920 BitField("spare", 0x0, 1), 7921 BitField("forceStandby", 0x0, 3) 7922 ] 7923 7924 7925class ImeisvRequest(Packet): 7926 """IMEISV request Section 10.5.5.10""" 7927 name = "IMEISV Request" 7928 fields_desc = [ 7929 XBitField("ieiIR", 0x0, 4), 7930 BitField("spare", 0x0, 1), 7931 BitField("imeisvVal", 0x0, 3) 7932 ] 7933 7934 7935# Fix 1/2 len problem 7936class ImeisvRequestAndForceToStandby(Packet): 7937 name = "IMEISV Request and Force To Standby" 7938 fields_desc = [ 7939 BitField("spare", 0x0, 1), 7940 BitField("imeisvVal", 0x0, 3), 7941 BitField("spareHalfOctets", 0x0, 4) 7942 ] 7943 7944 7945# length 4 to 19 7946class ReceiveNpduNumbersList(Packet): 7947 """Receive N-PDU Numbers list Section 10.5.5.11""" 7948 name = "Receive N-PDU Numbers list" 7949 fields_desc = [ 7950 ByteField("ieiRNNL", 0x0), 7951 7952 XByteField("lengthRNNL", None), 7953 7954 BitField("nbList0", 0x0, 16), 7955 # optional 7956 ByteField("nbList1", None), 7957 ByteField("nbList2", None), 7958 ByteField("nbList3", None), 7959 ByteField("nbList4", None), 7960 ByteField("nbList5", None), 7961 ByteField("nbList6", None), 7962 ByteField("nbList7", None), 7963 ByteField("nbList8", None), 7964 ByteField("nbList9", None), 7965 ByteField("nbList10", None), 7966 ByteField("nbList11", None), 7967 ByteField("nbList12", None), 7968 ByteField("nbList13", None), 7969 ByteField("nbList14", None), 7970 ByteField("nbList15", None), 7971 ] 7972 7973 def post_build(self, p, pay): 7974 a = [getattr(self, fld.name) for fld in self.fields_desc] 7975 res = adapt(4, 19, a, self.fields_desc) 7976 if self.lengthRNNL is None: 7977 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 7978 if res[0] != 0: 7979 p = p[:-res[0]] 7980 return p + pay 7981 7982 7983class MsNetworkCapability(Packet): 7984 """MS network capability Section 10.5.5.12""" 7985 name = "MS Network Capability" 7986 fields_desc = [ 7987 ByteField("ieiMNC", 0x0), 7988 XByteField("lengthMNC", 0x3), 7989 ByteField("msNetValue", 0x0) 7990 ] 7991 7992 7993# length 6 to 14 7994class MsRadioAccessCapability(Packet): 7995 """MS Radio Access capability Section 10.5.5.12a""" 7996 name = "MS Radio Access Capability" 7997 fields_desc = [ 7998 ByteField("ieiMRAC", 0x24), 7999 8000 XByteField("lengthMRAC", None), 8001 8002 BitField("spare1", 0x0, 1), # ... 8003 8004 BitField("accessCap", 0x0, 4), 8005 BitField("accessTechType", 0x0, 4), 8006 # access capability 8007 BitField("bool", 0x0, 1), 8008 BitField("lengthContent", 0x0, 7), 8009 BitField("spare1", 0x0, 1), # ... 8010 # content 8011 BitField("pwrCap", 0x0, 3), 8012 BitField("bool1", 0x0, 1), 8013 BitField("a51", 0x0, 1), 8014 BitField("a52", 0x0, 1), 8015 BitField("a53", 0x0, 1), 8016 BitField("a54", 0x0, 1), 8017 8018 BitField("a55", 0x0, 1), 8019 BitField("a56", 0x0, 1), 8020 BitField("a57", 0x0, 1), 8021 BitField("esInd", 0x0, 1), 8022 BitField("ps", 0x0, 1), 8023 BitField("vgcs", 0x0, 1), 8024 BitField("vbs", 0x0, 1), 8025 BitField("bool2", 0x0, 1), 8026 # multislot 8027 BitField("bool3", 0x0, 1), 8028 BitField("hscsd", 0x0, 5), 8029 8030 BitField("bool4", 0x0, 1), 8031 BitField("gprs", 0x0, 5), 8032 BitField("gprsExt", 0x0, 1), 8033 BitField("bool5", 0x0, 1), 8034 8035 BitField("smsVal", 0x0, 4), 8036 BitField("smVal", 0x0, 4) 8037 ] 8038 8039 8040# 10.5.5.13 Spare 8041# This is intentionally left spare. 8042 8043class GmmCause(Packet): 8044 """GMM cause Section 10.5.5.14""" 8045 name = "GMM Cause" 8046 fields_desc = [ 8047 ByteField("ieiGC", 0x0), 8048 ByteField("causeValue", 0x0) 8049 ] 8050 8051 8052class RoutingAreaIdentification(Packet): 8053 """Routing area identification Section 10.5.5.15""" 8054 name = "Routing Area Identification" 8055 fields_desc = [ 8056 ByteField("ieiRAI", 0x0), 8057 BitField("mccDigit2", 0x0, 4), 8058 BitField("mccDigit1", 0x0, 4), 8059 BitField("mncDigit3", 0x0, 4), 8060 BitField("mccDigit3", 0x0, 4), 8061 BitField("mccDigit2", 0x0, 4), 8062 BitField("mccDigit1", 0x0, 4), 8063 ByteField("LAC", 0x0), 8064 ByteField("LAC1", 0x0), 8065 ByteField("LAC", 0x0) 8066 ] 8067# 10.5.5.16 Spare 8068# This is intentionally left spare. 8069 8070 8071class UpdateResult(Packet): 8072 """Update result Section 10.5.5.17""" 8073 name = "Update Result" 8074 fields_desc = [ 8075 XBitField("ieiUR", 0x0, 4), 8076 BitField("spare", 0x0, 1), 8077 BitField("updateResVal", 0x0, 3) 8078 ] 8079 8080 8081class UpdateType(Packet): 8082 """Update type Section 10.5.5.18""" 8083 name = "Update Type" 8084 fields_desc = [ 8085 XBitField("ieiUT", 0x0, 4), 8086 BitField("spare", 0x0, 1), 8087 BitField("updateTypeVal", 0x0, 3) 8088 ] 8089 8090 8091# Fix 1/2 len problem 8092class UpdateTypeAndCiphKeySeqNr(Packet): 8093 name = "Update Type and Cipher Key Sequence Number" 8094 fields_desc = [ 8095 BitField("spare", 0x0, 1), 8096 BitField("updateTypeVal", 0x0, 3), 8097 BitField("spare", 0x0, 1), 8098 BitField("keySeq", 0x0, 3) 8099 ] 8100 8101 8102class AcReferenceNumber(Packet): 8103 """A&C reference number Section 10.5.5.19""" 8104 name = "A&C Reference Number" 8105 fields_desc = [ 8106 XBitField("ieiARN", 0x0, 4), 8107 BitField("acRefVal", 0x0, 4) 8108 ] 8109 8110 8111# Fix 1/2 len problem 8112class AcReferenceNumberAndSpareHalfOctets(Packet): 8113 name = "A&C Reference Number and Spare Half Octets" 8114 fields_desc = [ 8115 BitField("acRefVal", 0x0, 4), 8116 BitField("spareHalfOctets", 0x0, 4) 8117 ] 8118# 8119# 10.5.6 Session management information elements 8120# 8121# length 3 to 102 8122 8123 8124class AccessPointName(Packet): 8125 """Access Point Name Section 10.5.6.1""" 8126 name = "Access Point Name" 8127 fields_desc = [ 8128 ByteField("ieiAPN", 0x0), 8129 XByteField("lengthAPN", None), 8130 ByteField("apName", 0x0), 8131 # optional 8132 ByteField("apName1", None), 8133 ByteField("apName2", None), 8134 ByteField("apName3", None), 8135 ByteField("apName4", None), 8136 ByteField("apName5", None), 8137 ByteField("apName6", None), 8138 ByteField("apName7", None), 8139 ByteField("apName8", None), 8140 ByteField("apName9", None), 8141 ByteField("apName10", None), 8142 ByteField("apName11", None), 8143 ByteField("apName12", None), 8144 ByteField("apName13", None), 8145 ByteField("apName14", None), 8146 ByteField("apName15", None), 8147 ByteField("apName16", None), 8148 ByteField("apName17", None), 8149 ByteField("apName18", None), 8150 ByteField("apName19", None), 8151 ByteField("apName20", None), 8152 ByteField("apName21", None), 8153 ByteField("apName22", None), 8154 ByteField("apName23", None), 8155 ByteField("apName24", None), 8156 ByteField("apName25", None), 8157 ByteField("apName26", None), 8158 ByteField("apName27", None), 8159 ByteField("apName28", None), 8160 ByteField("apName29", None), 8161 ByteField("apName30", None), 8162 ByteField("apName31", None), 8163 ByteField("apName32", None), 8164 ByteField("apName33", None), 8165 ByteField("apName34", None), 8166 ByteField("apName35", None), 8167 ByteField("apName36", None), 8168 ByteField("apName37", None), 8169 ByteField("apName38", None), 8170 ByteField("apName39", None), 8171 ByteField("apName40", None), 8172 ByteField("apName41", None), 8173 ByteField("apName42", None), 8174 ByteField("apName43", None), 8175 ByteField("apName44", None), 8176 ByteField("apName45", None), 8177 ByteField("apName46", None), 8178 ByteField("apName47", None), 8179 ByteField("apName48", None), 8180 ByteField("apName49", None), 8181 ByteField("apName50", None), 8182 ByteField("apName51", None), 8183 ByteField("apName52", None), 8184 ByteField("apName53", None), 8185 ByteField("apName54", None), 8186 ByteField("apName55", None), 8187 ByteField("apName56", None), 8188 ByteField("apName57", None), 8189 ByteField("apName58", None), 8190 ByteField("apName59", None), 8191 ByteField("apName60", None), 8192 ByteField("apName61", None), 8193 ByteField("apName62", None), 8194 ByteField("apName63", None), 8195 ByteField("apName64", None), 8196 ByteField("apName65", None), 8197 ByteField("apName66", None), 8198 ByteField("apName67", None), 8199 ByteField("apName68", None), 8200 ByteField("apName69", None), 8201 ByteField("apName70", None), 8202 ByteField("apName71", None), 8203 ByteField("apName72", None), 8204 ByteField("apName73", None), 8205 ByteField("apName74", None), 8206 ByteField("apName75", None), 8207 ByteField("apName76", None), 8208 ByteField("apName77", None), 8209 ByteField("apName78", None), 8210 ByteField("apName79", None), 8211 ByteField("apName80", None), 8212 ByteField("apName81", None), 8213 ByteField("apName82", None), 8214 ByteField("apName83", None), 8215 ByteField("apName84", None), 8216 ByteField("apName85", None), 8217 ByteField("apName86", None), 8218 ByteField("apName87", None), 8219 ByteField("apName88", None), 8220 ByteField("apName89", None), 8221 ByteField("apName90", None), 8222 ByteField("apName91", None), 8223 ByteField("apName92", None), 8224 ByteField("apName93", None), 8225 ByteField("apName94", None), 8226 ByteField("apName95", None), 8227 ByteField("apName96", None), 8228 ByteField("apName97", None), 8229 ByteField("apName98", None), 8230 ByteField("apName99", None) 8231 ] 8232 8233 def post_build(self, p, pay): 8234 a = [getattr(self, fld.name) for fld in self.fields_desc] 8235 res = adapt(3, 102, a, self.fields_desc) 8236 if self.lengthAPN is None: 8237 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 8238 if res[0] != 0: 8239 p = p[:-res[0]] 8240 return p + pay 8241 8242 8243class NetworkServiceAccessPointIdentifier(Packet): 8244 """Network service access point identifier Section 10.5.6.2""" 8245 name = "Network Service Access Point Identifier" 8246 fields_desc = [ 8247 ByteField("ieiNSAPI", 0x0), 8248 BitField("spare", 0x0, 4), 8249 BitField("nsapiVal", 0x0, 4) 8250 ] 8251 8252 8253# length 2 to 253 8254class ProtocolConfigurationOptions(Packet): 8255 """Protocol configuration options Section 10.5.6.3""" 8256 name = "Protocol Configuration Options" 8257 fields_desc = [ 8258 ByteField("ieiPCO", 0x0), 8259 8260 XByteField("lengthPCO", None), 8261 # optional 8262 BitField("ext", None, 1), 8263 BitField("spare", None, 4), 8264 BitField("configProto", None, 3), 8265 8266 ByteField("protoId1", None), 8267 ByteField("lenProto1", None), 8268 ByteField("proto1Content", None), 8269 8270 ByteField("protoId2", None), 8271 ByteField("lenProto2", None), 8272 ByteField("proto2Content", None), 8273 8274 ByteField("protoId3", None), 8275 ByteField("lenProto3", None), 8276 ByteField("proto3Content", None), 8277 8278 ByteField("protoId4", None), 8279 ByteField("lenProto4", None), 8280 ByteField("proto4Content", None), 8281 8282 8283 ByteField("protoId5", None), 8284 ByteField("lenProto5", None), 8285 ByteField("proto5Content", None), 8286 8287 ByteField("protoId6", None), 8288 ByteField("lenProto6", None), 8289 ByteField("proto6Content", None), 8290 8291 ByteField("protoId7", None), 8292 ByteField("lenProto7", None), 8293 ByteField("proto7Content", None), 8294 8295 ByteField("protoId8", None), 8296 ByteField("lenProto8", None), 8297 ByteField("proto8Content", None), 8298 8299 ByteField("protoId9", None), 8300 ByteField("lenProto9", None), 8301 ByteField("proto9Content", None), 8302 8303 ByteField("protoId10", None), 8304 ByteField("lenProto10", None), 8305 ByteField("proto10Content", None), 8306 8307 ByteField("protoId11", None), 8308 ByteField("lenProto11", None), 8309 ByteField("proto11Content", None), 8310 8311 ByteField("protoId12", None), 8312 ByteField("lenProto12", None), 8313 ByteField("proto12Content", None), 8314 8315 ByteField("protoId13", None), 8316 ByteField("lenProto13", None), 8317 ByteField("proto13Content", None), 8318 8319 ByteField("protoId14", None), 8320 ByteField("lenProto14", None), 8321 ByteField("proto14Content", None), 8322 8323 ByteField("protoId15", None), 8324 ByteField("lenProto15", None), 8325 ByteField("proto15Content", None), 8326 8327 ByteField("protoId16", None), 8328 ByteField("lenProto16", None), 8329 ByteField("proto16Content", None), 8330 8331 ByteField("protoId17", None), 8332 ByteField("lenProto17", None), 8333 ByteField("proto17Content", None), 8334 8335 ByteField("protoId18", None), 8336 ByteField("lenProto18", None), 8337 ByteField("proto18Content", None), 8338 8339 ByteField("protoId19", None), 8340 ByteField("lenProto19", None), 8341 ByteField("proto19Content", None), 8342 8343 ByteField("protoId20", None), 8344 ByteField("lenProto20", None), 8345 ByteField("proto20Content", None), 8346 8347 ByteField("protoId21", None), 8348 ByteField("lenProto21", None), 8349 ByteField("proto21Content", None), 8350 8351 ByteField("protoId22", None), 8352 ByteField("lenProto22", None), 8353 ByteField("proto22Content", None), 8354 8355 ByteField("protoId23", None), 8356 ByteField("lenProto23", None), 8357 ByteField("proto23Content", None), 8358 8359 ByteField("protoId24", None), 8360 ByteField("lenProto24", None), 8361 ByteField("proto24Content", None), 8362 8363 ByteField("protoId25", None), 8364 ByteField("lenProto25", None), 8365 ByteField("proto25Content", None), 8366 8367 ByteField("protoId26", None), 8368 ByteField("lenProto26", None), 8369 ByteField("proto26Content", None), 8370 8371 ByteField("protoId27", None), 8372 ByteField("lenProto27", None), 8373 ByteField("proto27Content", None), 8374 8375 ByteField("protoId28", None), 8376 ByteField("lenProto28", None), 8377 ByteField("proto28Content", None), 8378 8379 ByteField("protoId29", None), 8380 ByteField("lenProto29", None), 8381 ByteField("proto29Content", None), 8382 8383 ByteField("protoId30", None), 8384 ByteField("lenProto30", None), 8385 ByteField("proto30Content", None), 8386 8387 ByteField("protoId31", None), 8388 ByteField("lenProto31", None), 8389 ByteField("proto31Content", None), 8390 8391 ByteField("protoId32", None), 8392 ByteField("lenProto32", None), 8393 ByteField("proto32Content", None), 8394 8395 ByteField("protoId33", None), 8396 ByteField("lenProto33", None), 8397 ByteField("proto33Content", None), 8398 8399 ByteField("protoId34", None), 8400 ByteField("lenProto34", None), 8401 ByteField("proto34Content", None), 8402 8403 ByteField("protoId35", None), 8404 ByteField("lenProto35", None), 8405 ByteField("proto35Content", None), 8406 8407 ByteField("protoId36", None), 8408 ByteField("lenProto36", None), 8409 ByteField("proto36Content", None), 8410 8411 ByteField("protoId37", None), 8412 ByteField("lenProto37", None), 8413 ByteField("proto37Content", None), 8414 8415 ByteField("protoId38", None), 8416 ByteField("lenProto38", None), 8417 ByteField("proto38Content", None), 8418 8419 ByteField("protoId39", None), 8420 ByteField("lenProto39", None), 8421 ByteField("proto39Content", None), 8422 8423 ByteField("protoId40", None), 8424 ByteField("lenProto40", None), 8425 ByteField("proto40Content", None), 8426 8427 ByteField("protoId41", None), 8428 ByteField("lenProto41", None), 8429 ByteField("proto41Content", None), 8430 8431 ByteField("protoId42", None), 8432 ByteField("lenProto42", None), 8433 ByteField("proto42Content", None), 8434 8435 ByteField("protoId43", None), 8436 ByteField("lenProto43", None), 8437 ByteField("proto43Content", None), 8438 8439 ByteField("protoId44", None), 8440 ByteField("lenProto44", None), 8441 ByteField("proto44Content", None), 8442 8443 ByteField("protoId45", None), 8444 ByteField("lenProto45", None), 8445 ByteField("proto45Content", None), 8446 8447 ByteField("protoId46", None), 8448 ByteField("lenProto46", None), 8449 ByteField("proto46Content", None), 8450 8451 ByteField("protoId47", None), 8452 ByteField("lenProto47", None), 8453 ByteField("proto47Content", None), 8454 8455 ByteField("protoId48", None), 8456 ByteField("lenProto48", None), 8457 ByteField("proto48Content", None), 8458 8459 ByteField("protoId49", None), 8460 ByteField("lenProto49", None), 8461 ByteField("proto49Content", None), 8462 8463 ByteField("protoId50", None), 8464 ByteField("lenProto50", None), 8465 ByteField("proto50Content", None), 8466 8467 ByteField("protoId51", None), 8468 ByteField("lenProto51", None), 8469 ByteField("proto51Content", None), 8470 8471 ByteField("protoId52", None), 8472 ByteField("lenProto52", None), 8473 ByteField("proto52Content", None), 8474 8475 ByteField("protoId53", None), 8476 ByteField("lenProto53", None), 8477 ByteField("proto53Content", None), 8478 8479 ByteField("protoId54", None), 8480 ByteField("lenProto54", None), 8481 ByteField("proto54Content", None), 8482 8483 ByteField("protoId55", None), 8484 ByteField("lenProto55", None), 8485 ByteField("proto55Content", None), 8486 8487 ByteField("protoId56", None), 8488 ByteField("lenProto56", None), 8489 ByteField("proto56Content", None), 8490 8491 ByteField("protoId57", None), 8492 ByteField("lenProto57", None), 8493 ByteField("proto57Content", None), 8494 8495 ByteField("protoId58", None), 8496 ByteField("lenProto58", None), 8497 ByteField("proto58Content", None), 8498 8499 ByteField("protoId59", None), 8500 ByteField("lenProto59", None), 8501 ByteField("proto59Content", None), 8502 8503 ByteField("protoId60", None), 8504 ByteField("lenProto60", None), 8505 ByteField("proto60Content", None), 8506 8507 ByteField("protoId61", None), 8508 ByteField("lenProto61", None), 8509 ByteField("proto61Content", None), 8510 8511 ByteField("protoId62", None), 8512 ByteField("lenProto62", None), 8513 ByteField("proto62Content", None), 8514 8515 ByteField("protoId63", None), 8516 ByteField("lenProto63", None), 8517 ByteField("proto63Content", None), 8518 8519 ByteField("protoId64", None), 8520 ByteField("lenProto64", None), 8521 ByteField("proto64Content", None), 8522 8523 ByteField("protoId65", None), 8524 ByteField("lenProto65", None), 8525 ByteField("proto65Content", None), 8526 8527 ByteField("protoId66", None), 8528 ByteField("lenProto66", None), 8529 ByteField("proto66Content", None), 8530 8531 ByteField("protoId67", None), 8532 ByteField("lenProto67", None), 8533 ByteField("proto67Content", None), 8534 8535 ByteField("protoId68", None), 8536 ByteField("lenProto68", None), 8537 ByteField("proto68Content", None), 8538 8539 ByteField("protoId69", None), 8540 ByteField("lenProto69", None), 8541 ByteField("proto69Content", None), 8542 8543 ByteField("protoId70", None), 8544 ByteField("lenProto70", None), 8545 ByteField("proto70Content", None), 8546 8547 ByteField("protoId71", None), 8548 ByteField("lenProto71", None), 8549 ByteField("proto71Content", None), 8550 8551 ByteField("protoId72", None), 8552 ByteField("lenProto72", None), 8553 ByteField("proto72Content", None), 8554 8555 ByteField("protoId73", None), 8556 ByteField("lenProto73", None), 8557 ByteField("proto73Content", None), 8558 8559 ByteField("protoId74", None), 8560 ByteField("lenProto74", None), 8561 ByteField("proto74Content", None), 8562 8563 ByteField("protoId75", None), 8564 ByteField("lenProto75", None), 8565 ByteField("proto75Content", None), 8566 8567 ByteField("protoId76", None), 8568 ByteField("lenProto76", None), 8569 ByteField("proto76Content", None), 8570 8571 ByteField("protoId77", None), 8572 ByteField("lenProto77", None), 8573 ByteField("proto77Content", None), 8574 8575 ByteField("protoId78", None), 8576 ByteField("lenProto78", None), 8577 ByteField("proto78Content", None), 8578 8579 ByteField("protoId79", None), 8580 ByteField("lenProto79", None), 8581 ByteField("proto79Content", None), 8582 8583 ByteField("protoId80", None), 8584 ByteField("lenProto80", None), 8585 ByteField("proto80Content", None), 8586 8587 ByteField("protoId81", None), 8588 ByteField("lenProto81", None), 8589 ByteField("proto81Content", None), 8590 8591 ByteField("protoId82", None), 8592 ByteField("lenProto82", None), 8593 ByteField("proto82Content", None), 8594 8595 ByteField("protoId83", None), 8596 ByteField("lenProto83", None), 8597 ByteField("proto83Content", None), 8598 ] 8599 8600 def post_build(self, p, pay): 8601 a = [getattr(self, fld.name) for fld in self.fields_desc] 8602 res = adapt(2, 253, a, self.fields_desc) 8603 if self.lengthPCO is None: 8604 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 8605 if res[0] != 0: 8606 p = p[:-res[0]] 8607 return p + pay 8608 8609 8610# len 4 to 20 8611class PacketDataProtocolAddress(Packet): 8612 """Packet data protocol address Section 10.5.6.4""" 8613 name = "Packet Data Protocol Address" 8614 fields_desc = [ 8615 ByteField("ieiPDPA", 0x0), 8616 8617 XByteField("lengthPDPA", None), 8618 8619 BitField("spare", 0x0, 4), 8620 BitField("pdpTypeOrga", 0x0, 4), 8621 8622 ByteField("pdpTypeNb", 0x0), 8623 # optional 8624 ByteField("addressInfo1", None), 8625 ByteField("addressInfo2", None), 8626 ByteField("addressInfo3", None), 8627 ByteField("addressInfo4", None), 8628 ByteField("addressInfo5", None), 8629 ByteField("addressInfo6", None), 8630 ByteField("addressInfo7", None), 8631 ByteField("addressInfo8", None), 8632 ByteField("addressInfo9", None), 8633 ByteField("addressInfo10", None), 8634 ByteField("addressInfo11", None), 8635 ByteField("addressInfo12", None), 8636 ByteField("addressInfo13", None), 8637 ByteField("addressInfo14", None), 8638 ByteField("addressInfo15", None), 8639 ByteField("addressInfo16", None) 8640 ] 8641 8642 def post_build(self, p, pay): 8643 a = [getattr(self, fld.name) for fld in self.fields_desc] 8644 res = adapt(4, 20, a, self.fields_desc) 8645 if self.lengthPDPA is None: 8646 p = p[:1] + struct.pack(">B", res[1]) + p[2:] 8647 if res[0] != 0: 8648 p = p[:-res[0]] 8649 return p + pay 8650 8651 8652class QualityOfService(Packet): 8653 """Quality of service Section 10.5.6.5""" 8654 name = "Quality of Service" 8655 fields_desc = [ 8656 ByteField("ieiQOS", 0x0), 8657 XByteField("lengthQOS", 0x5), 8658 8659 BitField("spare", 0x0, 2), 8660 BitField("delayClass", 0x0, 3), 8661 BitField("reliaClass", 0x0, 3), 8662 8663 BitField("peak", 0x0, 4), 8664 BitField("spare", 0x0, 1), 8665 BitField("precedenceCl", 0x0, 3), 8666 8667 BitField("spare", 0x0, 3), 8668 BitField("mean", 0x0, 5) 8669 ] 8670 8671 8672class SmCause(Packet): 8673 """SM cause Section 10.5.6.6""" 8674 name = "SM Cause" 8675 fields_desc = [ 8676 ByteField("ieiSC", 0x0), 8677 ByteField("causeVal", 0x0) 8678 ] 8679 8680# 10.5.6.7 Spare 8681# This is intentionally left spare. 8682 8683 8684class AaDeactivationCause(Packet): 8685 """AA deactivation cause Section 10.5.6.8""" 8686 name = "AA Deactivation Cause" 8687 fields_desc = [ 8688 XBitField("ieiADC", 0x0, 4), 8689 BitField("spare", 0x0, 1), 8690 BitField("aaVal", 0x0, 3) 8691 ] 8692 8693 8694# Fix 1/2 len problem 8695class AaDeactivationCauseAndSpareHalfOctets(Packet): 8696 name = "AA Deactivation Cause and Spare Half Octets" 8697 fields_desc = [ 8698 BitField("spare", 0x0, 1), 8699 BitField("aaVal", 0x0, 3), 8700 BitField("spareHalfOctets", 0x0, 4) 8701 ] 8702 8703 8704class LlcServiceAccessPointIdentifier(Packet): 8705 """LLC service access point identifier Section 10.5.6.9""" 8706 name = "LLC Service Access Point Identifier" 8707 fields_desc = [ 8708 ByteField("ieiLSAPI", None), 8709 BitField("spare", 0x0, 4), 8710 BitField("llcVal", 0x0, 4) 8711 ] 8712 8713 8714# 8715# 10.5.7 GPRS Common information elements 8716# 8717 8718# 10.5.7.1 [Spare] 8719 8720class RadioPriority(Packet): 8721 """Radio priority Section 10.5.7.2""" 8722 name = "Radio Priority" 8723 fields_desc = [ 8724 XBitField("ieiRP", 0x0, 4), 8725 BitField("spare", 0x1, 1), 8726 BitField("rplv", 0x0, 3) 8727 ] 8728 8729 8730# Fix 1/2 len problem 8731class RadioPriorityAndSpareHalfOctets(Packet): 8732 name = "Radio Priority and Spare Half Octets" 8733 fields_desc = [ 8734 BitField("spare", 0x1, 1), 8735 BitField("rplv", 0x0, 3), 8736 BitField("spareHalfOctets", 0x0, 4) 8737 ] 8738 8739 8740class GprsTimer(Packet): 8741 """GPRS Timer Section 10.5.7.3""" 8742 name = "GPRS Timer" 8743 fields_desc = [ 8744 ByteField("ieiGT", 0x0), 8745 BitField("unit", 0x0, 3), 8746 BitField("timerVal", 0x0, 5) 8747 ] 8748 8749 8750class CellIdentity(Packet): 8751 """ Cell identity Section 10.5.1.1 """ 8752 name = "Cell Identity" 8753 fields_desc = [ 8754 ByteField("ciValue1", 0x0), 8755 ByteField("ciValue2", 0x0) 8756 ] 8757 8758 8759class CiphKeySeqNr(Packet): 8760 """ Ciphering Key Sequence Number Section 10.5.1.2 """ 8761 name = "Cipher Key Sequence Number" 8762 fields_desc = [ 8763 BitField("spare", 0x0, 1), 8764 BitField("keySeq", 0x0, 3) 8765 ] 8766 8767 8768class LocalAreaId(Packet): 8769 """ Local Area Identification Section 10.5.1.3 """ 8770 name = "Location Area Identification" 8771 fields_desc = [ 8772 BitField("mccDigit2", 0x0, 4), 8773 BitField("mccDigit1", 0x0, 4), 8774 BitField("mncDigit3", 0x0, 4), 8775 BitField("mccDigit3", 0x0, 4), 8776 BitField("mncDigit2", 0x0, 4), 8777 BitField("mncDigit1", 0x0, 4), 8778 ByteField("lac1", 0x0), 8779 ByteField("lac2", 0x0) 8780 ] 8781# 8782# The Mobile Identity is a type 4 information element with a minimum 8783# length of 3 octet and 11 octets length maximal. 8784# 8785 8786 8787# len 3 - 11 8788class MobileId(Packet): 8789 """ Mobile Identity Section 10.5.1.4 """ 8790 name = "Mobile Identity" 8791 fields_desc = [ 8792 XByteField("lengthMI", None), 8793 BitField("idDigit1", 0x0, 4), 8794 BitField("oddEven", 0x0, 1), 8795 BitField("typeOfId", 0x0, 3), 8796 8797 BitField("idDigit2_1", None, 4), # optional 8798 BitField("idDigit2", None, 4), 8799 BitField("idDigit3_1", None, 4), 8800 BitField("idDigit3", None, 4), 8801 BitField("idDigit4_1", None, 4), 8802 BitField("idDigit4", None, 4), 8803 BitField("idDigit5_1", None, 4), 8804 BitField("idDigit5", None, 4), 8805 BitField("idDigit6_1", None, 4), 8806 BitField("idDigit6", None, 4), 8807 BitField("idDigit7_1", None, 4), 8808 BitField("idDigit7", None, 4), 8809 BitField("idDigit8_1", None, 4), 8810 BitField("idDigit8", None, 4), 8811 BitField("idDigit9_1", None, 4), 8812 BitField("idDigit9", None, 4), 8813 ] 8814 8815 def post_build(self, p, pay): 8816 a = [getattr(self, fld.name) for fld in self.fields_desc] 8817 res = adapt(2, 10, a, self.fields_desc, 1) 8818 if self.lengthMI is None: 8819 p = struct.pack(">B", res[1]) + p[1:] 8820 if res[0] != 0: 8821 p = p[:-res[0]] 8822 return p + pay 8823 8824 8825class MobileStationClassmark1(Packet): 8826 """ Mobile Station Classmark 1 Section 10.5.1.5 """ 8827 name = "Mobile Station Classmark 1" 8828 fields_desc = [ 8829 BitField("spare", 0x0, 1), 8830 BitField("revisionLvl", 0x0, 2), 8831 BitField("esInd", 0x0, 1), 8832 BitField("a51", 0x0, 1), 8833 BitField("rfPowerCap", 0x0, 3) 8834 ] 8835 8836 8837class MobileStationClassmark2(Packet): 8838 """ Mobile Station Classmark 2 Section 10.5.1.6 """ 8839 name = "Mobile Station Classmark 2" 8840 fields_desc = [ 8841 XByteField("lengthMSC2", 0x3), 8842 BitField("spare", 0x0, 1), 8843 BitField("revisionLvl", 0x0, 2), 8844 BitField("esInd", 0x0, 1), 8845 BitField("a51", 0x0, 1), 8846 BitField("rfPowerCap", 0x0, 3), 8847 BitField("spare1", 0x0, 1), 8848 BitField("psCap", 0x0, 1), 8849 BitField("ssScreenInd", 0x0, 2), 8850 BitField("smCaPabi", 0x0, 1), 8851 BitField("vbs", 0x0, 1), 8852 BitField("vgcs", 0x0, 1), 8853 BitField("fc", 0x0, 1), 8854 BitField("cm3", 0x0, 1), 8855 BitField("spare2", 0x0, 1), 8856 BitField("lcsvaCap", 0x0, 1), 8857 BitField("spare3", 0x0, 1), 8858 BitField("soLsa", 0x0, 1), 8859 BitField("cmsp", 0x0, 1), 8860 BitField("a53", 0x0, 1), 8861 BitField("a52", 0x0, 1) 8862 ] 8863 8864 8865class DescriptiveGroupOrBroadcastCallReference(Packet): 8866 """ Descriptive group or broadcast call reference Section 10.5.1.9 """ 8867 name = "Descriptive Group or Broadcast Call Reference" 8868 fields_desc = [ 8869 BitField("binCallRef", 0x0, 27), 8870 BitField("sf", 0x0, 1), 8871 BitField("fa", 0x0, 1), 8872 BitField("callPrio", 0x0, 3), 8873 BitField("cipherInfo", 0x0, 4), 8874 BitField("spare1", 0x0, 1), 8875 BitField("spare2", 0x0, 1), 8876 BitField("spare3", 0x0, 1), 8877 BitField("spare4", 0x0, 1) 8878 ] 8879 8880 8881class PdAndSapi(Packet): 8882 """ PD and SAPI $(CCBS)$ Section 10.5.1.10a """ 8883 name = "PD and SAPI $(CCBS)$" 8884 fields_desc = [ 8885 BitField("spare", 0x0, 1), 8886 BitField("spare1", 0x0, 1), 8887 BitField("sapi", 0x0, 2), 8888 BitField("pd", 0x0, 4) 8889 ] 8890 8891 8892class PriorityLevel(Packet): 8893 """ Priority Level Section 10.5.1.11 """ 8894 name = "Priority Level" 8895 fields_desc = [ 8896 BitField("spare", 0x0, 1), 8897 BitField("callPrio", 0x0, 3) 8898 ] 8899 8900# 8901# Radio Resource management information elements 8902# 8903 8904 8905# len 6 to max for L3 message (251) 8906class BaRange(Packet): 8907 """ BA Range Section 10.5.2.1a """ 8908 name = "BA Range" 8909 fields_desc = [ 8910 8911 XByteField("lengthBR", None), 8912#error: byte format requires -128 <= number <= 127 8913 ByteField("nrOfRanges", 0x0), 8914# # rX = range X 8915# # L o = Lower H i = higher 8916# # H p = high Part Lp = low Part 8917 ByteField("r1LoHp", 0x0), 8918 8919 BitField("r1LoLp", 0x0, 3), 8920 BitField("r1HiHp", 0x0, 5), 8921 8922 BitField("r1HiLp", 0x0, 4), 8923 BitField("r2LoHp", 0x0, 4), 8924 # optional 8925 BitField("r2LoLp", None, 5), 8926 BitField("r2HiHp", None, 3), 8927 8928 ByteField("r2HiLp", None), 8929 ByteField("r3LoHp", None), 8930 8931 BitField("r3LoLp", None, 5), 8932 BitField("r3HiHp", None, 3), 8933 8934 ByteField("r3HiLp", None), 8935 ByteField("r4LoHp", None), 8936 8937 BitField("r4LoLp", None, 5), 8938 BitField("r4HiHp", None, 3), 8939 ByteField("r4HiLp", None), 8940 ByteField("r5LoHp", None), 8941 8942 BitField("r5LoLp", None, 5), 8943 BitField("r5HiHp", None, 3), 8944 ByteField("r5HiLp", None), 8945 ByteField("r6LoHp", None), 8946 8947 BitField("r6LoLp", None, 5), 8948 BitField("r6HiHp", None, 3), 8949 ByteField("r6HiLp", None), 8950 ByteField("r7LoHp", None), 8951 8952 BitField("r7LoLp", None, 5), 8953 BitField("r7HiHp", None, 3), 8954 ByteField("r7HiLp", None), 8955 ByteField("r8LoHp", None), 8956 8957 BitField("r8LoLp", None, 5), 8958 BitField("r8HiHp", None, 3), 8959 ByteField("r8HiLp", None), 8960 ByteField("r9LoHp", None), 8961 8962 BitField("r9LoLp", None, 5), 8963 BitField("r9HiHp", None, 3), 8964 ByteField("r9HiLp", None), 8965 ByteField("r10LoHp", None), 8966 8967 BitField("r10LoLp", None, 5), 8968 BitField("r10HiHp", None, 3), 8969 ByteField("r10HiLp", None), 8970 ByteField("r11LoHp", None), 8971 8972 BitField("r11LoLp", None, 5), 8973 BitField("r11HiHp", None, 3), 8974 ByteField("r11HiLp", None), 8975 ByteField("r12LoHp", None), 8976 8977 BitField("r12LoLp", None, 5), 8978 BitField("r12HiHp", None, 3), 8979 ByteField("r12HiLp", None), 8980 ByteField("r13LoHp", None), 8981 8982 BitField("r13LoLp", None, 5), 8983 BitField("r13HiHp", None, 3), 8984 ByteField("r13HiLp", None), 8985 ByteField("r14LoHp", None), 8986 8987 BitField("r14LoLp", None, 5), 8988 BitField("r14HiHp", None, 3), 8989 ByteField("r14HiLp", None), 8990 ByteField("r15LoHp", None), 8991 8992 BitField("r15LoLp", None, 5), 8993 BitField("r15HiHp", None, 3), 8994 ByteField("r15HiLp", None), 8995 ByteField("r16LoHp", None), 8996 8997 BitField("r16LoLp", None, 5), 8998 BitField("r16HiHp", None, 3), 8999 ByteField("r16HiLp", None), 9000 ByteField("r17LoHp", None), 9001 9002 BitField("r17LoLp", None, 5), 9003 BitField("r17HiHp", None, 3), 9004 ByteField("r17HiLp", None), 9005 ByteField("r18LoHp", None), 9006 9007 BitField("r18LoLp", None, 5), 9008 BitField("r18HiHp", None, 3), 9009 ByteField("r18HiLp", None), 9010 ByteField("r19LoHp", None), 9011 9012 BitField("r19LoLp", None, 5), 9013 BitField("r19HiHp", None, 3), 9014 ByteField("r19HiLp", None), 9015 ByteField("r20LoHp", None), 9016 9017 BitField("r20LoLp", None, 5), 9018 BitField("r20HiHp", None, 3), 9019 ByteField("r20HiLp", None), 9020 ByteField("r21LoHp", None), 9021 9022 BitField("r21LoLp", None, 5), 9023 BitField("r21HiHp", None, 3), 9024 ByteField("r21HiLp", None), 9025 ByteField("r22LoHp", None), 9026 9027 BitField("r22LoLp", None, 5), 9028 BitField("r22HiHp", None, 3), 9029 ByteField("r22HiLp", None), 9030 ByteField("r23LoHp", None), 9031 9032 BitField("r23LoLp", None, 5), 9033 BitField("r23HiHp", None, 3), 9034 ByteField("r23HiLp", None), 9035 ByteField("r24LoHp", None), 9036 9037 BitField("r24LoLp", None, 5), 9038 BitField("r24HiHp", None, 3), 9039 ByteField("r24HiLp", None), 9040 ByteField("r25LoHp", None), 9041 9042 BitField("r25LoLp", None, 5), 9043 BitField("r25HiHp", None, 3), 9044 ByteField("r25HiLp", None), 9045 ByteField("r26LoHp", None), 9046 9047 BitField("r26LoLp", None, 5), 9048 BitField("r26HiHp", None, 3), 9049 ByteField("r26HiLp", None), 9050 ByteField("r27LoHp", None), 9051 9052 BitField("r27LoLp", None, 5), 9053 BitField("r27HiHp", None, 3), 9054 ByteField("r27HiLp", None), 9055 ByteField("r28LoHp", None), 9056 9057 BitField("r28LoLp", None, 5), 9058 BitField("r28HiHp", None, 3), 9059 ByteField("r28HiLp", None), 9060 ByteField("r29LoHp", None), 9061 9062 BitField("r29LoLp", None, 5), 9063 BitField("r29HiHp", None, 3), 9064 ByteField("r29HiLp", None), 9065 ByteField("r30LoHp", None), 9066 9067 BitField("r30LoLp", None, 5), 9068 BitField("r30HiHp", None, 3), 9069 ByteField("r30HiLp", None), 9070 ByteField("r31LoHp", None), 9071 9072 BitField("r31LoLp", None, 5), 9073 BitField("r31HiHp", None, 3), 9074 ByteField("r31HiLp", None), 9075 ByteField("r32LoHp", None), 9076 9077 BitField("r32LoLp", None, 5), 9078 BitField("r32HiHp", None, 3), 9079 ByteField("r32HiLp", None), 9080 ByteField("r33LoHp", None), 9081 9082 BitField("r33LoLp", None, 5), 9083 BitField("r33HiHp", None, 3), 9084 ByteField("r33HiLp", None), 9085 ByteField("r34LoHp", None), 9086 9087 BitField("r34LoLp", None, 5), 9088 BitField("r34HiHp", None, 3), 9089 ByteField("r34HiLp", None), 9090 ByteField("r35LoHp", None), 9091 9092 BitField("r35LoLp", None, 5), 9093 BitField("r35HiHp", None, 3), 9094 ByteField("r35HiLp", None), 9095 ByteField("r36LoHp", None), 9096 9097 BitField("r36LoLp", None, 5), 9098 BitField("r36HiHp", None, 3), 9099 ByteField("r36HiLp", None), 9100 ByteField("r37LoHp", None), 9101 9102 BitField("r37LoLp", None, 5), 9103 BitField("r37HiHp", None, 3), 9104 ByteField("r37HiLp", None), 9105 ByteField("r38LoHp", None), 9106 9107 BitField("r38LoLp", None, 5), 9108 BitField("r38HiHp", None, 3), 9109 ByteField("r38HiLp", None), 9110 ByteField("r39LoHp", None), 9111 9112 BitField("r39LoLp", None, 5), 9113 BitField("r39HiHp", None, 3), 9114 ByteField("r39HiLp", None), 9115 ByteField("r40LoHp", None), 9116 9117 BitField("r40LoLp", None, 5), 9118 BitField("r40HiHp", None, 3), 9119 ByteField("r40HiLp", None), 9120 ByteField("r41LoHp", None), 9121 9122 BitField("r41LoLp", None, 5), 9123 BitField("r41HiHp", None, 3), 9124 ByteField("r41HiLp", None), 9125 ByteField("r42LoHp", None), 9126 9127 BitField("r42LoLp", None, 5), 9128 BitField("r42HiHp", None, 3), 9129 ByteField("r42HiLp", None), 9130 ByteField("r43LoHp", None), 9131 9132 BitField("r43LoLp", None, 5), 9133 BitField("r43HiHp", None, 3), 9134 ByteField("r43HiLp", None), 9135 ByteField("r44LoHp", None), 9136 9137 BitField("r44LoLp", None, 5), 9138 BitField("r44HiHp", None, 3), 9139 ByteField("r44HiLp", None), 9140 ByteField("r45LoHp", None), 9141 9142 BitField("r45LoLp", None, 5), 9143 BitField("r45HiHp", None, 3), 9144 ByteField("r45HiLp", None), 9145 ByteField("r46LoHp", None), 9146 9147 BitField("r46LoLp", None, 5), 9148 BitField("r46HiHp", None, 3), 9149 ByteField("r46HiLp", None), 9150 ByteField("r47LoHp", None), 9151 9152 BitField("r47LoLp", None, 5), 9153 BitField("r47HiHp", None, 3), 9154 ByteField("r47HiLp", None), 9155 ByteField("r48LoHp", None), 9156 9157 BitField("r48LoLp", None, 5), 9158 BitField("r48HiHp", None, 3), 9159 ByteField("r48HiLp", None), 9160 ByteField("r49LoHp", None), 9161 9162 BitField("r49LoLp", None, 5), 9163 BitField("r49HiHp", None, 3), 9164 ByteField("r49HiLp", None), 9165 ByteField("r50LoHp", None), 9166 9167 BitField("r50LoLp", None, 5), 9168 BitField("r50HiHp", None, 3), 9169 ByteField("r50HiLp", None), 9170 ByteField("r51LoHp", None), 9171 9172 BitField("r51LoLp", None, 5), 9173 BitField("r51HiHp", None, 3), 9174 ByteField("r51HiLp", None), 9175 ByteField("r52LoHp", None), 9176 9177 BitField("r52LoLp", None, 5), 9178 BitField("r52HiHp", None, 3), 9179 ByteField("r52HiLp", None), 9180 ByteField("r53LoHp", None), 9181 9182 BitField("r53LoLp", None, 5), 9183 BitField("r53HiHp", None, 3), 9184 ByteField("r53HiLp", None), 9185 ByteField("r54LoHp", None), 9186 9187 BitField("r54LoLp", None, 5), 9188 BitField("r54HiHp", None, 3), 9189 ByteField("r54HiLp", None), 9190 ByteField("r55LoHp", None), 9191 9192 BitField("r55LoLp", None, 5), 9193 BitField("r55HiHp", None, 3), 9194 ByteField("r55HiLp", None), 9195 ByteField("r56LoHp", None), 9196 9197 BitField("r56LoLp", None, 5), 9198 BitField("r56HiHp", None, 3), 9199 ByteField("r56HiLp", None), 9200 ByteField("r57LoHp", None), 9201 9202 BitField("r57LoLp", None, 5), 9203 BitField("r57HiHp", None, 3), 9204 ByteField("r57HiLp", None), 9205 ByteField("r58LoHp", None), 9206 9207 BitField("r58LoLp", None, 5), 9208 BitField("r58HiHp", None, 3), 9209 ByteField("r58HiLp", None), 9210 ByteField("r59LoHp", None), 9211 9212 BitField("r59LoLp", None, 5), 9213 BitField("r59HiHp", None, 3), 9214 ByteField("r59HiLp", None), 9215 ByteField("r60LoHp", None), 9216 9217 BitField("r60LoLp", None, 5), 9218 BitField("r60HiHp", None, 3), 9219 ByteField("r60HiLp", None), 9220 ByteField("r61LoHp", None), 9221 9222 BitField("r61LoLp", None, 5), 9223 BitField("r61HiHp", None, 3), 9224 ByteField("r61HiLp", None), 9225 ByteField("r62LoHp", None), 9226 9227 BitField("r62LoLp", None, 5), 9228 BitField("r62HiHp", None, 3), 9229 ByteField("r62HiLp", None), 9230 ByteField("r63LoHp", None), 9231 9232 BitField("r63LoLp", None, 5), 9233 BitField("r63HiHp", None, 3), 9234 ByteField("r63HiLp", None), 9235 ByteField("r64LoHp", None), 9236 9237 BitField("r64LoLp", None, 5), 9238 BitField("r64HiHp", None, 3), 9239 ByteField("r64HiLp", None), 9240 ByteField("r65LoHp", None), 9241 9242 BitField("r65LoLp", None, 5), 9243 BitField("r65HiHp", None, 3), 9244 ByteField("r65HiLp", None), 9245 ByteField("r66LoHp", None), 9246 9247 BitField("r66LoLp", None, 5), 9248 BitField("r66HiHp", None, 3), 9249 ByteField("r66HiLp", None), 9250 ByteField("r67LoHp", None), 9251 9252 BitField("r67LoLp", None, 5), 9253 BitField("r67HiHp", None, 3), 9254 ByteField("r67HiLp", None), 9255 ByteField("r68LoHp", None), 9256 9257 BitField("r68LoLp", None, 5), 9258 BitField("r68HiHp", None, 3), 9259 ByteField("r68HiLp", None), 9260 ByteField("r69LoHp", None), 9261 9262 BitField("r69LoLp", None, 5), 9263 BitField("r69HiHp", None, 3), 9264 ByteField("r69HiLp", None), 9265 ByteField("r70LoHp", None), 9266 9267 BitField("r70LoLp", None, 5), 9268 BitField("r70HiHp", None, 3), 9269 ByteField("r70HiLp", None), 9270 ByteField("r71LoHp", None), 9271 9272 BitField("r71LoLp", None, 5), 9273 BitField("r71HiHp", None, 3), 9274 ByteField("r71HiLp", None), 9275 ByteField("r72LoHp", None), 9276 9277 BitField("r72LoLp", None, 5), 9278 BitField("r72HiHp", None, 3), 9279 ByteField("r72HiLp", None), 9280 ByteField("r73LoHp", None), 9281 9282 BitField("r73LoLp", None, 5), 9283 BitField("r73HiHp", None, 3), 9284 ByteField("r73HiLp", None), 9285 ByteField("r74LoHp", None), 9286 9287 BitField("r74LoLp", None, 5), 9288 BitField("r74HiHp", None, 3), 9289 ByteField("r74HiLp", None), 9290 ByteField("r75LoHp", None), 9291 9292 BitField("r75LoLp", None, 5), 9293 BitField("r75HiHp", None, 3), 9294 ByteField("r75HiLp", None), 9295 ByteField("r76LoHp", None), 9296 9297 BitField("r76LoLp", None, 5), 9298 BitField("r76HiHp", None, 3), 9299 ByteField("r76HiLp", None), 9300 ByteField("r77LoHp", None), 9301 9302 BitField("r77LoLp", None, 5), 9303 BitField("r77HiHp", None, 3), 9304 ByteField("r77HiLp", None), 9305 ByteField("r78LoHp", None), 9306 9307 BitField("r78LoLp", None, 5), 9308 BitField("r78HiHp", None, 3), 9309 ByteField("r78HiLp", None), 9310 ByteField("r79LoHp", None), 9311 9312 BitField("r79LoLp", None, 5), 9313 BitField("r79HiHp", None, 3), 9314 ByteField("r79HiLp", None), 9315 ByteField("r80LoHp", None), 9316 9317 BitField("r80LoLp", None, 5), 9318 BitField("r80HiHp", None, 3), 9319 ByteField("r80HiLp", None), 9320 ByteField("r81LoHp", None), 9321 9322 BitField("r81LoLp", None, 5), 9323 BitField("r81HiHp", None, 3), 9324 ByteField("r81HiLp", None), 9325 ByteField("r82LoHp", None), 9326 9327 BitField("r82LoLp", None, 5), 9328 BitField("r82HiHp", None, 3), 9329 ByteField("r82HiLp", None), 9330 ByteField("r83LoHp", None), 9331 9332 BitField("r83LoLp", None, 5), 9333 BitField("r83HiHp", None, 3), 9334 ByteField("r83HiLp", None), 9335 ByteField("r84LoHp", None), 9336 9337 BitField("r84LoLp", None, 5), 9338 BitField("r84HiHp", None, 3), 9339 ByteField("r84HiLp", None) 9340 ] 9341 9342 def post_build(self, p, pay): 9343 a = [getattr(self, fld.name) for fld in self.fields_desc] 9344 res = adapt(5, 253, a, self.fields_desc, 1) 9345 if self.lengthBR is None: 9346 p = struct.pack(">B", res[1]) + p[1:] 9347 if res[0] != 0: 9348 p = p[:-res[0]] 9349 return p + pay 9350 9351 9352# len 3 to max for L3 message (251) 9353class BaListPref(Packet): 9354 """ BA List Pref Section 10.5.2.1c """ 9355 name = "BA List Pref" 9356 fields_desc = [ 9357 XByteField("lengthBLP", None), 9358 9359 BitField("fixBit", 0x0, 1), 9360 BitField("rangeLower", 0x0, 10), 9361 BitField("fixBit2", 0x0, 1), 9362 BitField("rangeUpper", 0x0, 10), 9363 BitField("baFreq", 0x0, 10), 9364 BitField("sparePad", 0x0, 8) 9365 ] 9366 9367 9368# len 17 || Have a look at the specs for the field format 9369# Bit map 0 format 9370# Range 1024 format 9371# Range 512 format 9372# Range 256 format 9373# Range 128 format 9374# Variable bit map format 9375class CellChannelDescription(Packet): 9376 """ Cell Channel Description Section 10.5.2.1b """ 9377 name = "Cell Channel Description " 9378 fields_desc = [ 9379 BitField("bit128", 0x0, 1), 9380 BitField("bit127", 0x0, 1), 9381 BitField("spare1", 0x0, 1), 9382 BitField("spare2", 0x0, 1), 9383 BitField("bit124", 0x0, 1), 9384 BitField("bit123", 0x0, 1), 9385 BitField("bit122", 0x0, 1), 9386 BitField("bit121", 0x0, 1), 9387 ByteField("bit120", 0x0), 9388 ByteField("bit112", 0x0), 9389 ByteField("bit104", 0x0), 9390 ByteField("bit96", 0x0), 9391 ByteField("bit88", 0x0), 9392 ByteField("bit80", 0x0), 9393 ByteField("bit72", 0x0), 9394 ByteField("bit64", 0x0), 9395 ByteField("bit56", 0x0), 9396 ByteField("bit48", 0x0), 9397 ByteField("bit40", 0x0), 9398 ByteField("bit32", 0x0), 9399 ByteField("bit24", 0x0), 9400 ByteField("bit16", 0x0), 9401 ByteField("bit8", 0x0) 9402 ] 9403 9404 9405class CellDescription(Packet): 9406 """ Cell Description Section 10.5.2.2 """ 9407 name = "Cell Description" 9408 fields_desc = [ 9409 BitField("bcchHigh", 0x0, 2), 9410 BitField("ncc", 0x0, 3), 9411 BitField("bcc", 0x0, 3), 9412 ByteField("bcchLow", 0x0) 9413 ] 9414 9415 9416class CellOptionsBCCH(Packet): 9417 """ Cell Options (BCCH) Section 10.5.2.3 """ 9418 name = "Cell Options (BCCH)" 9419 fields_desc = [ 9420 BitField("spare", 0x0, 1), 9421 BitField("pwrc", 0x0, 1), 9422 BitField("dtx", 0x0, 2), 9423 BitField("rLinkTout", 0x0, 4) 9424 ] 9425 9426 9427class CellOptionsSACCH(Packet): 9428 """ Cell Options (SACCH) Section 10.5.2.3a """ 9429 name = "Cell Options (SACCH)" 9430 fields_desc = [ 9431 BitField("dtx", 0x0, 1), 9432 BitField("pwrc", 0x0, 1), 9433 BitField("dtx", 0x0, 1), 9434 BitField("rLinkTout", 0x0, 4) 9435 ] 9436 9437 9438class CellSelectionParameters(Packet): 9439 """ Cell Selection Parameters Section 10.5.2.4 """ 9440 name = "Cell Selection Parameters" 9441 fields_desc = [ 9442 BitField("cellReselect", 0x0, 3), 9443 BitField("msTxPwrMax", 0x0, 5), 9444 BitField("acs", None, 1), 9445 BitField("neci", None, 1), 9446 BitField("rxlenAccMin", None, 6) 9447 ] 9448 9449 9450class MacModeAndChannelCodingRequest(Packet): 9451 """ MAC Mode and Channel Coding Requested Section 10.5.2.4a """ 9452 name = "MAC Mode and Channel Coding Requested" 9453 fields_desc = [ 9454 BitField("macMode", 0x0, 2), 9455 BitField("cs", 0x0, 2) 9456 ] 9457 9458 9459class ChannelDescription(Packet): 9460 """ Channel Description Section 10.5.2.5 """ 9461 name = "Channel Description" 9462 fields_desc = [ 9463 9464 BitField("channelTyp", 0x0, 5), 9465 BitField("tn", 0x0, 3), 9466 9467 BitField("tsc", 0x0, 3), 9468 BitField("h", 0x1, 1), 9469 BitField("maioHi", 0x0, 4), 9470 9471 BitField("maioLo", 0x0, 2), 9472 BitField("hsn", 0x0, 6) 9473 ] 9474 9475 9476class ChannelDescription2(Packet): 9477 """ Channel Description 2 Section 10.5.2.5a """ 9478 name = "Channel Description 2" 9479 fields_desc = [ 9480 BitField("channelTyp", 0x0, 5), 9481 BitField("tn", 0x0, 3), 9482 BitField("tsc", 0x0, 3), 9483 BitField("h", 0x0, 1), 9484 # if h=1 9485 # BitField("maioHi", 0x0, 4), 9486 # BitField("maioLo", 0x0, 2), 9487 # BitField("hsn", 0x0, 6) 9488 BitField("spare", 0x0, 2), 9489 BitField("arfcnHigh", 0x0, 2), 9490 ByteField("arfcnLow", 0x0) 9491 ] 9492 9493 9494class ChannelMode(Packet): 9495 """ Channel Mode Section 10.5.2.6 """ 9496 name = "Channel Mode" 9497 fields_desc = [ 9498 ByteField("mode", 0x0) 9499 ] 9500 9501 9502class ChannelMode2(Packet): 9503 """ Channel Mode 2 Section 10.5.2.7 """ 9504 name = "Channel Mode 2" 9505 fields_desc = [ 9506 ByteField("mode", 0x0) 9507 ] 9508 9509 9510class ChannelNeeded(Packet): 9511 """ Channel Needed Section 10.5.2.8 """ 9512 name = "Channel Needed" 9513 fields_desc = [ 9514 BitField("channel2", 0x0, 2), 9515 BitField("channel1", 0x0, 2), 9516 ] 9517 9518 9519class ChannelRequestDescription(Packet): 9520 """Channel Request Description Section 10.5.2.8a """ 9521 name = "Channel Request Description" 9522 fields_desc = [ 9523 BitField("mt", 0x0, 1), 9524 ConditionalField(BitField("spare", 0x0, 39), 9525 lambda pkt: pkt.mt == 0), 9526 ConditionalField(BitField("spare", 0x0, 3), 9527 lambda pkt: pkt.mt == 1), 9528 ConditionalField(BitField("priority", 0x0, 2), 9529 lambda pkt: pkt.mt == 1), 9530 ConditionalField(BitField("rlcMode", 0x0, 1), 9531 lambda pkt: pkt.mt == 1), 9532 ConditionalField(BitField("llcFrame", 0x1, 1), 9533 lambda pkt: pkt.mt == 1), 9534 ConditionalField(ByteField("reqBandMsb", 0x0), 9535 lambda pkt: pkt.mt == 1), 9536 ConditionalField(ByteField("reqBandLsb", 0x0), 9537 lambda pkt: pkt.mt == 1), 9538 ConditionalField(ByteField("rlcMsb", 0x0), 9539 lambda pkt: pkt.mt == 1), 9540 ConditionalField(ByteField("rlcLsb", 0x0), 9541 lambda pkt: pkt.mt == 1) 9542 ] 9543 9544 9545class CipherModeSetting(Packet): 9546 """Cipher Mode Setting Section 10.5.2.9 """ 9547 name = "Cipher Mode Setting" 9548 fields_desc = [ 9549 BitField("algoId", 0x0, 3), 9550 BitField("sc", 0x0, 1), 9551 ] 9552 9553 9554class CipherResponse(Packet): 9555 """Cipher Response Section 10.5.2.10 """ 9556 name = "Cipher Response" 9557 fields_desc = [ 9558 BitField("spare", 0x0, 3), 9559 BitField("cr", 0x0, 1), 9560 ] 9561 9562 9563class ControlChannelDescription(Packet): 9564 """Control Channel Description Section 10.5.2.11 """ 9565 name = "Control Channel Description" 9566 fields_desc = [ 9567 9568 BitField("spare", 0x0, 1), 9569 BitField("att", 0x0, 1), 9570 BitField("bsAgBlksRes", 0x0, 3), 9571 BitField("ccchConf", 0x0, 3), 9572 9573 BitField("spare", 0x0, 1), 9574 BitField("spare1", 0x0, 1), 9575 BitField("spare2", 0x0, 1), 9576 BitField("spare3", 0x0, 1), 9577 BitField("spare4", 0x0, 1), 9578 BitField("bsPaMfrms", 0x0, 3), 9579 9580 ByteField("t3212", 0x0) 9581 ] 9582 9583 9584class FrequencyChannelSequence(Packet): 9585 """Frequency Channel Sequence Section 10.5.2.12""" 9586 name = "Frequency Channel Sequence" 9587 fields_desc = [ 9588 BitField("spare", 0x0, 1), 9589 BitField("lowestArfcn", 0x0, 7), 9590 BitField("skipArfcn01", 0x0, 4), 9591 BitField("skipArfcn02", 0x0, 4), 9592 BitField("skipArfcn03", 0x0, 4), 9593 BitField("skipArfcn04", 0x0, 4), 9594 BitField("skipArfcn05", 0x0, 4), 9595 BitField("skipArfcn06", 0x0, 4), 9596 BitField("skipArfcn07", 0x0, 4), 9597 BitField("skipArfcn08", 0x0, 4), 9598 BitField("skipArfcn09", 0x0, 4), 9599 BitField("skipArfcn10", 0x0, 4), 9600 BitField("skipArfcn11", 0x0, 4), 9601 BitField("skipArfcn12", 0x0, 4), 9602 BitField("skipArfcn13", 0x0, 4), 9603 BitField("skipArfcn14", 0x0, 4), 9604 BitField("skipArfcn15", 0x0, 4), 9605 BitField("skipArfcn16", 0x0, 4) 9606 ] 9607 9608 9609class FrequencyList(Packet): 9610 """Frequency List Section 10.5.2.13""" 9611 name = "Frequency List" 9612 # Problem: 9613 # There are several formats for the Frequency List information 9614 # element, distinguished by the "format indicator" subfield. 9615 # Some formats are frequency bit maps, the others use a special encoding 9616 # scheme. 9617 fields_desc = [ 9618 XByteField("lengthFL", None), 9619 9620 BitField("formatID", 0x0, 2), 9621 BitField("spare", 0x0, 2), 9622 BitField("arfcn124", 0x0, 1), 9623 BitField("arfcn123", 0x0, 1), 9624 BitField("arfcn122", 0x0, 1), 9625 BitField("arfcn121", 0x0, 1), 9626 9627 ByteField("arfcn120", 0x0), 9628 ByteField("arfcn112", 0x0), 9629 ByteField("arfcn104", 0x0), 9630 ByteField("arfcn96", 0x0), 9631 ByteField("arfcn88", 0x0), 9632 ByteField("arfcn80", 0x0), 9633 ByteField("arfcn72", 0x0), 9634 ByteField("arfcn64", 0x0), 9635 ByteField("arfcn56", 0x0), 9636 ByteField("arfcn48", 0x0), 9637 ByteField("arfcn40", 0x0), 9638 ByteField("arfcn32", 0x0), 9639 ByteField("arfcn24", 0x0), 9640 ByteField("arfcn16", 0x0), 9641 ByteField("arfcn8", 0x0) 9642 ] 9643 9644 9645# len 4 to 13 9646class GroupChannelDescription(Packet): 9647 """Group Channel Description Section 10.5.2.14b""" 9648 name = "Group Channel Description" 9649 fields_desc = [ 9650 XByteField("lengthGCD", None), 9651 9652 BitField("channelType", 0x0, 5), 9653 BitField("tn", 0x0, 3), 9654 9655 BitField("tsc", 0x0, 3), 9656 BitField("h", 0x0, 1), 9657 # if h == 0 the packet looks the following way: 9658 ConditionalField(BitField("spare", 0x0, 2), 9659 lambda pkt: pkt. h == 0x0), 9660 ConditionalField(BitField("arfcnHi", 0x0, 2), 9661 lambda pkt: pkt. h == 0x0), 9662 ConditionalField(ByteField("arfcnLo", None), 9663 lambda pkt: pkt. h == 0x0), 9664 # if h == 1 the packet looks the following way: 9665 ConditionalField(BitField("maioHi", 0x0, 4), 9666 lambda pkt: pkt. h == 0x1), 9667 ConditionalField(BitField("maioLo", None, 2), 9668 lambda pkt: pkt. h == 0x1), 9669 ConditionalField(BitField("hsn", None, 6), 9670 lambda pkt: pkt. h == 0x1), 9671 # finished with conditional fields 9672 ByteField("maC6", None), 9673 ByteField("maC7", None), 9674 ByteField("maC8", None), 9675 ByteField("maC9", None), 9676 ByteField("maC10", None), 9677 ByteField("maC11", None), 9678 ByteField("maC12", None), 9679 ByteField("maC13", None), 9680 ByteField("maC14", None) 9681 ] 9682 9683 def post_build(self, p, pay): 9684 a = [getattr(self, fld.name) for fld in self.fields_desc] 9685 res = adapt(4, 13, a, self.fields_desc, 1) 9686 if self.lengthGCD is None: 9687 p = struct.pack(">B", res[1]) + p[1:] 9688 if res[0] != 0: 9689 p = p[:-res[0]] 9690 return p + pay 9691 9692 9693class GprsResumption(Packet): 9694 """GPRS Resumption Section 10.5.2.14c""" 9695 name = "GPRS Resumption" 9696 fields_desc = [ 9697 BitField("spare", 0x0, 3), 9698 BitField("ack", 0x0, 1) 9699 ] 9700 9701 9702class HandoverReference(Packet): 9703 """Handover Reference Section 10.5.2.15""" 9704 name = "Handover Reference" 9705 fields_desc = [ 9706 ByteField("handoverRef", 0x0) 9707 ] 9708 9709 9710class IraRestOctets(Packet): 9711 """IAR Rest Octets Section 10.5.2.17""" 9712 name = "IAR Rest Octets" 9713 fields_desc = [ 9714 BitField("spare01", 0x0, 1), 9715 BitField("spare02", 0x0, 1), 9716 BitField("spare03", 0x1, 1), 9717 BitField("spare04", 0x0, 1), 9718 BitField("spare05", 0x1, 1), 9719 BitField("spare06", 0x0, 1), 9720 BitField("spare07", 0x1, 1), 9721 BitField("spare08", 0x1, 1), 9722 BitField("spare09", 0x0, 1), 9723 BitField("spare10", 0x0, 1), 9724 BitField("spare11", 0x1, 1), 9725 BitField("spare12", 0x0, 1), 9726 BitField("spare13", 0x1, 1), 9727 BitField("spare14", 0x0, 1), 9728 BitField("spare15", 0x1, 1), 9729 BitField("spare16", 0x1, 1), 9730 BitField("spare17", 0x0, 1), 9731 BitField("spare18", 0x0, 1), 9732 BitField("spare19", 0x1, 1), 9733 BitField("spare20", 0x0, 1), 9734 BitField("spare21", 0x1, 1), 9735 BitField("spare22", 0x0, 1), 9736 BitField("spare23", 0x1, 1), 9737 BitField("spare24", 0x1, 1) 9738 ] 9739 9740 9741# len is 1 to 5 what do we do with the variable size? no length 9742# field?! WTF 9743class IaxRestOctets(Packet): 9744 """IAX Rest Octets Section 10.5.2.18""" 9745 name = "IAX Rest Octets" 9746 fields_desc = [ 9747 BitField("spare01", 0x0, 1), 9748 BitField("spare02", 0x0, 1), 9749 BitField("spare03", 0x1, 1), 9750 BitField("spare04", 0x0, 1), 9751 BitField("spare05", 0x1, 1), 9752 BitField("spare06", 0x0, 1), 9753 BitField("spare07", 0x1, 1), 9754 BitField("spare08", 0x1, 1), 9755 ByteField("spareB1", None), 9756 ByteField("spareB2", None), 9757 ByteField("spareB3", None) 9758 ] 9759 9760 9761class L2PseudoLength(Packet): 9762 """L2 Pseudo Length Section 10.5.2.19""" 9763 name = "L2 Pseudo Length" 9764 fields_desc = [ 9765 BitField("l2pLength", None, 6), 9766 BitField("bit2", 0x0, 1), 9767 BitField("bit1", 0x1, 1) 9768 ] 9769 9770 9771class MeasurementResults(Packet): 9772 """Measurement Results Section 10.5.2.20""" 9773 name = "Measurement Results" 9774 fields_desc = [ 9775 BitField("baUsed", 0x0, 1), 9776 BitField("dtxUsed", 0x0, 1), 9777 BitField("rxLevFull", 0x0, 6), 9778 9779 BitField("spare", 0x0, 1), 9780 BitField("measValid", 0x0, 1), 9781 BitField("rxLevSub", 0x0, 6), 9782 9783 BitField("spare0", 0x0, 1), 9784 BitField("rxqualFull", 0x0, 3), 9785 BitField("rxqualSub", 0x0, 3), 9786 BitField("noNcellHi", 0x0, 1), 9787 9788 BitField("noNcellLo", 0x0, 2), 9789 BitField("rxlevC1", 0x0, 6), 9790 9791 BitField("bcchC1", 0x0, 5), 9792 BitField("bsicC1Hi", 0x0, 3), 9793 9794 BitField("bsicC1Lo", 0x0, 3), 9795 BitField("rxlevC2", 0x0, 5), 9796 9797 BitField("rxlevC2Lo", 0x0, 1), 9798 BitField("bcchC2", 0x0, 5), 9799 BitField("bsicC2Hi", 0x0, 2), 9800 9801 BitField("bscicC2Lo", 0x0, 4), 9802 BitField("bscicC2Hi", 0x0, 4), 9803 9804 BitField("rxlevC3Lo", 0x0, 2), 9805 BitField("bcchC3", 0x0, 5), 9806 BitField("rxlevC3Hi", 0x0, 1), 9807 9808 BitField("bsicC3Lo", 0x0, 5), 9809 BitField("bsicC3Hi", 0x0, 3), 9810 9811 BitField("rxlevC4Lo", 0x0, 3), 9812 BitField("bcchC4", 0x0, 5), 9813 9814 BitField("bsicC4", 0x0, 6), 9815 BitField("rxlevC5Hi", 0x0, 2), 9816 9817 BitField("rxlevC5Lo", 0x0, 4), 9818 BitField("bcchC5Hi", 0x0, 4), 9819 9820 BitField("bcchC5Lo", 0x0, 1), 9821 BitField("bsicC5", 0x0, 6), 9822 BitField("rxlevC6", 0x0, 1), 9823 9824 BitField("rxlevC6Lo", 0x0, 5), 9825 BitField("bcchC6Hi", 0x0, 3), 9826 9827 BitField("bcchC6Lo", 0x0, 3), 9828 BitField("bsicC6", 0x0, 5) 9829 ] 9830 9831 9832class GprsMeasurementResults(Packet): 9833 """GPRS Measurement Results Section 10.5.2.20a""" 9834 name = "GPRS Measurement Results" 9835 fields_desc = [ 9836 BitField("cValue", 0x0, 6), 9837 BitField("rxqualHi", 0x0, 2), 9838 BitField("rxqL", 0x0, 1), 9839 BitField("spare", 0x0, 1), 9840 BitField("signVar", 0x0, 6) 9841 ] 9842 9843 9844# len 3 to 10 9845class MobileAllocation(Packet): 9846 """Mobile Allocation Section 10.5.2.21""" 9847 name = "Mobile Allocation" 9848 fields_desc = [ 9849 XByteField("lengthMA", None), 9850 ByteField("maC64", 0x12), 9851 ByteField("maC56", None), # optional fields start here 9852 ByteField("maC48", None), 9853 ByteField("maC40", None), 9854 ByteField("maC32", None), 9855 ByteField("maC24", None), 9856 ByteField("maC16", None), 9857 ByteField("maC8", None) 9858 ] 9859 9860 def post_build(self, p, pay): 9861 a = [getattr(self, fld.name) for fld in self.fields_desc] 9862 res = adapt(2, 9, a, self.fields_desc, 1) 9863 if self.lengthMA is None: 9864 p = struct.pack(">B", res[1]) + p[1:] 9865 if res[0] != 0: 9866 p = p[:-res[0]] 9867 return p + pay 9868 9869 9870class MobileTimeDifference(Packet): 9871 """Mobile Time Difference Section 10.5.2.21a""" 9872 name = "Mobile Time Difference" 9873 fields_desc = [ 9874 XByteField("lengthMTD", 0x5), 9875 ByteField("valueHi", 0x0), 9876 ByteField("valueCnt", 0x0), 9877 BitField("valueLow", 0x0, 5), 9878 BitField("spare", 0x0, 1), 9879 BitField("spare1", 0x0, 1), 9880 BitField("spare2", 0x0, 1) 9881 ] 9882 9883 9884# min 4 octets max 8 9885class MultiRateConfiguration(Packet): 9886 """ MultiRate configuration Section 10.5.2.21aa""" 9887 name = "MultiRate Configuration" 9888 # This packet has a variable length and hence structure. This packet 9889 # implements the longest possible packet. If you build a shorter 9890 # packet, for example having only 6 bytes, the last 4 bytes are named 9891 # "Spare" in the specs. Here they are named "threshold2" 9892 fields_desc = [ 9893 XByteField("lengthMRC", None), 9894 9895 BitField("mrVersion", 0x0, 3), 9896 BitField("spare", 0x0, 1), 9897 BitField("icmi", 0x0, 1), 9898 BitField("spare", 0x0, 1), 9899 BitField("startMode", 0x0, 2), 9900 9901 ByteField("amrCodec", None), 9902 9903 BitField("spare", None, 2), 9904 BitField("threshold1", None, 6), 9905 9906 BitField("hysteresis1", None, 4), 9907 BitField("threshold2", None, 4), 9908 9909 BitField("threshold2cnt", None, 2), 9910 BitField("hysteresis2", None, 4), 9911 BitField("threshold3", None, 2), 9912 9913 BitField("threshold3cnt", None, 4), 9914 BitField("hysteresis3", None, 4) 9915 ] 9916 9917 def post_build(self, p, pay): 9918 # we set the length 9919 a = [getattr(self, fld.name) for fld in self.fields_desc] 9920 res = adapt(3, 7, a, self.fields_desc, 1) 9921 if self.lengthMRC is None: 9922 p = struct.pack(">B", res[1]) + p[1:] 9923 if res[0] != 0: 9924 p = p[:-res[0]] 9925 return p + pay 9926 9927 9928# len 2 to 11 9929class MultislotAllocation(Packet): 9930 """Multislot Allocation Section 10.5.2.21b""" 9931 name = "Multislot Allocation" 9932 fields_desc = [ 9933 XByteField("lengthMSA", None), 9934 BitField("ext0", 0x1, 1), 9935 BitField("da", 0x0, 7), 9936 ConditionalField(BitField("ext1", 0x1, 1), # optional 9937 lambda pkt: pkt.ext0 == 0), 9938 ConditionalField(BitField("ua", 0x0, 7), 9939 lambda pkt: pkt.ext0 == 0), 9940 ByteField("chan1", None), 9941 ByteField("chan2", None), 9942 ByteField("chan3", None), 9943 ByteField("chan4", None), 9944 ByteField("chan5", None), 9945 ByteField("chan6", None), 9946 ByteField("chan7", None), 9947 ByteField("chan8", None) 9948 ] 9949 9950 def post_build(self, p, pay): 9951 a = [getattr(self, fld.name) for fld in self.fields_desc] 9952 res = adapt(1, 11, a, self.fields_desc, 1) 9953 if res[0] != 0: 9954 p = p[:-res[0]] 9955 if self.lengthMSA is None: 9956 p = struct.pack(">B", len(p)-1) + p[1:] 9957 return p + pay 9958 9959 9960class NcMode(Packet): 9961 """NC mode Section 10.5.2.21c""" 9962 name = "NC Mode" 9963 fields_desc = [ 9964 BitField("spare", 0x0, 2), 9965 BitField("ncMode", 0x0, 2) 9966 ] 9967 9968 9969class NeighbourCellsDescription(Packet): 9970 """Neighbour Cells Description Section 10.5.2.22""" 9971 name = "Neighbour Cells Description" 9972 fields_desc = [ 9973 BitField("bit128", 0x0, 1), 9974 BitField("bit127", 0x0, 1), 9975 BitField("extInd", 0x0, 1), 9976 BitField("baInd", 0x0, 1), 9977 BitField("bit124", 0x0, 1), 9978 BitField("bit123", 0x0, 1), 9979 BitField("bit122", 0x0, 1), 9980 BitField("bit121", 0x0, 1), 9981 BitField("120bits", 0x0, 120) 9982 ] 9983 9984 9985class NeighbourCellsDescription2(Packet): 9986 """Neighbour Cells Description 2 Section 10.5.2.22a""" 9987 name = "Neighbour Cells Description 2" 9988 fields_desc = [ 9989 BitField("bit128", 0x0, 1), 9990 BitField("multiband", 0x0, 2), 9991 BitField("baInd", 0x0, 1), 9992 BitField("bit124", 0x0, 1), 9993 BitField("bit123", 0x0, 1), 9994 BitField("bit122", 0x0, 1), 9995 BitField("bit121", 0x0, 1), 9996 BitField("120bits", 0x0, 120) 9997 ] 9998 9999 10000# len 4 10001# strange packet, lots of valid formats 10002 10003# ideas for the dynamic packets: 10004# 1] for user interaction: Create an interactive "builder" based on a 10005# Q/A process (not very scapy like) 10006# 2] for usage in scripts, create an alternative packet for every 10007# possible packet layout 10008# 10009 10010class DedicatedModeOrTBF(Packet): 10011 """Dedicated mode or TBF Section 10.5.2.25b""" 10012 name = "Dedicated Mode or TBF" 10013 fields_desc = [ 10014 BitField("spare", 0x0, 1), 10015 BitField("tma", 0x0, 1), 10016 BitField("downlink", 0x0, 1), 10017 BitField("td", 0x0, 1) 10018 ] 10019 10020 10021class PageMode(Packet): 10022 """Page Mode Section 10.5.2.26""" 10023 name = "Page Mode" 10024 fields_desc = [ 10025 BitField("spare", 0x0, 1), 10026 BitField("spare1", 0x0, 1), 10027 BitField("pm", 0x0, 2) 10028 ] 10029 10030 10031class NccPermitted(Packet): 10032 """NCC Permitted Section 10.5.2.27""" 10033 name = "NCC Permitted" 10034 fields_desc = [ 10035 ByteField("nccPerm", 0x0) 10036 ] 10037 10038 10039class PowerCommand(Packet): 10040 """Power Command Section 10.5.2.28""" 10041 name = "Power Command" 10042 fields_desc = [ 10043 BitField("spare", 0x0, 1), 10044 BitField("spare1", 0x0, 1), 10045 BitField("spare2", 0x0, 1), 10046 BitField("powerLvl", 0x0, 5) 10047 ] 10048 10049 10050class PowerCommandAndAccessType(Packet): 10051 """Power Command and access type Section 10.5.2.28a""" 10052 name = "Power Command and Access Type" 10053 fields_desc = [ 10054 BitField("atc", 0x0, 1), 10055 BitField("spare", 0x0, 1), 10056 BitField("spare1", 0x0, 1), 10057 BitField("powerLvl", 0x0, 5) 10058 ] 10059 10060 10061class RachControlParameters(Packet): 10062 """RACH Control Parameters Section 10.5.2.29""" 10063 name = "RACH Control Parameters" 10064 fields_desc = [ 10065 BitField("maxRetrans", 0x0, 2), 10066 BitField("txInteger", 0x0, 4), 10067 BitField("cellBarrAccess", 0x0, 1), 10068 BitField("re", 0x0, 1), 10069 BitField("ACC15", 0x0, 1), 10070 BitField("ACC14", 0x0, 1), 10071 BitField("ACC13", 0x0, 1), 10072 BitField("ACC12", 0x0, 1), 10073 BitField("ACC11", 0x0, 1), 10074 BitField("ACC10", 0x0, 1), 10075 BitField("ACC09", 0x0, 1), 10076 BitField("ACC08", 0x0, 1), 10077 BitField("ACC07", 0x0, 1), 10078 BitField("ACC06", 0x0, 1), 10079 BitField("ACC05", 0x0, 1), 10080 BitField("ACC04", 0x0, 1), 10081 BitField("ACC03", 0x0, 1), 10082 BitField("ACC02", 0x0, 1), 10083 BitField("ACC01", 0x0, 1), 10084 BitField("ACC00", 0x0, 1), 10085 ] 10086 10087 10088class RequestReference(Packet): 10089 """Request Reference Section 10.5.2.30""" 10090 name = "Request Reference" 10091 fields_desc = [ 10092 ByteField("ra", 0x0), 10093 BitField("t1", 0x0, 5), 10094 BitField("t3Hi", 0x0, 3), 10095 BitField("t3Lo", 0x0, 3), 10096 BitField("t2", 0x0, 5) 10097 ] 10098 10099 10100class RrCause(Packet): 10101 """RR Cause Section 10.5.2.31""" 10102 name = "RR Cause" 10103 fields_desc = [ 10104 ByteField("rrCause", 0x0) 10105 ] 10106 10107 10108class StartingTime(Packet): 10109 """Starting Time Section 10.5.2.38""" 10110 name = "Starting Time" 10111 fields_desc = [ 10112 ByteField("ra", 0x0), 10113 BitField("t1", 0x0, 5), 10114 BitField("t3Hi", 0x0, 3), 10115 BitField("t3Lo", 0x0, 3), 10116 BitField("t2", 0x0, 5) 10117 ] 10118 10119 10120class SynchronizationIndication(Packet): 10121 """Synchronization Indication Section 10.5.2.39""" 10122 name = "Synchronization Indication" 10123 fields_desc = [ 10124 BitField("nci", 0x0, 1), 10125 BitField("rot", 0x0, 1), 10126 BitField("si", 0x0, 2) 10127 ] 10128 10129 10130class TimingAdvance(Packet): 10131 """Timing Advance Section 10.5.2.40""" 10132 name = "Timing Advance" 10133 fields_desc = [ 10134 BitField("spare", 0x0, 1), 10135 BitField("spare1", 0x0, 1), 10136 BitField("timingVal", 0x0, 6) 10137 ] 10138 10139 10140class TimeDifference(Packet): 10141 """ Time Difference Section 10.5.2.41""" 10142 name = "Time Difference" 10143 fields_desc = [ 10144 XByteField("lengthTD", 0x3), 10145 ByteField("timeValue", 0x0) 10146 ] 10147 10148 10149class Tlli(Packet): 10150 """ TLLI Section Section 10.5.2.41a""" 10151 name = "TLLI" 10152 fields_desc = [ 10153 ByteField("value", 0x0), 10154 ByteField("value1", 0x0), 10155 ByteField("value2", 0x0), 10156 ByteField("value3", 0x0) 10157 ] 10158 10159 10160class TmsiPTmsi(Packet): 10161 """ TMSI/P-TMSI Section 10.5.2.42""" 10162 name = "TMSI/P-TMSI" 10163 fields_desc = [ 10164 ByteField("value", 0x0), 10165 ByteField("value1", 0x0), 10166 ByteField("value2", 0x0), 10167 ByteField("value3", 0x0) 10168 ] 10169 10170 10171class VgcsTargetModeIdentication(Packet): 10172 """ VGCS target Mode Indication 10.5.2.42a""" 10173 name = "VGCS Target Mode Indication" 10174 fields_desc = [ 10175 XByteField("lengthVTMI", 0x2), 10176 BitField("targerMode", 0x0, 2), 10177 BitField("cipherKeyNb", 0x0, 4), 10178 BitField("spare", 0x0, 1), 10179 BitField("spare1", 0x0, 1) 10180 ] 10181 10182 10183class WaitIndication(Packet): 10184 """ Wait Indication Section 10.5.2.43""" 10185 name = "Wait Indication" 10186 fields_desc = [ # asciiart of specs strange 10187 ByteField("timeoutVal", 0x0) 10188 ] 10189 10190 10191#class Si10RestOctets(Packet): 10192# """SI10 rest octets 10.5.2.44""" 10193# name = "SI10 rest octets" 10194# fields_desc = [ 10195 10196 10197# len 17 10198class ExtendedMeasurementResults(Packet): 10199 """EXTENDED MEASUREMENT RESULTS Section 10.5.2.45""" 10200 name = "Extended Measurement Results" 10201 fields_desc = [ 10202 10203 BitField("scUsed", None, 1), 10204 BitField("dtxUsed", None, 1), 10205 BitField("rxLevC0", None, 6), 10206 10207 BitField("rxLevC1", None, 6), 10208 BitField("rxLevC2Hi", None, 2), 10209 10210 BitField("rxLevC2Lo", None, 4), 10211 BitField("rxLevC3Hi", None, 4), 10212 10213 BitField("rxLevC3Lo", None, 3), 10214 BitField("rxLevC4", None, 5), 10215 10216 BitField("rxLevC5", None, 6), 10217 BitField("rxLevC6Hi", None, 2), 10218 10219 BitField("rxLevC6Lo", None, 4), 10220 BitField("rxLevC7Hi", None, 4), 10221 10222 BitField("rxLevC7Lo", None, 2), 10223 BitField("rxLevC8", None, 6), 10224 10225 BitField("rxLevC9", None, 6), 10226 BitField("rxLevC10Hi", None, 2), 10227 10228 BitField("rxLevC10Lo", None, 4), 10229 BitField("rxLevC11Hi", None, 4), 10230 10231 BitField("rxLevC13Lo", None, 2), 10232 BitField("rxLevC12", None, 6), 10233 10234 BitField("rxLevC13", None, 6), 10235 BitField("rxLevC14Hi", None, 2), 10236 10237 BitField("rxLevC14Lo", None, 4), 10238 BitField("rxLevC15Hi", None, 4), 10239 10240 BitField("rxLevC15Lo", None, 2), 10241 BitField("rxLevC16", None, 6), 10242 10243 10244 BitField("rxLevC17", None, 6), 10245 BitField("rxLevC18Hi", None, 2), 10246 10247 BitField("rxLevC18Lo", None, 4), 10248 BitField("rxLevC19Hi", None, 4), 10249 10250 BitField("rxLevC19Lo", None, 2), 10251 BitField("rxLevC20", None, 6) 10252 ] 10253 10254 10255# len 17 10256class ExtendedMeasurementFrequencyList(Packet): 10257 """Extended Measurement Frequency List Section 10.5.2.46""" 10258 name = "Extended Measurement Frequency List" 10259 fields_desc = [ 10260 10261 BitField("bit128", 0x0, 1), 10262 BitField("bit127", 0x0, 1), 10263 BitField("spare", 0x0, 1), 10264 BitField("seqCode", 0x0, 1), 10265 BitField("bit124", 0x0, 1), 10266 BitField("bit123", 0x0, 1), 10267 BitField("bit122", 0x0, 1), 10268 BitField("bit121", 0x0, 1), 10269 10270 BitField("bitsRest", 0x0, 128) 10271 ] 10272 10273 10274class SuspensionCause(Packet): 10275 """Suspension Cause Section 10.5.2.47""" 10276 name = "Suspension Cause" 10277 fields_desc = [ 10278 ByteField("suspVal", 0x0) 10279 ] 10280 10281 10282class ApduID(Packet): 10283 """APDU Flags Section 10.5.2.48""" 10284 name = "Apdu Id" 10285 fields_desc = [ 10286 BitField("id", None, 4) 10287 ] 10288 10289 10290class ApduFlags(Packet): 10291 """APDU Flags Section 10.5.2.49""" 10292 name = "Apdu Flags" 10293 fields_desc = [ 10294 BitField("spare", 0x0, 1), 10295 BitField("cr", 0x0, 1), 10296 BitField("firstSeg", 0x0, 1), 10297 BitField("lastSeg", 0x0, 1) 10298 ] 10299 10300 10301# len 1 to max L3 (251) (done) 10302class ApduData(Packet): 10303 """APDU Data Section 10.5.2.50""" 10304 name = "Apdu Data" 10305 fields_desc = [ 10306 XByteField("lengthAD", None), 10307 #optional 10308 ByteField("apuInfo1", None), 10309 ByteField("apuInfo2", None), 10310 ByteField("apuInfo3", None), 10311 ByteField("apuInfo4", None), 10312 ByteField("apuInfo5", None), 10313 ByteField("apuInfo6", None), 10314 ByteField("apuInfo7", None), 10315 ByteField("apuInfo8", None), 10316 ByteField("apuInfo9", None), 10317 ByteField("apuInfo10", None), 10318 ByteField("apuInfo11", None), 10319 ByteField("apuInfo12", None), 10320 ByteField("apuInfo13", None), 10321 ByteField("apuInfo14", None), 10322 ByteField("apuInfo15", None), 10323 ByteField("apuInfo16", None), 10324 ByteField("apuInfo17", None), 10325 ByteField("apuInfo18", None), 10326 ByteField("apuInfo19", None), 10327 ByteField("apuInfo20", None), 10328 ByteField("apuInfo21", None), 10329 ByteField("apuInfo22", None), 10330 ByteField("apuInfo23", None), 10331 ByteField("apuInfo24", None), 10332 ByteField("apuInfo25", None), 10333 ByteField("apuInfo26", None), 10334 ByteField("apuInfo27", None), 10335 ByteField("apuInfo28", None), 10336 ByteField("apuInfo29", None), 10337 ByteField("apuInfo30", None), 10338 ByteField("apuInfo31", None), 10339 ByteField("apuInfo32", None), 10340 ByteField("apuInfo33", None), 10341 ByteField("apuInfo34", None), 10342 ByteField("apuInfo35", None), 10343 ByteField("apuInfo36", None), 10344 ByteField("apuInfo37", None), 10345 ByteField("apuInfo38", None), 10346 ByteField("apuInfo39", None), 10347 ByteField("apuInfo40", None), 10348 ByteField("apuInfo41", None), 10349 ByteField("apuInfo42", None), 10350 ByteField("apuInfo43", None), 10351 ByteField("apuInfo44", None), 10352 ByteField("apuInfo45", None), 10353 ByteField("apuInfo46", None), 10354 ByteField("apuInfo47", None), 10355 ByteField("apuInfo48", None), 10356 ByteField("apuInfo49", None), 10357 ByteField("apuInfo50", None), 10358 ByteField("apuInfo51", None), 10359 ByteField("apuInfo52", None), 10360 ByteField("apuInfo53", None), 10361 ByteField("apuInfo54", None), 10362 ByteField("apuInfo55", None), 10363 ByteField("apuInfo56", None), 10364 ByteField("apuInfo57", None), 10365 ByteField("apuInfo58", None), 10366 ByteField("apuInfo59", None), 10367 ByteField("apuInfo60", None), 10368 ByteField("apuInfo61", None), 10369 ByteField("apuInfo62", None), 10370 ByteField("apuInfo63", None), 10371 ByteField("apuInfo64", None), 10372 ByteField("apuInfo65", None), 10373 ByteField("apuInfo66", None), 10374 ByteField("apuInfo67", None), 10375 ByteField("apuInfo68", None), 10376 ByteField("apuInfo69", None), 10377 ByteField("apuInfo70", None), 10378 ByteField("apuInfo71", None), 10379 ByteField("apuInfo72", None), 10380 ByteField("apuInfo73", None), 10381 ByteField("apuInfo74", None), 10382 ByteField("apuInfo75", None), 10383 ByteField("apuInfo76", None), 10384 ByteField("apuInfo77", None), 10385 ByteField("apuInfo78", None), 10386 ByteField("apuInfo79", None), 10387 ByteField("apuInfo80", None), 10388 ByteField("apuInfo81", None), 10389 ByteField("apuInfo82", None), 10390 ByteField("apuInfo83", None), 10391 ByteField("apuInfo84", None), 10392 ByteField("apuInfo85", None), 10393 ByteField("apuInfo86", None), 10394 ByteField("apuInfo87", None), 10395 ByteField("apuInfo88", None), 10396 ByteField("apuInfo89", None), 10397 ByteField("apuInfo90", None), 10398 ByteField("apuInfo91", None), 10399 ByteField("apuInfo92", None), 10400 ByteField("apuInfo93", None), 10401 ByteField("apuInfo94", None), 10402 ByteField("apuInfo95", None), 10403 ByteField("apuInfo96", None), 10404 ByteField("apuInfo97", None), 10405 ByteField("apuInfo98", None), 10406 ByteField("apuInfo99", None), 10407 ByteField("apuInfo100", None), 10408 ByteField("apuInfo101", None), 10409 ByteField("apuInfo102", None), 10410 ByteField("apuInfo103", None), 10411 ByteField("apuInfo104", None), 10412 ByteField("apuInfo105", None), 10413 ByteField("apuInfo106", None), 10414 ByteField("apuInfo107", None), 10415 ByteField("apuInfo108", None), 10416 ByteField("apuInfo109", None), 10417 ByteField("apuInfo110", None), 10418 ByteField("apuInfo111", None), 10419 ByteField("apuInfo112", None), 10420 ByteField("apuInfo113", None), 10421 ByteField("apuInfo114", None), 10422 ByteField("apuInfo115", None), 10423 ByteField("apuInfo116", None), 10424 ByteField("apuInfo117", None), 10425 ByteField("apuInfo118", None), 10426 ByteField("apuInfo119", None), 10427 ByteField("apuInfo120", None), 10428 ByteField("apuInfo121", None), 10429 ByteField("apuInfo122", None), 10430 ByteField("apuInfo123", None), 10431 ByteField("apuInfo124", None), 10432 ByteField("apuInfo125", None), 10433 ByteField("apuInfo126", None), 10434 ByteField("apuInfo127", None), 10435 ByteField("apuInfo128", None), 10436 ByteField("apuInfo129", None), 10437 ByteField("apuInfo130", None), 10438 ByteField("apuInfo131", None), 10439 ByteField("apuInfo132", None), 10440 ByteField("apuInfo133", None), 10441 ByteField("apuInfo134", None), 10442 ByteField("apuInfo135", None), 10443 ByteField("apuInfo136", None), 10444 ByteField("apuInfo137", None), 10445 ByteField("apuInfo138", None), 10446 ByteField("apuInfo139", None), 10447 ByteField("apuInfo140", None), 10448 ByteField("apuInfo141", None), 10449 ByteField("apuInfo142", None), 10450 ByteField("apuInfo143", None), 10451 ByteField("apuInfo144", None), 10452 ByteField("apuInfo145", None), 10453 ByteField("apuInfo146", None), 10454 ByteField("apuInfo147", None), 10455 ByteField("apuInfo148", None), 10456 ByteField("apuInfo149", None), 10457 ByteField("apuInfo150", None), 10458 ByteField("apuInfo151", None), 10459 ByteField("apuInfo152", None), 10460 ByteField("apuInfo153", None), 10461 ByteField("apuInfo154", None), 10462 ByteField("apuInfo155", None), 10463 ByteField("apuInfo156", None), 10464 ByteField("apuInfo157", None), 10465 ByteField("apuInfo158", None), 10466 ByteField("apuInfo159", None), 10467 ByteField("apuInfo160", None), 10468 ByteField("apuInfo161", None), 10469 ByteField("apuInfo162", None), 10470 ByteField("apuInfo163", None), 10471 ByteField("apuInfo164", None), 10472 ByteField("apuInfo165", None), 10473 ByteField("apuInfo166", None), 10474 ByteField("apuInfo167", None), 10475 ByteField("apuInfo168", None), 10476 ByteField("apuInfo169", None), 10477 ByteField("apuInfo170", None), 10478 ByteField("apuInfo171", None), 10479 ByteField("apuInfo172", None), 10480 ByteField("apuInfo173", None), 10481 ByteField("apuInfo174", None), 10482 ByteField("apuInfo175", None), 10483 ByteField("apuInfo176", None), 10484 ByteField("apuInfo177", None), 10485 ByteField("apuInfo178", None), 10486 ByteField("apuInfo179", None), 10487 ByteField("apuInfo180", None), 10488 ByteField("apuInfo181", None), 10489 ByteField("apuInfo182", None), 10490 ByteField("apuInfo183", None), 10491 ByteField("apuInfo184", None), 10492 ByteField("apuInfo185", None), 10493 ByteField("apuInfo186", None), 10494 ByteField("apuInfo187", None), 10495 ByteField("apuInfo188", None), 10496 ByteField("apuInfo189", None), 10497 ByteField("apuInfo190", None), 10498 ByteField("apuInfo191", None), 10499 ByteField("apuInfo192", None), 10500 ByteField("apuInfo193", None), 10501 ByteField("apuInfo194", None), 10502 ByteField("apuInfo195", None), 10503 ByteField("apuInfo196", None), 10504 ByteField("apuInfo197", None), 10505 ByteField("apuInfo198", None), 10506 ByteField("apuInfo199", None), 10507 ByteField("apuInfo200", None), 10508 ByteField("apuInfo201", None), 10509 ByteField("apuInfo202", None), 10510 ByteField("apuInfo203", None), 10511 ByteField("apuInfo204", None), 10512 ByteField("apuInfo205", None), 10513 ByteField("apuInfo206", None), 10514 ByteField("apuInfo207", None), 10515 ByteField("apuInfo208", None), 10516 ByteField("apuInfo209", None), 10517 ByteField("apuInfo210", None), 10518 ByteField("apuInfo211", None), 10519 ByteField("apuInfo212", None), 10520 ByteField("apuInfo213", None), 10521 ByteField("apuInfo214", None), 10522 ByteField("apuInfo215", None), 10523 ByteField("apuInfo216", None), 10524 ByteField("apuInfo217", None), 10525 ByteField("apuInfo218", None), 10526 ByteField("apuInfo219", None), 10527 ByteField("apuInfo220", None), 10528 ByteField("apuInfo221", None), 10529 ByteField("apuInfo222", None), 10530 ByteField("apuInfo223", None), 10531 ByteField("apuInfo224", None), 10532 ByteField("apuInfo225", None), 10533 ByteField("apuInfo226", None), 10534 ByteField("apuInfo227", None), 10535 ByteField("apuInfo228", None), 10536 ByteField("apuInfo229", None), 10537 ByteField("apuInfo230", None), 10538 ByteField("apuInfo231", None), 10539 ByteField("apuInfo232", None), 10540 ByteField("apuInfo233", None), 10541 ByteField("apuInfo234", None), 10542 ByteField("apuInfo235", None), 10543 ByteField("apuInfo236", None), 10544 ByteField("apuInfo237", None), 10545 ByteField("apuInfo238", None), 10546 ByteField("apuInfo239", None), 10547 ByteField("apuInfo240", None), 10548 ByteField("apuInfo241", None), 10549 ByteField("apuInfo242", None), 10550 ByteField("apuInfo243", None), 10551 ByteField("apuInfo244", None), 10552 ByteField("apuInfo245", None), 10553 ByteField("apuInfo246", None), 10554 ByteField("apuInfo247", None), 10555 ByteField("apuInfo248", None), 10556 ByteField("apuInfo249", None) 10557 ] 10558 10559 def post_build(self, p, pay): 10560 a = [getattr(self, fld.name) for fld in self.fields_desc] 10561 res = adapt(1, 250, a, self.fields_desc, 1) 10562 if self.lengthAD is None: 10563 p = struct.pack(">B", res[1]) + p[1:] 10564 if res[0] != 0: 10565 p = p[:-res[0]] 10566 return p + pay 10567# 10568# 10.5.3 Mobility management information elements 10569# 10570 10571 10572# len 3 to L3 max (251) (done) 10573class NetworkName(Packet): 10574 """Network Name Section 10.5.3.5a""" 10575 name = "Network Name" 10576 fields_desc = [ 10577 10578 XByteField("lengthNN", None), 10579 10580 BitField("ext", 0x1, 1), 10581 BitField("codingScheme", 0x0, 3), 10582 BitField("addCi", 0x0, 1), 10583 BitField("nbSpare", 0x0, 3), 10584 # optional 10585 ByteField("txtString1", None), 10586 ByteField("txtString2", None), 10587 ByteField("txtString3", None), 10588 ByteField("txtString4", None), 10589 ByteField("txtString5", None), 10590 ByteField("txtString6", None), 10591 ByteField("txtString7", None), 10592 ByteField("txtString8", None), 10593 ByteField("txtString9", None), 10594 ByteField("txtString10", None), 10595 ByteField("txtString11", None), 10596 ByteField("txtString12", None), 10597 ByteField("txtString13", None), 10598 ByteField("txtString14", None), 10599 ByteField("txtString15", None), 10600 ByteField("txtString16", None), 10601 ByteField("txtString17", None), 10602 ByteField("txtString18", None), 10603 ByteField("txtString19", None), 10604 ByteField("txtString20", None), 10605 ByteField("txtString21", None), 10606 ByteField("txtString22", None), 10607 ByteField("txtString23", None), 10608 ByteField("txtString24", None), 10609 ByteField("txtString25", None), 10610 ByteField("txtString26", None), 10611 ByteField("txtString27", None), 10612 ByteField("txtString28", None), 10613 ByteField("txtString29", None), 10614 ByteField("txtString30", None), 10615 ByteField("txtString31", None), 10616 ByteField("txtString32", None), 10617 ByteField("txtString33", None), 10618 ByteField("txtString34", None), 10619 ByteField("txtString35", None), 10620 ByteField("txtString36", None), 10621 ByteField("txtString37", None), 10622 ByteField("txtString38", None), 10623 ByteField("txtString39", None), 10624 ByteField("txtString40", None), 10625 ByteField("txtString41", None), 10626 ByteField("txtString42", None), 10627 ByteField("txtString43", None), 10628 ByteField("txtString44", None), 10629 ByteField("txtString45", None), 10630 ByteField("txtString46", None), 10631 ByteField("txtString47", None), 10632 ByteField("txtString48", None), 10633 ByteField("txtString49", None), 10634 ByteField("txtString50", None), 10635 ByteField("txtString51", None), 10636 ByteField("txtString52", None), 10637 ByteField("txtString53", None), 10638 ByteField("txtString54", None), 10639 ByteField("txtString55", None), 10640 ByteField("txtString56", None), 10641 ByteField("txtString57", None), 10642 ByteField("txtString58", None), 10643 ByteField("txtString59", None), 10644 ByteField("txtString60", None), 10645 ByteField("txtString61", None), 10646 ByteField("txtString62", None), 10647 ByteField("txtString63", None), 10648 ByteField("txtString64", None), 10649 ByteField("txtString65", None), 10650 ByteField("txtString66", None), 10651 ByteField("txtString67", None), 10652 ByteField("txtString68", None), 10653 ByteField("txtString69", None), 10654 ByteField("txtString70", None), 10655 ByteField("txtString71", None), 10656 ByteField("txtString72", None), 10657 ByteField("txtString73", None), 10658 ByteField("txtString74", None), 10659 ByteField("txtString75", None), 10660 ByteField("txtString76", None), 10661 ByteField("txtString77", None), 10662 ByteField("txtString78", None), 10663 ByteField("txtString79", None), 10664 ByteField("txtString80", None), 10665 ByteField("txtString81", None), 10666 ByteField("txtString82", None), 10667 ByteField("txtString83", None), 10668 ByteField("txtString84", None), 10669 ByteField("txtString85", None), 10670 ByteField("txtString86", None), 10671 ByteField("txtString87", None), 10672 ByteField("txtString88", None), 10673 ByteField("txtString89", None), 10674 ByteField("txtString90", None), 10675 ByteField("txtString91", None), 10676 ByteField("txtString92", None), 10677 ByteField("txtString93", None), 10678 ByteField("txtString94", None), 10679 ByteField("txtString95", None), 10680 ByteField("txtString96", None), 10681 ByteField("txtString97", None), 10682 ByteField("txtString98", None), 10683 ByteField("txtString99", None), 10684 ByteField("txtString100", None), 10685 ByteField("txtString101", None), 10686 ByteField("txtString102", None), 10687 ByteField("txtString103", None), 10688 ByteField("txtString104", None), 10689 ByteField("txtString105", None), 10690 ByteField("txtString106", None), 10691 ByteField("txtString107", None), 10692 ByteField("txtString108", None), 10693 ByteField("txtString109", None), 10694 ByteField("txtString110", None), 10695 ByteField("txtString111", None), 10696 ByteField("txtString112", None), 10697 ByteField("txtString113", None), 10698 ByteField("txtString114", None), 10699 ByteField("txtString115", None), 10700 ByteField("txtString116", None), 10701 ByteField("txtString117", None), 10702 ByteField("txtString118", None), 10703 ByteField("txtString119", None), 10704 ByteField("txtString120", None), 10705 ByteField("txtString121", None), 10706 ByteField("txtString122", None), 10707 ByteField("txtString123", None), 10708 ByteField("txtString124", None), 10709 ByteField("txtString125", None), 10710 ByteField("txtString126", None), 10711 ByteField("txtString127", None), 10712 ByteField("txtString128", None), 10713 ByteField("txtString129", None), 10714 ByteField("txtString130", None), 10715 ByteField("txtString131", None), 10716 ByteField("txtString132", None), 10717 ByteField("txtString133", None), 10718 ByteField("txtString134", None), 10719 ByteField("txtString135", None), 10720 ByteField("txtString136", None), 10721 ByteField("txtString137", None), 10722 ByteField("txtString138", None), 10723 ByteField("txtString139", None), 10724 ByteField("txtString140", None), 10725 ByteField("txtString141", None), 10726 ByteField("txtString142", None), 10727 ByteField("txtString143", None), 10728 ByteField("txtString144", None), 10729 ByteField("txtString145", None), 10730 ByteField("txtString146", None), 10731 ByteField("txtString147", None), 10732 ByteField("txtString148", None), 10733 ByteField("txtString149", None), 10734 ByteField("txtString150", None), 10735 ByteField("txtString151", None), 10736 ByteField("txtString152", None), 10737 ByteField("txtString153", None), 10738 ByteField("txtString154", None), 10739 ByteField("txtString155", None), 10740 ByteField("txtString156", None), 10741 ByteField("txtString157", None), 10742 ByteField("txtString158", None), 10743 ByteField("txtString159", None), 10744 ByteField("txtString160", None), 10745 ByteField("txtString161", None), 10746 ByteField("txtString162", None), 10747 ByteField("txtString163", None), 10748 ByteField("txtString164", None), 10749 ByteField("txtString165", None), 10750 ByteField("txtString166", None), 10751 ByteField("txtString167", None), 10752 ByteField("txtString168", None), 10753 ByteField("txtString169", None), 10754 ByteField("txtString170", None), 10755 ByteField("txtString171", None), 10756 ByteField("txtString172", None), 10757 ByteField("txtString173", None), 10758 ByteField("txtString174", None), 10759 ByteField("txtString175", None), 10760 ByteField("txtString176", None), 10761 ByteField("txtString177", None), 10762 ByteField("txtString178", None), 10763 ByteField("txtString179", None), 10764 ByteField("txtString180", None), 10765 ByteField("txtString181", None), 10766 ByteField("txtString182", None), 10767 ByteField("txtString183", None), 10768 ByteField("txtString184", None), 10769 ByteField("txtString185", None), 10770 ByteField("txtString186", None), 10771 ByteField("txtString187", None), 10772 ByteField("txtString188", None), 10773 ByteField("txtString189", None), 10774 ByteField("txtString190", None), 10775 ByteField("txtString191", None), 10776 ByteField("txtString192", None), 10777 ByteField("txtString193", None), 10778 ByteField("txtString194", None), 10779 ByteField("txtString195", None), 10780 ByteField("txtString196", None), 10781 ByteField("txtString197", None), 10782 ByteField("txtString198", None), 10783 ByteField("txtString199", None), 10784 ByteField("txtString200", None), 10785 ByteField("txtString201", None), 10786 ByteField("txtString202", None), 10787 ByteField("txtString203", None), 10788 ByteField("txtString204", None), 10789 ByteField("txtString205", None), 10790 ByteField("txtString206", None), 10791 ByteField("txtString207", None), 10792 ByteField("txtString208", None), 10793 ByteField("txtString209", None), 10794 ByteField("txtString210", None), 10795 ByteField("txtString211", None), 10796 ByteField("txtString212", None), 10797 ByteField("txtString213", None), 10798 ByteField("txtString214", None), 10799 ByteField("txtString215", None), 10800 ByteField("txtString216", None), 10801 ByteField("txtString217", None), 10802 ByteField("txtString218", None), 10803 ByteField("txtString219", None), 10804 ByteField("txtString220", None), 10805 ByteField("txtString221", None), 10806 ByteField("txtString222", None), 10807 ByteField("txtString223", None), 10808 ByteField("txtString224", None), 10809 ByteField("txtString225", None), 10810 ByteField("txtString226", None), 10811 ByteField("txtString227", None), 10812 ByteField("txtString228", None), 10813 ByteField("txtString229", None), 10814 ByteField("txtString230", None), 10815 ByteField("txtString231", None), 10816 ByteField("txtString232", None), 10817 ByteField("txtString233", None), 10818 ByteField("txtString234", None), 10819 ByteField("txtString235", None), 10820 ByteField("txtString236", None), 10821 ByteField("txtString237", None), 10822 ByteField("txtString238", None), 10823 ByteField("txtString239", None), 10824 ByteField("txtString240", None), 10825 ByteField("txtString241", None), 10826 ByteField("txtString242", None), 10827 ByteField("txtString243", None), 10828 ByteField("txtString244", None), 10829 ByteField("txtString245", None), 10830 ByteField("txtString246", None), 10831 ByteField("txtString247", None), 10832 ByteField("txtString248", None) 10833 ] 10834 10835 def post_build(self, p, pay): 10836 a = [getattr(self, fld.name) for fld in self.fields_desc] 10837 res = adapt(2, 250, a, self.fields_desc, 1) 10838 if self.lengthNN is None: 10839 p = struct.pack(">B", res[1]) + p[1:] 10840 if res[0] != 0: 10841 p = p[:-res[0]] 10842 return p + pay 10843 10844 10845class TimeZone(Packet): 10846 """Time Zone Section 10.5.3.8""" 10847 name = "Time Zone" 10848 fields_desc = [ 10849 ByteField("timeZone", 0x0), 10850 ] 10851 10852 10853class TimeZoneAndTime(Packet): 10854 """Time Zone and Time Section 10.5.3.9""" 10855 name = "Time Zone and Time" 10856 fields_desc = [ 10857 ByteField("year", 0x0), 10858 ByteField("month", 0x0), 10859 ByteField("day", 0x0), 10860 ByteField("hour", 0x0), 10861 ByteField("minute", 0x0), 10862 ByteField("second", 0x0), 10863 ByteField("timeZone", 0x0) 10864 ] 10865 10866 10867class CtsPermission(Packet): 10868 """CTS permission Section 10.5.3.10""" 10869 name = "Cts Permission" 10870 fields_desc = [ 10871 ] 10872 10873 10874class LsaIdentifier(Packet): 10875 """LSA Identifier Section 10.5.3.11""" 10876 name = "Lsa Identifier" 10877 fields_desc = [ 10878 ByteField("lsaID", 0x0), 10879 ByteField("lsaID1", 0x0), 10880 ByteField("lsaID2", 0x0) 10881 ] 10882 10883 10884# 10885# 10.5.4 Call control information elements 10886# 10887 10888#10.5.4.1 Extensions of codesets 10889# This is only text and no packet 10890 10891class LockingShiftProcedure(Packet): 10892 """Locking shift procedure Section 10.5.4.2""" 10893 name = "Locking Shift Procedure" 10894 fields_desc = [ 10895 BitField("lockShift", 0x0, 1), 10896 BitField("codesetId", 0x0, 3) 10897 ] 10898 10899 10900class NonLockingShiftProcedure(Packet): 10901 """Non-locking shift procedure Section 10.5.4.3""" 10902 name = "Non-locking Shift Procedure" 10903 fields_desc = [ 10904 BitField("nonLockShift", 0x1, 1), 10905 BitField("codesetId", 0x0, 3) 10906 ] 10907 10908 10909class AuxiliaryStates(Packet): 10910 """Auxiliary states Section 10.5.4.4""" 10911 name = "Auxiliary States" 10912 fields_desc = [ 10913 XByteField("lengthAS", 0x3), 10914 BitField("ext", 0x1, 1), 10915 BitField("spare", 0x0, 3), 10916 BitField("holdState", 0x0, 2), 10917 BitField("mptyState", 0x0, 2) 10918 ] 10919 10920 10921# len 3 to 15 10922class BearerCapability(Packet): 10923 """Bearer capability Section 10.5.4.5""" 10924 name = "Bearer Capability" 10925 fields_desc = [ 10926 10927 XByteField("lengthBC", None), 10928 10929 BitField("ext0", 0x1, 1), 10930 BitField("radioChReq", 0x1, 2), 10931 BitField("codingStd", 0x0, 1), 10932 BitField("transMode", 0x0, 1), 10933 BitField("infoTransCa", 0x0, 3), 10934 # optional 10935 ConditionalField(BitField("ext1", 0x1, 1), 10936 lambda pkt: pkt.ext0 == 0), 10937 ConditionalField(BitField("coding", None, 1), 10938 lambda pkt: pkt.ext0 == 0), 10939 ConditionalField(BitField("spare", None, 2), 10940 lambda pkt: pkt.ext0 == 0), 10941 ConditionalField(BitField("speechVers", 0x0, 4), 10942 lambda pkt: pkt.ext0 == 0), 10943 10944 ConditionalField(BitField("ext2", 0x1, 1), 10945 lambda pkt: pkt.ext1 == 0), 10946 ConditionalField(BitField("compress", None, 1), 10947 lambda pkt: pkt.ext1 == 0), 10948 ConditionalField(BitField("structure", None, 2), 10949 lambda pkt: pkt.ext1 == 0), 10950 ConditionalField(BitField("dupMode", None, 1), 10951 lambda pkt: pkt.ext1 == 0), 10952 ConditionalField(BitField("config", None, 1), 10953 lambda pkt: pkt.ext1 == 0), 10954 ConditionalField(BitField("nirr", None, 1), 10955 lambda pkt: pkt.ext1 == 0), 10956 ConditionalField(BitField("establi", 0x0, 1), 10957 lambda pkt: pkt.ext1 == 0), 10958 10959 BitField("ext3", None, 1), 10960 BitField("accessId", None, 2), 10961 BitField("rateAda", None, 2), 10962 BitField("signaling", None, 3), 10963 10964 ConditionalField(BitField("ext4", None, 1), 10965 lambda pkt: pkt.ext3 == 0), 10966 ConditionalField(BitField("otherITC", None, 2), 10967 lambda pkt: pkt.ext3 == 0), 10968 ConditionalField(BitField("otherRate", None, 2), 10969 lambda pkt: pkt.ext3 == 0), 10970 ConditionalField(BitField("spare1", 0x0, 3), 10971 lambda pkt: pkt.ext3 == 0), 10972 10973 ConditionalField(BitField("ext5", 0x1, 1), 10974 lambda pkt: pkt.ext4 == 0), 10975 ConditionalField(BitField("hdr", None, 1), 10976 lambda pkt: pkt.ext4 == 0), 10977 ConditionalField(BitField("multiFr", None, 1), 10978 lambda pkt: pkt.ext4 == 0), 10979 ConditionalField(BitField("mode", None, 1), 10980 lambda pkt: pkt.ext4 == 0), 10981 ConditionalField(BitField("lli", None, 1), 10982 lambda pkt: pkt.ext4 == 0), 10983 ConditionalField(BitField("assig", None, 1), 10984 lambda pkt: pkt.ext4 == 0), 10985 ConditionalField(BitField("inbNeg", None, 1), 10986 lambda pkt: pkt.ext4 == 0), 10987 ConditionalField(BitField("spare2", 0x0, 1), 10988 lambda pkt: pkt.ext4 == 0), 10989 10990 BitField("ext6", None, 1), 10991 BitField("layer1Id", None, 2), 10992 BitField("userInf", None, 4), 10993 BitField("sync", None, 1), 10994 10995 ConditionalField(BitField("ext7", None, 1), 10996 lambda pkt: pkt.ext6 == 0), 10997 ConditionalField(BitField("stopBit", None, 1), 10998 lambda pkt: pkt.ext6 == 0), 10999 ConditionalField(BitField("negoc", None, 1), 11000 lambda pkt: pkt.ext6 == 0), 11001 ConditionalField(BitField("nbDataBit", None, 1), 11002 lambda pkt: pkt.ext6 == 0), 11003 ConditionalField(BitField("userRate", None, 4), 11004 lambda pkt: pkt.ext6 == 0), 11005 11006 ConditionalField(BitField("ext8", None, 1), 11007 lambda pkt: pkt.ext7 == 0), 11008 ConditionalField(BitField("interRate", None, 2), 11009 lambda pkt: pkt.ext7 == 0), 11010 ConditionalField(BitField("nicTX", None, 1), 11011 lambda pkt: pkt.ext7 == 0), 11012 ConditionalField(BitField("nicRX", None, 1), 11013 lambda pkt: pkt.ext7 == 0), 11014 ConditionalField(BitField("parity", None, 3), 11015 lambda pkt: pkt.ext7 == 0), 11016 11017 ConditionalField(BitField("ext9", None, 1), 11018 lambda pkt: pkt.ext8 == 0), 11019 ConditionalField(BitField("connEle", None, 2), 11020 lambda pkt: pkt.ext8 == 0), 11021 ConditionalField(BitField("modemType", None, 5), 11022 lambda pkt: pkt.ext8 == 0), 11023 11024 ConditionalField(BitField("ext10", None, 1), 11025 lambda pkt: pkt.ext9 == 0), 11026 ConditionalField(BitField("otherModemType", None, 2), 11027 lambda pkt: pkt.ext9 == 0), 11028 ConditionalField(BitField("netUserRate", None, 5), 11029 lambda pkt: pkt.ext9 == 0), 11030 11031 ConditionalField(BitField("ext11", None, 1), 11032 lambda pkt: pkt.ext10 == 0), 11033 ConditionalField(BitField("chanCoding", None, 4), 11034 lambda pkt: pkt.ext10 == 0), 11035 ConditionalField(BitField("maxTrafficChan", None, 3), 11036 lambda pkt: pkt.ext10 == 0), 11037 11038 ConditionalField(BitField("ext12", None, 1), 11039 lambda pkt: pkt.ext11 == 0), 11040 ConditionalField(BitField("uimi", None, 3), 11041 lambda pkt: pkt.ext11 == 0), 11042 ConditionalField(BitField("airInterfaceUserRate", None, 4), 11043 lambda pkt: pkt.ext11 == 0), 11044 11045 ConditionalField(BitField("ext13", 0x1, 1), 11046 lambda pkt: pkt.ext12 == 0), 11047 ConditionalField(BitField("layer2Ch", None, 2), 11048 lambda pkt: pkt.ext12 == 0), 11049 ConditionalField(BitField("userInfoL2", 0x0, 5), 11050 lambda pkt: pkt.ext12 == 0) 11051 ] 11052 11053 def post_build(self, p, pay): 11054 a = [getattr(self, fld.name) for fld in self.fields_desc] 11055 res = adapt(2, 15, a, self.fields_desc, 1) 11056 if res[0] != 0: 11057 p = p[:-res[0]] 11058 if self.lengthBC is None: 11059 p = struct.pack(">B", len(p)-1) + p[1:] 11060 return p + pay 11061 11062 11063class CallControlCapabilities(Packet): 11064 """Call Control Capabilities Section 10.5.4.5a""" 11065 name = "Call Control Capabilities" 11066 fields_desc = [ 11067 XByteField("lengthCCC", 0x3), 11068 BitField("spare", 0x0, 6), 11069 BitField("pcp", 0x0, 1), 11070 BitField("dtmf", 0x0, 1) 11071 ] 11072 11073 11074class CallState(Packet): 11075 """Call State Section 10.5.4.6""" 11076 name = "Call State" 11077 fields_desc = [ 11078 BitField("codingStd", 0x0, 2), 11079 BitField("stateValue", 0x0, 6) 11080 ] 11081 11082 11083# len 3 to 43 11084class CalledPartyBcdNumber(Packet): 11085 """Called party BCD number Section 10.5.4.7""" 11086 name = "Called Party BCD Number" 11087 fields_desc = [ 11088 XByteField("lengthCPBN", None), 11089 BitField("ext", 0x1, 1), 11090 BitField("typeNb", 0x0, 3), 11091 BitField("nbPlanId", 0x0, 4), 11092 # optional 11093 BitField("nbDigit2", None, 4), 11094 BitField("nbDigit1", None, 4), 11095 BitField("nbDigit4", None, 4), 11096 BitField("nbDigit3", None, 4), 11097 11098 BitField("nbDigit6", None, 4), 11099 BitField("nbDigit5", None, 4), 11100 BitField("nbDigit8", None, 4), 11101 BitField("nbDigit7", None, 4), 11102 11103 BitField("nbDigit10", None, 4), 11104 BitField("nbDigit9", None, 4), 11105 BitField("nbDigit12", None, 4), 11106 BitField("nbDigit11", None, 4), 11107 11108 BitField("nbDigit14", None, 4), 11109 BitField("nbDigit13", None, 4), 11110 BitField("nbDigit16", None, 4), 11111 BitField("nbDigit15", None, 4), 11112 11113 BitField("nbDigit18", None, 4), 11114 BitField("nbDigit17", None, 4), 11115 BitField("nbDigit20", None, 4), 11116 BitField("nbDigit19", None, 4), 11117 11118 BitField("nbDigit22", None, 4), 11119 BitField("nbDigit21", None, 4), 11120 BitField("nbDigit24", None, 4), 11121 BitField("nbDigit23", None, 4), 11122 11123 BitField("nbDigit26", None, 4), 11124 BitField("nbDigit25", None, 4), 11125 BitField("nbDigit28", None, 4), 11126 BitField("nbDigit27", None, 4), 11127 11128 BitField("nbDigit30", None, 4), 11129 BitField("nbDigit29", None, 4), 11130 BitField("nbDigit32", None, 4), 11131 BitField("nbDigit31", None, 4), 11132 11133 BitField("nbDigit34", None, 4), 11134 BitField("nbDigit33", None, 4), 11135 BitField("nbDigit36", None, 4), 11136 BitField("nbDigit35", None, 4), 11137 11138 BitField("nbDigit38", None, 4), 11139 BitField("nbDigit37", None, 4), 11140 BitField("nbDigit40", None, 4), 11141 BitField("nbDigit39", None, 4), 11142# ^^^^^^ 20 first optional bytes ^^^^^^^^^^^^^^^ 11143 BitField("nbDigit42", None, 4), 11144 BitField("nbDigit41", None, 4), 11145 BitField("nbDigit44", None, 4), 11146 BitField("nbDigit43", None, 4), 11147 11148 BitField("nbDigit46", None, 4), 11149 BitField("nbDigit45", None, 4), 11150 BitField("nbDigit48", None, 4), 11151 BitField("nbDigit47", None, 4), 11152 11153 BitField("nbDigit50", None, 4), 11154 BitField("nbDigit49", None, 4), 11155 BitField("nbDigit52", None, 4), 11156 BitField("nbDigit51", None, 4), 11157 11158 BitField("nbDigit54", None, 4), 11159 BitField("nbDigit53", None, 4), 11160 BitField("nbDigit56", None, 4), 11161 BitField("nbDigit55", None, 4), 11162 11163 BitField("nbDigit58", None, 4), 11164 BitField("nbDigit57", None, 4), 11165 BitField("nbDigit60", None, 4), 11166 BitField("nbDigit59", None, 4), 11167 11168 BitField("nbDigit62", None, 4), 11169 BitField("nbDigit61", None, 4), 11170 BitField("nbDigit64", None, 4), 11171 BitField("nbDigit63", None, 4), 11172 11173 BitField("nbDigit66", None, 4), 11174 BitField("nbDigit65", None, 4), 11175 BitField("nbDigit68", None, 4), 11176 BitField("nbDigit67", None, 4), 11177 11178 BitField("nbDigit70", None, 4), 11179 BitField("nbDigit69", None, 4), 11180 BitField("nbDigit72", None, 4), 11181 BitField("nbDigit71", None, 4), 11182 11183 BitField("nbDigit74", None, 4), 11184 BitField("nbDigit73", None, 4), 11185 BitField("nbDigit76", None, 4), 11186 BitField("nbDigit75", None, 4), 11187 11188 BitField("nbDigit78", None, 4), 11189 BitField("nbDigit77", None, 4), 11190 BitField("nbDigit80", None, 4), 11191 BitField("nbDigit79", None, 4), 11192 ] 11193 11194 def post_build(self, p, pay): 11195 a = [getattr(self, fld.name) for fld in self.fields_desc] 11196 res = adapt(2, 42, a, self.fields_desc, 1) 11197 if self.lengthCPBN is None: 11198 p = struct.pack(">B", res[1]) + p[1:] 11199 if res[0] != 0: 11200 p = p[:-res[0]] 11201 return p + pay 11202 11203 11204# len 2 to 23 11205class CalledPartySubaddress(Packet): 11206 """Called party subaddress Section 10.5.4.8""" 11207 name = "Called Party Subaddress" 11208 fields_desc = [ 11209 XByteField("lengthCPS", None), 11210 # optional 11211 BitField("ext", None, 1), 11212 BitField("subAddr", None, 3), 11213 BitField("oddEven", None, 1), 11214 BitField("spare", None, 3), 11215 11216 ByteField("subInfo0", None), 11217 ByteField("subInfo1", None), 11218 ByteField("subInfo2", None), 11219 ByteField("subInfo3", None), 11220 ByteField("subInfo4", None), 11221 ByteField("subInfo5", None), 11222 ByteField("subInfo6", None), 11223 ByteField("subInfo7", None), 11224 ByteField("subInfo8", None), 11225 ByteField("subInfo9", None), 11226 ByteField("subInfo10", None), 11227 ByteField("subInfo11", None), 11228 ByteField("subInfo12", None), 11229 ByteField("subInfo13", None), 11230 ByteField("subInfo14", None), 11231 ByteField("subInfo15", None), 11232 ByteField("subInfo16", None), 11233 ByteField("subInfo17", None), 11234 ByteField("subInfo18", None), 11235 ByteField("subInfo19", None) 11236 ] 11237 11238 def post_build(self, p, pay): 11239 a = [getattr(self, fld.name) for fld in self.fields_desc] 11240 res = adapt(2, 23, a, self.fields_desc, 1) 11241 if self.lengthCPS is None: 11242 p = struct.pack(">B", res[1]) + p[1:] 11243 if res[0] != 0: 11244 p = p[:-res[0]] 11245 return p + pay 11246 11247 11248# len 3 to 14 11249class CallingPartyBcdNumber(Packet): 11250 """Called party subaddress Section 10.5.4.9""" 11251 name = "Called Party Subaddress" 11252 fields_desc = [ 11253 XByteField("lengthCPBN", None), 11254 BitField("ext", 0x1, 1), 11255 BitField("typeNb", 0x0, 3), 11256 BitField("nbPlanId", 0x0, 4), 11257 # optional 11258 ConditionalField(BitField("ext1", 0x1, 1), 11259 lambda pkt: pkt.ext == 0), 11260 ConditionalField(BitField("presId", None, 2), 11261 lambda pkt: pkt.ext == 0), 11262 ConditionalField(BitField("spare", None, 3), 11263 lambda pkt: pkt.ext == 0), 11264 ConditionalField(BitField("screenId", 0x0, 2), 11265 lambda pkt: pkt.ext == 0), 11266 11267 BitField("nbDigit2", None, 4), 11268 BitField("nbDigit1", None, 4), 11269 11270 BitField("nbDigit4", None, 4), 11271 BitField("nbDigit3", None, 4), 11272 11273 BitField("nbDigit6", None, 4), 11274 BitField("nbDigit5", None, 4), 11275 11276 BitField("nbDigit8", None, 4), 11277 BitField("nbDigit7", None, 4), 11278 11279 BitField("nbDigit10", None, 4), 11280 BitField("nbDigit9", None, 4), 11281 11282 BitField("nbDigit12", None, 4), 11283 BitField("nbDigit11", None, 4), 11284 11285 BitField("nbDigit14", None, 4), 11286 BitField("nbDigit13", None, 4), 11287 11288 BitField("nbDigit16", None, 4), 11289 BitField("nbDigit15", None, 4), 11290 11291 BitField("nbDigit18", None, 4), 11292 BitField("nbDigit17", None, 4), 11293 11294 BitField("nbDigit20", None, 4), 11295 BitField("nbDigit19", None, 4), 11296 ] 11297 11298 def post_build(self, p, pay): 11299 a = [getattr(self, fld.name) for fld in self.fields_desc] 11300 res = adapt(2, 13, a, self.fields_desc, 1) 11301 if res[0] != 0: 11302 p = p[:-res[0]] 11303 if self.lengthCPBN is None: 11304 p = struct.pack(">B", len(p)-1) + p[1:] 11305 return p + pay 11306 11307 11308# len 2 to 23 11309class CallingPartySubaddress(Packet): 11310 """Calling party subaddress Section 10.5.4.10""" 11311 name = "Calling Party Subaddress" 11312 fields_desc = [ 11313 XByteField("lengthCPS", None), 11314 # optional 11315 BitField("ext1", None, 1), 11316 BitField("typeAddr", None, 3), 11317 BitField("oddEven", None, 1), 11318 BitField("spare", None, 3), 11319 11320 ByteField("subInfo0", None), 11321 ByteField("subInfo1", None), 11322 ByteField("subInfo2", None), 11323 ByteField("subInfo3", None), 11324 ByteField("subInfo4", None), 11325 ByteField("subInfo5", None), 11326 ByteField("subInfo6", None), 11327 ByteField("subInfo7", None), 11328 ByteField("subInfo8", None), 11329 ByteField("subInfo9", None), 11330 ByteField("subInfo10", None), 11331 ByteField("subInfo11", None), 11332 ByteField("subInfo12", None), 11333 ByteField("subInfo13", None), 11334 ByteField("subInfo14", None), 11335 ByteField("subInfo15", None), 11336 ByteField("subInfo16", None), 11337 ByteField("subInfo17", None), 11338 ByteField("subInfo18", None), 11339 ByteField("subInfo19", None) 11340 ] 11341 11342 def post_build(self, p, pay): 11343 a = [getattr(self, fld.name) for fld in self.fields_desc] 11344 res = adapt(1, 22, a, self.fields_desc, 1) 11345 if self.lengthCPS is None: 11346 p = struct.pack(">B", res[1]) + p[1:] 11347 if res[0] != 0: 11348 p = p[:-res[0]] 11349 return p + pay 11350 11351 11352# len 4 to 32 11353class Cause(Packet): 11354 """Cause Section 10.5.4.11""" 11355 name = "Cause" 11356 fields_desc = [ 11357 11358 XByteField("lengthC", None), 11359 11360 BitField("ext", 0x1, 1), 11361 BitField("codingStd", 0x0, 2), 11362 BitField("spare", 0x0, 1), 11363 BitField("location", 0x0, 4), 11364 11365 ConditionalField(BitField("ext1", 0x1, 1), 11366 lambda pkt: pkt.ext == 0), 11367 ConditionalField(BitField("recommendation", 0x1, 7), 11368 lambda pkt: pkt.ext == 0), 11369 # optional 11370 BitField("ext2", None, 1), 11371 BitField("causeValue", None, 7), 11372 11373 ByteField("diagnositc0", None), 11374 ByteField("diagnositc1", None), 11375 ByteField("diagnositc2", None), 11376 ByteField("diagnositc3", None), 11377 ByteField("diagnositc4", None), 11378 ByteField("diagnositc5", None), 11379 ByteField("diagnositc6", None), 11380 ByteField("diagnositc7", None), 11381 ByteField("diagnositc8", None), 11382 ByteField("diagnositc9", None), 11383 ByteField("diagnositc10", None), 11384 ByteField("diagnositc11", None), 11385 ByteField("diagnositc12", None), 11386 ByteField("diagnositc13", None), 11387 ByteField("diagnositc14", None), 11388 ByteField("diagnositc15", None), 11389 ByteField("diagnositc16", None), 11390 ByteField("diagnositc17", None), 11391 ByteField("diagnositc18", None), 11392 ByteField("diagnositc19", None), 11393 ByteField("diagnositc20", None), 11394 ByteField("diagnositc21", None), 11395 ByteField("diagnositc22", None), 11396 ByteField("diagnositc23", None), 11397 ByteField("diagnositc24", None), 11398 ByteField("diagnositc25", None), 11399 ByteField("diagnositc26", None), 11400 ] 11401 11402 def post_build(self, p, pay): 11403 a = [getattr(self, fld.name) for fld in self.fields_desc] 11404 res = adapt(3, 31, a, self.fields_desc, 1) 11405 if res[0] != 0: 11406 p = p[:-res[0]] 11407 if self.lengthC is None: 11408 p = struct.pack(">B", len(p)-1) + p[1:] 11409 return p + pay 11410 11411 11412class ClirSuppression(Packet): 11413 """CLIR suppression Section 10.5.4.11a""" 11414 name = "Clir Suppression" 11415 fields_desc = [ 11416 ] 11417 11418 11419class ClirInvocation(Packet): 11420 """CLIR invocation Section 10.5.4.11b""" 11421 name = "Clir Invocation" 11422 fields_desc = [ 11423 ] 11424 11425 11426class CongestionLevel(Packet): 11427 """Congestion level Section 10.5.4.12""" 11428 name = "Congestion Level" 11429 fields_desc = [ 11430 BitField("notDef", 0x0, 4) # not defined by the std 11431 ] 11432 11433 11434# len 3 to 14 11435class ConnectedNumber(Packet): 11436 """Connected number Section 10.5.4.13""" 11437 name = "Connected Number" 11438 fields_desc = [ 11439 11440 XByteField("lengthCN", None), 11441 11442 BitField("ext", 0x1, 1), 11443 BitField("typeNb", 0x0, 3), 11444 BitField("typePlanId", 0x0, 4), 11445 # optional 11446 ConditionalField(BitField("ext1", 0x1, 1), 11447 lambda pkt: pkt.ext == 0), 11448 ConditionalField(BitField("presId", None, 2), 11449 lambda pkt: pkt.ext == 0), 11450 ConditionalField(BitField("spare", None, 3), 11451 lambda pkt: pkt.ext == 0), 11452 ConditionalField(BitField("screenId", None, 2), 11453 lambda pkt: pkt.ext == 0), 11454 11455 BitField("nbDigit2", None, 4), 11456 BitField("nbDigit1", None, 4), 11457 11458 BitField("nbDigit4", None, 4), 11459 BitField("nbDigit3", None, 4), 11460 11461 BitField("nbDigit6", None, 4), 11462 BitField("nbDigit5", None, 4), 11463 11464 BitField("nbDigit8", None, 4), 11465 BitField("nbDigit7", None, 4), 11466 11467 BitField("nbDigit10", None, 4), 11468 BitField("nbDigit9", None, 4), 11469 11470 BitField("nbDigit12", None, 4), 11471 BitField("nbDigit11", None, 4), 11472 11473 BitField("nbDigit14", None, 4), 11474 BitField("nbDigit13", None, 4), 11475 11476 BitField("nbDigit16", None, 4), 11477 BitField("nbDigit15", None, 4), 11478 11479 BitField("nbDigit18", None, 4), 11480 BitField("nbDigit17", None, 4), 11481 11482 BitField("nbDigit20", None, 4), 11483 BitField("nbDigit19", None, 4) 11484 ] 11485 11486 def post_build(self, p, pay): 11487 a = [getattr(self, fld.name) for fld in self.fields_desc] 11488 res = adapt(2, 13, a, self.fields_desc, 1) 11489 if res[0] != 0: 11490 p = p[:-res[0]] 11491 if self.lengthCN is None: 11492 p = struct.pack(">B", len(p)-1) + p[1:] 11493 return p + pay 11494 11495 11496# len 2 to 23 11497class ConnectedSubaddress(Packet): 11498 """Connected subaddress Section 10.5.4.14""" 11499 name = "Connected Subaddress" 11500 fields_desc = [ 11501 11502 XByteField("lengthCS", None), 11503 # optional 11504 BitField("ext", None, 1), 11505 BitField("typeOfSub", None, 3), 11506 BitField("oddEven", None, 1), 11507 BitField("spare", None, 3), 11508 11509 ByteField("subInfo0", None), 11510 ByteField("subInfo1", None), 11511 ByteField("subInfo2", None), 11512 ByteField("subInfo3", None), 11513 ByteField("subInfo4", None), 11514 ByteField("subInfo5", None), 11515 ByteField("subInfo6", None), 11516 ByteField("subInfo7", None), 11517 ByteField("subInfo8", None), 11518 ByteField("subInfo9", None), 11519 ByteField("subInfo10", None), 11520 ByteField("subInfo11", None), 11521 ByteField("subInfo12", None), 11522 ByteField("subInfo13", None), 11523 ByteField("subInfo14", None), 11524 ByteField("subInfo15", None), 11525 ByteField("subInfo16", None), 11526 ByteField("subInfo17", None), 11527 ByteField("subInfo18", None), 11528 ByteField("subInfo19", None) 11529 ] 11530 11531 def post_build(self, p, pay): 11532 a = [getattr(self, fld.name) for fld in self.fields_desc] 11533 res = adapt(1, 22, a, self.fields_desc, 1) 11534 if self.lengthCS is None: 11535 p = struct.pack(">B", res[1]) + p[1:] 11536 if res[0] != 0: 11537 p = p[:-res[0]] 11538 return p + pay 11539 11540 11541# len 2 to L3 (251) (done) 11542class Facility(Packet): 11543 """Facility Section 10.5.4.15""" 11544 name = "Facility" 11545 fields_desc = [ 11546 XByteField("lengthF", None), 11547 # optional 11548 ByteField("facilityInfo1", None), 11549 ByteField("facilityInfo2", None), 11550 ByteField("facilityInfo3", None), 11551 ByteField("facilityInfo4", None), 11552 ByteField("facilityInfo5", None), 11553 ByteField("facilityInfo6", None), 11554 ByteField("facilityInfo7", None), 11555 ByteField("facilityInfo8", None), 11556 ByteField("facilityInfo9", None), 11557 ByteField("facilityInfo10", None), 11558 ByteField("facilityInfo11", None), 11559 ByteField("facilityInfo12", None), 11560 ByteField("facilityInfo13", None), 11561 ByteField("facilityInfo14", None), 11562 ByteField("facilityInfo15", None), 11563 ByteField("facilityInfo16", None), 11564 ByteField("facilityInfo17", None), 11565 ByteField("facilityInfo18", None), 11566 ByteField("facilityInfo19", None), 11567 ByteField("facilityInfo20", None), 11568 ByteField("facilityInfo21", None), 11569 ByteField("facilityInfo22", None), 11570 ByteField("facilityInfo23", None), 11571 ByteField("facilityInfo24", None), 11572 ByteField("facilityInfo25", None), 11573 ByteField("facilityInfo26", None), 11574 ByteField("facilityInfo27", None), 11575 ByteField("facilityInfo28", None), 11576 ByteField("facilityInfo29", None), 11577 ByteField("facilityInfo30", None), 11578 ByteField("facilityInfo31", None), 11579 ByteField("facilityInfo32", None), 11580 ByteField("facilityInfo33", None), 11581 ByteField("facilityInfo34", None), 11582 ByteField("facilityInfo35", None), 11583 ByteField("facilityInfo36", None), 11584 ByteField("facilityInfo37", None), 11585 ByteField("facilityInfo38", None), 11586 ByteField("facilityInfo39", None), 11587 ByteField("facilityInfo40", None), 11588 ByteField("facilityInfo41", None), 11589 ByteField("facilityInfo42", None), 11590 ByteField("facilityInfo43", None), 11591 ByteField("facilityInfo44", None), 11592 ByteField("facilityInfo45", None), 11593 ByteField("facilityInfo46", None), 11594 ByteField("facilityInfo47", None), 11595 ByteField("facilityInfo48", None), 11596 ByteField("facilityInfo49", None), 11597 ByteField("facilityInfo50", None), 11598 ByteField("facilityInfo51", None), 11599 ByteField("facilityInfo52", None), 11600 ByteField("facilityInfo53", None), 11601 ByteField("facilityInfo54", None), 11602 ByteField("facilityInfo55", None), 11603 ByteField("facilityInfo56", None), 11604 ByteField("facilityInfo57", None), 11605 ByteField("facilityInfo58", None), 11606 ByteField("facilityInfo59", None), 11607 ByteField("facilityInfo60", None), 11608 ByteField("facilityInfo61", None), 11609 ByteField("facilityInfo62", None), 11610 ByteField("facilityInfo63", None), 11611 ByteField("facilityInfo64", None), 11612 ByteField("facilityInfo65", None), 11613 ByteField("facilityInfo66", None), 11614 ByteField("facilityInfo67", None), 11615 ByteField("facilityInfo68", None), 11616 ByteField("facilityInfo69", None), 11617 ByteField("facilityInfo70", None), 11618 ByteField("facilityInfo71", None), 11619 ByteField("facilityInfo72", None), 11620 ByteField("facilityInfo73", None), 11621 ByteField("facilityInfo74", None), 11622 ByteField("facilityInfo75", None), 11623 ByteField("facilityInfo76", None), 11624 ByteField("facilityInfo77", None), 11625 ByteField("facilityInfo78", None), 11626 ByteField("facilityInfo79", None), 11627 ByteField("facilityInfo80", None), 11628 ByteField("facilityInfo81", None), 11629 ByteField("facilityInfo82", None), 11630 ByteField("facilityInfo83", None), 11631 ByteField("facilityInfo84", None), 11632 ByteField("facilityInfo85", None), 11633 ByteField("facilityInfo86", None), 11634 ByteField("facilityInfo87", None), 11635 ByteField("facilityInfo88", None), 11636 ByteField("facilityInfo89", None), 11637 ByteField("facilityInfo90", None), 11638 ByteField("facilityInfo91", None), 11639 ByteField("facilityInfo92", None), 11640 ByteField("facilityInfo93", None), 11641 ByteField("facilityInfo94", None), 11642 ByteField("facilityInfo95", None), 11643 ByteField("facilityInfo96", None), 11644 ByteField("facilityInfo97", None), 11645 ByteField("facilityInfo98", None), 11646 ByteField("facilityInfo99", None), 11647 ByteField("facilityInfo100", None), 11648 ByteField("facilityInfo101", None), 11649 ByteField("facilityInfo102", None), 11650 ByteField("facilityInfo103", None), 11651 ByteField("facilityInfo104", None), 11652 ByteField("facilityInfo105", None), 11653 ByteField("facilityInfo106", None), 11654 ByteField("facilityInfo107", None), 11655 ByteField("facilityInfo108", None), 11656 ByteField("facilityInfo109", None), 11657 ByteField("facilityInfo110", None), 11658 ByteField("facilityInfo111", None), 11659 ByteField("facilityInfo112", None), 11660 ByteField("facilityInfo113", None), 11661 ByteField("facilityInfo114", None), 11662 ByteField("facilityInfo115", None), 11663 ByteField("facilityInfo116", None), 11664 ByteField("facilityInfo117", None), 11665 ByteField("facilityInfo118", None), 11666 ByteField("facilityInfo119", None), 11667 ByteField("facilityInfo120", None), 11668 ByteField("facilityInfo121", None), 11669 ByteField("facilityInfo122", None), 11670 ByteField("facilityInfo123", None), 11671 ByteField("facilityInfo124", None), 11672 ByteField("facilityInfo125", None), 11673 ByteField("facilityInfo126", None), 11674 ByteField("facilityInfo127", None), 11675 ByteField("facilityInfo128", None), 11676 ByteField("facilityInfo129", None), 11677 ByteField("facilityInfo130", None), 11678 ByteField("facilityInfo131", None), 11679 ByteField("facilityInfo132", None), 11680 ByteField("facilityInfo133", None), 11681 ByteField("facilityInfo134", None), 11682 ByteField("facilityInfo135", None), 11683 ByteField("facilityInfo136", None), 11684 ByteField("facilityInfo137", None), 11685 ByteField("facilityInfo138", None), 11686 ByteField("facilityInfo139", None), 11687 ByteField("facilityInfo140", None), 11688 ByteField("facilityInfo141", None), 11689 ByteField("facilityInfo142", None), 11690 ByteField("facilityInfo143", None), 11691 ByteField("facilityInfo144", None), 11692 ByteField("facilityInfo145", None), 11693 ByteField("facilityInfo146", None), 11694 ByteField("facilityInfo147", None), 11695 ByteField("facilityInfo148", None), 11696 ByteField("facilityInfo149", None), 11697 ByteField("facilityInfo150", None), 11698 ByteField("facilityInfo151", None), 11699 ByteField("facilityInfo152", None), 11700 ByteField("facilityInfo153", None), 11701 ByteField("facilityInfo154", None), 11702 ByteField("facilityInfo155", None), 11703 ByteField("facilityInfo156", None), 11704 ByteField("facilityInfo157", None), 11705 ByteField("facilityInfo158", None), 11706 ByteField("facilityInfo159", None), 11707 ByteField("facilityInfo160", None), 11708 ByteField("facilityInfo161", None), 11709 ByteField("facilityInfo162", None), 11710 ByteField("facilityInfo163", None), 11711 ByteField("facilityInfo164", None), 11712 ByteField("facilityInfo165", None), 11713 ByteField("facilityInfo166", None), 11714 ByteField("facilityInfo167", None), 11715 ByteField("facilityInfo168", None), 11716 ByteField("facilityInfo169", None), 11717 ByteField("facilityInfo170", None), 11718 ByteField("facilityInfo171", None), 11719 ByteField("facilityInfo172", None), 11720 ByteField("facilityInfo173", None), 11721 ByteField("facilityInfo174", None), 11722 ByteField("facilityInfo175", None), 11723 ByteField("facilityInfo176", None), 11724 ByteField("facilityInfo177", None), 11725 ByteField("facilityInfo178", None), 11726 ByteField("facilityInfo179", None), 11727 ByteField("facilityInfo180", None), 11728 ByteField("facilityInfo181", None), 11729 ByteField("facilityInfo182", None), 11730 ByteField("facilityInfo183", None), 11731 ByteField("facilityInfo184", None), 11732 ByteField("facilityInfo185", None), 11733 ByteField("facilityInfo186", None), 11734 ByteField("facilityInfo187", None), 11735 ByteField("facilityInfo188", None), 11736 ByteField("facilityInfo189", None), 11737 ByteField("facilityInfo190", None), 11738 ByteField("facilityInfo191", None), 11739 ByteField("facilityInfo192", None), 11740 ByteField("facilityInfo193", None), 11741 ByteField("facilityInfo194", None), 11742 ByteField("facilityInfo195", None), 11743 ByteField("facilityInfo196", None), 11744 ByteField("facilityInfo197", None), 11745 ByteField("facilityInfo198", None), 11746 ByteField("facilityInfo199", None), 11747 ByteField("facilityInfo200", None), 11748 ByteField("facilityInfo201", None), 11749 ByteField("facilityInfo202", None), 11750 ByteField("facilityInfo203", None), 11751 ByteField("facilityInfo204", None), 11752 ByteField("facilityInfo205", None), 11753 ByteField("facilityInfo206", None), 11754 ByteField("facilityInfo207", None), 11755 ByteField("facilityInfo208", None), 11756 ByteField("facilityInfo209", None), 11757 ByteField("facilityInfo210", None), 11758 ByteField("facilityInfo211", None), 11759 ByteField("facilityInfo212", None), 11760 ByteField("facilityInfo213", None), 11761 ByteField("facilityInfo214", None), 11762 ByteField("facilityInfo215", None), 11763 ByteField("facilityInfo216", None), 11764 ByteField("facilityInfo217", None), 11765 ByteField("facilityInfo218", None), 11766 ByteField("facilityInfo219", None), 11767 ByteField("facilityInfo220", None), 11768 ByteField("facilityInfo221", None), 11769 ByteField("facilityInfo222", None), 11770 ByteField("facilityInfo223", None), 11771 ByteField("facilityInfo224", None), 11772 ByteField("facilityInfo225", None), 11773 ByteField("facilityInfo226", None), 11774 ByteField("facilityInfo227", None), 11775 ByteField("facilityInfo228", None), 11776 ByteField("facilityInfo229", None), 11777 ByteField("facilityInfo230", None), 11778 ByteField("facilityInfo231", None), 11779 ByteField("facilityInfo232", None), 11780 ByteField("facilityInfo233", None), 11781 ByteField("facilityInfo234", None), 11782 ByteField("facilityInfo235", None), 11783 ByteField("facilityInfo236", None), 11784 ByteField("facilityInfo237", None), 11785 ByteField("facilityInfo238", None), 11786 ByteField("facilityInfo239", None), 11787 ByteField("facilityInfo240", None), 11788 ByteField("facilityInfo241", None), 11789 ByteField("facilityInfo242", None), 11790 ByteField("facilityInfo243", None), 11791 ByteField("facilityInfo244", None), 11792 ByteField("facilityInfo245", None), 11793 ByteField("facilityInfo246", None), 11794 ByteField("facilityInfo247", None), 11795 ByteField("facilityInfo248", None), 11796 ByteField("facilityInfo249", None) 11797 ] 11798 11799 def post_build(self, p, pay): 11800 a = [getattr(self, fld.name) for fld in self.fields_desc] 11801 res = adapt(7, 250, a, self.fields_desc, 1) 11802 if self.lengthF is None: 11803 p = struct.pack(">B", res[1]) + p[1:] 11804 if res[0] != 0: 11805 p = p[:-res[0]] 11806 return p + pay 11807 11808 11809#len 2 to 5 11810class HighLayerCompatibility(Packet): 11811 """High layer compatibility Section 10.5.4.16""" 11812 name = "High Layer Compatibility" 11813 fields_desc = [ 11814 11815 XByteField("lengthHLC", None), 11816 # optional 11817 BitField("ext", None, 1), 11818 BitField("codingStd", None, 2), 11819 BitField("interpret", None, 3), 11820 BitField("presMeth", None, 2), 11821 11822 BitField("ext1", None, 1), 11823 BitField("highLayerId", None, 7), 11824 11825 ConditionalField(BitField("ext2", 0x1, 1), 11826 lambda pkt: pkt.ext1 == 0), 11827 ConditionalField(BitField("exHiLayerId", 0x0, 7), 11828 lambda pkt: pkt.ext1 == 0), 11829 ] 11830 11831 def post_build(self, p, pay): 11832 a = [getattr(self, fld.name) for fld in self.fields_desc] 11833 res = adapt(1, 4, a, self.fields_desc, 1) 11834 if res[0] != 0: 11835 p = p[:-res[0]] 11836 if self.lengthHLC is None: 11837 p = struct.pack(">B", len(p)-1) + p[1:] 11838 return p + pay 11839# 11840# 10.5.4.16.1 Static conditions for the high layer 11841# compatibility IE contents 11842# 11843 11844 11845class KeypadFacility(Packet): 11846 """Keypad facility Section 10.5.4.17""" 11847 name = "Keypad Facility" 11848 fields_desc = [ 11849 BitField("spare", 0x0, 1), 11850 BitField("keyPadInfo", 0x0, 7) 11851 ] 11852 11853 11854# len 2 to 15 11855class LowLayerCompatibility(Packet): 11856 """Low layer compatibility Section 10.5.4.18""" 11857 name = "Low Layer Compatibility" 11858 fields_desc = [ 11859 11860 XByteField("lengthLLC", None), 11861 # optional 11862 ByteField("rest0", None), 11863 ByteField("rest1", None), 11864 ByteField("rest2", None), 11865 ByteField("rest3", None), 11866 ByteField("rest4", None), 11867 ByteField("rest5", None), 11868 ByteField("rest6", None), 11869 ByteField("rest7", None), 11870 ByteField("rest8", None), 11871 ByteField("rest9", None), 11872 ByteField("rest10", None), 11873 ByteField("rest11", None), 11874 ByteField("rest12", None) 11875 ] 11876 11877 def post_build(self, p, pay): 11878 a = [getattr(self, fld.name) for fld in self.fields_desc] 11879 res = adapt(1, 14, a, self.fields_desc, 1) 11880 if self.lengthLLC is None: 11881 p = struct.pack(">B", res[1]) + p[1:] 11882 if res[0] != 0: 11883 p = p[:-res[0]] 11884 return p + pay 11885 11886 11887class MoreData(Packet): 11888 """More data Section 10.5.4.19""" 11889 name = "More Data" 11890 fields_desc = [ 11891 ] 11892 11893 11894class NotificationIndicator(Packet): 11895 """Notification indicator Section 10.5.4.20""" 11896 name = "Notification Indicator" 11897 fields_desc = [ 11898 BitField("ext1", 0x1, 1), 11899 BitField("notifDesc", 0x0, 7) 11900 ] 11901 11902 11903class ProgressIndicator(Packet): 11904 """Progress indicator Section 10.5.4.21""" 11905 name = "Progress Indicator" 11906 fields_desc = [ 11907 XByteField("lengthPI", 0x2), 11908 BitField("ext", 0x1, 1), 11909 BitField("codingStd", 0x0, 2), 11910 BitField("spare", 0x0, 1), 11911 BitField("location", 0x0, 4), 11912 BitField("ext1", 0x1, 1), 11913 BitField("progressDesc", 0x0, 7) 11914 ] 11915 11916 11917class RecallType(Packet): 11918 """Recall type $(CCBS)$ Section 10.5.4.21a""" 11919 name = "Recall Type $(CCBS)$" 11920 fields_desc = [ 11921 BitField("spare", 0x0, 5), 11922 BitField("recallType", 0x0, 3) 11923 ] 11924 11925 11926# len 3 to 19 11927class RedirectingPartyBcdNumber(Packet): 11928 """Redirecting party BCD number Section 10.5.4.21b""" 11929 name = "Redirecting Party BCD Number" 11930 fields_desc = [ 11931 11932 XByteField("lengthRPBN", None), 11933 11934 BitField("ext", 0x1, 1), 11935 BitField("typeNb", 0x0, 3), 11936 BitField("numberingPlan", 0x0, 4), 11937 # optional 11938 ConditionalField(BitField("ext1", 0x1, 1), 11939 lambda pkt: pkt.ext == 0), 11940 ConditionalField(BitField("presId", 0x0, 2), 11941 lambda pkt: pkt.ext == 0), 11942 ConditionalField(BitField("spare", 0x0, 3), 11943 lambda pkt: pkt.ext == 0), 11944 ConditionalField(BitField("screenId", 0x0, 2), 11945 lambda pkt: pkt.ext == 0), 11946 11947 BitField("nbDigit2", None, 4), 11948 BitField("nbDigit1", None, 4), 11949 11950 BitField("nbDigit4", None, 4), 11951 BitField("nbDigit3", None, 4), 11952 11953 BitField("nbDigit6", None, 4), 11954 BitField("nbDigit5", None, 4), 11955 11956 BitField("nbDigit8", None, 4), 11957 BitField("nbDigit7", None, 4), 11958 11959 BitField("nbDigit10", None, 4), 11960 BitField("nbDigit9", None, 4), 11961 11962 BitField("nbDigit12", None, 4), 11963 BitField("nbDigit11", None, 4), 11964 11965 BitField("nbDigit14", None, 4), 11966 BitField("nbDigit13", None, 4), 11967 11968 BitField("nbDigit16", None, 4), 11969 BitField("nbDigit15", None, 4), 11970 11971 BitField("nbDigit18", None, 4), 11972 BitField("nbDigit17", None, 4), 11973 11974 BitField("nbDigit20", None, 4), 11975 BitField("nbDigit19", None, 4), 11976 11977 BitField("nbDigit22", None, 4), 11978 BitField("nbDigit21", None, 4), 11979 11980 BitField("nbDigit24", None, 4), 11981 BitField("nbDigit23", None, 4), 11982 11983 BitField("nbDigit26", None, 4), 11984 BitField("nbDigit25", None, 4), 11985 11986 BitField("nbDigit28", None, 4), 11987 BitField("nbDigit27", None, 4), 11988 11989 BitField("nbDigit30", None, 4), 11990 BitField("nbDigit29", None, 4), 11991 ] 11992 11993 def post_build(self, p, pay): 11994 a = [getattr(self, fld.name) for fld in self.fields_desc] 11995 res = adapt(2, 18, a, self.fields_desc, 1) 11996 if res[0] != 0: 11997 p = p[:-res[0]] 11998 if self.lengthRPBN is None: 11999 p = struct.pack(">B", len(p)-1) + p[1:] 12000 return p + pay 12001 12002 12003# length 2 to 23 12004class RedirectingPartySubaddress(Packet): 12005 """Redirecting party subaddress Section 10.5.4.21c""" 12006 name = "Redirecting Party BCD Number" 12007 fields_desc = [ 12008 12009 XByteField("lengthRPS", None), 12010 # optional 12011 BitField("ext", None, 1), 12012 BitField("typeSub", None, 3), 12013 BitField("oddEven", None, 1), 12014 BitField("spare", None, 3), 12015 12016 ByteField("subInfo0", None), 12017 ByteField("subInfo1", None), 12018 ByteField("subInfo2", None), 12019 ByteField("subInfo3", None), 12020 ByteField("subInfo4", None), 12021 ByteField("subInfo5", None), 12022 ByteField("subInfo6", None), 12023 ByteField("subInfo7", None), 12024 ByteField("subInfo8", None), 12025 ByteField("subInfo9", None), 12026 ByteField("subInfo10", None), 12027 ByteField("subInfo11", None), 12028 ByteField("subInfo12", None), 12029 ByteField("subInfo13", None), 12030 ByteField("subInfo14", None), 12031 ByteField("subInfo15", None), 12032 ByteField("subInfo16", None), 12033 ByteField("subInfo17", None), 12034 ByteField("subInfo18", None), 12035 ByteField("subInfo19", None) 12036 ] 12037 12038 def post_build(self, p, pay): 12039 a = [getattr(self, fld.name) for fld in self.fields_desc] 12040 res = adapt(1, 22, a, self.fields_desc, 1) 12041 if self.lengthRPS is None: 12042 p = struct.pack(">B", res[1]) + p[1:] 12043 if res[0] != 0: 12044 p = p[:-res[0]] 12045 return p + pay 12046 12047 12048class RepeatIndicator(Packet): 12049 """Repeat indicator Section 10.5.4.22""" 12050 name = "Repeat Indicator" 12051 fields_desc = [ 12052 BitField("repeatIndic", 0x0, 4) 12053 ] 12054 12055 12056# no upper length min 2(max for L3) (251) 12057class SetupContainer(Packet): 12058 """SETUP Container $(CCBS)$ Section 10.5.4.22b""" 12059 name = "Setup Container $(CCBS)$" 12060 fields_desc = [ 12061 XByteField("lengthSC", None), 12062 # optional 12063 ByteField("mess1", None), 12064 ByteField("mess2", None), 12065 ByteField("mess3", None), 12066 ByteField("mess4", None), 12067 ByteField("mess5", None), 12068 ByteField("mess6", None), 12069 ByteField("mess7", None), 12070 ByteField("mess8", None), 12071 ByteField("mess9", None), 12072 ByteField("mess10", None), 12073 ByteField("mess11", None), 12074 ByteField("mess12", None), 12075 ByteField("mess13", None), 12076 ByteField("mess14", None), 12077 ByteField("mess15", None), 12078 ByteField("mess16", None), 12079 ByteField("mess17", None), 12080 ByteField("mess18", None), 12081 ByteField("mess19", None), 12082 ByteField("mess20", None), 12083 ByteField("mess21", None), 12084 ByteField("mess22", None), 12085 ByteField("mess23", None), 12086 ByteField("mess24", None), 12087 ByteField("mess25", None), 12088 ByteField("mess26", None), 12089 ByteField("mess27", None), 12090 ByteField("mess28", None), 12091 ByteField("mess29", None), 12092 ByteField("mess30", None), 12093 ByteField("mess31", None), 12094 ByteField("mess32", None), 12095 ByteField("mess33", None), 12096 ByteField("mess34", None), 12097 ByteField("mess35", None), 12098 ByteField("mess36", None), 12099 ByteField("mess37", None), 12100 ByteField("mess38", None), 12101 ByteField("mess39", None), 12102 ByteField("mess40", None), 12103 ByteField("mess41", None), 12104 ByteField("mess42", None), 12105 ByteField("mess43", None), 12106 ByteField("mess44", None), 12107 ByteField("mess45", None), 12108 ByteField("mess46", None), 12109 ByteField("mess47", None), 12110 ByteField("mess48", None), 12111 ByteField("mess49", None), 12112 ByteField("mess50", None), 12113 ByteField("mess51", None), 12114 ByteField("mess52", None), 12115 ByteField("mess53", None), 12116 ByteField("mess54", None), 12117 ByteField("mess55", None), 12118 ByteField("mess56", None), 12119 ByteField("mess57", None), 12120 ByteField("mess58", None), 12121 ByteField("mess59", None), 12122 ByteField("mess60", None), 12123 ByteField("mess61", None), 12124 ByteField("mess62", None), 12125 ByteField("mess63", None), 12126 ByteField("mess64", None), 12127 ByteField("mess65", None), 12128 ByteField("mess66", None), 12129 ByteField("mess67", None), 12130 ByteField("mess68", None), 12131 ByteField("mess69", None), 12132 ByteField("mess70", None), 12133 ByteField("mess71", None), 12134 ByteField("mess72", None), 12135 ByteField("mess73", None), 12136 ByteField("mess74", None), 12137 ByteField("mess75", None), 12138 ByteField("mess76", None), 12139 ByteField("mess77", None), 12140 ByteField("mess78", None), 12141 ByteField("mess79", None), 12142 ByteField("mess80", None), 12143 ByteField("mess81", None), 12144 ByteField("mess82", None), 12145 ByteField("mess83", None), 12146 ByteField("mess84", None), 12147 ByteField("mess85", None), 12148 ByteField("mess86", None), 12149 ByteField("mess87", None), 12150 ByteField("mess88", None), 12151 ByteField("mess89", None), 12152 ByteField("mess90", None), 12153 ByteField("mess91", None), 12154 ByteField("mess92", None), 12155 ByteField("mess93", None), 12156 ByteField("mess94", None), 12157 ByteField("mess95", None), 12158 ByteField("mess96", None), 12159 ByteField("mess97", None), 12160 ByteField("mess98", None), 12161 ByteField("mess99", None), 12162 ByteField("mess100", None), 12163 ByteField("mess101", None), 12164 ByteField("mess102", None), 12165 ByteField("mess103", None), 12166 ByteField("mess104", None), 12167 ByteField("mess105", None), 12168 ByteField("mess106", None), 12169 ByteField("mess107", None), 12170 ByteField("mess108", None), 12171 ByteField("mess109", None), 12172 ByteField("mess110", None), 12173 ByteField("mess111", None), 12174 ByteField("mess112", None), 12175 ByteField("mess113", None), 12176 ByteField("mess114", None), 12177 ByteField("mess115", None), 12178 ByteField("mess116", None), 12179 ByteField("mess117", None), 12180 ByteField("mess118", None), 12181 ByteField("mess119", None), 12182 ByteField("mess120", None), 12183 ByteField("mess121", None), 12184 ByteField("mess122", None), 12185 ByteField("mess123", None), 12186 ByteField("mess124", None), 12187 ByteField("mess125", None), 12188 ByteField("mess126", None), 12189 ByteField("mess127", None), 12190 ByteField("mess128", None), 12191 ByteField("mess129", None), 12192 ByteField("mess130", None), 12193 ByteField("mess131", None), 12194 ByteField("mess132", None), 12195 ByteField("mess133", None), 12196 ByteField("mess134", None), 12197 ByteField("mess135", None), 12198 ByteField("mess136", None), 12199 ByteField("mess137", None), 12200 ByteField("mess138", None), 12201 ByteField("mess139", None), 12202 ByteField("mess140", None), 12203 ByteField("mess141", None), 12204 ByteField("mess142", None), 12205 ByteField("mess143", None), 12206 ByteField("mess144", None), 12207 ByteField("mess145", None), 12208 ByteField("mess146", None), 12209 ByteField("mess147", None), 12210 ByteField("mess148", None), 12211 ByteField("mess149", None), 12212 ByteField("mess150", None), 12213 ByteField("mess151", None), 12214 ByteField("mess152", None), 12215 ByteField("mess153", None), 12216 ByteField("mess154", None), 12217 ByteField("mess155", None), 12218 ByteField("mess156", None), 12219 ByteField("mess157", None), 12220 ByteField("mess158", None), 12221 ByteField("mess159", None), 12222 ByteField("mess160", None), 12223 ByteField("mess161", None), 12224 ByteField("mess162", None), 12225 ByteField("mess163", None), 12226 ByteField("mess164", None), 12227 ByteField("mess165", None), 12228 ByteField("mess166", None), 12229 ByteField("mess167", None), 12230 ByteField("mess168", None), 12231 ByteField("mess169", None), 12232 ByteField("mess170", None), 12233 ByteField("mess171", None), 12234 ByteField("mess172", None), 12235 ByteField("mess173", None), 12236 ByteField("mess174", None), 12237 ByteField("mess175", None), 12238 ByteField("mess176", None), 12239 ByteField("mess177", None), 12240 ByteField("mess178", None), 12241 ByteField("mess179", None), 12242 ByteField("mess180", None), 12243 ByteField("mess181", None), 12244 ByteField("mess182", None), 12245 ByteField("mess183", None), 12246 ByteField("mess184", None), 12247 ByteField("mess185", None), 12248 ByteField("mess186", None), 12249 ByteField("mess187", None), 12250 ByteField("mess188", None), 12251 ByteField("mess189", None), 12252 ByteField("mess190", None), 12253 ByteField("mess191", None), 12254 ByteField("mess192", None), 12255 ByteField("mess193", None), 12256 ByteField("mess194", None), 12257 ByteField("mess195", None), 12258 ByteField("mess196", None), 12259 ByteField("mess197", None), 12260 ByteField("mess198", None), 12261 ByteField("mess199", None), 12262 ByteField("mess200", None), 12263 ByteField("mess201", None), 12264 ByteField("mess202", None), 12265 ByteField("mess203", None), 12266 ByteField("mess204", None), 12267 ByteField("mess205", None), 12268 ByteField("mess206", None), 12269 ByteField("mess207", None), 12270 ByteField("mess208", None), 12271 ByteField("mess209", None), 12272 ByteField("mess210", None), 12273 ByteField("mess211", None), 12274 ByteField("mess212", None), 12275 ByteField("mess213", None), 12276 ByteField("mess214", None), 12277 ByteField("mess215", None), 12278 ByteField("mess216", None), 12279 ByteField("mess217", None), 12280 ByteField("mess218", None), 12281 ByteField("mess219", None), 12282 ByteField("mess220", None), 12283 ByteField("mess221", None), 12284 ByteField("mess222", None), 12285 ByteField("mess223", None), 12286 ByteField("mess224", None), 12287 ByteField("mess225", None), 12288 ByteField("mess226", None), 12289 ByteField("mess227", None), 12290 ByteField("mess228", None), 12291 ByteField("mess229", None), 12292 ByteField("mess230", None), 12293 ByteField("mess231", None), 12294 ByteField("mess232", None), 12295 ByteField("mess233", None), 12296 ByteField("mess234", None), 12297 ByteField("mess235", None), 12298 ByteField("mess236", None), 12299 ByteField("mess237", None), 12300 ByteField("mess238", None), 12301 ByteField("mess239", None), 12302 ByteField("mess240", None), 12303 ByteField("mess241", None), 12304 ByteField("mess242", None), 12305 ByteField("mess243", None), 12306 ByteField("mess244", None), 12307 ByteField("mess245", None), 12308 ByteField("mess246", None), 12309 ByteField("mess247", None), 12310 ByteField("mess248", None), 12311 ByteField("mess249", None), 12312 ] 12313 12314 def post_build(self, p, pay): 12315 a = [getattr(self, fld.name) for fld in self.fields_desc] 12316 res = adapt(1, 250, a, self.fields_desc, 1) 12317 if self.lengthSC is None: 12318 p = struct.pack(">B", res[1]) + p[1:] 12319 if res[0] != 0: 12320 p = p[:-res[0]] 12321 return p + pay 12322 12323 12324class Signal(Packet): 12325 """Signal Section 10.5.4.23""" 12326 name = "Signal" 12327 fields_desc = [ 12328 ByteField("sigValue", 0x0) 12329 ] 12330 12331 12332# length 2 to max for L3 message (251) 12333class SsVersionIndicator(Packet): 12334 """SS Version Indicator Section 10.5.4.24""" 12335 name = "SS Version Indicator" 12336 fields_desc = [ 12337 XByteField("lengthSVI", None), 12338 # optional 12339 ByteField("info1", None), 12340 ByteField("info2", None), 12341 ByteField("info3", None), 12342 ByteField("info4", None), 12343 ByteField("info5", None), 12344 ByteField("info6", None), 12345 ByteField("info7", None), 12346 ByteField("info8", None), 12347 ByteField("info9", None), 12348 ByteField("info10", None), 12349 ByteField("info11", None), 12350 ByteField("info12", None), 12351 ByteField("info13", None), 12352 ByteField("info14", None), 12353 ByteField("info15", None), 12354 ByteField("info16", None), 12355 ByteField("info17", None), 12356 ByteField("info18", None), 12357 ByteField("info19", None), 12358 ByteField("info20", None), 12359 ByteField("info21", None), 12360 ByteField("info22", None), 12361 ByteField("info23", None), 12362 ByteField("info24", None), 12363 ByteField("info25", None), 12364 ByteField("info26", None), 12365 ByteField("info27", None), 12366 ByteField("info28", None), 12367 ByteField("info29", None), 12368 ByteField("info30", None), 12369 ByteField("info31", None), 12370 ByteField("info32", None), 12371 ByteField("info33", None), 12372 ByteField("info34", None), 12373 ByteField("info35", None), 12374 ByteField("info36", None), 12375 ByteField("info37", None), 12376 ByteField("info38", None), 12377 ByteField("info39", None), 12378 ByteField("info40", None), 12379 ByteField("info41", None), 12380 ByteField("info42", None), 12381 ByteField("info43", None), 12382 ByteField("info44", None), 12383 ByteField("info45", None), 12384 ByteField("info46", None), 12385 ByteField("info47", None), 12386 ByteField("info48", None), 12387 ByteField("info49", None), 12388 ByteField("info50", None), 12389 ByteField("info51", None), 12390 ByteField("info52", None), 12391 ByteField("info53", None), 12392 ByteField("info54", None), 12393 ByteField("info55", None), 12394 ByteField("info56", None), 12395 ByteField("info57", None), 12396 ByteField("info58", None), 12397 ByteField("info59", None), 12398 ByteField("info60", None), 12399 ByteField("info61", None), 12400 ByteField("info62", None), 12401 ByteField("info63", None), 12402 ByteField("info64", None), 12403 ByteField("info65", None), 12404 ByteField("info66", None), 12405 ByteField("info67", None), 12406 ByteField("info68", None), 12407 ByteField("info69", None), 12408 ByteField("info70", None), 12409 ByteField("info71", None), 12410 ByteField("info72", None), 12411 ByteField("info73", None), 12412 ByteField("info74", None), 12413 ByteField("info75", None), 12414 ByteField("info76", None), 12415 ByteField("info77", None), 12416 ByteField("info78", None), 12417 ByteField("info79", None), 12418 ByteField("info80", None), 12419 ByteField("info81", None), 12420 ByteField("info82", None), 12421 ByteField("info83", None), 12422 ByteField("info84", None), 12423 ByteField("info85", None), 12424 ByteField("info86", None), 12425 ByteField("info87", None), 12426 ByteField("info88", None), 12427 ByteField("info89", None), 12428 ByteField("info90", None), 12429 ByteField("info91", None), 12430 ByteField("info92", None), 12431 ByteField("info93", None), 12432 ByteField("info94", None), 12433 ByteField("info95", None), 12434 ByteField("info96", None), 12435 ByteField("info97", None), 12436 ByteField("info98", None), 12437 ByteField("info99", None), 12438 ByteField("info100", None), 12439 ByteField("info101", None), 12440 ByteField("info102", None), 12441 ByteField("info103", None), 12442 ByteField("info104", None), 12443 ByteField("info105", None), 12444 ByteField("info106", None), 12445 ByteField("info107", None), 12446 ByteField("info108", None), 12447 ByteField("info109", None), 12448 ByteField("info110", None), 12449 ByteField("info111", None), 12450 ByteField("info112", None), 12451 ByteField("info113", None), 12452 ByteField("info114", None), 12453 ByteField("info115", None), 12454 ByteField("info116", None), 12455 ByteField("info117", None), 12456 ByteField("info118", None), 12457 ByteField("info119", None), 12458 ByteField("info120", None), 12459 ByteField("info121", None), 12460 ByteField("info122", None), 12461 ByteField("info123", None), 12462 ByteField("info124", None), 12463 ByteField("info125", None), 12464 ByteField("info126", None), 12465 ByteField("info127", None), 12466 ByteField("info128", None), 12467 ByteField("info129", None), 12468 ByteField("info130", None), 12469 ByteField("info131", None), 12470 ByteField("info132", None), 12471 ByteField("info133", None), 12472 ByteField("info134", None), 12473 ByteField("info135", None), 12474 ByteField("info136", None), 12475 ByteField("info137", None), 12476 ByteField("info138", None), 12477 ByteField("info139", None), 12478 ByteField("info140", None), 12479 ByteField("info141", None), 12480 ByteField("info142", None), 12481 ByteField("info143", None), 12482 ByteField("info144", None), 12483 ByteField("info145", None), 12484 ByteField("info146", None), 12485 ByteField("info147", None), 12486 ByteField("info148", None), 12487 ByteField("info149", None), 12488 ByteField("info150", None), 12489 ByteField("info151", None), 12490 ByteField("info152", None), 12491 ByteField("info153", None), 12492 ByteField("info154", None), 12493 ByteField("info155", None), 12494 ByteField("info156", None), 12495 ByteField("info157", None), 12496 ByteField("info158", None), 12497 ByteField("info159", None), 12498 ByteField("info160", None), 12499 ByteField("info161", None), 12500 ByteField("info162", None), 12501 ByteField("info163", None), 12502 ByteField("info164", None), 12503 ByteField("info165", None), 12504 ByteField("info166", None), 12505 ByteField("info167", None), 12506 ByteField("info168", None), 12507 ByteField("info169", None), 12508 ByteField("info170", None), 12509 ByteField("info171", None), 12510 ByteField("info172", None), 12511 ByteField("info173", None), 12512 ByteField("info174", None), 12513 ByteField("info175", None), 12514 ByteField("info176", None), 12515 ByteField("info177", None), 12516 ByteField("info178", None), 12517 ByteField("info179", None), 12518 ByteField("info180", None), 12519 ByteField("info181", None), 12520 ByteField("info182", None), 12521 ByteField("info183", None), 12522 ByteField("info184", None), 12523 ByteField("info185", None), 12524 ByteField("info186", None), 12525 ByteField("info187", None), 12526 ByteField("info188", None), 12527 ByteField("info189", None), 12528 ByteField("info190", None), 12529 ByteField("info191", None), 12530 ByteField("info192", None), 12531 ByteField("info193", None), 12532 ByteField("info194", None), 12533 ByteField("info195", None), 12534 ByteField("info196", None), 12535 ByteField("info197", None), 12536 ByteField("info198", None), 12537 ByteField("info199", None), 12538 ByteField("info200", None), 12539 ByteField("info201", None), 12540 ByteField("info202", None), 12541 ByteField("info203", None), 12542 ByteField("info204", None), 12543 ByteField("info205", None), 12544 ByteField("info206", None), 12545 ByteField("info207", None), 12546 ByteField("info208", None), 12547 ByteField("info209", None), 12548 ByteField("info210", None), 12549 ByteField("info211", None), 12550 ByteField("info212", None), 12551 ByteField("info213", None), 12552 ByteField("info214", None), 12553 ByteField("info215", None), 12554 ByteField("info216", None), 12555 ByteField("info217", None), 12556 ByteField("info218", None), 12557 ByteField("info219", None), 12558 ByteField("info220", None), 12559 ByteField("info221", None), 12560 ByteField("info222", None), 12561 ByteField("info223", None), 12562 ByteField("info224", None), 12563 ByteField("info225", None), 12564 ByteField("info226", None), 12565 ByteField("info227", None), 12566 ByteField("info228", None), 12567 ByteField("info229", None), 12568 ByteField("info230", None), 12569 ByteField("info231", None), 12570 ByteField("info232", None), 12571 ByteField("info233", None), 12572 ByteField("info234", None), 12573 ByteField("info235", None), 12574 ByteField("info236", None), 12575 ByteField("info237", None), 12576 ByteField("info238", None), 12577 ByteField("info239", None), 12578 ByteField("info240", None), 12579 ByteField("info241", None), 12580 ByteField("info242", None), 12581 ByteField("info243", None), 12582 ByteField("info244", None), 12583 ByteField("info245", None), 12584 ByteField("info246", None), 12585 ByteField("info247", None), 12586 ByteField("info248", None), 12587 ByteField("info249", None), 12588 ] 12589 12590 def post_build(self, p, pay): 12591 a = [getattr(self, fld.name) for fld in self.fields_desc] 12592 res = adapt(1, 250, a, self.fields_desc, 1) 12593 if self.lengthSVI is None: 12594 p = struct.pack(">B", res[1]) + p[1:] 12595 if res[0] != 0: 12596 p = p[:-res[0]] 12597 return p + pay 12598 12599 12600# length 3 to 35 or 131 12601class UserUser(Packet): 12602 """User-user Section 10.5.4.25""" 12603 name = "User-User" 12604 fields_desc = [ 12605 12606 XByteField("lengthUU", None), # dynamic length of field depending 12607 # of the type of message 12608 # let user decide which length he 12609 # wants to take 12610 # => more fuzzing options 12611 ByteField("userUserPD", 0x0), 12612 # optional 12613 ByteField("userUserInfo1", None), 12614 ByteField("userUserInfo2", None), 12615 ByteField("userUserInfo3", None), 12616 ByteField("userUserInfo4", None), 12617 ByteField("userUserInfo5", None), 12618 ByteField("userUserInfo6", None), 12619 ByteField("userUserInfo7", None), 12620 ByteField("userUserInfo8", None), 12621 ByteField("userUserInfo9", None), 12622 ByteField("userUserInfo10", None), 12623 ByteField("userUserInfo11", None), 12624 ByteField("userUserInfo12", None), 12625 ByteField("userUserInfo13", None), 12626 ByteField("userUserInfo14", None), 12627 ByteField("userUserInfo15", None), 12628 ByteField("userUserInfo16", None), 12629 ByteField("userUserInfo17", None), 12630 ByteField("userUserInfo18", None), 12631 ByteField("userUserInfo19", None), 12632 ByteField("userUserInfo20", None), 12633 ByteField("userUserInfo21", None), 12634 ByteField("userUserInfo22", None), 12635 ByteField("userUserInfo23", None), 12636 ByteField("userUserInfo24", None), 12637 ByteField("userUserInfo25", None), 12638 ByteField("userUserInfo26", None), 12639 ByteField("userUserInfo27", None), 12640 ByteField("userUserInfo28", None), 12641 ByteField("userUserInfo29", None), 12642 ByteField("userUserInfo30", None), 12643 ByteField("userUserInfo31", None), 12644 ByteField("userUserInfo32", None), 12645 # long packet 12646 ByteField("userUserInfo33", None), 12647 ByteField("userUserInfo34", None), 12648 ByteField("userUserInfo35", None), 12649 ByteField("userUserInfo36", None), 12650 ByteField("userUserInfo37", None), 12651 ByteField("userUserInfo38", None), 12652 ByteField("userUserInfo39", None), 12653 ByteField("userUserInfo40", None), 12654 ByteField("userUserInfo41", None), 12655 ByteField("userUserInfo42", None), 12656 ByteField("userUserInfo43", None), 12657 ByteField("userUserInfo44", None), 12658 ByteField("userUserInfo45", None), 12659 ByteField("userUserInfo46", None), 12660 ByteField("userUserInfo47", None), 12661 ByteField("userUserInfo48", None), 12662 ByteField("userUserInfo49", None), 12663 ByteField("userUserInfo50", None), 12664 ByteField("userUserInfo51", None), 12665 ByteField("userUserInfo52", None), 12666 ByteField("userUserInfo53", None), 12667 ByteField("userUserInfo54", None), 12668 ByteField("userUserInfo55", None), 12669 ByteField("userUserInfo56", None), 12670 ByteField("userUserInfo57", None), 12671 ByteField("userUserInfo58", None), 12672 ByteField("userUserInfo59", None), 12673 ByteField("userUserInfo60", None), 12674 ByteField("userUserInfo61", None), 12675 ByteField("userUserInfo62", None), 12676 ByteField("userUserInfo63", None), 12677 ByteField("userUserInfo64", None), 12678 ByteField("userUserInfo65", None), 12679 ByteField("userUserInfo66", None), 12680 ByteField("userUserInfo67", None), 12681 ByteField("userUserInfo68", None), 12682 ByteField("userUserInfo69", None), 12683 ByteField("userUserInfo70", None), 12684 ByteField("userUserInfo71", None), 12685 ByteField("userUserInfo72", None), 12686 ByteField("userUserInfo73", None), 12687 ByteField("userUserInfo74", None), 12688 ByteField("userUserInfo75", None), 12689 ByteField("userUserInfo76", None), 12690 ByteField("userUserInfo77", None), 12691 ByteField("userUserInfo78", None), 12692 ByteField("userUserInfo79", None), 12693 ByteField("userUserInfo80", None), 12694 ByteField("userUserInfo81", None), 12695 ByteField("userUserInfo82", None), 12696 ByteField("userUserInfo83", None), 12697 ByteField("userUserInfo84", None), 12698 ByteField("userUserInfo85", None), 12699 ByteField("userUserInfo86", None), 12700 ByteField("userUserInfo87", None), 12701 ByteField("userUserInfo88", None), 12702 ByteField("userUserInfo89", None), 12703 ByteField("userUserInfo90", None), 12704 ByteField("userUserInfo91", None), 12705 ByteField("userUserInfo92", None), 12706 ByteField("userUserInfo93", None), 12707 ByteField("userUserInfo94", None), 12708 ByteField("userUserInfo95", None), 12709 ByteField("userUserInfo96", None), 12710 ByteField("userUserInfo97", None), 12711 ByteField("userUserInfo98", None), 12712 ByteField("userUserInfo99", None), 12713 ByteField("userUserInfo100", None), 12714 ByteField("userUserInfo101", None), 12715 ByteField("userUserInfo102", None), 12716 ByteField("userUserInfo103", None), 12717 ByteField("userUserInfo104", None), 12718 ByteField("userUserInfo105", None), 12719 ByteField("userUserInfo106", None), 12720 ByteField("userUserInfo107", None), 12721 ByteField("userUserInfo108", None), 12722 ByteField("userUserInfo109", None), 12723 ByteField("userUserInfo110", None), 12724 ByteField("userUserInfo111", None), 12725 ByteField("userUserInfo112", None), 12726 ByteField("userUserInfo113", None), 12727 ByteField("userUserInfo114", None), 12728 ByteField("userUserInfo115", None), 12729 ByteField("userUserInfo116", None), 12730 ByteField("userUserInfo117", None), 12731 ByteField("userUserInfo118", None), 12732 ByteField("userUserInfo119", None), 12733 ByteField("userUserInfo120", None), 12734 ByteField("userUserInfo121", None), 12735 ByteField("userUserInfo122", None), 12736 ByteField("userUserInfo123", None), 12737 ByteField("userUserInfo124", None), 12738 ByteField("userUserInfo125", None), 12739 ByteField("userUserInfo126", None), 12740 ByteField("userUserInfo127", None), 12741 ByteField("userUserInfo128", None), 12742 ByteField("userUserInfo129", None), 12743 ByteField("userUserInfo130", None), 12744 ByteField("userUserInfo131", None) 12745 ] 12746 12747 def post_build(self, p, pay): 12748 a = [getattr(self, fld.name) for fld in self.fields_desc] 12749 res = adapt(2, 133, a, self.fields_desc, 1) 12750 if self.lengthUU is None: 12751 p = struct.pack(">B", res[1]) + p[1:] 12752 if res[0] != 0: 12753 p = p[:-res[0]] 12754 return p + pay 12755 12756 12757class AlertingPattern(Packet): 12758 """Alerting Pattern 10.5.4.26""" 12759 name = "Alerting Pattern" 12760 fields_desc = [ 12761 XByteField("lengthAP", 0x3), 12762 BitField("spare", 0x0, 4), 12763 BitField("alertingValue", 0x0, 4) 12764 ] 12765 12766 12767class AllowedActions(Packet): 12768 """Allowed actions $(CCBS)$ Section 10.5.4.26""" 12769 name = "Allowed Actions $(CCBS)$" 12770 fields_desc = [ 12771 XByteField("lengthAP", 0x3), 12772 BitField("CCBS", 0x0, 1), 12773 BitField("spare", 0x0, 7) 12774 ] 12775 12776 12777# 12778# 10.5.5 GPRS mobility management information elements 12779# 12780 12781 12782class AttachType(Packet): 12783 """Attach type Section 10.5.5.2""" 12784 name = "Attach Type" 12785 fields_desc = [ 12786 BitField("spare", 0x0, 1), 12787 BitField("type", 0x1, 3) 12788 ] 12789 12790 12791if __name__ == "__main__": 12792 from scapy.main import interact 12793 interact(mydict=globals(), mybanner="Scapy GSM-UM (Air) Addon") 12794