diff --git a/vnt/packet/src/lib.rs b/vnt/packet/src/lib.rs index ac58415..1604c79 100644 --- a/vnt/packet/src/lib.rs +++ b/vnt/packet/src/lib.rs @@ -103,9 +103,9 @@ pub fn ipv4_cal_checksum( src_ip: &Ipv4Addr, dest_ip: &Ipv4Addr, protocol: u8, - length: u16, ) -> u16 { use std::io::Cursor; + let length = buffer.len(); let mut sum = 0; let src_ip = src_ip.octets(); sum += u32c(src_ip[0], src_ip[1]); diff --git a/vnt/packet/src/tcp/tcp.rs b/vnt/packet/src/tcp/tcp.rs index 3424abf..1be0235 100644 --- a/vnt/packet/src/tcp/tcp.rs +++ b/vnt/packet/src/tcp/tcp.rs @@ -134,7 +134,6 @@ impl> TcpPacket { &self.source_ip, &self.destination_ip, 6, - self.buffer.as_ref().len() as u16, ) } pub fn urgent_pointer(&self) -> u16 { diff --git a/vnt/packet/src/udp/udp.rs b/vnt/packet/src/udp/udp.rs index 917ae39..9aedce1 100644 --- a/vnt/packet/src/udp/udp.rs +++ b/vnt/packet/src/udp/udp.rs @@ -102,7 +102,6 @@ impl> UdpPacket { &self.source_ip, &self.destination_ip, 17, - self.length(), ) } }