Signed-off-by: Yuichi Ito <[email protected]>
---
 ryu/lib/packet/udp.py             |    2 +-
 ryu/tests/unit/packet/test_udp.py |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ryu/lib/packet/udp.py b/ryu/lib/packet/udp.py
index e3bf5e5..a960886 100644
--- a/ryu/lib/packet/udp.py
+++ b/ryu/lib/packet/udp.py
@@ -41,7 +41,7 @@ class udp(packet_base.PacketBase):
     _PACK_STR = '!HHHH'
     _MIN_LEN = struct.calcsize(_PACK_STR)

-    def __init__(self, src_port, dst_port, total_length=0, csum=0):
+    def __init__(self, src_port=0, dst_port=0, total_length=0, csum=0):
         super(udp, self).__init__()
         self.src_port = src_port
         self.dst_port = dst_port
diff --git a/ryu/tests/unit/packet/test_udp.py 
b/ryu/tests/unit/packet/test_udp.py
index 6418743..40da616 100644
--- a/ryu/tests/unit/packet/test_udp.py
+++ b/ryu/tests/unit/packet/test_udp.py
@@ -94,3 +94,13 @@ class Test_udp(unittest.TestCase):
     def test_malformed_udp(self):
         m_short_buf = self.buf[1:udp._MIN_LEN]
         udp.parser(m_short_buf)
+
+    def test_default_args(self):
+        prev = ipv4(proto=inet.IPPROTO_UDP)
+        u = udp()
+        buf = u.serialize(bytearray(), prev)
+        res = struct.unpack(udp._PACK_STR, buf)
+
+        eq_(res[0], 0)
+        eq_(res[1], 0)
+        eq_(res[2], udp._MIN_LEN)
-- 
1.7.10.4


------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to