Signed-off-by: Yuichi Ito <ito.yuic...@gmail.com>
---
 ryu/lib/packet/igmp.py             |    3 ++-
 ryu/tests/unit/packet/test_igmp.py |    9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ryu/lib/packet/igmp.py b/ryu/lib/packet/igmp.py
index 2b9485b..88eab85 100644
--- a/ryu/lib/packet/igmp.py
+++ b/ryu/lib/packet/igmp.py
@@ -90,7 +90,8 @@ class igmp(packet_base.PacketBase):
     _PACK_STR = '!BBH4s'
     _MIN_LEN = struct.calcsize(_PACK_STR)

-    def __init__(self, msgtype, maxresp, csum, address):
+    def __init__(self, msgtype=IGMP_TYPE_QUERY, maxresp=0, csum=0,
+                 address='0.0.0.0'):
         super(igmp, self).__init__()
         self.msgtype = msgtype
         self.maxresp = maxresp
diff --git a/ryu/tests/unit/packet/test_igmp.py 
b/ryu/tests/unit/packet/test_igmp.py
index e5a810b..f5a49fe 100644
--- a/ryu/tests/unit/packet/test_igmp.py
+++ b/ryu/tests/unit/packet/test_igmp.py
@@ -145,3 +145,12 @@ class Test_igmp(unittest.TestCase):
     def test_malformed_igmp(self):
         m_short_buf = self.buf[1:igmp._MIN_LEN]
         igmp.parser(m_short_buf)
+
+    def test_default_args(self):
+        ig = igmp()
+        buf = ig.serialize(bytearray(), None)
+        res = unpack_from(igmp._PACK_STR, str(buf))
+
+        eq_(res[0], 0x11)
+        eq_(res[1], 0)
+        eq_(res[3], addrconv.ipv4.text_to_bin('0.0.0.0'))
-- 
1.7.10.4


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to