diff --git a/waterutil/tun_ipv4.go b/waterutil/tun_ipv4.go index 6e249e5..c0aba4c 100644 --- a/waterutil/tun_ipv4.go +++ b/waterutil/tun_ipv4.go @@ -1,6 +1,7 @@ package waterutil import ( + "encoding/binary" "net" ) @@ -12,6 +13,10 @@ func IPv4ECN(packet []byte) byte { return packet[1] & 0x03 } +func IPv4TotalLength(packet []byte) uint16 { + return binary.BigEndian.Uint16(packet[2:4]) +} + func IPv4Identification(packet []byte) [2]byte { return [2]byte{packet[4], packet[5]} }