mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 13:56:09 +02:00
packet lib: igmp: support default parameters
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
ba963ae2cf
commit
ddf1cbc5f6
@ -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
|
||||
|
||||
@ -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'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user