From 79ae3751360554cb2324fb22341631049aa900a4 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Mon, 27 Aug 2012 11:37:25 +0900 Subject: [PATCH] packet lib: calculate the ip total length If the total length is not given, calculate it. Signed-off-by: FUJITA Tomonori --- ryu/lib/packet/ipv4.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ryu/lib/packet/ipv4.py b/ryu/lib/packet/ipv4.py index b802bd67..fa7c5250 100644 --- a/ryu/lib/packet/ipv4.py +++ b/ryu/lib/packet/ipv4.py @@ -72,6 +72,8 @@ class ipv4(packet_base.PacketBase): hdr = bytearray().zfill(self.header_length * 4) version = self.version << 4 | self.header_length flags = self.flags << 15 | self.offset + if self.total_length == 0: + self.total_length = self.header_length * 4 + len(payload) struct.pack_into(ipv4._PACK_STR, hdr, 0, version, self.tos, self.total_length, self.identification, flags, self.ttl, self.proto, 0, self.src, self.dst)