Sorry, I have sent a malformed patch.
I resend a corrected patch.

Fixed flags bitshift.

Signed-off-by: HIYAMA Manabu <[email protected]>
---
 ryu/lib/packet/ipv4.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ryu/lib/packet/ipv4.py b/ryu/lib/packet/ipv4.py
index 343049a..e4f8778 100644
--- a/ryu/lib/packet/ipv4.py
+++ b/ryu/lib/packet/ipv4.py
@@ -50,8 +50,8 @@ class ipv4(packet_base.PacketBase):
          src, dst) = struct.unpack_from(cls._PACK_STR, buf)
         header_length = version & 0xf
         version = version >> 4
-        offset = flags & ((1 << 15) - 1)
-        flags = flags >> 15
+        offset = flags & ((1 << 13) - 1)
+        flags = flags >> 13
         msg = cls(version, header_length, tos, total_length, identification,
                   flags, offset, ttl, proto, csum, src, dst)

@@ -63,7 +63,7 @@ class ipv4(packet_base.PacketBase):
     def serialize(self, payload, prev):
         hdr = bytearray().zfill(self.header_length * 4)
         version = self.version << 4 | self.header_length
-        flags = self.flags << 15 | self.offset
+        flags = self.flags << 13 | 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,
--
1.7.5.4


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to