86890704fd
todo: add documentation & wireshark dissector
77 lines
No EOL
1.7 KiB
Text
Executable file
77 lines
No EOL
1.7 KiB
Text
Executable file
############
|
|
% IGMP tests
|
|
############
|
|
|
|
+ Basic IGMP tests
|
|
|
|
= Build IGMP - Basic
|
|
|
|
a=Ether(src="00:01:02:03:04:05")
|
|
b=IP(src="1.2.3.4")
|
|
c=IGMP(gaddr="0.0.0.0")
|
|
x = a/b/c
|
|
x[IGMP].igmpize()
|
|
assert x.mrcode == 20
|
|
assert x[IP].dst == "224.0.0.1"
|
|
|
|
= Build IGMP - Custom membership
|
|
|
|
a=Ether(src="00:01:02:03:04:05")
|
|
b=IP(src="1.2.3.4")
|
|
c=IGMP(gaddr="224.0.1.2")
|
|
x = a/b/c
|
|
x[IGMP].igmpize()
|
|
assert x.mrcode == 20
|
|
assert x[IP].dst == "224.0.1.2"
|
|
|
|
= Build IGMP - LG
|
|
|
|
a=Ether(src="00:01:02:03:04:05")
|
|
b=IP(src="1.2.3.4")
|
|
c=IGMP(type=0x17, gaddr="224.2.3.4")
|
|
x = a/b/c
|
|
x[IGMP].igmpize()
|
|
assert x.dst == "01:00:5e:00:00:02"
|
|
assert x.mrcode == 0
|
|
assert x[IP].dst == "224.0.0.2"
|
|
|
|
= Change IGMP params
|
|
|
|
x = Ether(src="00:01:02:03:04:05")/IP()/IGMP()
|
|
x[IGMP].igmpize()
|
|
assert x.mrcode == 20
|
|
assert x[IP].dst == "224.0.0.1"
|
|
|
|
x = Ether(src="00:01:02:03:04:05")/IP()/IGMP(gaddr="224.2.3.4", type=0x12)
|
|
x.mrcode = 1
|
|
x[IGMP].igmpize()
|
|
x = Ether(raw(x))
|
|
assert x.mrcode == 0
|
|
|
|
x.gaddr = "224.3.2.4"
|
|
x[IGMP].igmpize()
|
|
assert x.dst == "01:00:5e:03:02:04"
|
|
|
|
x.ttl = 64
|
|
x[IGMP].igmpize()
|
|
assert x.ttl == 1
|
|
|
|
= Test mysummary
|
|
|
|
x = Ether(src="00:01:02:03:04:05")/IP(src="192.168.0.1")/IGMP(gaddr="224.0.0.2", type=0x17)
|
|
x[IGMP].igmpize()
|
|
assert x[IGMP].mysummary() == "IGMP: 192.168.0.1 > 224.0.0.2 Leave Group 224.0.0.2"
|
|
|
|
assert IGMP().mysummary() == "IGMP Group Membership Query 0.0.0.0"
|
|
|
|
= IGMP - misc
|
|
~ netaccess
|
|
|
|
x = Ether(src="00:01:02:03:04:05")/IP(dst="192.168.0.1")/IGMP(gaddr="www.google.fr", type=0x11)
|
|
x = Ether(raw(x))
|
|
assert not x[IGMP].igmpize()
|
|
assert x[IP].dst == "192.168.0.1"
|
|
|
|
x = Ether(src="00:01:02:03:04:05")/IP(dst="192.168.0.1")/IGMP(gaddr="124.0.2.1", type=0x00)
|
|
assert not x[IGMP].igmpize()
|
|
assert x[IP].dst == "192.168.0.1" |