blob: 5c4507528329fdcab9298b0182ae1d23b1149460 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
dofile"setup.lua"
test("+igmp", function()
local n = net.init()
local igmpt = {type=0x11, code=0, ip="1.2.3.4"}
local ipt = {src="1.2.3.4", dst="5.6.7.8", protocol=2}
local etht = {src="01:02:03:01:02:03", dst="04:05:06:04:05:06"}
local pkt = "0405060405060102030102030800".. -- eth
"4500001c0000000040026acd0102030405060708".. -- ip
"1100eaf901020304" -- igmp
print" w/no-payload"
local gtag = n:igmp(igmpt)
local itag = n:ipv4(ipt)
local etag = n:eth(etht)
local b = n:block()
dump(n)
print("want", pkt)
print("have", h(b))
assert(pkt == h(b), h(b))
print"ok"
print" w/payload"
igmpt.payload = "\0\0\0"
igmpt.ptag = gtag
local gtag = n:igmp(igmpt)
local b = n:block()
dump(n)
print("want", pkt)
print("have", h(b))
assert(pkt.."000000" == h(b), h(b))
print"ok"
n:destroy()
end)
|