diff --git a/decrypt_packets/src/pcap.rs b/decrypt_packets/src/pcap.rs index 67a11bc..bc9da35 100644 --- a/decrypt_packets/src/pcap.rs +++ b/decrypt_packets/src/pcap.rs @@ -347,11 +347,13 @@ pub fn analyze(path: &Path) -> Result<()> { pso_packet.header.flags(), pso_packet.header.size() ); - if pso_packet.body.is_empty() { - println!(""); - } else { - println!("{:?}", pso_packet.body.hex_conf(hex_cfg)); - } + + // get full packet bytes for the hex dump since it is probably useful most + // of the time to include the header bytes alongside the body + // TODO: this feels sloppy ... + let mut packet_bytes = Vec::new(); + pso_packet.write_bytes(&mut packet_bytes)?; + println!("{:?}", packet_bytes.hex_conf(hex_cfg)); println!(); } } diff --git a/psoutils/src/packets.rs b/psoutils/src/packets.rs index f298c8a..cac3584 100644 --- a/psoutils/src/packets.rs +++ b/psoutils/src/packets.rs @@ -90,6 +90,12 @@ impl GenericPacket { }) } + pub fn write_bytes(&self, writer: &mut T) -> Result<(), PacketError> { + self.header.write_bytes(writer)?; + writer.write_all(self.body.as_ref())?; + Ok(()) + } + pub fn size(&self) -> usize { self.header.size as usize + self.body.len() }