From 86bed1d0fabf7333c8eec9619dab899b2968fb81 Mon Sep 17 00:00:00 2001 From: tiannian Date: Sat, 22 Oct 2022 14:27:12 +0800 Subject: [PATCH] add debug --- pkt/src/layer3/ipv4/packet.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkt/src/layer3/ipv4/packet.rs b/pkt/src/layer3/ipv4/packet.rs index 3acb1bc..0ebd170 100644 --- a/pkt/src/layer3/ipv4/packet.rs +++ b/pkt/src/layer3/ipv4/packet.rs @@ -12,11 +12,16 @@ pub struct Packet { impl> Display for Packet { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - f.write_str("Ipv4 Packet:}")?; + f.write_str("Ipv4 Packet:")?; f.write_fmt(format_args!( - "Destination: {}, Source: {}", + "Destination: {}, Source: {}, Length: {}, Ident: {}, TTL: {}, Protocol: {:?}, Checksum: {}", self.dst_addr(), - self.src_addr() + self.src_addr(), + self.total_len() as usize - self.header_len() as usize, + self.ident(), + self.ttl(), + self.protocol(), + self.checksum(), ))?; Ok(()) }