Skip to content

Commit

Permalink
add debug
Browse files Browse the repository at this point in the history
  • Loading branch information
tiannian committed Oct 22, 2022
1 parent 5161e09 commit 86bed1d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkt/src/layer3/ipv4/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ pub struct Packet<T> {

impl<T: AsRef<[u8]>> Display for Packet<T> {
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(())
}
Expand Down

0 comments on commit 86bed1d

Please sign in to comment.