1little_endian_packets 2 3packet BasicFrame { 4 _size_(_payload_) : 16, 5 channel_id : 16, 6 _payload_, 7} 8 9enum Continuation : 1 { 10 END = 0, 11 CONTINUE = 1, 12} 13 14// ChannelId 2 is connectionless 15packet GroupFrame : BasicFrame (channel_id = 0x02) { 16 psm : 16, 17 _payload_, 18} 19 20enum FrameType : 1 { 21 I_FRAME = 0, 22 S_FRAME = 1, 23} 24 25group FrameGroup { 26 frame_type: FrameType 27} 28 29enum SupervisoryFunction : 2 { 30 RECEIVER_READY = 0, 31 REJECT = 1, 32 RECEIVER_NOT_READY = 2, 33 SELECT_REJECT = 3, 34} 35 36enum RetransmissionDisable : 1 { 37 NORMAL = 0, 38 DISABLE = 1, 39} 40 41enum SegmentationAndReassembly : 2 { 42 UNSEGMENTED = 0, 43 START = 1, 44 END = 2, 45 CONTINUATION = 3, 46} 47 48packet StandardFrame : BasicFrame { 49 _payload_, 50} 51 52group StandardSupervisoryControl { 53 FrameGroup { 54 frame_type = S_FRAME 55 }, 56 _fixed_ = 0 : 1, 57 s : SupervisoryFunction, 58 _reserved_ : 3, 59 r : RetransmissionDisable, 60 req_seq : 6, 61 _reserved_ : 2, 62} 63 64group StandardInformationControl { 65 FrameGroup { 66 frame_type = I_FRAME 67 }, 68 tx_seq : 6, 69 r : RetransmissionDisable, 70 req_seq : 6, 71 sar : SegmentationAndReassembly, 72} 73 74packet StandardSupervisoryFrame : StandardFrame { 75 StandardSupervisoryControl, 76} 77 78packet StandardInformationFrame : StandardFrame { 79 StandardInformationControl, 80 _payload_, 81} 82 83packet StandardInformationStartFrame : StandardInformationFrame (sar = START) { 84 l2cap_sdu_length : 16, 85 _payload_, 86} 87 88enum Poll : 1 { 89 NOT_SET = 0, 90 POLL = 1, 91} 92 93enum Final : 1 { 94 NOT_SET = 0, 95 POLL_RESPONSE = 1, 96} 97 98group EnhancedSupervisoryControl { 99 FrameGroup { 100 frame_type = S_FRAME 101 }, 102 _fixed_ = 0 : 1, 103 s : SupervisoryFunction, 104 p : Poll, 105 _reserved_ : 2, 106 f : Final, 107 req_seq : 6, 108 _reserved_ : 2, 109} 110 111group EnhancedInformationControl { 112 FrameGroup { 113 frame_type = I_FRAME 114 }, 115 tx_seq : 6, 116 f : Final, 117 req_seq : 6, 118 sar : SegmentationAndReassembly, 119} 120 121packet EnhancedSupervisoryFrame : StandardFrame { 122 EnhancedSupervisoryControl, 123} 124 125packet EnhancedInformationFrame : StandardFrame { 126 EnhancedInformationControl, 127 _payload_, 128} 129 130packet EnhancedInformationStartFrame : EnhancedInformationFrame (sar = START) { 131 l2cap_sdu_length : 16, 132 _payload_, 133} 134 135group ExtendedSupervisoryControl { 136 FrameGroup { 137 frame_type = S_FRAME 138 }, 139 f : Final, 140 req_seq : 14, 141 s : SupervisoryFunction, 142 p : Poll, 143 _reserved_ : 5, 144 _reserved_ : 8, 145} 146 147group ExtendedInformationControl { 148 FrameGroup { 149 frame_type = I_FRAME 150 }, 151 f : Final, 152 req_seq : 14, 153 sar : SegmentationAndReassembly, 154 tx_seq : 14, 155} 156 157packet ExtendedSupervisoryFrame : StandardFrame { 158 ExtendedSupervisoryControl, 159} 160 161packet ExtendedInformationFrame : StandardFrame { 162 ExtendedInformationControl, 163 _payload_, 164} 165 166packet ExtendedInformationStartFrame : ExtendedInformationFrame (sar = START) { 167 l2cap_sdu_length : 16, 168 _payload_, 169} 170 171packet FirstLeInformationFrame : BasicFrame { 172 l2cap_sdu_length : 16, 173 _payload_, 174} 175 176enum CommandCode : 8 { 177 COMMAND_REJECT = 0x01, 178 CONNECTION_REQUEST = 0x02, 179 CONNECTION_RESPONSE = 0x03, 180 CONFIGURATION_REQUEST = 0x04, 181 CONFIGURATION_RESPONSE = 0x05, 182 DISCONNECTION_REQUEST = 0x06, 183 DISCONNECTION_RESPONSE = 0x07, 184 ECHO_REQUEST = 0x08, 185 ECHO_RESPONSE = 0x09, 186 INFORMATION_REQUEST = 0x0A, 187 INFORMATION_RESPONSE = 0x0B, 188 CREATE_CHANNEL_REQUEST = 0x0C, 189 CREATE_CHANNEL_RESPONSE = 0x0D, 190 MOVE_CHANNEL_REQUEST = 0x0E, 191 MOVE_CHANNEL_RESPONSE = 0x0F, 192 MOVE_CHANNEL_CONFIRMATION_REQUEST = 0x10, 193 MOVE_CHANNEL_CONFIRMATION_RESPONSE = 0x11, 194 FLOW_CONTROL_CREDIT = 0x16, // Core 5.2 COC 195 CREDIT_BASED_CONNECTION_REQUEST = 0x17, 196 CREDIT_BASED_CONNECTION_RESPONSE = 0x18, 197 CREDIT_BASED_RECONFIGURE_REQUEST = 0x19, 198 CREDIT_BASED_RECONFIGURE_RESPONSE = 0x1A, 199} 200 201packet ControlFrame : BasicFrame (channel_id = 0x0001) { 202 _payload_, 203} 204 205packet Control { 206 code : CommandCode, 207 identifier : 8, 208 _size_(_payload_) : 16, 209 _payload_, 210} 211 212enum CommandRejectReason : 16 { 213 COMMAND_NOT_UNDERSTOOD = 0x0000, 214 SIGNALING_MTU_EXCEEDED = 0x0001, 215 INVALID_CID_IN_REQUEST = 0x0002, 216} 217 218packet CommandReject : Control (code = COMMAND_REJECT) { 219 reason : CommandRejectReason, 220 _body_, 221} 222 223packet CommandRejectNotUnderstood : CommandReject (reason = COMMAND_NOT_UNDERSTOOD) { 224} 225 226packet CommandRejectMtuExceeded : CommandReject (reason = SIGNALING_MTU_EXCEEDED) { 227 actual_mtu : 16, 228} 229 230packet CommandRejectInvalidCid : CommandReject (reason = INVALID_CID_IN_REQUEST) { 231 local_channel : 16, // Relative to the sender of the CommandReject 232 remote_channel : 16, 233} 234 235packet ConnectionRequest : Control (code = CONNECTION_REQUEST) { 236 psm : 16, 237 source_cid : 16, 238} 239 240enum ConnectionResponseResult : 16 { 241 SUCCESS = 0x0000, 242 PENDING = 0x0001, 243 PSM_NOT_SUPPORTED = 0x0002, 244 SECURITY_BLOCK = 0x0003, 245 NO_RESOURCES_AVAILABLE = 0x0004, 246 INVALID_CID = 0x0006, 247 SOURCE_CID_ALREADY_ALLOCATED = 0x0007, 248} 249 250enum ConnectionResponseStatus : 16 { 251 NO_FURTHER_INFORMATION_AVAILABLE = 0x0000, 252 AUTHENTICATION_PENDING = 0x0001, 253 AUTHORIZATION_PENDING = 0x0002, 254 RESERVED = .., 255} 256 257packet ConnectionResponse : Control (code = CONNECTION_RESPONSE) { 258 destination_cid : 16, 259 source_cid : 16, 260 result : ConnectionResponseResult, 261 status : ConnectionResponseStatus, 262} 263 264enum ConfigurationOptionType : 7 { 265 MTU = 0x01, 266 FLUSH_TIMEOUT = 0x02, 267 QUALITY_OF_SERVICE = 0x03, 268 RETRANSMISSION_AND_FLOW_CONTROL = 0x04, 269 FRAME_CHECK_SEQUENCE = 0x05, 270 EXTENDED_FLOW_SPECIFICATION = 0x06, 271 EXTENDED_WINDOW_SIZE = 0x07, 272} 273 274enum ConfigurationOptionIsHint : 1 { 275 OPTION_MUST_BE_RECOGNIZED = 0, 276 OPTION_IS_A_HINT = 1, 277} 278 279enum QosServiceType : 8 { 280 NO_TRAFFIC = 0x00, 281 BEST_EFFORT = 0x01, // Default 282 GUARANTEED = 0x02, 283} 284 285enum RetransmissionAndFlowControlModeOption : 8 { 286 L2CAP_BASIC = 0x00, 287 RETRANSMISSION = 0x01, 288 FLOW_CONTROL = 0x02, 289 ENHANCED_RETRANSMISSION = 0x03, 290 STREAMING = 0x04, 291} 292 293enum FcsType : 8 { 294 NO_FCS = 0, 295 DEFAULT = 1, // 16-bit FCS 296} 297 298enum ConfigurationResponseResult : 16 { 299 SUCCESS = 0x0000, 300 UNACCEPTABLE_PARAMETERS = 0x0001, 301 REJECTED = 0x0002, 302 UNKNOWN_OPTIONS = 0x0003, 303 PENDING = 0x0004, 304 FLOW_SPEC_REJECTED = 0x0005, 305} 306 307packet DisconnectionRequest : Control (code = DISCONNECTION_REQUEST) { 308 destination_cid : 16, 309 source_cid : 16, 310} 311 312packet DisconnectionResponse : Control (code = DISCONNECTION_RESPONSE) { 313 destination_cid : 16, 314 source_cid : 16, 315} 316 317packet EchoRequest : Control (code = ECHO_REQUEST) { 318 _payload_, // Optional and implementation specific 319} 320 321packet EchoResponse : Control (code = ECHO_RESPONSE) { 322 _payload_, // Optional and implementation specific 323} 324 325enum InformationRequestInfoType : 16 { 326 CONNECTIONLESS_MTU = 0x0001, 327 EXTENDED_FEATURES_SUPPORTED = 0x0002, 328 FIXED_CHANNELS_SUPPORTED = 0x0003, 329} 330 331packet InformationRequest : Control (code = INFORMATION_REQUEST) { 332 info_type : InformationRequestInfoType, 333} 334 335enum InformationRequestResult : 16 { 336 SUCCESS = 0x0000, 337 NOT_SUPPORTED = 0x0001, 338} 339 340packet InformationResponse : Control (code = INFORMATION_RESPONSE) { 341 info_type : InformationRequestInfoType, 342 result : InformationRequestResult, 343 _body_, 344} 345 346packet InformationResponseConnectionlessMtu : InformationResponse (info_type = CONNECTIONLESS_MTU) { 347 connectionless_mtu : 16, 348} 349 350packet InformationResponseExtendedFeatures : InformationResponse (info_type = EXTENDED_FEATURES_SUPPORTED) { 351 // ExtendedFeatureMask : 32, 352 flow_control_mode : 1, 353 retransmission_mode : 1, 354 bi_directional_qoS : 1, 355 enhanced_retransmission_mode : 1, 356 streaming_mode : 1, 357 fcs_option : 1, 358 extended_flow_specification_for_br_edr : 1, 359 fixed_channels : 1, 360 extended_window_size : 1, 361 unicast_connectionless_data_reception : 1, 362 enhanced_credit_based_flow_control_mode : 1, 363 _reserved_ : 21, 364} 365 366packet InformationResponseFixedChannels : InformationResponse (info_type = FIXED_CHANNELS_SUPPORTED) { 367 fixed_channels : 64, // bit 0 must be 0, bit 1 must be 1, all others 1 = supported 368} 369 370packet CreateChannelRequest : Control (code = CREATE_CHANNEL_REQUEST) { 371 psm : 16, 372 source_cid : 16, 373 controller_id : 8, 374} 375 376enum CreateChannelResponseResult : 16 { 377 SUCCESS = 0x0000, 378 PENDING = 0x0001, 379 PSM_NOT_SUPPORTED = 0x0002, 380 SECURITY_BLOCK = 0x0003, 381 NO_RESOURCES_AVAILABLE = 0x0004, 382 CONTROLLER_ID_NOT_SUPPORTED = 0x0005, 383 INVALID_CID = 0x0006, 384 SOURCE_CID_ALREADY_ALLOCATED = 0x0007, 385} 386 387enum CreateChannelResponseStatus : 16 { 388 NO_FURTHER_INFORMATION_AVAILABLE = 0x0000, 389 AUTHENTICATION_PENDING = 0x0001, 390 AUTHORIZATION_PENDING = 0x0002, 391} 392 393packet CreateChannelResponse : Control (code = CREATE_CHANNEL_RESPONSE) { 394 destination_cid : 16, 395 source_cid : 16, 396 result : CreateChannelResponseResult, 397 status : CreateChannelResponseStatus, 398} 399 400// AMP Only ? 401packet MoveChannelRequest : Control (code = MOVE_CHANNEL_REQUEST) { 402 initiator_cid : 16, 403 dest_controller_id : 8, 404} 405 406enum MoveChannelResponseResult : 16 { 407 SUCCESS = 0x0000, 408 PENDING = 0x0001, 409 CONTROLLER_ID_NOT_SUPPORTED = 0x0002, 410 NEW_CONTROLLER_ID_IS_SAME = 0x0003, 411 CONFIGURATION_NOT_SUPPORTED = 0x0004, 412 CHANNEL_COLLISION = 0x0005, 413 CHANNEL_NOT_ALLOWED_TO_BE_MOVED = 0x0006, 414} 415 416packet MoveChannelResponse : Control (code = MOVE_CHANNEL_RESPONSE) { 417 initiator_cid : 16, 418 result : MoveChannelResponseResult, 419} 420 421enum MoveChannelConfirmationResult : 16 { 422 SUCCESS = 0x0000, 423 FAILURE = 0x0001, 424} 425 426packet MoveChannelConfirmationRequest : Control (code = MOVE_CHANNEL_CONFIRMATION_REQUEST) { 427 initiator_cid : 16, 428 result : MoveChannelConfirmationResult, 429} 430 431packet MoveChannelConfirmationResponse : Control (code = MOVE_CHANNEL_CONFIRMATION_RESPONSE) { 432 initiator_cid : 16, 433} 434 435// Core 5.2 COC 436 437packet FlowControlCredit : Control (code = FLOW_CONTROL_CREDIT) { 438 cid : 16, // Receiver's destination CID 439 credits : 16, 440} 441 442packet CreditBasedConnectionRequest : Control (code = CREDIT_BASED_CONNECTION_REQUEST) { 443 spsm : 16, 444 mtu : 16, 445 mps : 16, 446 initial_credits : 16, 447 source_cid : 16[], 448} 449 450enum CreditBasedConnectionResponseResult : 16 { 451 SUCCESS = 0x0000, 452 SPSM_NOT_SUPPORTED = 0x0002, 453 SOME_REFUSED_NO_RESOURCES_AVAILABLE = 0x0004, 454 ALL_REFUSED_INSUFFICIENT_AUTHENTICATION = 0x0005, 455 ALL_REFUSED_INSUFFICIENT_AUTHORIZATION = 0x0006, 456 ALL_REFUSED_INSUFFICIENT_ENCRYPTION_KEY_SIZE = 0x0007, 457 ALL_REFUSED_INSUFFICIENT_ENCRYPTION = 0x0008, 458 SOME_REFUSED_INVALID_SOURCE_CID = 0x0009, 459 SOME_REFUSED_SOURCE_CID_ALREADY_ALLOCATED = 0x000A, 460 ALL_REFUSED_UNACCEPTABLE_PARAMETERS = 0x000B, 461 ALL_REFUSED_INVALID_PARAMETERS = 0x000C, 462} 463 464packet CreditBasedConnectionResponse : Control (code = CREDIT_BASED_CONNECTION_RESPONSE) { 465 mtu : 16, 466 mps : 16, 467 initial_credits : 16, 468 result : CreditBasedConnectionResponseResult, 469 destination_cid : 16[], 470} 471 472packet CreditBasedReconfigureRequest : Control (code = CREDIT_BASED_RECONFIGURE_REQUEST) { 473 mtu : 16, 474 mps : 16, 475 destination_cid : 16[], 476} 477 478enum CreditBasedReconfigureResponseResult : 16 { 479 SUCCESS = 0x0000, 480 MTU_NOT_ALLOWED = 0x01, 481 MPS_NOT_ALLOWED = 0x02, 482 INVALID_DESTINATION_CID = 0x03, 483 UNACCEPTABLE_PARAMETERS = 0x04, 484} 485 486packet CreditBasedReconfigureResponse : Control (code = CREDIT_BASED_RECONFIGURE_RESPONSE) { 487 result: CreditBasedReconfigureResponseResult, 488} 489 490enum LeCommandCode : 8 { 491 COMMAND_REJECT = 0x01, 492 DISCONNECTION_REQUEST = 0x06, 493 DISCONNECTION_RESPONSE = 0x07, 494 CONNECTION_PARAMETER_UPDATE_REQUEST = 0x12, 495 CONNECTION_PARAMETER_UPDATE_RESPONSE = 0x13, 496 LE_CREDIT_BASED_CONNECTION_REQUEST = 0x14, 497 LE_CREDIT_BASED_CONNECTION_RESPONSE = 0x15, 498 LE_FLOW_CONTROL_CREDIT = 0x16, 499 CREDIT_BASED_CONNECTION_REQUEST = 0x17, // Core 5.2 COC 500 CREDIT_BASED_CONNECTION_RESPONSE = 0x18, 501 CREDIT_BASED_RECONFIGURE_REQUEST = 0x19, 502 CREDIT_BASED_RECONFIGURE_RESPONSE = 0x1A, 503} 504 505packet LeControlFrame : BasicFrame (channel_id = 0x0005) { 506 _payload_, 507} 508 509packet LeControl { 510 code : LeCommandCode, 511 identifier : 8, // Must be non-zero 512 _size_(_payload_) : 16, 513 _payload_, 514} 515 516 517packet LeCommandReject : LeControl (code = COMMAND_REJECT) { 518 reason : CommandRejectReason, 519 _payload_, 520} 521 522packet LeCommandRejectNotUnderstood : LeCommandReject (reason = COMMAND_NOT_UNDERSTOOD) { 523} 524 525packet LeCommandRejectMtuExceeded : LeCommandReject (reason = SIGNALING_MTU_EXCEEDED) { 526 actual_mtu : 16, 527} 528 529packet LeCommandRejectInvalidCid : LeCommandReject (reason = INVALID_CID_IN_REQUEST) { 530 local_channel : 16, // Relative to the sender of the CommandReject 531 remote_channel : 16, 532} 533 534packet LeDisconnectionRequest : LeControl (code = DISCONNECTION_REQUEST) { 535 destination_cid : 16, 536 source_cid : 16, 537} 538 539packet LeDisconnectionResponse : LeControl (code = DISCONNECTION_RESPONSE) { 540 destination_cid : 16, 541 source_cid : 16, 542} 543 544packet ConnectionParameterUpdateRequest : LeControl (code = CONNECTION_PARAMETER_UPDATE_REQUEST) { 545 interval_min : 16, 546 interval_max : 16, 547 peripheral_latency : 16, 548 timeout_multiplier : 16, 549} 550 551enum ConnectionParameterUpdateResponseResult : 16 { 552 ACCEPTED = 0, 553 REJECTED = 1, 554} 555 556packet ConnectionParameterUpdateResponse : LeControl (code = CONNECTION_PARAMETER_UPDATE_RESPONSE) { 557 result : ConnectionParameterUpdateResponseResult, 558} 559 560packet LeCreditBasedConnectionRequest : LeControl (code = LE_CREDIT_BASED_CONNECTION_REQUEST) { 561 le_psm : 16, // 0x0001-0x007F Fixed, 0x0080-0x00FF Dynamic 562 source_cid : 16, 563 mtu : 16, 564 mps : 16, 565 initial_credits : 16, 566} 567 568enum LeCreditBasedConnectionResponseResult : 16 { 569 SUCCESS = 0x0000, 570 LE_PSM_NOT_SUPPORTED = 0x0002, 571 NO_RESOURCES_AVAILABLE = 0x0004, 572 INSUFFICIENT_AUTHENTICATION = 0x0005, 573 INSUFFICIENT_AUTHORIZATION = 0x0006, 574 INSUFFICIENT_ENCRYPTION_KEY_SIZE = 0x0007, 575 INSUFFICIENT_ENCRYPTION = 0x0008, 576 INVALID_SOURCE_CID = 0x0009, 577 SOURCE_CID_ALREADY_ALLOCATED = 0x000A, 578 UNACCEPTABLE_PARAMETERS = 0x000B, 579} 580 581packet LeCreditBasedConnectionResponse : LeControl (code = LE_CREDIT_BASED_CONNECTION_RESPONSE) { 582 destination_cid : 16, 583 mtu : 16, 584 mps : 16, 585 initial_credits : 16, 586 result : LeCreditBasedConnectionResponseResult, 587} 588 589packet LeFlowControlCredit : LeControl (code = LE_FLOW_CONTROL_CREDIT) { 590 cid : 16, // Receiver's destination CID 591 credits : 16, 592} 593 594packet LeEnhancedCreditBasedConnectionRequest : LeControl (code = CREDIT_BASED_CONNECTION_REQUEST) { 595 spsm : 16, 596 mtu : 16, 597 mps : 16, 598 initial_credits : 16, 599 source_cid : 16[], 600} 601 602packet LeEnhancedCreditBasedConnectionResponse : LeControl (code = CREDIT_BASED_CONNECTION_RESPONSE) { 603 mtu : 16, 604 mps : 16, 605 initial_credits : 16, 606 result : CreditBasedConnectionResponseResult, 607 destination_cid : 16[], 608} 609 610packet LeEnhancedCreditBasedReconfigureRequest : LeControl (code = CREDIT_BASED_RECONFIGURE_REQUEST) { 611 mtu : 16, 612 mps : 16, 613 destination_cid : 16[], 614} 615 616packet LeEnhancedCreditBasedReconfigureResponse : LeControl (code = CREDIT_BASED_RECONFIGURE_RESPONSE) { 617 result: CreditBasedReconfigureResponseResult, 618} 619