Fixed fields in IGMPv3 (#952)

* Reserved field must have 2 bytes long in IGMPv3mr

* Bind default values for dst ipaddr and mrcode in membership reports

* Use valid packets in tests
This commit is contained in:
AStotal 2017-12-19 04:02:04 +07:00 committed by Guillaume Valadon
parent 2a8f057513
commit 4ad2bf2a6c
2 changed files with 10 additions and 9 deletions

View File

@ -150,7 +150,7 @@ class IGMPv3mr(Packet):
"""IGMP Membership Report extension for IGMPv3.
Payload of IGMPv3 when type=0x22"""
name = "IGMPv3mr"
fields_desc = [ ByteField("res2", 0),
fields_desc = [ XShortField("res2", 0),
FieldLenField("numgrp", None, count_of="records"),
PacketListField("records", [], IGMPv3gr, count_from=lambda x: x.numgrp)]
@ -164,8 +164,9 @@ class IGMPv3mra(Packet):
bind_layers(IP, IGMPv3, frag=0,
proto=2,
ttl=1,
tos=0xc0)
tos=0xc0,
dst='224.0.0.22')
bind_layers(IGMPv3, IGMPv3mq, type=0x11)
bind_layers(IGMPv3, IGMPv3mr, type=0x22)
bind_layers(IGMPv3, IGMPv3mr, type=0x22, mrcode=0x0)
bind_layers(IGMPv3, IGMPv3mra, type=0x30)

View File

@ -17,21 +17,21 @@ assert isinstance(IGMP(raw(x[IGMPv3])), IGMPv3)
= Dissect IGMPv3 - IGMPv3mq
x = Ether(b'\x14\x0cv\x8f\xfe(\x00\x01\x02\x03\x04\x05\x08\x00F\xc0\x00$\x00\x01\x00\x00\x01\x02\xe4h\xc0\xa8\x00\x01\x7f\x00\x00\x01\x94\x04\x00\x00\x11\x14\x0e\xe9\xe0\x00\x00\x02\x00\x00\x00\x00')
x = Ether(b'\x14\x0cv\x8f\xfe(\x00\x01\x02\x03\x04\x05\x08\x00F\xc0\x00$\x00\x01\x00\x00\x01\x02\xe4h\xc0\xa8\x00\x01\xe0\x00\x00\x16\x94\x04\x00\x00\x11\x14\x0e\xe9\xe6\x00\x00\x02\x00\x00\x00\x00')
assert IGMPv3 in x
assert IGMPv3mq in x
assert x[IGMPv3mq].gaddr == "224.0.0.2"
assert x.summary() == "Ether / IP / IGMPv3: 192.168.0.1 > 127.0.0.1 Membership Query / IGMPv3mq"
assert x[IGMPv3mq].gaddr == "230.0.0.2"
assert x.summary() == "Ether / IP / IGMPv3: 192.168.0.1 > 224.0.0.22 Membership Query / IGMPv3mq"
assert isinstance(IGMP(raw(x[IGMPv3])), IGMPv3)
= Dissect IGMPv3 - IGMPv3mr
x = Ether(b'\x14\x0cv\x8f\xfe(\x00\x01\x02\x03\x04\x05\x08\x00F\xc0\x00;\x00\x01\x00\x00\x01\x02\xe4Q\xc0\xa8\x00\x01\x7f\x00\x00\x01\x94\x04\x00\x00"\x14w\xcc\x00\x00\x02\x01\x00\x00\x02{{{{\xc0\xa8\x00\x01\xc0\xa8\x84\xf7\x01\x00\x00\x01\x04\x04\x04\x04\x0c\x0c\x0c\x0c')
x = Ether(b'\x01\x00^\x00\x00\x16\xa8\xf9K\x00\x00\x01\x08\x00E\xc0\x00D\x00\x01\x00\x00\x01\x02\xd6\xdf\x01\x01\x01\x01\xe0\x00\x00\x16"\x00;\xa6\x00\x00\x00\x04\x01\x00\x00\x02\xe6\x00\x00\x00\xc0\xa8\x00\x01\xc0\xa8\x84\xf7\x01\x00\x00\x00\xe6\x00\x00\x01\x01\x00\x00\x00\xe6\x00\x00\x02\x01\x00\x00\x00\xe6\x00\x00\x03')
assert IGMPv3 in x
assert IGMPv3mr in x
assert len(x[IGMPv3mr].records) == 2
assert len(x[IGMPv3mr].records) == 4
assert x[IGMPv3mr].records[0].srcaddrs == ["192.168.0.1", "192.168.132.247"]
assert x[IGMPv3mr].records[1].maddr == "4.4.4.4"
assert x[IGMPv3mr].records[1].maddr == "230.0.0.1"
assert isinstance(IGMP(raw(x[IGMPv3])), IGMPv3)
= Dissect IGMPv3 - IGMPv3mra