Loading floss/hcidoc/src/groups/connections.rs +11 −11 Original line number Diff line number Diff line Loading @@ -6,12 +6,11 @@ use std::io::Write; use crate::engine::{Rule, RuleGroup, Signal}; use crate::parser::{Packet, PacketChild}; use bt_packets::custom_types::Address; use bt_packets::hci::{ AclCommandChild, AclPacket, CommandChild, CommandStatusPacket, ConnectionManagementCommandChild, ErrorCode, EventChild, EventPacket, LeConnectionManagementCommandChild, LeMetaEventChild, NumberOfCompletedPacketsPacket, OpCode, ScoConnectionCommandChild, SecurityCommandChild, SubeventCode, Acl, AclCommandChild, Address, CommandChild, CommandStatus, ConnectionManagementCommandChild, ErrorCode, Event, EventChild, LeConnectionManagementCommandChild, LeMetaEventChild, NumberOfCompletedPackets, OpCode, ScoConnectionCommandChild, SecurityCommandChild, SubeventCode, }; enum ConnectionSignal { Loading @@ -38,7 +37,7 @@ pub const INVALID_CONN_HANDLE: u16 = 0xfffeu16; /// When we attempt to create a sco connection on an unknown handle, use this address as /// a placeholder. pub const UNKNOWN_SCO_ADDRESS: Address = Address { bytes: [0xde, 0xad, 0xbe, 0xef, 0x00, 0x00] }; pub const UNKNOWN_SCO_ADDRESS: [u8; 6] = [0xdeu8, 0xad, 0xbe, 0xef, 0x00, 0x00]; /// Any outstanding NOCP or disconnection that is more than 5s away from the sent ACL packet should /// result in an NOCP signal being generated. Loading Loading @@ -145,9 +144,10 @@ impl OddDisconnectionsRule { _ => INVALID_CONN_HANDLE, }; let unknown_address = Address::from(&UNKNOWN_SCO_ADDRESS); let address = match self.active_handles.get(&handle).as_ref() { Some((_ts, address)) => address, None => &UNKNOWN_SCO_ADDRESS, None => &unknown_address, }; let has_existing = match sco_conn { Loading Loading @@ -206,7 +206,7 @@ impl OddDisconnectionsRule { } } pub fn process_command_status(&mut self, cs: &CommandStatusPacket, packet: &Packet) { pub fn process_command_status(&mut self, cs: &CommandStatus, packet: &Packet) { // Clear last connection attempt since it was successful. let last_address = match cs.get_command_op_code() { OpCode::CreateConnection | OpCode::AcceptConnectionRequest => { Loading Loading @@ -264,7 +264,7 @@ impl OddDisconnectionsRule { } } pub fn process_event(&mut self, ev: &EventPacket, packet: &Packet) { pub fn process_event(&mut self, ev: &Event, packet: &Packet) { match ev.specialize() { EventChild::ConnectionComplete(cc) => { match self.connection_attempt.remove(&cc.get_bd_addr()) { Loading Loading @@ -413,7 +413,7 @@ impl OddDisconnectionsRule { } } pub fn process_acl_tx(&mut self, acl_tx: &AclPacket, packet: &Packet) { pub fn process_acl_tx(&mut self, acl_tx: &Acl, packet: &Packet) { let handle = acl_tx.get_handle(); // Insert empty Nocp data for handle if it doesn't exist. Loading @@ -426,7 +426,7 @@ impl OddDisconnectionsRule { } } pub fn process_nocp(&mut self, nocp: &NumberOfCompletedPacketsPacket, packet: &Packet) { pub fn process_nocp(&mut self, nocp: &NumberOfCompletedPackets, packet: &Packet) { let ts = &packet.ts; for completed_packet in nocp.get_completed_packets() { let handle = completed_packet.connection_handle; Loading floss/hcidoc/src/groups/informational.rs +2 −3 Original line number Diff line number Diff line Loading @@ -7,10 +7,9 @@ use std::io::Write; use crate::engine::{Rule, RuleGroup, Signal}; use crate::parser::{Packet, PacketChild}; use bt_packets::custom_types::Address; use bt_packets::hci::{ AclCommandChild, CommandChild, ConnectionManagementCommandChild, ErrorCode, EventChild, GapData, GapDataType, LeMetaEventChild, AclCommandChild, Address, CommandChild, ConnectionManagementCommandChild, ErrorCode, EventChild, GapData, GapDataType, LeMetaEventChild, }; /// Valid values are in the range 0x0000-0x0EFF. Loading floss/hcidoc/src/main.rs +1 −1 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ fn main() { match Packet::try_from((pos, &v)) { Ok(p) => engine.process(p), Err(e) => match v.opcode() { LinuxSnoopOpcodes::CommandPacket | LinuxSnoopOpcodes::EventPacket => { LinuxSnoopOpcodes::Command | LinuxSnoopOpcodes::Event => { eprintln!("#{}: {}", pos, e); } _ => (), Loading floss/hcidoc/src/parser.rs +11 −11 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ use std::convert::TryFrom; use std::fs::File; use std::io::{BufRead, BufReader, Error, ErrorKind, Read}; use bt_packets::hci::{AclPacket, CommandPacket, EventPacket}; use bt_packets::hci::{Acl, Command, Event}; /// Linux snoop file header format. This format is used by `btmon` on Linux systems that have bluez /// installed. Loading Loading @@ -70,8 +70,8 @@ impl TryFrom<&[u8]> for LinuxSnoopHeader { pub enum LinuxSnoopOpcodes { NewIndex = 0, DeleteIndex, CommandPacket, EventPacket, Command, Event, AclTxPacket, AclRxPacket, ScoTxPacket, Loading Loading @@ -279,10 +279,10 @@ impl<'a> LogParser { /// Data owned by a packet. #[derive(Debug, Clone)] pub enum PacketChild { HciCommand(CommandPacket), HciEvent(EventPacket), AclTx(AclPacket), AclRx(AclPacket), HciCommand(Command), HciEvent(Event), AclTx(Acl), AclRx(Acl), } impl<'a> TryFrom<&'a LinuxSnoopPacket> for PacketChild { Loading @@ -290,22 +290,22 @@ impl<'a> TryFrom<&'a LinuxSnoopPacket> for PacketChild { fn try_from(item: &'a LinuxSnoopPacket) -> Result<Self, Self::Error> { match item.opcode() { LinuxSnoopOpcodes::CommandPacket => match CommandPacket::parse(item.data.as_slice()) { LinuxSnoopOpcodes::Command => match Command::parse(item.data.as_slice()) { Ok(command) => Ok(PacketChild::HciCommand(command)), Err(e) => Err(format!("Couldn't parse command: {:?}", e)), }, LinuxSnoopOpcodes::EventPacket => match EventPacket::parse(item.data.as_slice()) { LinuxSnoopOpcodes::Event => match Event::parse(item.data.as_slice()) { Ok(event) => Ok(PacketChild::HciEvent(event)), Err(e) => Err(format!("Couldn't parse event: {:?}", e)), }, LinuxSnoopOpcodes::AclTxPacket => match AclPacket::parse(item.data.as_slice()) { LinuxSnoopOpcodes::AclTxPacket => match Acl::parse(item.data.as_slice()) { Ok(data) => Ok(PacketChild::AclTx(data)), Err(e) => Err(format!("Couldn't parse acl tx: {:?}", e)), }, LinuxSnoopOpcodes::AclRxPacket => match AclPacket::parse(item.data.as_slice()) { LinuxSnoopOpcodes::AclRxPacket => match Acl::parse(item.data.as_slice()) { Ok(data) => Ok(PacketChild::AclRx(data)), Err(e) => Err(format!("Couldn't parse acl rx: {:?}", e)), }, Loading Loading
floss/hcidoc/src/groups/connections.rs +11 −11 Original line number Diff line number Diff line Loading @@ -6,12 +6,11 @@ use std::io::Write; use crate::engine::{Rule, RuleGroup, Signal}; use crate::parser::{Packet, PacketChild}; use bt_packets::custom_types::Address; use bt_packets::hci::{ AclCommandChild, AclPacket, CommandChild, CommandStatusPacket, ConnectionManagementCommandChild, ErrorCode, EventChild, EventPacket, LeConnectionManagementCommandChild, LeMetaEventChild, NumberOfCompletedPacketsPacket, OpCode, ScoConnectionCommandChild, SecurityCommandChild, SubeventCode, Acl, AclCommandChild, Address, CommandChild, CommandStatus, ConnectionManagementCommandChild, ErrorCode, Event, EventChild, LeConnectionManagementCommandChild, LeMetaEventChild, NumberOfCompletedPackets, OpCode, ScoConnectionCommandChild, SecurityCommandChild, SubeventCode, }; enum ConnectionSignal { Loading @@ -38,7 +37,7 @@ pub const INVALID_CONN_HANDLE: u16 = 0xfffeu16; /// When we attempt to create a sco connection on an unknown handle, use this address as /// a placeholder. pub const UNKNOWN_SCO_ADDRESS: Address = Address { bytes: [0xde, 0xad, 0xbe, 0xef, 0x00, 0x00] }; pub const UNKNOWN_SCO_ADDRESS: [u8; 6] = [0xdeu8, 0xad, 0xbe, 0xef, 0x00, 0x00]; /// Any outstanding NOCP or disconnection that is more than 5s away from the sent ACL packet should /// result in an NOCP signal being generated. Loading Loading @@ -145,9 +144,10 @@ impl OddDisconnectionsRule { _ => INVALID_CONN_HANDLE, }; let unknown_address = Address::from(&UNKNOWN_SCO_ADDRESS); let address = match self.active_handles.get(&handle).as_ref() { Some((_ts, address)) => address, None => &UNKNOWN_SCO_ADDRESS, None => &unknown_address, }; let has_existing = match sco_conn { Loading Loading @@ -206,7 +206,7 @@ impl OddDisconnectionsRule { } } pub fn process_command_status(&mut self, cs: &CommandStatusPacket, packet: &Packet) { pub fn process_command_status(&mut self, cs: &CommandStatus, packet: &Packet) { // Clear last connection attempt since it was successful. let last_address = match cs.get_command_op_code() { OpCode::CreateConnection | OpCode::AcceptConnectionRequest => { Loading Loading @@ -264,7 +264,7 @@ impl OddDisconnectionsRule { } } pub fn process_event(&mut self, ev: &EventPacket, packet: &Packet) { pub fn process_event(&mut self, ev: &Event, packet: &Packet) { match ev.specialize() { EventChild::ConnectionComplete(cc) => { match self.connection_attempt.remove(&cc.get_bd_addr()) { Loading Loading @@ -413,7 +413,7 @@ impl OddDisconnectionsRule { } } pub fn process_acl_tx(&mut self, acl_tx: &AclPacket, packet: &Packet) { pub fn process_acl_tx(&mut self, acl_tx: &Acl, packet: &Packet) { let handle = acl_tx.get_handle(); // Insert empty Nocp data for handle if it doesn't exist. Loading @@ -426,7 +426,7 @@ impl OddDisconnectionsRule { } } pub fn process_nocp(&mut self, nocp: &NumberOfCompletedPacketsPacket, packet: &Packet) { pub fn process_nocp(&mut self, nocp: &NumberOfCompletedPackets, packet: &Packet) { let ts = &packet.ts; for completed_packet in nocp.get_completed_packets() { let handle = completed_packet.connection_handle; Loading
floss/hcidoc/src/groups/informational.rs +2 −3 Original line number Diff line number Diff line Loading @@ -7,10 +7,9 @@ use std::io::Write; use crate::engine::{Rule, RuleGroup, Signal}; use crate::parser::{Packet, PacketChild}; use bt_packets::custom_types::Address; use bt_packets::hci::{ AclCommandChild, CommandChild, ConnectionManagementCommandChild, ErrorCode, EventChild, GapData, GapDataType, LeMetaEventChild, AclCommandChild, Address, CommandChild, ConnectionManagementCommandChild, ErrorCode, EventChild, GapData, GapDataType, LeMetaEventChild, }; /// Valid values are in the range 0x0000-0x0EFF. Loading
floss/hcidoc/src/main.rs +1 −1 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ fn main() { match Packet::try_from((pos, &v)) { Ok(p) => engine.process(p), Err(e) => match v.opcode() { LinuxSnoopOpcodes::CommandPacket | LinuxSnoopOpcodes::EventPacket => { LinuxSnoopOpcodes::Command | LinuxSnoopOpcodes::Event => { eprintln!("#{}: {}", pos, e); } _ => (), Loading
floss/hcidoc/src/parser.rs +11 −11 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ use std::convert::TryFrom; use std::fs::File; use std::io::{BufRead, BufReader, Error, ErrorKind, Read}; use bt_packets::hci::{AclPacket, CommandPacket, EventPacket}; use bt_packets::hci::{Acl, Command, Event}; /// Linux snoop file header format. This format is used by `btmon` on Linux systems that have bluez /// installed. Loading Loading @@ -70,8 +70,8 @@ impl TryFrom<&[u8]> for LinuxSnoopHeader { pub enum LinuxSnoopOpcodes { NewIndex = 0, DeleteIndex, CommandPacket, EventPacket, Command, Event, AclTxPacket, AclRxPacket, ScoTxPacket, Loading Loading @@ -279,10 +279,10 @@ impl<'a> LogParser { /// Data owned by a packet. #[derive(Debug, Clone)] pub enum PacketChild { HciCommand(CommandPacket), HciEvent(EventPacket), AclTx(AclPacket), AclRx(AclPacket), HciCommand(Command), HciEvent(Event), AclTx(Acl), AclRx(Acl), } impl<'a> TryFrom<&'a LinuxSnoopPacket> for PacketChild { Loading @@ -290,22 +290,22 @@ impl<'a> TryFrom<&'a LinuxSnoopPacket> for PacketChild { fn try_from(item: &'a LinuxSnoopPacket) -> Result<Self, Self::Error> { match item.opcode() { LinuxSnoopOpcodes::CommandPacket => match CommandPacket::parse(item.data.as_slice()) { LinuxSnoopOpcodes::Command => match Command::parse(item.data.as_slice()) { Ok(command) => Ok(PacketChild::HciCommand(command)), Err(e) => Err(format!("Couldn't parse command: {:?}", e)), }, LinuxSnoopOpcodes::EventPacket => match EventPacket::parse(item.data.as_slice()) { LinuxSnoopOpcodes::Event => match Event::parse(item.data.as_slice()) { Ok(event) => Ok(PacketChild::HciEvent(event)), Err(e) => Err(format!("Couldn't parse event: {:?}", e)), }, LinuxSnoopOpcodes::AclTxPacket => match AclPacket::parse(item.data.as_slice()) { LinuxSnoopOpcodes::AclTxPacket => match Acl::parse(item.data.as_slice()) { Ok(data) => Ok(PacketChild::AclTx(data)), Err(e) => Err(format!("Couldn't parse acl tx: {:?}", e)), }, LinuxSnoopOpcodes::AclRxPacket => match AclPacket::parse(item.data.as_slice()) { LinuxSnoopOpcodes::AclRxPacket => match Acl::parse(item.data.as_slice()) { Ok(data) => Ok(PacketChild::AclRx(data)), Err(e) => Err(format!("Couldn't parse acl rx: {:?}", e)), }, Loading