diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-08-27 11:37:25 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-08-28 05:58:25 +0900 |
commit | 79ae3751360554cb2324fb22341631049aa900a4 (patch) | |
tree | da568f40581d76b079468185c83e8fe908ba25c8 | |
parent | d0cc259e3be4e18a7529841e5e72fa54700c90b6 (diff) |
packet lib: calculate the ip total length
If the total length is not given, calculate it.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/lib/packet/ipv4.py | 2 |
1 files changed, 2 insertions, 0 deletions
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) |