Loading floss/hcidoc/src/groups/connections.rs +40 −4 Original line number Diff line number Diff line Loading @@ -7,16 +7,17 @@ use std::io::Write; use crate::engine::{Rule, RuleGroup, Signal}; use crate::parser::{Packet, PacketChild}; use bt_packets::hci::{ Acl, AclCommandChild, Address, CommandChild, CommandStatus, ConnectionManagementCommandChild, DisconnectReason, ErrorCode, Event, EventChild, LeConnectionManagementCommandChild, LeMetaEventChild, NumberOfCompletedPackets, OpCode, ScoConnectionCommandChild, SecurityCommandChild, SubeventCode, Acl, AclCommandChild, Address, AuthenticatedPayloadTimeoutExpired, CommandChild, CommandStatus, ConnectionManagementCommandChild, DisconnectReason, ErrorCode, Event, EventChild, LeConnectionManagementCommandChild, LeMetaEventChild, NumberOfCompletedPackets, OpCode, ScoConnectionCommandChild, SecurityCommandChild, SubeventCode, }; enum ConnectionSignal { LinkKeyMismatch, // Peer forgets the link key or it mismatches ours NocpDisconnect, // Peer is disconnected when NOCP packet isn't yet received NocpTimeout, // Host doesn't receive NOCP packet 5 seconds after ACL is sent ApteDisconnect, // Host doesn't receive a packet with valid MIC for a while. } impl Into<&'static str> for ConnectionSignal { Loading @@ -25,6 +26,7 @@ impl Into<&'static str> for ConnectionSignal { ConnectionSignal::LinkKeyMismatch => "LinkKeyMismatch", ConnectionSignal::NocpDisconnect => "Nocp", ConnectionSignal::NocpTimeout => "Nocp", ConnectionSignal::ApteDisconnect => "AuthenticatedPayloadTimeoutExpired", } } } Loading Loading @@ -73,6 +75,9 @@ struct OddDisconnectionsRule { /// identify bursts. nocp_by_handle: HashMap<ConnectionHandle, NocpData>, /// Number of |Authenticated Payload Timeout Expired| events hapened. apte_by_handle: HashMap<ConnectionHandle, u32>, /// Pre-defined signals discovered in the logs. signals: Vec<Signal>, Loading @@ -91,6 +96,7 @@ impl OddDisconnectionsRule { sco_connection_attempt: HashMap::new(), last_sco_connection_attempt: None, nocp_by_handle: HashMap::new(), apte_by_handle: HashMap::new(), signals: vec![], reportable: vec![], } Loading Loading @@ -315,6 +321,26 @@ impl OddDisconnectionsRule { // Remove nocp information for handles that were removed. self.nocp_by_handle.remove(&handle); // Check if auth payload timeout happened. match self.apte_by_handle.get_mut(&handle) { Some(apte_count) => { self.signals.push(Signal { index: packet.index, ts: packet.ts.clone(), tag: ConnectionSignal::ApteDisconnect.into(), }); self.reportable.push(( packet.ts, format!("DisconnectionComplete with {} Authenticated Payload Timeout Expired (handle={})", apte_count, handle))); } None => (), } // Remove apte information for handles that were removed. self.apte_by_handle.remove(&handle); } EventChild::SynchronousConnectionComplete(scc) => { Loading Loading @@ -436,6 +462,11 @@ impl OddDisconnectionsRule { } } fn process_apte(&mut self, apte: &AuthenticatedPayloadTimeoutExpired, _packet: &Packet) { let handle = apte.get_connection_handle(); *self.apte_by_handle.entry(handle).or_insert(0) += 1; } fn process_reset(&mut self) { self.active_handles.clear(); self.connection_attempt.clear(); Loading @@ -445,6 +476,7 @@ impl OddDisconnectionsRule { self.sco_connection_attempt.clear(); self.last_sco_connection_attempt = None; self.nocp_by_handle.clear(); self.apte_by_handle.clear(); } } Loading Loading @@ -518,6 +550,10 @@ impl Rule for OddDisconnectionsRule { self.process_nocp(&nocp, packet); } EventChild::AuthenticatedPayloadTimeoutExpired(apte) => { self.process_apte(&apte, packet); } // end hci event _ => (), }, Loading system/main/shim/hci_layer.cc +1 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ bool is_valid_event_code(bluetooth::hci::EventCode event_code) { return true; case bluetooth::hci::EventCode::VENDOR_SPECIFIC: case bluetooth::hci::EventCode::LE_META_EVENT: // Private to hci case bluetooth::hci::EventCode::AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED: return false; } return false; Loading system/pdl/hci/hci_packets.pdl +6 −0 Original line number Diff line number Diff line Loading @@ -831,6 +831,7 @@ enum EventCode : 8 { REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION = 0x3D, LE_META_EVENT = 0x3e, NUMBER_OF_COMPLETED_DATA_BLOCKS = 0x48, AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED = 0x57, VENDOR_SPECIFIC = 0xFF, } Loading Loading @@ -5803,6 +5804,11 @@ packet NumberOfCompletedDataBlocks : Event (event_code = NUMBER_OF_COMPLETED_DAT _payload_, // placeholder (unimplemented) } packet AuthenticatedPayloadTimeoutExpired : Event (event_code = AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED) { connection_handle : 12, _reserved_ : 4, } // LE Events packet LeConnectionComplete : LeMetaEvent (subevent_code = CONNECTION_COMPLETE) { status : ErrorCode, Loading Loading
floss/hcidoc/src/groups/connections.rs +40 −4 Original line number Diff line number Diff line Loading @@ -7,16 +7,17 @@ use std::io::Write; use crate::engine::{Rule, RuleGroup, Signal}; use crate::parser::{Packet, PacketChild}; use bt_packets::hci::{ Acl, AclCommandChild, Address, CommandChild, CommandStatus, ConnectionManagementCommandChild, DisconnectReason, ErrorCode, Event, EventChild, LeConnectionManagementCommandChild, LeMetaEventChild, NumberOfCompletedPackets, OpCode, ScoConnectionCommandChild, SecurityCommandChild, SubeventCode, Acl, AclCommandChild, Address, AuthenticatedPayloadTimeoutExpired, CommandChild, CommandStatus, ConnectionManagementCommandChild, DisconnectReason, ErrorCode, Event, EventChild, LeConnectionManagementCommandChild, LeMetaEventChild, NumberOfCompletedPackets, OpCode, ScoConnectionCommandChild, SecurityCommandChild, SubeventCode, }; enum ConnectionSignal { LinkKeyMismatch, // Peer forgets the link key or it mismatches ours NocpDisconnect, // Peer is disconnected when NOCP packet isn't yet received NocpTimeout, // Host doesn't receive NOCP packet 5 seconds after ACL is sent ApteDisconnect, // Host doesn't receive a packet with valid MIC for a while. } impl Into<&'static str> for ConnectionSignal { Loading @@ -25,6 +26,7 @@ impl Into<&'static str> for ConnectionSignal { ConnectionSignal::LinkKeyMismatch => "LinkKeyMismatch", ConnectionSignal::NocpDisconnect => "Nocp", ConnectionSignal::NocpTimeout => "Nocp", ConnectionSignal::ApteDisconnect => "AuthenticatedPayloadTimeoutExpired", } } } Loading Loading @@ -73,6 +75,9 @@ struct OddDisconnectionsRule { /// identify bursts. nocp_by_handle: HashMap<ConnectionHandle, NocpData>, /// Number of |Authenticated Payload Timeout Expired| events hapened. apte_by_handle: HashMap<ConnectionHandle, u32>, /// Pre-defined signals discovered in the logs. signals: Vec<Signal>, Loading @@ -91,6 +96,7 @@ impl OddDisconnectionsRule { sco_connection_attempt: HashMap::new(), last_sco_connection_attempt: None, nocp_by_handle: HashMap::new(), apte_by_handle: HashMap::new(), signals: vec![], reportable: vec![], } Loading Loading @@ -315,6 +321,26 @@ impl OddDisconnectionsRule { // Remove nocp information for handles that were removed. self.nocp_by_handle.remove(&handle); // Check if auth payload timeout happened. match self.apte_by_handle.get_mut(&handle) { Some(apte_count) => { self.signals.push(Signal { index: packet.index, ts: packet.ts.clone(), tag: ConnectionSignal::ApteDisconnect.into(), }); self.reportable.push(( packet.ts, format!("DisconnectionComplete with {} Authenticated Payload Timeout Expired (handle={})", apte_count, handle))); } None => (), } // Remove apte information for handles that were removed. self.apte_by_handle.remove(&handle); } EventChild::SynchronousConnectionComplete(scc) => { Loading Loading @@ -436,6 +462,11 @@ impl OddDisconnectionsRule { } } fn process_apte(&mut self, apte: &AuthenticatedPayloadTimeoutExpired, _packet: &Packet) { let handle = apte.get_connection_handle(); *self.apte_by_handle.entry(handle).or_insert(0) += 1; } fn process_reset(&mut self) { self.active_handles.clear(); self.connection_attempt.clear(); Loading @@ -445,6 +476,7 @@ impl OddDisconnectionsRule { self.sco_connection_attempt.clear(); self.last_sco_connection_attempt = None; self.nocp_by_handle.clear(); self.apte_by_handle.clear(); } } Loading Loading @@ -518,6 +550,10 @@ impl Rule for OddDisconnectionsRule { self.process_nocp(&nocp, packet); } EventChild::AuthenticatedPayloadTimeoutExpired(apte) => { self.process_apte(&apte, packet); } // end hci event _ => (), }, Loading
system/main/shim/hci_layer.cc +1 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ bool is_valid_event_code(bluetooth::hci::EventCode event_code) { return true; case bluetooth::hci::EventCode::VENDOR_SPECIFIC: case bluetooth::hci::EventCode::LE_META_EVENT: // Private to hci case bluetooth::hci::EventCode::AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED: return false; } return false; Loading
system/pdl/hci/hci_packets.pdl +6 −0 Original line number Diff line number Diff line Loading @@ -831,6 +831,7 @@ enum EventCode : 8 { REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION = 0x3D, LE_META_EVENT = 0x3e, NUMBER_OF_COMPLETED_DATA_BLOCKS = 0x48, AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED = 0x57, VENDOR_SPECIFIC = 0xFF, } Loading Loading @@ -5803,6 +5804,11 @@ packet NumberOfCompletedDataBlocks : Event (event_code = NUMBER_OF_COMPLETED_DAT _payload_, // placeholder (unimplemented) } packet AuthenticatedPayloadTimeoutExpired : Event (event_code = AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED) { connection_handle : 12, _reserved_ : 4, } // LE Events packet LeConnectionComplete : LeMetaEvent (subevent_code = CONNECTION_COMPLETE) { status : ErrorCode, Loading