Skip to content
Snippets Groups Projects
regression.uts 405 KiB
Newer Older
Phil's avatar
Phil committed
a.otype == 0x05 and a.optlen == 3 and a.value == 0xffff


Phil's avatar
Phil committed
+ Test Jumbo Class (RFC 2675)

= Jumbo - Basic Instantiation 
raw(Jumbo()) == b'\xc2\x04\x00\x00\x00\x00'
Phil's avatar
Phil committed

= Jumbo - Basic Dissection 
gpotter2's avatar
gpotter2 committed
a=Jumbo(b'\xc2\x04\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.otype == 0xC2 and a.optlen == 4 and a.jumboplen == 0

= Jumbo - Instantiation with specific values
raw(Jumbo(optlen=6, jumboplen=0xffffffff)) == b'\xc2\x06\xff\xff\xff\xff'
Phil's avatar
Phil committed

= Jumbo - Dissection with specific values 
gpotter2's avatar
gpotter2 committed
a=Jumbo(b'\xc2\x06\xff\xff\xff\xff')
Phil's avatar
Phil committed
a.otype == 0xc2 and a.optlen == 6 and a.jumboplen == 0xffffffff


Phil's avatar
Phil committed
+ Test HAO Class (RFC 3775)

= HAO - Basic Instantiation 
raw(HAO()) == b'\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= HAO - Basic Dissection 
gpotter2's avatar
gpotter2 committed
a=HAO(b'\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.otype == 0xC9 and a.optlen == 16 and a.hoa == "::"

= HAO - Instantiation with specific values
raw(HAO(optlen=9, hoa="2001::ffff")) == b'\xc9\t \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff'
Phil's avatar
Phil committed

= HAO - Dissection with specific values 
gpotter2's avatar
gpotter2 committed
a=HAO(b'\xc9\t \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff')
Phil's avatar
Phil committed
a.otype == 0xC9 and a.optlen == 9 and a.hoa == "2001::ffff"

= HAO - hashret

p = IPv6()/IPv6ExtHdrDestOpt(options=HAO(hoa="2001:db8::1"))/ICMPv6EchoRequest()
gpotter2's avatar
gpotter2 committed
p.hashret() == b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00:\x00\x00\x00\x00"
Phil's avatar
Phil committed

Phil's avatar
Phil committed
+ Test IPv6ExtHdrHopByHop()

= IPv6ExtHdrHopByHop - Basic Instantiation 
raw(IPv6ExtHdrHopByHop()) ==  b';\x00\x01\x04\x00\x00\x00\x00'
Phil's avatar
Phil committed

= IPv6ExtHdrHopByHop - Instantiation with HAO option
raw(IPv6ExtHdrHopByHop(options=[HAO()])) == b';\x02\x01\x02\x00\x00\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= IPv6ExtHdrHopByHop - Instantiation with RouterAlert option
raw(IPv6ExtHdrHopByHop(options=[RouterAlert()])) == b';\x00\x05\x02\x00\x00\x01\x00'
Phil's avatar
Phil committed
 
= IPv6ExtHdrHopByHop - Instantiation with Jumbo option
raw(IPv6ExtHdrHopByHop(options=[Jumbo()])) == b';\x00\xc2\x04\x00\x00\x00\x00'
Phil's avatar
Phil committed

= IPv6ExtHdrHopByHop - Instantiation with Pad1 option
raw(IPv6ExtHdrHopByHop(options=[Pad1()])) == b';\x00\x00\x01\x03\x00\x00\x00'
Phil's avatar
Phil committed

= IPv6ExtHdrHopByHop - Instantiation with PadN option
raw(IPv6ExtHdrHopByHop(options=[Pad1()])) == b';\x00\x00\x01\x03\x00\x00\x00'
Phil's avatar
Phil committed

= IPv6ExtHdrHopByHop - Instantiation with Jumbo, RouterAlert, HAO
raw(IPv6ExtHdrHopByHop(options=[Jumbo(), RouterAlert(), HAO()])) == b';\x03\xc2\x04\x00\x00\x00\x00\x05\x02\x00\x00\x01\x00\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= IPv6ExtHdrHopByHop - Instantiation with HAO, Jumbo, RouterAlert
raw(IPv6ExtHdrHopByHop(options=[HAO(), Jumbo(), RouterAlert()])) == b';\x04\x01\x02\x00\x00\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\xc2\x04\x00\x00\x00\x00\x05\x02\x00\x00\x01\x02\x00\x00'
Phil's avatar
Phil committed

= IPv6ExtHdrHopByHop - Instantiation with RouterAlert, HAO, Jumbo
raw(IPv6ExtHdrHopByHop(options=[RouterAlert(), HAO(), Jumbo()])) == b';\x03\x05\x02\x00\x00\xc9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\xc2\x04\x00\x00\x00\x00'
Phil's avatar
Phil committed

= IPv6ExtHdrHopByHop - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=IPv6ExtHdrHopByHop(b';\x00\x01\x04\x00\x00\x00\x00')
a.nh == 59 and a.len == 0 and len(a.options) == 1 and isinstance(a.options[0], PadN) and a.options[0].otype == 1 and a.options[0].optlen == 4 and a.options[0].optdata == b'\x00'*4
Phil's avatar
Phil committed

#= IPv6ExtHdrHopByHop - Automatic length computation
#raw(IPv6ExtHdrHopByHop(options=["toto"])) == b'\x00\x00toto'
Phil's avatar
Phil committed
#= IPv6ExtHdrHopByHop - Automatic length computation
#raw(IPv6ExtHdrHopByHop(options=["toto"])) == b'\x00\x00tototo'
Phil's avatar
Phil committed
+ Test ICMPv6ND_RS() class - ICMPv6 Type 133 Code 0

= ICMPv6ND_RS - Basic instantiation
raw(ICMPv6ND_RS()) == b'\x85\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6ND_RS - Basic instantiation with empty dst in IPv6 underlayer
raw(IPv6(src="2001:db8::1")/ICMPv6ND_RS()) == b'`\x00\x00\x00\x00\x08:\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x85\x00M\xfe\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6ND_RS - Basic dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6ND_RS(b'\x85\x00\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type == 133 and a.code == 0 and a.cksum == 0 and a.res == 0 

= ICMPv6ND_RS - Basic instantiation with empty dst in IPv6 underlayer
gpotter2's avatar
gpotter2 committed
a=IPv6(b'`\x00\x00\x00\x00\x08:\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x85\x00M\xfe\x00\x00\x00\x00')
Phil's avatar
Phil committed
isinstance(a, IPv6) and a.nh == 58 and a.hlim == 255 and isinstance(a.payload, ICMPv6ND_RS) and a.payload.type == 133 and a.payload.code == 0 and a.payload.cksum == 0x4dfe and a.payload.res == 0


Phil's avatar
Phil committed
+ Test ICMPv6ND_RA() class - ICMPv6 Type 134 Code 0

= ICMPv6ND_RA - Basic Instantiation 
raw(ICMPv6ND_RA()) == b'\x86\x00\x00\x00\x00\x08\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6ND_RA - Basic instantiation with empty dst in IPv6 underlayer
raw(IPv6(src="2001:db8::1")/ICMPv6ND_RA()) == b'`\x00\x00\x00\x00\x10:\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x86\x00E\xe7\x00\x08\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6ND_RA - Basic dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6ND_RA(b'\x86\x00\x00\x00\x00\x08\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type == 134 and a.code == 0 and a.cksum == 0 and a.chlim == 0 and a.M == 0 and a.O == 0 and a.H == 0 and a.prf == 1 and a.res == 0 and a.routerlifetime == 1800 and a.reachabletime == 0 and a.retranstimer == 0

= ICMPv6ND_RA - Basic instantiation with empty dst in IPv6 underlayer
gpotter2's avatar
gpotter2 committed
a=IPv6(b'`\x00\x00\x00\x00\x10:\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x86\x00E\xe7\x00\x08\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
isinstance(a, IPv6) and a.nh == 58 and a.hlim == 255 and isinstance(a.payload, ICMPv6ND_RA) and a.payload.type == 134 and a.code == 0 and a.cksum == 0x45e7 and a.chlim == 0 and a.M == 0 and a.O == 0 and a.H == 0 and a.prf == 1 and a.res == 0 and a.routerlifetime == 1800 and a.reachabletime == 0 and a.retranstimer == 0 

= ICMPv6ND_RA - Answers
assert ICMPv6ND_RA().answers(ICMPv6ND_RS())
a=IPv6(b'`\x00\x00\x00\x00\x10:\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x86\x00E\xe7\x00\x08\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00')
b = IPv6(b"`\x00\x00\x00\x00\x10:\xff\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x85\x00M\xff\x00\x00\x00\x00")
assert a.answers(b)
Phil's avatar
Phil committed

Phil's avatar
Phil committed
+ ICMPv6ND_NS Class Test

= ICMPv6ND_NS - Basic Instantiation
raw(ICMPv6ND_NS()) == b'\x87\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6ND_NS - Instantiation with specific values
raw(ICMPv6ND_NS(code=0x11, res=3758096385, tgt="ffff::1111")) == b'\x87\x11\x00\x00\xe0\x00\x00\x01\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11'
Phil's avatar
Phil committed

= ICMPv6ND_NS - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6ND_NS(b'\x87\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.code==0 and a.res==0 and a.tgt=="::"
Phil's avatar
Phil committed

= ICMPv6ND_NS - Dissection with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6ND_NS(b'\x87\x11\x00\x00\xe0\x00\x00\x01\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11')
a.code==0x11 and a.res==3758096385 and a.tgt=="ffff::1111"
Phil's avatar
Phil committed

= ICMPv6ND_NS - IPv6 layer fields overloading
a=IPv6(raw(IPv6()/ICMPv6ND_NS()))
Phil's avatar
Phil committed
a.nh == 58 and a.dst=="ff02::1" and a.hlim==255

Phil's avatar
Phil committed
+ ICMPv6ND_NA Class Test

= ICMPv6ND_NA - Basic Instantiation
raw(ICMPv6ND_NA()) == b'\x88\x00\x00\x00\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6ND_NA - Instantiation with specific values
raw(ICMPv6ND_NA(code=0x11, R=0, S=1, O=0, res=1, tgt="ffff::1111")) == b'\x88\x11\x00\x00@\x00\x00\x01\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11'
Phil's avatar
Phil committed

= ICMPv6ND_NA - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6ND_NA(b'\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.code==0 and a.R==0 and a.S==0 and a.O==0 and a.res==0 and a.tgt=="::"

= ICMPv6ND_NA - Dissection with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6ND_NA(b'\x88\x11\x00\x00@\x00\x00\x01\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11')
Phil's avatar
Phil committed
a.code==0x11 and a.R==0 and a.S==1 and a.O==0 and a.res==1 and a.tgt=="ffff::1111"

= ICMPv6ND_NS - IPv6 layer fields overloading
a=IPv6(raw(IPv6()/ICMPv6ND_NS()))
Phil's avatar
Phil committed
a.nh == 58 and a.dst=="ff02::1" and a.hlim==255

Phil's avatar
Phil committed
+ ICMPv6ND_ND/ICMPv6ND_ND matching test

=  ICMPv6ND_ND/ICMPv6ND_ND matching - test 1
# Sent NS 
gpotter2's avatar
gpotter2 committed
a=IPv6(b'`\x00\x00\x00\x00\x18:\xff\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x0f\x1f\xff\xfe\xcaFP\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87\x00UC\x00\x00\x00\x00\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x0f4\xff\xfe\x8a\x8a\xa1')
Phil's avatar
Phil committed
# Received NA 
gpotter2's avatar
gpotter2 committed
b=IPv6(b'n\x00\x00\x00\x00 :\xff\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x0f4\xff\xfe\x8a\x8a\xa1\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x0f\x1f\xff\xfe\xcaFP\x88\x00\xf3F\xe0\x00\x00\x00\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x0f4\xff\xfe\x8a\x8a\xa1\x02\x01\x00\x0f4\x8a\x8a\xa1')
Phil's avatar
Phil committed
b.answers(a)


Phil's avatar
Phil committed
+ ICMPv6NDOptUnknown Class Test

= ICMPv6NDOptUnknown - Basic Instantiation
raw(ICMPv6NDOptUnknown()) == b'\x00\x02'
Phil's avatar
Phil committed

= ICMPv6NDOptUnknown - Instantiation with specific values
raw(ICMPv6NDOptUnknown(len=4, data="somestring")) == b'\x00\x04somestring'
Phil's avatar
Phil committed

= ICMPv6NDOptUnknown - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptUnknown(b'\x00\x02')
Phil's avatar
Phil committed
a.type == 0 and a.len == 2

= ICMPv6NDOptUnknown - Dissection with specific values 
a=ICMPv6NDOptUnknown(b'\x00\x04somerawing')
a.type == 0 and a.len==4 and a.data == b"so" and isinstance(a.payload, Raw) and a.payload.load == b"merawing"
Phil's avatar
Phil committed

Phil's avatar
Phil committed
+ ICMPv6NDOptSrcLLAddr Class Test

= ICMPv6NDOptSrcLLAddr - Basic Instantiation
raw(ICMPv6NDOptSrcLLAddr()) == b'\x01\x01\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptSrcLLAddr - Instantiation with specific values
raw(ICMPv6NDOptSrcLLAddr(len=2, lladdr="11:11:11:11:11:11")) == b'\x01\x02\x11\x11\x11\x11\x11\x11'
Phil's avatar
Phil committed

= ICMPv6NDOptSrcLLAddr - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptSrcLLAddr(b'\x01\x01\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type == 1 and a.len == 1 and a.lladdr == "00:00:00:00:00:00"

= ICMPv6NDOptSrcLLAddr - Instantiation with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptSrcLLAddr(b'\x01\x02\x11\x11\x11\x11\x11\x11') 
Phil's avatar
Phil committed
a.type == 1 and a.len == 2 and a.lladdr == "11:11:11:11:11:11"

Phil's avatar
Phil committed
+ ICMPv6NDOptDstLLAddr Class Test

= ICMPv6NDOptDstLLAddr - Basic Instantiation
raw(ICMPv6NDOptDstLLAddr()) == b'\x02\x01\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptDstLLAddr - Instantiation with specific values
raw(ICMPv6NDOptDstLLAddr(len=2, lladdr="11:11:11:11:11:11")) == b'\x02\x02\x11\x11\x11\x11\x11\x11'
Phil's avatar
Phil committed

= ICMPv6NDOptDstLLAddr - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptDstLLAddr(b'\x02\x01\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type == 2 and a.len == 1 and a.lladdr == "00:00:00:00:00:00"

= ICMPv6NDOptDstLLAddr - Instantiation with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptDstLLAddr(b'\x02\x02\x11\x11\x11\x11\x11\x11') 
Phil's avatar
Phil committed
a.type == 2 and a.len == 2 and a.lladdr == "11:11:11:11:11:11"

Phil's avatar
Phil committed
+ ICMPv6NDOptPrefixInfo Class Test

= ICMPv6NDOptPrefixInfo - Basic Instantiation
raw(ICMPv6NDOptPrefixInfo()) == b'\x03\x04\x00\xc0\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptPrefixInfo - Instantiation with specific values
raw(ICMPv6NDOptPrefixInfo(len=5, prefixlen=64, L=0, A=0, R=1, res1=1, validlifetime=0x11111111, preferredlifetime=0x22222222, res2=0x33333333, prefix="2001:db8::1")) == b'\x03\x05@!\x11\x11\x11\x11""""3333 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'
Phil's avatar
Phil committed

= ICMPv6NDOptPrefixInfo - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptPrefixInfo(b'\x03\x04\x00\xc0\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type == 3 and a.len == 4 and a.prefixlen == 0 and a.L == 1 and a.A == 1 and a.R == 0 and a.res1 == 0 and a.validlifetime == 0xffffffff and a.preferredlifetime == 0xffffffff and a.res2 == 0 and a.prefix == "::"

= ICMPv6NDOptPrefixInfo - Instantiation with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptPrefixInfo(b'\x03\x05@!\x11\x11\x11\x11""""3333 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
Phil's avatar
Phil committed
a.type == 3 and a.len == 5 and a.prefixlen == 64 and a.L == 0 and a.A == 0 and a.R == 1 and a.res1 == 1 and a.validlifetime == 0x11111111 and a.preferredlifetime == 0x22222222 and a.res2 == 0x33333333 and a.prefix == "2001:db8::1"


Phil's avatar
Phil committed
+ ICMPv6NDOptRedirectedHdr Class Test 

= ICMPv6NDOptRedirectedHdr - Basic Instantiation
~ ICMPv6NDOptRedirectedHdr
raw(ICMPv6NDOptRedirectedHdr()) == b'\x04\x01\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptRedirectedHdr - Instantiation with specific values 
~ ICMPv6NDOptRedirectedHdr
raw(ICMPv6NDOptRedirectedHdr(len=0xff, res="abcdef", pkt="somestringthatisnotanipv6packet")) == b'\x04\xffabcdefsomestringthatisnotanipv'
Phil's avatar
Phil committed

= ICMPv6NDOptRedirectedHdr - Instantiation with simple IPv6 packet (no upper layer)
~ ICMPv6NDOptRedirectedHdr
raw(ICMPv6NDOptRedirectedHdr(pkt=IPv6())) == b'\x04\x06\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'
Phil's avatar
Phil committed

= ICMPv6NDOptRedirectedHdr - Basic Dissection
~ ICMPv6NDOptRedirectedHdr
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptRedirectedHdr(b'\x04\x00\x00\x00')
assert(a.type == 4)
assert(a.len == 0)
gpotter2's avatar
gpotter2 committed
assert(a.res == b"\x00\x00")
Phil's avatar
Phil committed

= ICMPv6NDOptRedirectedHdr - Disssection with specific values
~ ICMPv6NDOptRedirectedHdr
a=ICMPv6NDOptRedirectedHdr(b'\x04\xff\x11\x11\x00\x00\x00\x00somerawingthatisnotanipv6pac')
a.type == 4 and a.len == 255 and a.res == b'\x11\x11\x00\x00\x00\x00' and isinstance(a.pkt, Raw) and a.pkt.load == b"somerawingthatisnotanipv6pac"
Phil's avatar
Phil committed

= ICMPv6NDOptRedirectedHdr - Dissection with cut IPv6 Header
~ ICMPv6NDOptRedirectedHdr
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptRedirectedHdr(b'\x04\x06\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.type == 4 and a.len == 6 and a.res == b"\x00\x00\x00\x00\x00\x00" and isinstance(a.pkt, Raw) and a.pkt.load == b'`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptRedirectedHdr - Complete dissection
~ ICMPv6NDOptRedirectedHdr
gpotter2's avatar
gpotter2 committed
x=ICMPv6NDOptRedirectedHdr(b'\x04\x06\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
y=x.copy()
del(y.len)
x == ICMPv6NDOptRedirectedHdr(raw(y))
Phil's avatar
Phil committed
# Add more tests

Phil's avatar
Phil committed
+ ICMPv6NDOptMTU Class Test 

= ICMPv6NDOptMTU - Basic Instantiation
raw(ICMPv6NDOptMTU()) == b'\x05\x01\x00\x00\x00\x00\x05\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptMTU - Instantiation with specific values
raw(ICMPv6NDOptMTU(len=2, res=0x1111, mtu=1500)) == b'\x05\x02\x11\x11\x00\x00\x05\xdc'
Phil's avatar
Phil committed
 
= ICMPv6NDOptMTU - Basic dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptMTU(b'\x05\x01\x00\x00\x00\x00\x05\x00')
Phil's avatar
Phil committed
a.type == 5 and a.len == 1 and a.res == 0 and a.mtu == 1280

= ICMPv6NDOptMTU - Dissection with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptMTU(b'\x05\x02\x11\x11\x00\x00\x05\xdc')
Phil's avatar
Phil committed
a.type == 5 and a.len == 2 and a.res == 0x1111 and a.mtu == 1500

Phil's avatar
Phil committed
+ ICMPv6NDOptShortcutLimit Class Test (RFC2491)

= ICMPv6NDOptShortcutLimit - Basic Instantiation
raw(ICMPv6NDOptShortcutLimit()) == b'\x06\x01(\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptShortcutLimit - Instantiation with specific values
raw(ICMPv6NDOptShortcutLimit(len=2, shortcutlim=0x11, res1=0xee, res2=0xaaaaaaaa)) == b'\x06\x02\x11\xee\xaa\xaa\xaa\xaa'
Phil's avatar
Phil committed

= ICMPv6NDOptShortcutLimit - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptShortcutLimit(b'\x06\x01(\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type == 6 and a.len == 1 and a.shortcutlim == 40 and a.res1 == 0 and a.res2 == 0

= ICMPv6NDOptShortcutLimit - Dissection with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptShortcutLimit(b'\x06\x02\x11\xee\xaa\xaa\xaa\xaa')
Phil's avatar
Phil committed
a.len==2 and a.shortcutlim==0x11 and a.res1==0xee and a.res2==0xaaaaaaaa


Phil's avatar
Phil committed
+ ICMPv6NDOptAdvInterval Class Test 

= ICMPv6NDOptAdvInterval - Basic Instantiation
raw(ICMPv6NDOptAdvInterval()) == b'\x07\x01\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptAdvInterval - Instantiation with specific values
raw(ICMPv6NDOptAdvInterval(len=2, res=0x1111, advint=0xffffffff)) == b'\x07\x02\x11\x11\xff\xff\xff\xff'
Phil's avatar
Phil committed
 
= ICMPv6NDOptAdvInterval - Basic dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptAdvInterval(b'\x07\x01\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type == 7 and a.len == 1 and a.res == 0 and a.advint == 0

= ICMPv6NDOptAdvInterval - Dissection with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptAdvInterval(b'\x07\x02\x11\x11\xff\xff\xff\xff')
Phil's avatar
Phil committed
a.type == 7 and a.len == 2 and a.res == 0x1111 and a.advint == 0xffffffff

Phil's avatar
Phil committed
+ ICMPv6NDOptHAInfo Class Test

= ICMPv6NDOptHAInfo - Basic Instantiation
raw(ICMPv6NDOptHAInfo()) == b'\x08\x01\x00\x00\x00\x00\x00\x01'
Phil's avatar
Phil committed

= ICMPv6NDOptHAInfo - Instantiation with specific values
raw(ICMPv6NDOptHAInfo(len=2, res=0x1111, pref=0x2222, lifetime=0x3333)) == b'\x08\x02\x11\x11""33'
Phil's avatar
Phil committed
 
= ICMPv6NDOptHAInfo - Basic dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptHAInfo(b'\x08\x01\x00\x00\x00\x00\x00\x01')
Phil's avatar
Phil committed
a.type == 8 and a.len == 1 and a.res == 0 and a.pref == 0 and a.lifetime == 1

= ICMPv6NDOptHAInfo - Dissection with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptHAInfo(b'\x08\x02\x11\x11""33')
Phil's avatar
Phil committed
a.type == 8 and a.len == 2 and a.res == 0x1111 and a.pref == 0x2222 and a.lifetime == 0x3333

Phil's avatar
Phil committed
+ ICMPv6NDOptSrcAddrList Class Test 

= ICMPv6NDOptSrcAddrList - Basic Instantiation
raw(ICMPv6NDOptSrcAddrList()) == b'\t\x01\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptSrcAddrList - Instantiation with specific values (auto len)
raw(ICMPv6NDOptSrcAddrList(res="BBBBBB", addrlist=["ffff::ffff", "1111::1111"])) == b'\t\x05BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11'
Phil's avatar
Phil committed

= ICMPv6NDOptSrcAddrList - Instantiation with specific values 
raw(ICMPv6NDOptSrcAddrList(len=3, res="BBBBBB", addrlist=["ffff::ffff", "1111::1111"])) == b'\t\x03BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11'
Phil's avatar
Phil committed

= ICMPv6NDOptSrcAddrList - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptSrcAddrList(b'\t\x01\x00\x00\x00\x00\x00\x00')
a.type == 9 and a.len == 1 and a.res == b'\x00\x00\x00\x00\x00\x00' and not a.addrlist
Phil's avatar
Phil committed

= ICMPv6NDOptSrcAddrList - Dissection with specific values (auto len)
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptSrcAddrList(b'\t\x05BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11')
a.type == 9 and a.len == 5 and a.res == b'BBBBBB' and len(a.addrlist) == 2 and a.addrlist[0] == "ffff::ffff" and a.addrlist[1] == "1111::1111"
Phil's avatar
Phil committed

= ICMPv6NDOptSrcAddrList - Dissection with specific values 
conf.debug_dissector = False
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptSrcAddrList(b'\t\x03BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11')
conf.debug_dissector = True
a.type == 9 and a.len == 3 and a.res == b'BBBBBB' and len(a.addrlist) == 1 and a.addrlist[0] == "ffff::ffff" and isinstance(a.payload, Raw) and a.payload.load == b'\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11'
Phil's avatar
Phil committed
+ ICMPv6NDOptTgtAddrList Class Test 

= ICMPv6NDOptTgtAddrList - Basic Instantiation
raw(ICMPv6NDOptTgtAddrList()) == b'\n\x01\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptTgtAddrList - Instantiation with specific values (auto len)
raw(ICMPv6NDOptTgtAddrList(res="BBBBBB", addrlist=["ffff::ffff", "1111::1111"])) == b'\n\x05BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11'
Phil's avatar
Phil committed

= ICMPv6NDOptTgtAddrList - Instantiation with specific values 
raw(ICMPv6NDOptTgtAddrList(len=3, res="BBBBBB", addrlist=["ffff::ffff", "1111::1111"])) == b'\n\x03BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11'
Phil's avatar
Phil committed

= ICMPv6NDOptTgtAddrList - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptTgtAddrList(b'\n\x01\x00\x00\x00\x00\x00\x00')
a.type == 10 and a.len == 1 and a.res == b'\x00\x00\x00\x00\x00\x00' and not a.addrlist
Phil's avatar
Phil committed

= ICMPv6NDOptTgtAddrList - Dissection with specific values (auto len)
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptTgtAddrList(b'\n\x05BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11')
a.type == 10 and a.len == 5 and a.res == b'BBBBBB' and len(a.addrlist) == 2 and a.addrlist[0] == "ffff::ffff" and a.addrlist[1] == "1111::1111"
Phil's avatar
Phil committed

= ICMPv6NDOptTgtAddrList - Instantiation with specific values 
conf.debug_dissector = False
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptTgtAddrList(b'\n\x03BBBBBB\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11')
conf.debug_dissector = True
a.type == 10 and a.len == 3 and a.res == b'BBBBBB' and len(a.addrlist) == 1 and a.addrlist[0] == "ffff::ffff" and isinstance(a.payload, Raw) and a.payload.load == b'\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11'
Phil's avatar
Phil committed
+ ICMPv6NDOptIPAddr Class Test (RFC 4068)

= ICMPv6NDOptIPAddr - Basic Instantiation 
raw(ICMPv6NDOptIPAddr()) == b'\x11\x03\x01@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptIPAddr - Instantiation with specific values
raw(ICMPv6NDOptIPAddr(len=5, optcode=0xff, plen=40, res=0xeeeeeeee, addr="ffff::1111")) == b'\x11\x05\xff(\xee\xee\xee\xee\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11'
Phil's avatar
Phil committed

= ICMPv6NDOptIPAddr - Basic Dissection 
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptIPAddr(b'\x11\x03\x01@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type == 17 and a.len == 3 and a.optcode == 1 and a.plen == 64 and a.res == 0 and a.addr == "::"

= ICMPv6NDOptIPAddr - Dissection with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptIPAddr(b'\x11\x05\xff(\xee\xee\xee\xee\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11')
Phil's avatar
Phil committed
a.type == 17 and a.len == 5 and a.optcode == 0xff and a.plen == 40 and a.res == 0xeeeeeeee and a.addr == "ffff::1111"


Phil's avatar
Phil committed
+ ICMPv6NDOptNewRtrPrefix Class Test (RFC 4068)

= ICMPv6NDOptNewRtrPrefix - Basic Instantiation 
raw(ICMPv6NDOptNewRtrPrefix()) == b'\x12\x03\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptNewRtrPrefix - Instantiation with specific values
raw(ICMPv6NDOptNewRtrPrefix(len=5, optcode=0xff, plen=40, res=0xeeeeeeee, prefix="ffff::1111")) == b'\x12\x05\xff(\xee\xee\xee\xee\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11'
Phil's avatar
Phil committed

= ICMPv6NDOptNewRtrPrefix - Basic Dissection 
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptNewRtrPrefix(b'\x12\x03\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type == 18 and a.len == 3 and a.optcode == 0 and a.plen == 64 and a.res == 0 and a.prefix == "::"

= ICMPv6NDOptNewRtrPrefix - Dissection with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptNewRtrPrefix(b'\x12\x05\xff(\xee\xee\xee\xee\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11')
Phil's avatar
Phil committed
a.type == 18 and a.len == 5 and a.optcode == 0xff and a.plen == 40 and a.res == 0xeeeeeeee and a.prefix == "ffff::1111"

Phil's avatar
Phil committed
+ ICMPv6NDOptLLA Class Test (RFC 4068)

= ICMPv6NDOptLLA - Basic Instantiation 
raw(ICMPv6NDOptLLA()) == b'\x13\x01\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptLLA - Instantiation with specific values
raw(ICMPv6NDOptLLA(len=2, optcode=3, lla="ff:11:ff:11:ff:11")) == b'\x13\x02\x03\xff\x11\xff\x11\xff\x11'
Phil's avatar
Phil committed

= ICMPv6NDOptLLA - Basic Dissection 
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptLLA(b'\x13\x01\x00\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type == 19 and a.len == 1 and a.optcode == 0 and a.lla == "00:00:00:00:00:00"

= ICMPv6NDOptLLA - Dissection with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptLLA(b'\x13\x02\x03\xff\x11\xff\x11\xff\x11')
Phil's avatar
Phil committed
a.type == 19 and a.len == 2 and a.optcode == 3 and a.lla == "ff:11:ff:11:ff:11"


Phil's avatar
Phil committed
+ ICMPv6NDOptRouteInfo Class Test

= ICMPv6NDOptRouteInfo - Basic Instantiation
raw(ICMPv6NDOptRouteInfo()) == b'\x18\x01\x00\x00\xff\xff\xff\xff'
Phil's avatar
Phil committed

= ICMPv6NDOptRouteInfo - Instantiation with forced prefix but no length
raw(ICMPv6NDOptRouteInfo(prefix="2001:db8:1:1:1:1:1:1")) == b'\x18\x03\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01'
Phil's avatar
Phil committed

= ICMPv6NDOptRouteInfo - Instantiation with forced length values (1/4)
raw(ICMPv6NDOptRouteInfo(len=1, prefix="2001:db8:1:1:1:1:1:1")) == b'\x18\x01\x00\x00\xff\xff\xff\xff'
Phil's avatar
Phil committed

= ICMPv6NDOptRouteInfo - Instantiation with forced length values (2/4)
raw(ICMPv6NDOptRouteInfo(len=2, prefix="2001:db8:1:1:1:1:1:1")) == b'\x18\x02\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x01\x00\x01'
Phil's avatar
Phil committed

= ICMPv6NDOptRouteInfo - Instantiation with forced length values (3/4)
raw(ICMPv6NDOptRouteInfo(len=3, prefix="2001:db8:1:1:1:1:1:1")) == b'\x18\x03\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01'
Phil's avatar
Phil committed

= ICMPv6NDOptRouteInfo - Instantiation with forced length values (4/4)
raw(ICMPv6NDOptRouteInfo(len=4, prefix="2001:db8:1:1:1:1:1:1")) == b'\x18\x04\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptRouteInfo - Instantiation with specific values 
raw(ICMPv6NDOptRouteInfo(len=6, plen=0x11, res1=1, prf=3, res2=1, rtlifetime=0x22222222, prefix="2001:db8::1")) == b'\x18\x06\x119"""" \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptRouteInfo - Basic dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptRouteInfo(b'\x18\x03\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type == 24 and a.len == 3 and a.plen == 0 and a.res1 == 0 and a.prf == 0 and a.res2 == 0 and a.rtlifetime == 0xffffffff and a. prefix == "::"

= ICMPv6NDOptRouteInfo - Dissection with specific values 
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptRouteInfo(b'\x18\x04\x119"""" \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
Phil's avatar
Phil committed
a.plen == 0x11 and a.res1 == 1 and a.prf == 3 and a.res2 == 1 and a.rtlifetime == 0x22222222 and a.prefix == "2001:db8::1" 

Phil's avatar
Phil committed
+ ICMPv6NDOptMAP Class Test

= ICMPv6NDOptMAP - Basic Instantiation
raw(ICMPv6NDOptMAP()) == b'\x17\x03\x1f\x80\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptMAP - Instantiation with specific values
raw(ICMPv6NDOptMAP(len=5, dist=3, pref=10, R=0, res=1, validlifetime=0x11111111, addr="ffff::1111")) == b'\x17\x05:\x01\x11\x11\x11\x11\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11'
Phil's avatar
Phil committed

= ICMPv6NDOptMAP - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptMAP(b'\x17\x03\x1f\x80\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type==23 and a.len==3 and a.dist==1 and a.pref==15 and a.R==1 and a.res==0 and a.validlifetime==0xffffffff and a.addr=="::"

= ICMPv6NDOptMAP - Dissection with specific values
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptMAP(b'\x17\x05:\x01\x11\x11\x11\x11\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11')
Phil's avatar
Phil committed
a.type==23 and a.len==5 and a.dist==3 and a.pref==10 and a.R==0 and a.res==1 and a.validlifetime==0x11111111 and a.addr=="ffff::1111"

Phil's avatar
Phil committed
+ ICMPv6NDOptRDNSS Class Test

= ICMPv6NDOptRDNSS - Basic Instantiation
raw(ICMPv6NDOptRDNSS()) == b'\x19\x01\x00\x00\xff\xff\xff\xff'
Phil's avatar
Phil committed

= ICMPv6NDOptRDNSS - Basic instantiation with 1 DNS address
raw(ICMPv6NDOptRDNSS(dns=["2001:db8::1"])) == b'\x19\x03\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'
Phil's avatar
Phil committed

= ICMPv6NDOptRDNSS - Basic instantiation with 2 DNS addresses
raw(ICMPv6NDOptRDNSS(dns=["2001:db8::1", "2001:db8::2"])) == b'\x19\x05\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02'
Phil's avatar
Phil committed

= ICMPv6NDOptRDNSS - Instantiation with specific values
raw(ICMPv6NDOptRDNSS(len=43, res=0xaaee, lifetime=0x11111111, dns=["2001:db8::2"])) == b'\x19+\xaa\xee\x11\x11\x11\x11 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02'
Phil's avatar
Phil committed

= ICMPv6NDOptRDNSS - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptRDNSS(b'\x19\x01\x00\x00\xff\xff\xff\xff')
Phil's avatar
Phil committed
a.type==25 and a.len==1 and a.res == 0 and a.dns==[]

= ICMPv6NDOptRDNSS - Dissection (with 1 DNS address)
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptRDNSS(b'\x19\x03\x00\x00\xff\xff\xff\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
Phil's avatar
Phil committed
a.type==25 and a.len==3 and a.res ==0 and len(a.dns) == 1 and a.dns[0] == "2001:db8::1"

= ICMPv6NDOptRDNSS - Dissection (with 2 DNS addresses)
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptRDNSS(b'\x19\x05\xaa\xee\xff\xff\xff\xff \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02')
Phil's avatar
Phil committed
a.type==25 and a.len==5 and a.res == 0xaaee and len(a.dns) == 2 and a.dns[0] == "2001:db8::1" and a.dns[1] == "2001:db8::2"

+ ICMPv6NDOptDNSSL Class Test

= ICMPv6NDOptDNSSL - Basic Instantiation
raw(ICMPv6NDOptDNSSL()) == b'\x1f\x01\x00\x00\xff\xff\xff\xff'

= ICMPv6NDOptDNSSL - Instantiation with 1 search domain, as seen in the wild
raw(ICMPv6NDOptDNSSL(lifetime=60, searchlist=["home."])) == b'\x1f\x02\x00\x00\x00\x00\x00<\x04home\x00\x00\x00'

= ICMPv6NDOptDNSSL - Basic instantiation with 2 search domains
raw(ICMPv6NDOptDNSSL(searchlist=["home.", "office."])) == b'\x1f\x03\x00\x00\xff\xff\xff\xff\x04home\x00\x06office\x00\x00\x00'

= ICMPv6NDOptDNSSL - Basic instantiation with 3 search domains
raw(ICMPv6NDOptDNSSL(searchlist=["home.", "office.", "here.there."])) == b'\x1f\x05\x00\x00\xff\xff\xff\xff\x04home\x00\x06office\x00\x04here\x05there\x00\x00\x00\x00\x00\x00\x00'

= ICMPv6NDOptDNSSL - Basic Dissection
gpotter2's avatar
gpotter2 committed
p = ICMPv6NDOptDNSSL(b'\x1f\x01\x00\x00\xff\xff\xff\xff')
p.type == 31 and p.len == 1 and p.res == 0 and p.searchlist == []

= ICMPv6NDOptDNSSL - Basic Dissection with specific values
gpotter2's avatar
gpotter2 committed
p = ICMPv6NDOptDNSSL(b'\x1f\x02\x00\x00\x00\x00\x00<\x04home\x00\x00\x00')
p.type == 31 and p.len == 2 and p.res == 0 and p.lifetime == 60 and p.searchlist == ["home."]

Phil's avatar
Phil committed
+ ICMPv6NDOptEFA Class Test

= ICMPv6NDOptEFA - Basic Instantiation
raw(ICMPv6NDOptEFA()) == b'\x1a\x01\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NDOptEFA - Basic Dissection
gpotter2's avatar
gpotter2 committed
a=ICMPv6NDOptEFA(b'\x1a\x01\x00\x00\x00\x00\x00\x00')
Phil's avatar
Phil committed
a.type==26 and a.len==1 and a.res == 0

Phil's avatar
Phil committed
+ Test Node Information Query - ICMPv6NIQueryNOOP

= ICMPv6NIQueryNOOP - Basic Instantiation
raw(ICMPv6NIQueryNOOP(nonce=b"\x00"*8)) == b'\x8b\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NIQueryNOOP - Basic Dissection
gpotter2's avatar
gpotter2 committed
a = ICMPv6NIQueryNOOP(b'\x8b\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.type == 139 and a.code == 1 and a.cksum == 0 and a.qtype == 0 and a.unused == 0 and a.flags == 0 and a.nonce == b"\x00"*8 and a.data == b""
Phil's avatar
Phil committed
+ Test Node Information Query - ICMPv6NIQueryName

= ICMPv6NIQueryName - single label DNS name (internal)
a=ICMPv6NIQueryName(data="abricot").getfieldval("data")
gpotter2's avatar
gpotter2 committed
type(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x07abricot\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NIQueryName - single label DNS name
ICMPv6NIQueryName(data="abricot").data == "abricot"

= ICMPv6NIQueryName - fqdn (internal)
a=ICMPv6NIQueryName(data="n.d.org").getfieldval("data")
gpotter2's avatar
gpotter2 committed
type(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x01n\x01d\x03org\x00'
Phil's avatar
Phil committed

= ICMPv6NIQueryName - fqdn
ICMPv6NIQueryName(data="n.d.org").data == "n.d.org"

= ICMPv6NIQueryName - IPv6 address (internal)
a=ICMPv6NIQueryName(data="2001:db8::1").getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 0 and a[1] == '2001:db8::1'

= ICMPv6NIQueryName - IPv6 address 
ICMPv6NIQueryName(data="2001:db8::1").data == "2001:db8::1"

= ICMPv6NIQueryName - IPv4 address (internal)
a=ICMPv6NIQueryName(data="169.254.253.252").getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 2 and a[1] == '169.254.253.252'

= ICMPv6NIQueryName - IPv4 address
ICMPv6NIQueryName(data="169.254.253.252").data == '169.254.253.252'

= ICMPv6NIQueryName - build & dissection
s = raw(IPv6()/ICMPv6NIQueryName(data="n.d.org"))
p = IPv6(s)
ICMPv6NIQueryName in p and p[ICMPv6NIQueryName].data == "n.d.org"

Phil's avatar
Phil committed

Phil's avatar
Phil committed
+ Test Node Information Query - ICMPv6NIQueryIPv6

= ICMPv6NIQueryIPv6 - single label DNS name (internal)
a = ICMPv6NIQueryIPv6(data="abricot")
ls(a)
a = a.getfieldval("data")
gpotter2's avatar
gpotter2 committed
type(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x07abricot\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NIQueryIPv6 - single label DNS name
ICMPv6NIQueryIPv6(data="abricot").data == "abricot"

= ICMPv6NIQueryIPv6 - fqdn (internal)
a=ICMPv6NIQueryIPv6(data="n.d.org").getfieldval("data")
gpotter2's avatar
gpotter2 committed
type(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x01n\x01d\x03org\x00'
Phil's avatar
Phil committed

= ICMPv6NIQueryIPv6 - fqdn
ICMPv6NIQueryIPv6(data="n.d.org").data == "n.d.org"

= ICMPv6NIQueryIPv6 - IPv6 address (internal)
a=ICMPv6NIQueryIPv6(data="2001:db8::1").getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 0 and a[1] == '2001:db8::1'

= ICMPv6NIQueryIPv6 - IPv6 address 
ICMPv6NIQueryIPv6(data="2001:db8::1").data == "2001:db8::1"

= ICMPv6NIQueryIPv6 - IPv4 address (internal)
a=ICMPv6NIQueryIPv6(data="169.254.253.252").getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 2 and a[1] == '169.254.253.252'

= ICMPv6NIQueryIPv6 - IPv4 address
ICMPv6NIQueryIPv6(data="169.254.253.252").data == '169.254.253.252'


Phil's avatar
Phil committed
+ Test Node Information Query - ICMPv6NIQueryIPv4

= ICMPv6NIQueryIPv4 - single label DNS name (internal)
a=ICMPv6NIQueryIPv4(data="abricot").getfieldval("data")
gpotter2's avatar
gpotter2 committed
type(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x07abricot\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NIQueryIPv4 - single label DNS name
ICMPv6NIQueryIPv4(data="abricot").data == "abricot"

= ICMPv6NIQueryIPv4 - fqdn (internal)
a=ICMPv6NIQueryIPv4(data="n.d.org").getfieldval("data")
gpotter2's avatar
gpotter2 committed
type(a) is tuple and len(a) == 2 and a[0] == 1 and a[1] == b'\x01n\x01d\x03org\x00'
Phil's avatar
Phil committed

= ICMPv6NIQueryIPv4 - fqdn
ICMPv6NIQueryIPv4(data="n.d.org").data == "n.d.org"

= ICMPv6NIQueryIPv4 - IPv6 address (internal)
a=ICMPv6NIQueryIPv4(data="2001:db8::1").getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 0 and a[1] == '2001:db8::1'

= ICMPv6NIQueryIPv4 - IPv6 address 
ICMPv6NIQueryIPv4(data="2001:db8::1").data == "2001:db8::1"

= ICMPv6NIQueryIPv4 - IPv4 address (internal)
a=ICMPv6NIQueryIPv4(data="169.254.253.252").getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 2 and a[1] == '169.254.253.252'

= ICMPv6NIQueryIPv4 - IPv4 address
ICMPv6NIQueryIPv4(data="169.254.253.252").data == '169.254.253.252'

Phil's avatar
Phil committed
+ Test Node Information Query - Flags tests

= ICMPv6NIQuery* - flags handling (Test 1)
t = ICMPv6NIQueryIPv6(flags="T")
a = ICMPv6NIQueryIPv6(flags="A")
c = ICMPv6NIQueryIPv6(flags="C")
l = ICMPv6NIQueryIPv6(flags="L")
s = ICMPv6NIQueryIPv6(flags="S")
g = ICMPv6NIQueryIPv6(flags="G")
allflags = ICMPv6NIQueryIPv6(flags="TALCLSG")
t.flags == 1 and a.flags == 2 and c.flags == 4 and l.flags == 8 and s.flags == 16 and g.flags == 32 and allflags.flags == 63
Phil's avatar
Phil committed


= ICMPv6NIQuery* - flags handling (Test 2)
t = raw(ICMPv6NIQueryNOOP(flags="T", nonce="A"*8))[6:8]
a = raw(ICMPv6NIQueryNOOP(flags="A", nonce="A"*8))[6:8]
c = raw(ICMPv6NIQueryNOOP(flags="C", nonce="A"*8))[6:8]
l = raw(ICMPv6NIQueryNOOP(flags="L", nonce="A"*8))[6:8]
s = raw(ICMPv6NIQueryNOOP(flags="S", nonce="A"*8))[6:8]
g = raw(ICMPv6NIQueryNOOP(flags="G", nonce="A"*8))[6:8]
allflags = raw(ICMPv6NIQueryNOOP(flags="TALCLSG", nonce="A"*8))[6:8]
gpotter2's avatar
gpotter2 committed
t == b'\x00\x01' and a == b'\x00\x02' and c == b'\x00\x04' and l == b'\x00\x08' and s == b'\x00\x10' and g == b'\x00\x20' and allflags == b'\x00\x3F'
Phil's avatar
Phil committed


= ICMPv6NIReply* - flags handling (Test 1)
t = ICMPv6NIReplyIPv6(flags="T")
a = ICMPv6NIReplyIPv6(flags="A")
c = ICMPv6NIReplyIPv6(flags="C")
l = ICMPv6NIReplyIPv6(flags="L")
s = ICMPv6NIReplyIPv6(flags="S")
g = ICMPv6NIReplyIPv6(flags="G")
allflags = ICMPv6NIReplyIPv6(flags="TALCLSG")
t.flags == 1 and a.flags == 2 and c.flags == 4 and l.flags == 8 and s.flags == 16 and g.flags == 32 and allflags.flags == 63
Phil's avatar
Phil committed


= ICMPv6NIReply* - flags handling (Test 2)
t = raw(ICMPv6NIReplyNOOP(flags="T", nonce="A"*8))[6:8]
a = raw(ICMPv6NIReplyNOOP(flags="A", nonce="A"*8))[6:8]
c = raw(ICMPv6NIReplyNOOP(flags="C", nonce="A"*8))[6:8]
l = raw(ICMPv6NIReplyNOOP(flags="L", nonce="A"*8))[6:8]
s = raw(ICMPv6NIReplyNOOP(flags="S", nonce="A"*8))[6:8]
g = raw(ICMPv6NIReplyNOOP(flags="G", nonce="A"*8))[6:8]
allflags = raw(ICMPv6NIReplyNOOP(flags="TALCLSG", nonce="A"*8))[6:8]
gpotter2's avatar
gpotter2 committed
t == b'\x00\x01' and a == b'\x00\x02' and c == b'\x00\x04' and l == b'\x00\x08' and s == b'\x00\x10' and g == b'\x00\x20' and allflags == b'\x00\x3F'
Phil's avatar
Phil committed


= ICMPv6NIQuery* - Flags Default values
a = ICMPv6NIQueryNOOP()
b = ICMPv6NIQueryName()
c = ICMPv6NIQueryIPv4()
d = ICMPv6NIQueryIPv6()
a.flags == 0 and b.flags == 0 and c.flags == 0 and d.flags == 62

= ICMPv6NIReply* - Flags Default values
a = ICMPv6NIReplyIPv6()
b = ICMPv6NIReplyName()
c = ICMPv6NIReplyIPv6()
d = ICMPv6NIReplyIPv4()
e = ICMPv6NIReplyRefuse()
f = ICMPv6NIReplyUnknown()
a.flags == 0 and b.flags == 0 and c.flags == 0 and d.flags == 0 and e.flags == 0 and f.flags == 0



# Nonces 
# hashret and answers
# payload guess
# automatic destination address computation when integrated in scapy6
# at least computeNIGroupAddr


Phil's avatar
Phil committed
+ Test Node Information Query - Dispatching

= ICMPv6NIQueryIPv6 - dispatch with nothing in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv6())
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryIPv6)

= ICMPv6NIQueryIPv6 - dispatch with IPv6 address in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv6(data="2001::db8::1"))
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryIPv6)

= ICMPv6NIQueryIPv6 - dispatch with IPv4 address in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv6(data="192.168.0.1"))
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryIPv6)

= ICMPv6NIQueryIPv6 - dispatch with name in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv6(data="alfred"))
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryIPv6)

= ICMPv6NIQueryName - dispatch with nothing in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryName())
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryName)

= ICMPv6NIQueryName - dispatch with IPv6 address in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryName(data="2001:db8::1"))
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryName)

= ICMPv6NIQueryName - dispatch with IPv4 address in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryName(data="192.168.0.1"))
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryName)

= ICMPv6NIQueryName - dispatch with name in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryName(data="alfred"))
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryName)

= ICMPv6NIQueryIPv4 - dispatch with nothing in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv4())
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryIPv4)

= ICMPv6NIQueryIPv4 - dispatch with IPv6 address in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv4(data="2001:db8::1"))
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryIPv4)

= ICMPv6NIQueryIPv4 - dispatch with IPv6 address in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv4(data="192.168.0.1"))
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryIPv4)

= ICMPv6NIQueryIPv4 - dispatch with name in data
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIQueryIPv4(data="alfred"))
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIQueryIPv4)

= ICMPv6NIReplyName - dispatch
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIReplyName())
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIReplyName)

= ICMPv6NIReplyIPv6 - dispatch
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIReplyIPv6())
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIReplyIPv6)

= ICMPv6NIReplyIPv4 - dispatch
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIReplyIPv4())
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIReplyIPv4)

= ICMPv6NIReplyRefuse - dispatch
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIReplyRefuse())
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIReplyRefuse)

= ICMPv6NIReplyUnknown - dispatch
s = raw(IPv6(src="2001:db8::1", dst="2001:db8::2")/ICMPv6NIReplyUnknown())
Phil's avatar
Phil committed
p = IPv6(s)
isinstance(p.payload, ICMPv6NIReplyUnknown)


Phil's avatar
Phil committed
+ Test Node Information Query - ICMPv6NIReplyNOOP

= ICMPv6NIReplyNOOP - single DNS name without hint => understood as string (internal)
a=ICMPv6NIReplyNOOP(data="abricot").getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 0 and type(a[1]) is str and a[1] == "abricot"

= ICMPv6NIReplyNOOP - single DNS name without hint => understood as string
ICMPv6NIReplyNOOP(data="abricot").data == "abricot"

= ICMPv6NIReplyNOOP - fqdn without hint => understood as string (internal)
a=ICMPv6NIReplyNOOP(data="n.d.tld").getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 0 and type(a[1]) is str and a[1] == "n.d.tld"

= ICMPv6NIReplyNOOP - fqdn without hint => understood as string 
ICMPv6NIReplyNOOP(data="n.d.tld").data == "n.d.tld"

= ICMPv6NIReplyNOOP - IPv6 address without hint => understood as string (internal)
a=ICMPv6NIReplyNOOP(data="2001:0db8::1").getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 0 and type(a[1]) is str and a[1] == "2001:0db8::1"

= ICMPv6NIReplyNOOP - IPv6 address without hint => understood as string
ICMPv6NIReplyNOOP(data="2001:0db8::1").data == "2001:0db8::1"

= ICMPv6NIReplyNOOP - IPv4 address without hint => understood as string (internal)
a=ICMPv6NIReplyNOOP(data="169.254.253.010").getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 0 and type(a[1]) is str and a[1] == "169.254.253.010"

= ICMPv6NIReplyNOOP - IPv4 address without hint => understood as string
ICMPv6NIReplyNOOP(data="169.254.253.010").data == "169.254.253.010"


Phil's avatar
Phil committed
+ Test Node Information Query - ICMPv6NIReplyName

= ICMPv6NIReplyName - single label DNS name as a rawing (without ttl) (internal)
Phil's avatar
Phil committed
a=ICMPv6NIReplyName(data="abricot").getfieldval("data")
gpotter2's avatar
gpotter2 committed
type(a) is tuple and len(a) == 2 and a[0] == 2 and type(a[1]) is list and len(a[1]) == 2 and a[1][0] == 0 and a[1][1] == b'\x07abricot\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NIReplyName - single label DNS name as a rawing (without ttl)
Phil's avatar
Phil committed
ICMPv6NIReplyName(data="abricot").data == [0, "abricot"]

= ICMPv6NIReplyName - fqdn name as a rawing (without ttl) (internal)
Phil's avatar
Phil committed
a=ICMPv6NIReplyName(data="n.d.tld").getfieldval("data")
gpotter2's avatar
gpotter2 committed
type(a) is tuple and len(a) == 2 and a[0] == 2 and type(a[1]) is list and len(a[1]) == 2 and a[1][0] == 0 and a[1][1] == b'\x01n\x01d\x03tld\x00'
Phil's avatar
Phil committed

= ICMPv6NIReplyName - fqdn name as a rawing (without ttl)
Phil's avatar
Phil committed
ICMPv6NIReplyName(data="n.d.tld").data == [0, 'n.d.tld']

= ICMPv6NIReplyName - list of 2 single label DNS names (without ttl) (internal)
a=ICMPv6NIReplyName(data=["abricot", "poire"]).getfieldval("data")
gpotter2's avatar
gpotter2 committed
type(a) is tuple and len(a) == 2 and a[0] == 2 and type(a[1]) is list and len(a[1]) == 2 and a[1][0] == 0 and a[1][1] == b'\x07abricot\x00\x00\x05poire\x00\x00'
Phil's avatar
Phil committed

= ICMPv6NIReplyName - list of 2 single label DNS names (without ttl)
ICMPv6NIReplyName(data=["abricot", "poire"]).data == [0, "abricot", "poire"]

= ICMPv6NIReplyName - [ttl, single-label, single-label, fqdn] (internal)
a=ICMPv6NIReplyName(data=[42, "abricot", "poire", "n.d.tld"]).getfieldval("data")
gpotter2's avatar
gpotter2 committed
type(a) is tuple and len(a) == 2 and a[0] == 2 and type(a[1]) is list and len(a[1]) == 2 and a[1][0] == 42 and a[1][1] == b'\x07abricot\x00\x00\x05poire\x00\x00\x01n\x01d\x03tld\x00'
Phil's avatar
Phil committed

= ICMPv6NIReplyName - [ttl, single-label, single-label, fqdn]
ICMPv6NIReplyName(data=[42, "abricot", "poire", "n.d.tld"]).data == [42, "abricot", "poire", "n.d.tld"]


Phil's avatar
Phil committed
+ Test Node Information Query - ICMPv6NIReplyIPv6

= ICMPv6NIReplyIPv6 - one IPv6 address without TTL (internal)
a=ICMPv6NIReplyIPv6(data="2001:db8::1").getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 3 and type(a[1]) is list and len(a[1]) == 1 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "2001:db8::1" 

= ICMPv6NIReplyIPv6 - one IPv6 address without TTL
ICMPv6NIReplyIPv6(data="2001:db8::1").data == [(0, '2001:db8::1')]

= ICMPv6NIReplyIPv6 - one IPv6 address without TTL (as a list)  (internal)
a=ICMPv6NIReplyIPv6(data=["2001:db8::1"]).getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 3 and type(a[1]) is list and len(a[1]) == 1 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "2001:db8::1" 

= ICMPv6NIReplyIPv6 - one IPv6 address without TTL (as a list) 
ICMPv6NIReplyIPv6(data=["2001:db8::1"]).data == [(0, '2001:db8::1')]

= ICMPv6NIReplyIPv6 - one IPv6 address with TTL  (internal)
a=ICMPv6NIReplyIPv6(data=[(0, "2001:db8::1")]).getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 3 and type(a[1]) is list and len(a[1]) == 1 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "2001:db8::1" 

= ICMPv6NIReplyIPv6 - one IPv6 address with TTL
ICMPv6NIReplyIPv6(data=[(0, "2001:db8::1")]).data == [(0, '2001:db8::1')]

= ICMPv6NIReplyIPv6 - two IPv6 addresses as a list of rawings (without TTL) (internal)
Phil's avatar
Phil committed
a=ICMPv6NIReplyIPv6(data=["2001:db8::1", "2001:db8::2"]).getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 3 and type(a[1]) is list and len(a[1]) == 2 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 0 and a[1][0][1] == "2001:db8::1" and len(a[1][1]) == 2 and a[1][1][0] == 0 and a[1][1][1] == "2001:db8::2" 

= ICMPv6NIReplyIPv6 - two IPv6 addresses as a list of rawings (without TTL)
Phil's avatar
Phil committed
ICMPv6NIReplyIPv6(data=["2001:db8::1", "2001:db8::2"]).data == [(0, '2001:db8::1'), (0, '2001:db8::2')]

= ICMPv6NIReplyIPv6 - two IPv6 addresses as a list (first with ttl, second without) (internal)
a=ICMPv6NIReplyIPv6(data=[(42, "2001:db8::1"), "2001:db8::2"]).getfieldval("data")
type(a) is tuple and len(a) == 2 and a[0] == 3 and type(a[1]) is list and len(a[1]) == 2 and type(a[1][0]) is tuple and len(a[1][0]) == 2 and a[1][0][0] == 42 and a[1][0][1] == "2001:db8::1" and len(a[1][1]) == 2 and a[1][1][0] == 0 and a[1][1][1] == "2001:db8::2" 

= ICMPv6NIReplyIPv6 - two IPv6 addresses as a list (first with ttl, second without)
ICMPv6NIReplyIPv6(data=[(42, "2001:db8::1"), "2001:db8::2"]).data == [(42, "2001:db8::1"), (0, "2001:db8::2")]