% DHCPv6 regression tests for Scapy

# More information at http://www.secdev.org/projects/UTscapy/

#####################################################################
#####################################################################
##########################     DHCPv6      ##########################
#####################################################################
#####################################################################


############
############
+ Test DHCP6 DUID_LLT

= DUID_LLT basic instantiation
a=DUID_LLT() 

= DUID_LLT basic build
raw(DUID_LLT()) == b'\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

= DUID_LLT build with specific values
raw(DUID_LLT(lladdr="ff:ff:ff:ff:ff:ff", timeval=0x11111111, hwtype=0x2222)) == b'\x00\x01""\x11\x11\x11\x11\xff\xff\xff\xff\xff\xff'

= DUID_LLT basic dissection 
a=DUID_LLT(raw(DUID_LLT()))
a.type == 1 and a.hwtype == 1 and a.timeval == 0 and a.lladdr == "00:00:00:00:00:00"

= DUID_LLT dissection with specific values
a=DUID_LLT(b'\x00\x01""\x11\x11\x11\x11\xff\xff\xff\xff\xff\xff') 
a.type == 1 and a.hwtype == 0x2222 and a.timeval == 0x11111111 and a.lladdr == "ff:ff:ff:ff:ff:ff"


############
############
+ Test DHCP6 DUID_EN

= DUID_EN basic instantiation
a=DUID_EN() 

= DUID_EN basic build
raw(DUID_EN()) == b'\x00\x02\x00\x00\x017'

= DUID_EN build with specific values
raw(DUID_EN(enterprisenum=0x11111111, id="iamastring")) == b'\x00\x02\x11\x11\x11\x11iamastring'

= DUID_EN basic dissection 
a=DUID_EN(b'\x00\x02\x00\x00\x017')
a.type == 2 and a.enterprisenum == 311 

= DUID_EN dissection with specific values 
a=DUID_EN(b'\x00\x02\x11\x11\x11\x11iamarawing')
a.type == 2 and a.enterprisenum == 0x11111111 and a.id == b"iamarawing"


############
############
+ Test DHCP6 DUID_LL

= DUID_LL basic instantiation
a=DUID_LL() 

= DUID_LL basic build
raw(DUID_LL()) == b'\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00'

= DUID_LL build with specific values
raw(DUID_LL(hwtype=1, lladdr="ff:ff:ff:ff:ff:ff")) == b'\x00\x03\x00\x01\xff\xff\xff\xff\xff\xff'

= DUID_LL basic dissection
a=DUID_LL(raw(DUID_LL()))
a.type == 3 and a.hwtype == 1 and a.lladdr == "00:00:00:00:00:00"

= DUID_LL with specific values 
a=DUID_LL(b'\x00\x03\x00\x01\xff\xff\xff\xff\xff\xff')
a.hwtype == 1 and a.lladdr == "ff:ff:ff:ff:ff:ff"


############
############
+ Test DHCP6 DUID_UUID

= DUID_UUID basic instantiation
a=DUID_UUID() 

= DUID_UUID basic build
raw(DUID_UUID()) == b"\0\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"

= DUID_UUID build with specific values
raw(DUID_UUID(uuid="272adcca-138c-4e8d-b3f4-634e953128cf")) == \
   b"\x00\x04'*\xdc\xca\x13\x8cN\x8d\xb3\xf4cN\x951(\xcf"

= DUID_UUID basic dissection
a=DUID_UUID(raw(DUID_UUID()))
a.type == 4 and str(a.uuid) == "00000000-0000-0000-0000-000000000000"

= DUID_UUID with specific values 
a=DUID_UUID(b"\x00\x04'*\xdc\xca\x13\x8cN\x8d\xb3\xf4cN\x951(\xcf")
a.type == 4 and str(a.uuid) == "272adcca-138c-4e8d-b3f4-634e953128cf"


############
############
+ Test DHCP6 Opt Unknown

= DHCP6 Opt Unknown basic instantiation 
a=DHCP6OptUnknown()

= DHCP6 Opt Unknown basic build (default values)
raw(DHCP6OptUnknown()) == b'\x00\x00\x00\x00'

= DHCP6 Opt Unknown - len computation test
raw(DHCP6OptUnknown(data="shouldbe9")) == b'\x00\x00\x00\tshouldbe9'


############
############
+ Test DHCP6 Client Identifier option

= DHCP6OptClientId basic instantiation
a=DHCP6OptClientId()

= DHCP6OptClientId basic build
raw(DHCP6OptClientId()) == b'\x00\x01\x00\x00'

= DHCP6OptClientId instantiation with specific values 
raw(DHCP6OptClientId(duid="toto")) == b'\x00\x01\x00\x04toto'

= DHCP6OptClientId instantiation with DUID_LL
raw(DHCP6OptClientId(duid=DUID_LL())) == b'\x00\x01\x00\n\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00'

= DHCP6OptClientId instantiation with DUID_LLT
raw(DHCP6OptClientId(duid=DUID_LLT())) == b'\x00\x01\x00\x0e\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

= DHCP6OptClientId instantiation with DUID_EN
raw(DHCP6OptClientId(duid=DUID_EN())) == b'\x00\x01\x00\x06\x00\x02\x00\x00\x017'

= DHCP6OptClientId instantiation with specified length
raw(DHCP6OptClientId(optlen=80, duid="somestring")) == b'\x00\x01\x00Psomestring'

= DHCP6OptClientId basic dissection
a=DHCP6OptClientId(b'\x00\x01\x00\x00') 
a.optcode == 1 and a.optlen == 0

= DHCP6OptClientId instantiation with specified length
raw(DHCP6OptClientId(optlen=80, duid="somestring")) == b'\x00\x01\x00Psomestring'

= DHCP6OptClientId basic dissection
a=DHCP6OptClientId(b'\x00\x01\x00\x00') 
a.optcode == 1 and a.optlen == 0

= DHCP6OptClientId dissection with specific duid value
a=DHCP6OptClientId(b'\x00\x01\x00\x04somerawing')
a.optcode == 1 and a.optlen == 4 and isinstance(a.duid, Raw) and a.duid.load == b'some' and isinstance(a.payload, DHCP6OptUnknown)

= DHCP6OptClientId dissection with specific DUID_LL as duid value
a=DHCP6OptClientId(b'\x00\x01\x00\n\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00')
a.optcode == 1 and a.optlen == 10 and isinstance(a.duid, DUID_LL) and a.duid.type == 3 and a.duid.hwtype == 1 and a.duid.lladdr == "00:00:00:00:00:00"

= DHCP6OptClientId dissection with specific DUID_LLT as duid value
a=DHCP6OptClientId(b'\x00\x01\x00\x0e\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.optcode == 1 and a.optlen == 14 and isinstance(a.duid, DUID_LLT) and a.duid.type == 1 and a.duid.hwtype == 1 and a.duid.timeval == 0 and a.duid.lladdr == "00:00:00:00:00:00"

= DHCP6OptClientId dissection with specific DUID_EN as duid value
a=DHCP6OptClientId(b'\x00\x01\x00\x06\x00\x02\x00\x00\x017')
a.optcode == 1 and a.optlen == 6 and isinstance(a.duid, DUID_EN) and a.duid.type == 2 and a.duid.enterprisenum == 311 and a.duid.id == b""


############
############
+ Test DHCP6 Server Identifier option

= DHCP6OptServerId basic instantiation
a=DHCP6OptServerId()

= DHCP6OptServerId basic build 
raw(DHCP6OptServerId()) == b'\x00\x02\x00\x00'

= DHCP6OptServerId basic build with specific values
raw(DHCP6OptServerId(duid="toto")) == b'\x00\x02\x00\x04toto'

= DHCP6OptServerId instantiation with DUID_LL
raw(DHCP6OptServerId(duid=DUID_LL())) == b'\x00\x02\x00\n\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00'

= DHCP6OptServerId instantiation with DUID_LLT
raw(DHCP6OptServerId(duid=DUID_LLT())) == b'\x00\x02\x00\x0e\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

= DHCP6OptServerId instantiation with DUID_EN
raw(DHCP6OptServerId(duid=DUID_EN())) == b'\x00\x02\x00\x06\x00\x02\x00\x00\x017'

= DHCP6OptServerId instantiation with specified length
raw(DHCP6OptServerId(optlen=80, duid="somestring")) == b'\x00\x02\x00Psomestring'

= DHCP6OptServerId basic dissection
a=DHCP6OptServerId(b'\x00\x02\x00\x00') 
a.optcode == 2 and a.optlen == 0

= DHCP6OptServerId dissection with specific duid value
a=DHCP6OptServerId(b'\x00\x02\x00\x04somerawing')
a.optcode == 2 and a.optlen == 4 and isinstance(a.duid, Raw) and a.duid.load == b'some' and isinstance(a.payload, DHCP6OptUnknown)

= DHCP6OptServerId dissection with specific DUID_LL as duid value
a=DHCP6OptServerId(b'\x00\x02\x00\n\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00')
a.optcode == 2 and a.optlen == 10 and isinstance(a.duid, DUID_LL) and a.duid.type == 3 and a.duid.hwtype == 1 and a.duid.lladdr == "00:00:00:00:00:00"

= DHCP6OptServerId dissection with specific DUID_LLT as duid value
a=DHCP6OptServerId(b'\x00\x02\x00\x0e\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.optcode == 2 and a.optlen == 14 and isinstance(a.duid, DUID_LLT) and a.duid.type == 1 and a.duid.hwtype == 1 and a.duid.timeval == 0 and a.duid.lladdr == "00:00:00:00:00:00"

= DHCP6OptServerId dissection with specific DUID_EN as duid value
a=DHCP6OptServerId(b'\x00\x02\x00\x06\x00\x02\x00\x00\x017')
a.optcode == 2 and a.optlen == 6 and isinstance(a.duid, DUID_EN) and a.duid.type == 2 and a.duid.enterprisenum == 311 and a.duid.id == b""


############
############
+ Test DHCP6 IA Address Option (IA_TA or IA_NA suboption)

= DHCP6OptIAAddress - Basic Instantiation
raw(DHCP6OptIAAddress()) == b'\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

= DHCP6OptIAAddress - Basic Dissection
a = DHCP6OptIAAddress(b'\x00\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.optcode == 5 and a.optlen == 24 and a.addr == "::" and a.preflft == 0 and a. validlft == 0 and a.iaaddropts == []

= DHCP6OptIAAddress - Instantiation with specific values
raw(DHCP6OptIAAddress(optlen=0x1111, addr="2222:3333::5555", preflft=0x66666666, validlft=0x77777777, iaaddropts="somestring")) == b'\x00\x05\x11\x11""33\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00UUffffwwwwsomestring'

= DHCP6OptIAAddress - Instantiation with specific values (default optlen computation)
raw(DHCP6OptIAAddress(addr="2222:3333::5555", preflft=0x66666666, validlft=0x77777777, iaaddropts="somestring")) == b'\x00\x05\x00"""33\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00UUffffwwwwsomestring'

= DHCP6OptIAAddress - Dissection with specific values 
a = DHCP6OptIAAddress(b'\x00\x05\x00"""33\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00UUffffwwwwsomerawing')
a.optcode == 5 and a.optlen == 34 and a.addr == "2222:3333::5555" and a.preflft == 0x66666666 and a. validlft == 0x77777777 and a.iaaddropts[0].load == b"somerawing"


############
############
+ Test DHCP6 Identity Association for Non-temporary Addresses Option

= DHCP6OptIA_NA - Basic Instantiation
raw(DHCP6OptIA_NA()) == b'\x00\x03\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

= DHCP6OptIA_NA - Basic Dissection
a = DHCP6OptIA_NA(b'\x00\x03\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.optcode == 3 and a.optlen == 12 and a.iaid == 0 and a.T1 == 0 and a.T2==0 and a.ianaopts == []

= DHCP6OptIA_NA - Instantiation with specific values (keep automatic length computation) 
raw(DHCP6OptIA_NA(iaid=0x22222222, T1=0x33333333, T2=0x44444444)) == b'\x00\x03\x00\x0c""""3333DDDD'

= DHCP6OptIA_NA - Instantiation with specific values (forced optlen)
raw(DHCP6OptIA_NA(optlen=0x1111, iaid=0x22222222, T1=0x33333333, T2=0x44444444)) == b'\x00\x03\x11\x11""""3333DDDD'

= DHCP6OptIA_NA - Instantiation with a list of IA Addresses (optlen automatic computation)
raw(DHCP6OptIA_NA(iaid=0x22222222, T1=0x33333333, T2=0x44444444, ianaopts=[DHCP6OptIAAddress(), DHCP6OptIAAddress()])) == b'\x00\x03\x00D""""3333DDDD\x00\x05\x00\x18\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\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

= DHCP6OptIA_NA - Dissection with specific values
a = DHCP6OptIA_NA(b'\x00\x03\x00L""""3333DDDD\x00\x05\x00\x18\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\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.optcode == 3 and a.optlen == 76 and a.iaid == 0x22222222 and a.T1 == 0x33333333 and a.T2==0x44444444 and len(a.ianaopts) == 2 and isinstance(a.ianaopts[0], DHCP6OptIAAddress) and isinstance(a.ianaopts[1], DHCP6OptIAAddress)

= DHCP6OptIA_NA - Instantiation with a list of different opts: IA Address and Status Code (optlen automatic computation)
raw(DHCP6OptIA_NA(iaid=0x22222222, T1=0x33333333, T2=0x44444444, ianaopts=[DHCP6OptIAAddress(), DHCP6OptStatusCode(statuscode=0xff, statusmsg="Hello")])) == b'\x00\x03\x003""""3333DDDD\x00\x05\x00\x18\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\r\x00\x07\x00\xffHello'


############
############
+ Test DHCP6 Identity Association for Temporary Addresses Option

= DHCP6OptIA_TA - Basic Instantiation
raw(DHCP6OptIA_TA()) == b'\x00\x04\x00\x04\x00\x00\x00\x00'

= DHCP6OptIA_TA - Basic Dissection
a = DHCP6OptIA_TA(b'\x00\x04\x00\x04\x00\x00\x00\x00')
a.optcode == 4 and a.optlen == 4 and a.iaid == 0 and a.iataopts == []

= DHCP6OptIA_TA - Instantiation with specific values
raw(DHCP6OptIA_TA(optlen=0x1111, iaid=0x22222222, iataopts=[DHCP6OptIAAddress(), DHCP6OptIAAddress()])) == b'\x00\x04\x11\x11""""\x00\x05\x00\x18\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\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

= DHCP6OptIA_TA - Dissection with specific values
a = DHCP6OptIA_TA(b'\x00\x04\x11\x11""""\x00\x05\x00\x18\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\x05\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.optcode == 4 and a.optlen == 0x1111 and a.iaid == 0x22222222 and len(a.iataopts) == 2 and isinstance(a.iataopts[0], DHCP6OptIAAddress) and isinstance(a.iataopts[1], DHCP6OptIAAddress)

= DHCP6OptIA_TA - Instantiation with a list of different opts: IA Address and Status Code (optlen automatic computation)
raw(DHCP6OptIA_TA(iaid=0x22222222, iataopts=[DHCP6OptIAAddress(), DHCP6OptStatusCode(statuscode=0xff, statusmsg="Hello")])) == b'\x00\x04\x00+""""\x00\x05\x00\x18\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\r\x00\x07\x00\xffHello'


############
############
+ Test DHCP6 Option Request Option

= DHCP6OptOptReq - Basic Instantiation
raw(DHCP6OptOptReq()) ==  b'\x00\x06\x00\x04\x00\x17\x00\x18'

= DHCP6OptOptReq - optlen field computation
raw(DHCP6OptOptReq(reqopts=[1,2,3,4])) == b'\x00\x06\x00\x08\x00\x01\x00\x02\x00\x03\x00\x04'

= DHCP6OptOptReq - instantiation with empty list
raw(DHCP6OptOptReq(reqopts=[])) == b'\x00\x06\x00\x00'

= DHCP6OptOptReq - Basic dissection
a=DHCP6OptOptReq(b'\x00\x06\x00\x00')
a.optcode == 6 and a.optlen == 0 and a.reqopts == [23,24]

= DHCP6OptOptReq - Dissection with specific value
a=DHCP6OptOptReq(b'\x00\x06\x00\x08\x00\x01\x00\x02\x00\x03\x00\x04')
a.optcode == 6 and a.optlen == 8 and a.reqopts == [1,2,3,4]

= DHCP6OptOptReq - repr
a.show()


############
############
+ Test DHCP6 Option - Preference option

= DHCP6OptPref - Basic instantiation
raw(DHCP6OptPref()) == b'\x00\x07\x00\x01\xff'

= DHCP6OptPref - Instantiation with specific values 
raw(DHCP6OptPref(optlen=0xffff, prefval= 0x11)) == b'\x00\x07\xff\xff\x11'

= DHCP6OptPref - Basic Dissection
a=DHCP6OptPref(b'\x00\x07\x00\x01\xff')
a.optcode == 7 and a.optlen == 1 and a.prefval == 255

= DHCP6OptPref - Dissection with specific values
a=DHCP6OptPref(b'\x00\x07\xff\xff\x11')
a.optcode == 7 and a.optlen == 0xffff and a.prefval == 0x11


############
############
+ Test DHCP6 Option - Elapsed Time

= DHCP6OptElapsedTime - Basic Instantiation
raw(DHCP6OptElapsedTime()) == b'\x00\x08\x00\x02\x00\x00'

= DHCP6OptElapsedTime - Instantiation with specific elapsedtime value
raw(DHCP6OptElapsedTime(elapsedtime=421)) == b'\x00\x08\x00\x02\x01\xa5'

= DHCP6OptElapsedTime - Basic Dissection
a=DHCP6OptElapsedTime(b'\x00\x08\x00\x02\x00\x00') 
a.optcode == 8 and a.optlen == 2 and a.elapsedtime == 0

= DHCP6OptElapsedTime - Dissection with specific values
a=DHCP6OptElapsedTime(b'\x00\x08\x00\x02\x01\xa5')
a.optcode == 8 and a.optlen == 2 and a.elapsedtime == 421

= DHCP6OptElapsedTime - Repr
a.show()


############
############
+ Test DHCP6 Option - Server Unicast Address

= DHCP6OptServerUnicast - Basic Instantiation
raw(DHCP6OptServerUnicast()) == b'\x00\x0c\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

= DHCP6OptServerUnicast - Instantiation with specific values (test 1)
raw(DHCP6OptServerUnicast(srvaddr="2001::1")) == b'\x00\x0c\x00\x10 \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'

= DHCP6OptServerUnicast - Instantiation with specific values (test 2)
raw(DHCP6OptServerUnicast(srvaddr="2001::1", optlen=42)) == b'\x00\x0c\x00* \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'

= DHCP6OptServerUnicast - Dissection with default values
a=DHCP6OptServerUnicast(b'\x00\x0c\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.optcode == 12 and a.optlen == 16 and a.srvaddr == "::"

= DHCP6OptServerUnicast - Dissection with specific values (test 1)
a=DHCP6OptServerUnicast(b'\x00\x0c\x00\x10 \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
a.optcode == 12 and a.optlen == 16 and a.srvaddr == "2001::1"

= DHCP6OptServerUnicast - Dissection with specific values (test 2)
a=DHCP6OptServerUnicast(b'\x00\x0c\x00* \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
a.optcode == 12 and a.optlen == 42 and a.srvaddr == "2001::1"


############
############
+ Test DHCP6 Option - Status Code

= DHCP6OptStatusCode - Basic Instantiation
raw(DHCP6OptStatusCode()) == b'\x00\r\x00\x02\x00\x00' 

= DHCP6OptStatusCode - Instantiation with specific values
raw(DHCP6OptStatusCode(optlen=42, statuscode=0xff, statusmsg="Hello")) == b'\x00\r\x00*\x00\xffHello'

= DHCP6OptStatusCode - Automatic Length computation
raw(DHCP6OptStatusCode(statuscode=0xff, statusmsg="Hello")) == b'\x00\r\x00\x07\x00\xffHello'

# Add tests to verify Unicode behavior


############
############
+ Test DHCP6 Option - Rapid Commit

= DHCP6OptRapidCommit - Basic Instantiation
raw(DHCP6OptRapidCommit()) == b'\x00\x0e\x00\x00'

= DHCP6OptRapidCommit - Basic Dissection
a=DHCP6OptRapidCommit(b'\x00\x0e\x00\x00')
a.optcode == 14 and a.optlen == 0


############
############
+ Test DHCP6 Option - User class

= DHCP6OptUserClass - Basic Instantiation
raw(DHCP6OptUserClass()) == b'\x00\x0f\x00\x00'

= DHCP6OptUserClass - Basic Dissection
a = DHCP6OptUserClass(b'\x00\x0f\x00\x00')
a.optcode == 15 and a.optlen == 0 and a.userclassdata == []

= DHCP6OptUserClass - Instantiation with one user class data rawucture
raw(DHCP6OptUserClass(userclassdata=[USER_CLASS_DATA(data="something")])) == b'\x00\x0f\x00\x0b\x00\tsomething'

= DHCP6OptUserClass - Dissection with one user class data rawucture
a = DHCP6OptUserClass(b'\x00\x0f\x00\x0b\x00\tsomething')
a.optcode == 15 and a.optlen == 11 and len(a.userclassdata) == 1 and isinstance(a.userclassdata[0], USER_CLASS_DATA) and a.userclassdata[0].len == 9 and a.userclassdata[0].data == b'something'

= DHCP6OptUserClass - Instantiation with two user class data rawuctures
raw(DHCP6OptUserClass(userclassdata=[USER_CLASS_DATA(data="something"), USER_CLASS_DATA(data="somethingelse")])) == b'\x00\x0f\x00\x1a\x00\tsomething\x00\rsomethingelse'

= DHCP6OptUserClass - Dissection with two user class data rawuctures
a = DHCP6OptUserClass(b'\x00\x0f\x00\x1a\x00\tsomething\x00\rsomethingelse')
a.optcode == 15 and a.optlen == 26 and len(a.userclassdata) == 2 and isinstance(a.userclassdata[0], USER_CLASS_DATA) and isinstance(a.userclassdata[1], USER_CLASS_DATA) and a.userclassdata[0].len == 9 and a.userclassdata[0].data == b'something' and a.userclassdata[1].len == 13 and a.userclassdata[1].data == b'somethingelse'


############
############
+ Test DHCP6 Option - Vendor class

= DHCP6OptVendorClass - Basic Instantiation
raw(DHCP6OptVendorClass()) == b'\x00\x10\x00\x04\x00\x00\x00\x00'

= DHCP6OptVendorClass - Basic Dissection
a = DHCP6OptVendorClass(b'\x00\x10\x00\x04\x00\x00\x00\x00')
a.optcode == 16 and a.optlen == 4 and a.enterprisenum == 0 and a.vcdata == []

= DHCP6OptVendorClass - Instantiation with one vendor class data rawucture
raw(DHCP6OptVendorClass(vcdata=[VENDOR_CLASS_DATA(data="something")])) == b'\x00\x10\x00\x0f\x00\x00\x00\x00\x00\tsomething'

= DHCP6OptVendorClass - Dissection with one vendor class data rawucture
a = DHCP6OptVendorClass(b'\x00\x10\x00\x0f\x00\x00\x00\x00\x00\tsomething')
a.optcode == 16 and a.optlen == 15 and a.enterprisenum == 0 and len(a.vcdata) == 1 and isinstance(a.vcdata[0], VENDOR_CLASS_DATA) and a.vcdata[0].len == 9 and a.vcdata[0].data == b'something'

= DHCP6OptVendorClass - Instantiation with two vendor class data rawuctures
raw(DHCP6OptVendorClass(vcdata=[VENDOR_CLASS_DATA(data="something"), VENDOR_CLASS_DATA(data="somethingelse")])) == b'\x00\x10\x00\x1e\x00\x00\x00\x00\x00\tsomething\x00\rsomethingelse'

= DHCP6OptVendorClass - Dissection with two vendor class data rawuctures
a = DHCP6OptVendorClass(b'\x00\x10\x00\x1e\x00\x00\x00\x00\x00\tsomething\x00\rsomethingelse')
a.optcode == 16 and a.optlen == 30 and a.enterprisenum == 0 and len(a.vcdata) == 2 and isinstance(a.vcdata[0], VENDOR_CLASS_DATA) and isinstance(a.vcdata[1], VENDOR_CLASS_DATA) and a.vcdata[0].len == 9 and a.vcdata[0].data == b'something' and a.vcdata[1].len == 13 and a.vcdata[1].data == b'somethingelse'


############
############
+ Test DHCP6 Option - Vendor-specific information

= DHCP6OptVendorSpecificInfo - Basic Instantiation
raw(DHCP6OptVendorSpecificInfo()) == b'\x00\x11\x00\x04\x00\x00\x00\x00'

= DHCP6OptVendorSpecificInfo - Basic Dissection
a = DHCP6OptVendorSpecificInfo(b'\x00\x11\x00\x04\x00\x00\x00\x00')
a.optcode == 17 and a.optlen == 4 and a.enterprisenum == 0

= DHCP6OptVendorSpecificInfo - Instantiation with specific values (one option)
raw(DHCP6OptVendorSpecificInfo(enterprisenum=0xeeeeeeee, vso=[VENDOR_SPECIFIC_OPTION(optcode=43, optdata="something")])) == b'\x00\x11\x00\x11\xee\xee\xee\xee\x00+\x00\tsomething'

= DHCP6OptVendorSpecificInfo - Dissection with with specific values (one option)
a = DHCP6OptVendorSpecificInfo(b'\x00\x11\x00\x11\xee\xee\xee\xee\x00+\x00\tsomething')
a.optcode == 17 and a.optlen == 17 and a.enterprisenum == 0xeeeeeeee and len(a.vso) == 1 and isinstance(a.vso[0], VENDOR_SPECIFIC_OPTION) and a.vso[0].optlen == 9 and a.vso[0].optdata == b'something'

= DHCP6OptVendorSpecificInfo - Instantiation with specific values (two options)
raw(DHCP6OptVendorSpecificInfo(enterprisenum=0xeeeeeeee, vso=[VENDOR_SPECIFIC_OPTION(optcode=43, optdata="something"), VENDOR_SPECIFIC_OPTION(optcode=42, optdata="somethingelse")])) == b'\x00\x11\x00"\xee\xee\xee\xee\x00+\x00\tsomething\x00*\x00\rsomethingelse'

= DHCP6OptVendorSpecificInfo - Dissection with with specific values (two options)
a = DHCP6OptVendorSpecificInfo(b'\x00\x11\x00"\xee\xee\xee\xee\x00+\x00\tsomething\x00*\x00\rsomethingelse')
a.optcode == 17 and a.optlen == 34 and a.enterprisenum == 0xeeeeeeee and len(a.vso) == 2 and isinstance(a.vso[0], VENDOR_SPECIFIC_OPTION) and isinstance(a.vso[1], VENDOR_SPECIFIC_OPTION) and a.vso[0].optlen == 9 and a.vso[0].optdata == b'something' and a.vso[1].optlen == 13 and a.vso[1].optdata == b'somethingelse'


############
############
+ Test DHCP6 Option - Interface-Id 

= DHCP6OptIfaceId - Basic Instantiation
raw(DHCP6OptIfaceId()) == b'\x00\x12\x00\x00'

= DHCP6OptIfaceId - Basic Dissection
a = DHCP6OptIfaceId(b'\x00\x12\x00\x00')
a.optcode == 18 and a.optlen == 0

= DHCP6OptIfaceId - Instantiation with specific value
raw(DHCP6OptIfaceId(ifaceid="something")) == b'\x00\x12\x00\x09something'

= DHCP6OptIfaceId - Dissection with specific value
a = DHCP6OptIfaceId(b'\x00\x12\x00\x09something')
a.optcode == 18 and a.optlen == 9 and a.ifaceid == b"something"


############
############
+ Test DHCP6 Option - Reconfigure Message

= DHCP6OptReconfMsg - Basic Instantiation
raw(DHCP6OptReconfMsg()) == b'\x00\x13\x00\x01\x0b'

= DHCP6OptReconfMsg - Basic Dissection
a = DHCP6OptReconfMsg(b'\x00\x13\x00\x01\x0b')
a.optcode == 19 and a.optlen == 1 and a.msgtype == 11

= DHCP6OptReconfMsg - Instantiation with specific values
raw(DHCP6OptReconfMsg(optlen=4, msgtype=5)) == b'\x00\x13\x00\x04\x05'

= DHCP6OptReconfMsg - Dissection with specific values
a = DHCP6OptReconfMsg(b'\x00\x13\x00\x04\x05')
a.optcode == 19 and a.optlen == 4 and a.msgtype == 5


############
############
+ Test DHCP6 Option - Reconfigure Accept

= DHCP6OptReconfAccept - Basic Instantiation
raw(DHCP6OptReconfAccept()) == b'\x00\x14\x00\x00'

= DHCP6OptReconfAccept - Basic Dissection
a = DHCP6OptReconfAccept(b'\x00\x14\x00\x00')
a.optcode == 20 and a.optlen == 0

= DHCP6OptReconfAccept - Instantiation with specific values
raw(DHCP6OptReconfAccept(optlen=23)) == b'\x00\x14\x00\x17'

= DHCP6OptReconfAccept - Dssection with specific values
a = DHCP6OptReconfAccept(b'\x00\x14\x00\x17')
a.optcode == 20 and a.optlen == 23


############
############
+ Test DHCP6 Option - SIP Servers Domain Name List

= DHCP6OptSIPDomains - Basic Instantiation
raw(DHCP6OptSIPDomains()) == b'\x00\x15\x00\x00'

= DHCP6OptSIPDomains - Basic Dissection
a = DHCP6OptSIPDomains(b'\x00\x15\x00\x00') 
a.optcode == 21 and a.optlen == 0 and a.sipdomains == []

= DHCP6OptSIPDomains - Instantiation with one domain
raw(DHCP6OptSIPDomains(sipdomains=["toto.example.org"])) == b'\x00\x15\x00\x12\x04toto\x07example\x03org\x00'

= DHCP6OptSIPDomains - Dissection with one domain
a = DHCP6OptSIPDomains(b'\x00\x15\x00\x12\x04toto\x07example\x03org\x00')
a.optcode == 21 and a.optlen == 18 and len(a.sipdomains) == 1 and a.sipdomains[0] == "toto.example.org."

= DHCP6OptSIPDomains - Instantiation with two domains
raw(DHCP6OptSIPDomains(sipdomains=["toto.example.org", "titi.example.org"])) == b'\x00\x15\x00$\x04toto\x07example\x03org\x00\x04titi\x07example\x03org\x00'

= DHCP6OptSIPDomains - Dissection with two domains
a = DHCP6OptSIPDomains(b'\x00\x15\x00$\x04toto\x07example\x03org\x00\x04TITI\x07example\x03org\x00')
a.optcode == 21 and a.optlen == 36 and len(a.sipdomains) == 2 and a.sipdomains[0] == "toto.example.org." and a.sipdomains[1] == "TITI.example.org."

= DHCP6OptSIPDomains - Enforcing only one dot at end of domain
raw(DHCP6OptSIPDomains(sipdomains=["toto.example.org."])) == b'\x00\x15\x00\x12\x04toto\x07example\x03org\x00'


############
############
+ Test DHCP6 Option - SIP Servers IPv6 Address List

= DHCP6OptSIPServers - Basic Instantiation
raw(DHCP6OptSIPServers()) == b'\x00\x16\x00\x00'

= DHCP6OptSIPServers - Basic Dissection
a = DHCP6OptSIPServers(b'\x00\x16\x00\x00')
a.optcode == 22 and a. optlen == 0 and a.sipservers == []

= DHCP6OptSIPServers - Instantiation with specific values (1 address)
raw(DHCP6OptSIPServers(sipservers = ["2001:db8::1"] )) == b'\x00\x16\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'

= DHCP6OptSIPServers - Dissection with specific values (1 address)
a = DHCP6OptSIPServers(b'\x00\x16\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
a.optcode == 22 and a.optlen == 16 and len(a.sipservers) == 1 and a.sipservers[0] == "2001:db8::1" 

= DHCP6OptSIPServers - Instantiation with specific values (2 addresses)
raw(DHCP6OptSIPServers(sipservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00\x16\x00  \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'

= DHCP6OptSIPServers - Dissection with specific values (2 addresses)
a = DHCP6OptSIPServers(b'\x00\x16\x00  \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')
a.optcode == 22 and a.optlen == 32 and len(a.sipservers) == 2 and a.sipservers[0] == "2001:db8::1" and a.sipservers[1] == "2001:db8::2"


############
############
+ Test DHCP6 Option - DNS Recursive Name Server

= DHCP6OptDNSServers - Basic Instantiation
raw(DHCP6OptDNSServers()) == b'\x00\x17\x00\x00'

= DHCP6OptDNSServers - Basic Dissection
a = DHCP6OptDNSServers(b'\x00\x17\x00\x00')
a.optcode == 23 and a. optlen == 0 and a.dnsservers == []

= DHCP6OptDNSServers - Instantiation with specific values (1 address)
raw(DHCP6OptDNSServers(dnsservers = ["2001:db8::1"] )) == b'\x00\x17\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'

= DHCP6OptDNSServers - Dissection with specific values (1 address)
a = DHCP6OptDNSServers(b'\x00\x17\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
a.optcode == 23 and a.optlen == 16 and len(a.dnsservers) == 1 and a.dnsservers[0] == "2001:db8::1" 

= DHCP6OptDNSServers - Instantiation with specific values (2 addresses)
raw(DHCP6OptDNSServers(dnsservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00\x17\x00  \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'

= DHCP6OptDNSServers - Dissection with specific values (2 addresses)
a = DHCP6OptDNSServers(b'\x00\x17\x00  \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')
a.optcode == 23 and a.optlen == 32 and len(a.dnsservers) == 2 and a.dnsservers[0] == "2001:db8::1" and a.dnsservers[1] == "2001:db8::2"


############
############
+ Test DHCP6 Option - DNS Domain Search List Option

= DHCP6OptDNSDomains - Basic Instantiation
raw(DHCP6OptDNSDomains()) == b'\x00\x18\x00\x00'

= DHCP6OptDNSDomains - Basic Dissection
a = DHCP6OptDNSDomains(b'\x00\x18\x00\x00')
a.optcode == 24 and a.optlen == 0 and a.dnsdomains == []

= DHCP6OptDNSDomains - Instantiation with specific values (1 domain) 
raw(DHCP6OptDNSDomains(dnsdomains=["toto.example.com."])) == b'\x00\x18\x00\x12\x04toto\x07example\x03com\x00'

= DHCP6OptDNSDomains - Dissection with specific values (1 domain) 
a = DHCP6OptDNSDomains(b'\x00\x18\x00\x12\x04toto\x07example\x03com\x00')
a.optcode == 24 and a.optlen == 18 and len(a.dnsdomains) == 1 and a.dnsdomains[0] == "toto.example.com."

= DHCP6OptDNSDomains - Instantiation with specific values (2 domains) 
raw(DHCP6OptDNSDomains(dnsdomains=["toto.example.com.", "titi.example.com."])) == b'\x00\x18\x00$\x04toto\x07example\x03com\x00\x04titi\x07example\x03com\x00'

= DHCP6OptDNSDomains - Dissection with specific values (2 domains) 
a = DHCP6OptDNSDomains(b'\x00\x18\x00$\x04toto\x07example\x03com\x00\x04titi\x07example\x03com\x00')
a.optcode == 24 and a.optlen == 36 and len(a.dnsdomains) == 2 and a.dnsdomains[0] == "toto.example.com." and a.dnsdomains[1] == "titi.example.com."


############
############
+ Test DHCP6 Option - IA_PD Prefix Option

= DHCP6OptIAPrefix - Basic Instantiation
raw(DHCP6OptIAPrefix()) == b'\x00\x1a\x00\x19\x00\x00\x00\x00\x00\x00\x00\x000 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

= DHCP6OptIAPrefix - Basic Dissection
a = DHCP6OptIAPrefix(b'\x00\x1a\x00\x19\x00\x00\x00\x00\x00\x00\x00\x000 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.optcode == 26 and a.optlen == 25 and a.prefix == "2001:db8::" and a.plen == 48 and a.preflft == 0 and a. validlft == 0 and a.iaprefopts == []

= DHCP6OptIAPrefix - Instantiation with specific values
raw(DHCP6OptIAPrefix(optlen=0x1111, prefix="1111:2222:3333:4444::", plen=64, preflft=0x66666666, validlft=0x77777777, iaprefopts="somestring")) == b'\x00\x1a\x11\x11ffffwwww@\x11\x11""33DD\x00\x00\x00\x00\x00\x00\x00\x00somestring'

= DHCP6OptIAPrefix - Instantiation with specific values (default optlen computation)
raw(DHCP6OptIAPrefix(prefix="1111:2222:3333:4444::", plen=64, preflft=0x66666666, validlft=0x77777777, iaprefopts="somestring")) == b'\x00\x1a\x00#ffffwwww@\x11\x11""33DD\x00\x00\x00\x00\x00\x00\x00\x00somestring'

= DHCP6OptIAPrefix - Dissection with specific values 
a = DHCP6OptIAPrefix(b'\x00\x1a\x00#ffffwwww@\x11\x11""33DD\x00\x00\x00\x00\x00\x00\x00\x00somerawing')
a.optcode == 26 and a.optlen == 35 and a.prefix == "1111:2222:3333:4444::" and a.plen == 64 and a.preflft == 0x66666666 and a.validlft == 0x77777777 and a.iaprefopts[0].load == b"somerawing"


############
############
+ Test DHCP6 Option - Identity Association for Prefix Delegation

= DHCP6OptIA_PD - Basic Instantiation
raw(DHCP6OptIA_PD()) == b'\x00\x19\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

= DHCP6OptIA_PD - Basic Dissection
a = DHCP6OptIA_PD(b'\x00\x19\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.optcode == 25 and a.optlen == 12 and a.iaid == 0 and a.T1 == 0 and a.T2==0 and a.iapdopt == []

= DHCP6OptIA_PD - Instantiation with specific values (keep automatic length computation) 
print(raw(DHCP6OptIA_PD(iaid=0x22222222, T1=0x33333333, T2=0x44444444)))
raw(DHCP6OptIA_PD(iaid=0x22222222, T1=0x33333333, T2=0x44444444)) == b'\x00\x19\x00\x0c""""3333DDDD'

= DHCP6OptIA_PD - Instantiation with specific values (forced optlen)
raw(DHCP6OptIA_PD(optlen=0x1111, iaid=0x22222222, T1=0x33333333, T2=0x44444444)) == b'\x00\x19\x11\x11""""3333DDDD'

= DHCP6OptIA_PD - Instantiation with a list of IA Prefixes (optlen automatic computation)
raw(DHCP6OptIA_PD(iaid=0x22222222, T1=0x33333333, T2=0x44444444, iapdopt=[DHCP6OptIAPrefix(), DHCP6OptIAPrefix()])) == b'\x00\x19\x00F""""3333DDDD\x00\x1a\x00\x19\x00\x00\x00\x00\x00\x00\x00\x000 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x19\x00\x00\x00\x00\x00\x00\x00\x000 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

= DHCP6OptIA_PD - Dissection with specific values
a = DHCP6OptIA_PD(b'\x00\x19\x00N""""3333DDDD\x00\x1a\x00\x19\x00\x00\x00\x00\x00\x00\x00\x000 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x19\x00\x00\x00\x00\x00\x00\x00\x000 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
a.optcode == 25 and a.optlen == 78 and a.iaid == 0x22222222 and a.T1 == 0x33333333 and a.T2==0x44444444 and len(a.iapdopt) == 2 and isinstance(a.iapdopt[0], DHCP6OptIAPrefix) and isinstance(a.iapdopt[1], DHCP6OptIAPrefix)

= DHCP6OptIA_PD - Instantiation with a list of different opts: IA Prefix and Status Code (optlen automatic computation)
raw(DHCP6OptIA_PD(iaid=0x22222222, T1=0x33333333, T2=0x44444444, iapdopt=[DHCP6OptIAPrefix(), DHCP6OptStatusCode(statuscode=0xff, statusmsg="Hello")])) == b'\x00\x19\x004""""3333DDDD\x00\x1a\x00\x19\x00\x00\x00\x00\x00\x00\x00\x000 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\r\x00\x07\x00\xffHello'


############
############
+ Test DHCP6 Option - NIS Servers

= DHCP6OptNISServers - Basic Instantiation
raw(DHCP6OptNISServers()) == b'\x00\x1b\x00\x00'

= DHCP6OptNISServers - Basic Dissection
a = DHCP6OptNISServers(b'\x00\x1b\x00\x00')
a.optcode == 27 and a. optlen == 0 and a.nisservers == []

= DHCP6OptNISServers - Instantiation with specific values (1 address)
raw(DHCP6OptNISServers(nisservers = ["2001:db8::1"] )) == b'\x00\x1b\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'

= DHCP6OptNISServers - Dissection with specific values (1 address)
a = DHCP6OptNISServers(b'\x00\x1b\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
a.optcode == 27 and a.optlen == 16 and len(a.nisservers) == 1 and a.nisservers[0] == "2001:db8::1" 

= DHCP6OptNISServers - Instantiation with specific values (2 addresses)
raw(DHCP6OptNISServers(nisservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00\x1b\x00  \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'

= DHCP6OptNISServers - Dissection with specific values (2 addresses)
a = DHCP6OptNISServers(b'\x00\x1b\x00  \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')
a.optcode == 27 and a.optlen == 32 and len(a.nisservers) == 2 and a.nisservers[0] == "2001:db8::1" and a.nisservers[1] == "2001:db8::2"


############
############
+ Test DHCP6 Option - NIS+ Servers

= DHCP6OptNISPServers - Basic Instantiation
raw(DHCP6OptNISPServers()) == b'\x00\x1c\x00\x00'

= DHCP6OptNISPServers - Basic Dissection
a = DHCP6OptNISPServers(b'\x00\x1c\x00\x00')
a.optcode == 28 and a. optlen == 0 and a.nispservers == []

= DHCP6OptNISPServers - Instantiation with specific values (1 address)
raw(DHCP6OptNISPServers(nispservers = ["2001:db8::1"] )) == b'\x00\x1c\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'

= DHCP6OptNISPServers - Dissection with specific values (1 address)
a = DHCP6OptNISPServers(b'\x00\x1c\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
a.optcode == 28 and a.optlen == 16 and len(a.nispservers) == 1 and a.nispservers[0] == "2001:db8::1" 

= DHCP6OptNISPServers - Instantiation with specific values (2 addresses)
raw(DHCP6OptNISPServers(nispservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00\x1c\x00  \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'

= DHCP6OptNISPServers - Dissection with specific values (2 addresses)
a = DHCP6OptNISPServers(b'\x00\x1c\x00  \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')
a.optcode == 28 and a.optlen == 32 and len(a.nispservers) == 2 and a.nispservers[0] == "2001:db8::1" and a.nispservers[1] == "2001:db8::2"


############
############
+ Test DHCP6 Option - NIS Domain Name

= DHCP6OptNISDomain - Basic Instantiation
raw(DHCP6OptNISDomain()) == b'\x00\x1d\x00\x01\x00'

= DHCP6OptNISDomain - Basic Dissection
a = DHCP6OptNISDomain(b'\x00\x1d\x00\x00')
a.optcode == 29 and a.optlen == 0 and a.nisdomain == b"."

= DHCP6OptNISDomain - Instantiation with one domain name
raw(DHCP6OptNISDomain(nisdomain="toto.example.org")) == b'\x00\x1d\x00\x12\x04toto\x07example\x03org\x00'

= DHCP6OptNISDomain - Dissection with one domain name
a = DHCP6OptNISDomain(b'\x00\x1d\x00\x11\x04toto\x07example\x03org\x00')
a.optcode == 29 and a.optlen == 17 and a.nisdomain == b"toto.example.org."

= DHCP6OptNISDomain - Instantiation with one domain with trailing dot
raw(DHCP6OptNISDomain(nisdomain="toto.example.org.")) == b'\x00\x1d\x00\x12\x04toto\x07example\x03org\x00'


############
############
+ Test DHCP6 Option - NIS+ Domain Name

= DHCP6OptNISPDomain - Basic Instantiation
raw(DHCP6OptNISPDomain()) == b'\x00\x1e\x00\x01\x00'

= DHCP6OptNISPDomain - Basic Dissection
a = DHCP6OptNISPDomain(b'\x00\x1e\x00\x00')
a.optcode == 30 and a.optlen == 0 and a.nispdomain == b"."

= DHCP6OptNISPDomain - Instantiation with one domain name
raw(DHCP6OptNISPDomain(nispdomain="toto.example.org")) == b'\x00\x1e\x00\x12\x04toto\x07example\x03org\x00'

= DHCP6OptNISPDomain - Dissection with one domain name
a = DHCP6OptNISPDomain(b'\x00\x1e\x00\x12\x04toto\x07example\x03org\x00')
a.optcode == 30 and a.optlen == 18 and a.nispdomain == b"toto.example.org."

= DHCP6OptNISPDomain - Instantiation with one domain with trailing dot
raw(DHCP6OptNISPDomain(nispdomain="toto.example.org.")) == b'\x00\x1e\x00\x12\x04toto\x07example\x03org\x00'


############
############
+ Test DHCP6 Option - SNTP Servers

= DHCP6OptSNTPServers - Basic Instantiation
raw(DHCP6OptSNTPServers()) == b'\x00\x1f\x00\x00'

= DHCP6OptSNTPServers - Basic Dissection
a = DHCP6OptSNTPServers(b'\x00\x1f\x00\x00')
a.optcode == 31 and a. optlen == 0 and a.sntpservers == []

= DHCP6OptSNTPServers - Instantiation with specific values (1 address)
raw(DHCP6OptSNTPServers(sntpservers = ["2001:db8::1"] )) == b'\x00\x1f\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'

= DHCP6OptSNTPServers - Dissection with specific values (1 address)
a = DHCP6OptSNTPServers(b'\x00\x1f\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
a.optcode == 31 and a.optlen == 16 and len(a.sntpservers) == 1 and a.sntpservers[0] == "2001:db8::1" 

= DHCP6OptSNTPServers - Instantiation with specific values (2 addresses)
raw(DHCP6OptSNTPServers(sntpservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00\x1f\x00  \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'

= DHCP6OptSNTPServers - Dissection with specific values (2 addresses)
a = DHCP6OptSNTPServers(b'\x00\x1f\x00  \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')
a.optcode == 31 and a.optlen == 32 and len(a.sntpservers) == 2 and a.sntpservers[0] == "2001:db8::1" and a.sntpservers[1] == "2001:db8::2"

############
############
+ Test DHCP6 Option - Information Refresh Time

= DHCP6OptInfoRefreshTime - Basic Instantiation
raw(DHCP6OptInfoRefreshTime()) == b'\x00 \x00\x04\x00\x01Q\x80'

= DHCP6OptInfoRefreshTime - Basic Dissction
a = DHCP6OptInfoRefreshTime(b'\x00 \x00\x04\x00\x01Q\x80')
a.optcode == 32 and a.optlen == 4 and a.reftime == 86400

= DHCP6OptInfoRefreshTime - Instantiation with specific values
raw(DHCP6OptInfoRefreshTime(optlen=7, reftime=42)) == b'\x00 \x00\x07\x00\x00\x00*'

############
############
+ Test DHCP6 Option - BCMCS Servers

= DHCP6OptBCMCSServers - Basic Instantiation
raw(DHCP6OptBCMCSServers()) == b'\x00"\x00\x00'

= DHCP6OptBCMCSServers - Basic Dissection
a = DHCP6OptBCMCSServers(b'\x00"\x00\x00')
a.optcode == 34 and a. optlen == 0 and a.bcmcsservers == []

= DHCP6OptBCMCSServers - Instantiation with specific values (1 address)
raw(DHCP6OptBCMCSServers(bcmcsservers = ["2001:db8::1"] )) == b'\x00"\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'

= DHCP6OptBCMCSServers - Dissection with specific values (1 address)
a = DHCP6OptBCMCSServers(b'\x00"\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
a.optcode == 34 and a.optlen == 16 and len(a.bcmcsservers) == 1 and a.bcmcsservers[0] == "2001:db8::1" 

= DHCP6OptBCMCSServers - Instantiation with specific values (2 addresses)
raw(DHCP6OptBCMCSServers(bcmcsservers = ["2001:db8::1", "2001:db8::2"] )) == b'\x00"\x00  \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'

= DHCP6OptBCMCSServers - Dissection with specific values (2 addresses)
a = DHCP6OptBCMCSServers(b'\x00"\x00  \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')
a.optcode == 34 and a.optlen == 32 and len(a.bcmcsservers) == 2 and a.bcmcsservers[0] == "2001:db8::1" and a.bcmcsservers[1] == "2001:db8::2"


############
############
+ Test DHCP6 Option - BCMCS Domains

= DHCP6OptBCMCSDomains - Basic Instantiation
raw(DHCP6OptBCMCSDomains()) == b'\x00!\x00\x00'

= DHCP6OptBCMCSDomains - Basic Dissection
a = DHCP6OptBCMCSDomains(b'\x00!\x00\x00')
a.optcode == 33 and a.optlen == 0 and a.bcmcsdomains == []

= DHCP6OptBCMCSDomains - Instantiation with specific values (1 domain) 
raw(DHCP6OptBCMCSDomains(bcmcsdomains=["toto.example.com."])) == b'\x00!\x00\x12\x04toto\x07example\x03com\x00'

= DHCP6OptBCMCSDomains - Dissection with specific values (1 domain) 
a = DHCP6OptBCMCSDomains(b'\x00!\x00\x12\x04toto\x07example\x03com\x00')
a.optcode == 33 and a.optlen == 18 and len(a.bcmcsdomains) == 1 and a.bcmcsdomains[0] == "toto.example.com."

= DHCP6OptBCMCSDomains - Instantiation with specific values (2 domains) 
raw(DHCP6OptBCMCSDomains(bcmcsdomains=["toto.example.com.", "titi.example.com."])) == b'\x00!\x00$\x04toto\x07example\x03com\x00\x04titi\x07example\x03com\x00'

= DHCP6OptBCMCSDomains - Dissection with specific values (2 domains) 
a = DHCP6OptBCMCSDomains(b'\x00!\x00$\x04toto\x07example\x03com\x00\x04titi\x07example\x03com\x00')
a.optcode == 33 and a.optlen == 36 and len(a.bcmcsdomains) == 2 and a.bcmcsdomains[0] == "toto.example.com." and a.bcmcsdomains[1] == "titi.example.com."


############
############
+ Test DHCP6 Option - Relay Agent Remote-ID

= DHCP6OptRemoteID - Basic Instantiation
raw(DHCP6OptRemoteID()) == b'\x00%\x00\x04\x00\x00\x00\x00'

= DHCP6OptRemoteID - Basic Dissection
a = DHCP6OptRemoteID(b'\x00%\x00\x04\x00\x00\x00\x00')
a.optcode == 37 and a.optlen == 4 and a.enterprisenum == 0 and a.remoteid == b""

= DHCP6OptRemoteID - Instantiation with specific values 
raw(DHCP6OptRemoteID(enterprisenum=0xeeeeeeee, remoteid="someid")) == b'\x00%\x00\n\xee\xee\xee\xeesomeid'

= DHCP6OptRemoteID - Dissection with specific values
a = DHCP6OptRemoteID(b'\x00%\x00\n\xee\xee\xee\xeesomeid')
a.optcode == 37 and a.optlen == 10 and a.enterprisenum == 0xeeeeeeee and a.remoteid == b"someid"


############
############
+ Test DHCP6 Option - Subscriber ID

= DHCP6OptSubscriberID - Basic Instantiation
raw(DHCP6OptSubscriberID()) == b'\x00&\x00\x00'

= DHCP6OptSubscriberID - Basic Dissection
a = DHCP6OptSubscriberID(b'\x00&\x00\x00')
a.optcode == 38 and a.optlen == 0 and a.subscriberid == b""

= DHCP6OptSubscriberID - Instantiation with specific values
raw(DHCP6OptSubscriberID(subscriberid="someid")) == b'\x00&\x00\x06someid'

= DHCP6OptSubscriberID - Dissection with specific values
a = DHCP6OptSubscriberID(b'\x00&\x00\x06someid')
a.optcode == 38 and a.optlen == 6 and a.subscriberid == b"someid"


############
############
+ Test DHCP6 Option - Client FQDN

= DHCP6OptClientFQDN - Basic Instantiation
raw(DHCP6OptClientFQDN()) == b"\x00'\x00\x02\x00\x00"

= DHCP6OptClientFQDN - Basic Dissection
a = DHCP6OptClientFQDN(b"\x00'\x00\x01\x00")
a.optcode == 39 and a.optlen == 1 and a.res == 0 and a.flags == 0 and a.fqdn == b"."

= DHCP6OptClientFQDN - Instantiation with various flags combinations
raw(DHCP6OptClientFQDN(flags="S")) == b"\x00'\x00\x02\x01\x00" and raw(DHCP6OptClientFQDN(flags="O")) == b"\x00'\x00\x02\x02\x00" and raw(DHCP6OptClientFQDN(flags="N")) == b"\x00'\x00\x02\x04\x00" and raw(DHCP6OptClientFQDN(flags="SON")) == b"\x00'\x00\x02\x07\x00" and raw(DHCP6OptClientFQDN(flags="ON")) == b"\x00'\x00\x02\x06\x00"

= DHCP6OptClientFQDN - Instantiation with one fqdn 
raw(DHCP6OptClientFQDN(fqdn="toto.example.org")) == b"\x00'\x00\x13\x00\x04toto\x07example\x03org\x00"

= DHCP6OptClientFQDN - Dissection with one fqdn 
a = DHCP6OptClientFQDN(b"\x00'\x00\x12\x00\x04toto\x07example\x03org\x00")
a.optcode == 39 and a.optlen == 18 and a.res == 0 and a.flags == 0 and a.fqdn == b"toto.example.org."


############
############
+ Test DHCP6 Option PANA Auth Agent

= DHCP6OptPanaAuthAgent - Basic Instantiation
raw(DHCP6OptPanaAuthAgent()) ==  b'\x00(\x00\x00'

= DHCP6OptPanaAuthAgent - Basic Dissection
a = DHCP6OptPanaAuthAgent(b"\x00(\x00\x00")
a.optcode == 40 and a.optlen == 0 and a.paaaddr == []

= DHCP6OptPanaAuthAgent - Instantiation with specific values (1 address)
raw(DHCP6OptPanaAuthAgent(paaaddr=["2001:db8::1"])) == b'\x00(\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'

= DHCP6OptPanaAuthAgent - Dissection with specific values (1 address)
a = DHCP6OptPanaAuthAgent(b'\x00(\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
a.optcode == 40 and a.optlen == 16 and len(a.paaaddr) == 1 and a.paaaddr[0] == "2001:db8::1"

= DHCP6OptPanaAuthAgent - Instantiation with specific values (2 addresses)
raw(DHCP6OptPanaAuthAgent(paaaddr=["2001:db8::1", "2001:db8::2"])) == b'\x00(\x00  \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'

= DHCP6OptPanaAuthAgent - Dissection with specific values (2 addresses)
a = DHCP6OptPanaAuthAgent(b'\x00(\x00  \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')
a.optcode == 40 and a.optlen == 32 and len(a.paaaddr) == 2 and a.paaaddr[0] == "2001:db8::1" and a.paaaddr[1] == "2001:db8::2"


############
############
+ Test DHCP6 Option - New POSIX Time Zone

= DHCP6OptNewPOSIXTimeZone - Basic Instantiation
raw(DHCP6OptNewPOSIXTimeZone()) == b'\x00)\x00\x00'

= DHCP6OptNewPOSIXTimeZone - Basic Dissection
a = DHCP6OptNewPOSIXTimeZone(b'\x00)\x00\x00')
a.optcode == 41 and a.optlen == 0 and a.optdata == b""

= DHCP6OptNewPOSIXTimeZone - Instantiation with specific values
raw(DHCP6OptNewPOSIXTimeZone(optdata="EST5EDT4,M3.2.0/02:00,M11.1.0/02:00")) == b'\x00)\x00#EST5EDT4,M3.2.0/02:00,M11.1.0/02:00'

= DHCP6OptNewPOSIXTimeZone - Dissection with specific values
a = DHCP6OptNewPOSIXTimeZone(b'\x00)\x00#EST5EDT4,M3.2.0/02:00,M11.1.0/02:00')
a.optcode == 41 and a.optlen == 35 and a.optdata == b"EST5EDT4,M3.2.0/02:00,M11.1.0/02:00"


############
############
+ Test DHCP6 Option - New TZDB Time Zone

= DHCP6OptNewTZDBTimeZone - Basic Instantiation
raw(DHCP6OptNewTZDBTimeZone()) == b'\x00*\x00\x00'

= DHCP6OptNewTZDBTimeZone - Basic Dissection
a = DHCP6OptNewTZDBTimeZone(b'\x00*\x00\x00')
a.optcode == 42 and a.optlen == 0 and a.optdata == b""

= DHCP6OptNewTZDBTimeZone - Instantiation with specific values
raw(DHCP6OptNewTZDBTimeZone(optdata="Europe/Zurich")) == b'\x00*\x00\rEurope/Zurich'

= DHCP6OptNewTZDBTimeZone - Dissection with specific values
a = DHCP6OptNewTZDBTimeZone(b'\x00*\x00\rEurope/Zurich')
a.optcode == 42 and a.optlen == 13 and a.optdata == b"Europe/Zurich"


############
############
+ Test DHCP6 Option Relay Agent Echo Request Option

= DHCP6OptRelayAgentERO - Basic Instantiation
raw(DHCP6OptRelayAgentERO()) ==  b'\x00+\x00\x04\x00\x17\x00\x18'

= DHCP6OptRelayAgentERO - optlen field computation
raw(DHCP6OptRelayAgentERO(reqopts=[1,2,3,4])) == b'\x00+\x00\x08\x00\x01\x00\x02\x00\x03\x00\x04'

= DHCP6OptRelayAgentERO - instantiation with empty list
raw(DHCP6OptRelayAgentERO(reqopts=[])) == b'\x00+\x00\x00'

= DHCP6OptRelayAgentERO - Basic dissection
a=DHCP6OptRelayAgentERO(b'\x00+\x00\x00')
a.optcode == 43 and a.optlen == 0 and a.reqopts == [23,24]

= DHCP6OptRelayAgentERO - Dissection with specific value
a=DHCP6OptRelayAgentERO(b'\x00+\x00\x08\x00\x01\x00\x02\x00\x03\x00\x04')
a.optcode == 43 and a.optlen == 8 and a.reqopts == [1,2,3,4]


############
############
+ Test DHCP6 Option LQ Client Link

= DHCP6OptLQClientLink - Basic Instantiation
raw(DHCP6OptLQClientLink()) ==  b'\x000\x00\x00'

= DHCP6OptLQClientLink - Basic Dissection
a = DHCP6OptLQClientLink(b"\x000\x00\x00")
a.optcode == 48 and a.optlen == 0 and a.linkaddress == []

= DHCP6OptLQClientLink - Instantiation with specific values (1 address)
raw(DHCP6OptLQClientLink(linkaddress=["2001:db8::1"])) == b'\x000\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'

= DHCP6OptLQClientLink - Dissection with specific values (1 address)
a = DHCP6OptLQClientLink(b'\x000\x00\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
a.optcode == 48 and a.optlen == 16 and len(a.linkaddress) == 1 and a.linkaddress[0] == "2001:db8::1"

= DHCP6OptLQClientLink - Instantiation with specific values (2 addresses)
raw(DHCP6OptLQClientLink(linkaddress=["2001:db8::1", "2001:db8::2"])) == b'\x000\x00  \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'

= DHCP6OptLQClientLink - Dissection with specific values (2 addresses)
a = DHCP6OptLQClientLink(b'\x000\x00  \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')
a.optcode == 48 and a.optlen == 32 and len(a.linkaddress) == 2 and a.linkaddress[0] == "2001:db8::1" and a.linkaddress[1] == "2001:db8::2"

############
############
+ Test DHCP6 Option - Boot File URL

= DHCP6OptBootFileUrl - Basic Instantiation
raw(DHCP6OptBootFileUrl()) == b'\x00;\x00\x00'

= DHCP6OptBootFileUrl - Basic Dissection
a = DHCP6OptBootFileUrl(b'\x00;\x00\x00')
a.optcode == 59 and a.optlen == 0 and a.optdata == b""

= DHCP6OptBootFileUrl - Instantiation with specific values
raw(DHCP6OptBootFileUrl(optdata="http://wp.pl/file")) == b'\x00;\x00\x11http://wp.pl/file'

= DHCP6OptBootFileUrl - Dissection with specific values
a = DHCP6OptBootFileUrl(b'\x00;\x00\x11http://wp.pl/file')
a.optcode == 59 and a.optlen == 17 and a.optdata == b"http://wp.pl/file"


############
############
+ Test DHCP6 Option - Client Arch Type

= DHCP6OptClientArchType - Basic Instantiation
raw(DHCP6OptClientArchType())
raw(DHCP6OptClientArchType()) == b'\x00=\x00\x00'

= DHCP6OptClientArchType - Basic Dissection
a = DHCP6OptClientArchType(b'\x00=\x00\x00')
a.optcode == 61 and a.optlen == 0 and a.archtypes == []

= DHCP6OptClientArchType - Instantiation with specific value as just int
raw(DHCP6OptClientArchType(archtypes=7)) == b'\x00=\x00\x02\x00\x07'

= DHCP6OptClientArchType - Instantiation with specific value as single item list of int
raw(DHCP6OptClientArchType(archtypes=[7])) == b'\x00=\x00\x02\x00\x07'

= DHCP6OptClientArchType - Dissection with specific 1 value list
a = DHCP6OptClientArchType(b'\x00=\x00\x02\x00\x07')
a.optcode == 61 and a.optlen == 2 and a.archtypes == [7]

= DHCP6OptClientArchType - Instantiation with specific value as 2 item list of int
raw(DHCP6OptClientArchType(archtypes=[7, 9])) == b'\x00=\x00\x04\x00\x07\x00\x09'

= DHCP6OptClientArchType - Dissection with specific 2 values list
a = DHCP6OptClientArchType(b'\x00=\x00\x04\x00\x07\x00\x09')
a.optcode == 61 and a.optlen == 4 and a.archtypes == [7, 9]


############
############
+ Test DHCP6 Option - Client Network Inter Id

= DHCP6OptClientNetworkInterId - Basic Instantiation
raw(DHCP6OptClientNetworkInterId())
raw(DHCP6OptClientNetworkInterId()) == b'\x00>\x00\x03\x00\x00\x00'

= DHCP6OptClientNetworkInterId - Basic Dissection
a = DHCP6OptClientNetworkInterId(b'\x00>\x00\x03\x00\x00\x00')
a.optcode == 62 and a.optlen == 3 and a.iitype == 0 and a.iimajor == 0 and a.iiminor == 0

= DHCP6OptClientNetworkInterId - Instantiation with specific values
raw(DHCP6OptClientNetworkInterId(iitype=1, iimajor=2, iiminor=3)) == b'\x00>\x00\x03\x01\x02\x03'

= DHCP6OptClientNetworkInterId - Dissection with specific values
a = DHCP6OptClientNetworkInterId(b'\x00>\x00\x03\x01\x02\x03')
a.optcode == 62 and a.optlen == 3 and a.iitype == 1 and a.iimajor == 2 and a.iiminor == 3


############
############
+ Test DHCP6 Option - ERP Domain

= DHCP6OptERPDomain - Basic Instantiation
raw(DHCP6OptERPDomain()) == b'\x00A\x00\x00'

= DHCP6OptERPDomain - Basic Dissection
a = DHCP6OptERPDomain(b'\x00A\x00\x00')
a.optcode == 65 and a.optlen == 0 and a.erpdomain == []

= DHCP6OptERPDomain - Instantiation with specific values (1 domain)
raw(DHCP6OptERPDomain(erpdomain=["toto.example.com."])) == b'\x00A\x00\x12\x04toto\x07example\x03com\x00'

= DHCP6OptERPDomain - Dissection with specific values (1 domain)
a = DHCP6OptERPDomain(b'\x00A\x00\x12\x04toto\x07example\x03com\x00')
a.optcode == 65 and a.optlen == 18 and len(a.erpdomain) == 1 and a.erpdomain[0] == "toto.example.com."

= DHCP6OptERPDomain - Instantiation with specific values (2 domains)
raw(DHCP6OptERPDomain(erpdomain=["toto.example.com.", "titi.example.com."])) == b'\x00A\x00$\x04toto\x07example\x03com\x00\x04titi\x07example\x03com\x00'

= DHCP6OptERPDomain - Dissection with specific values (2 domains)
a = DHCP6OptERPDomain(b'\x00A\x00$\x04toto\x07example\x03com\x00\x04titi\x07example\x03com\x00')
a.optcode == 65 and a.optlen == 36 and len(a.erpdomain) == 2 and a.erpdomain[0] == "toto.example.com." and a.erpdomain[1] == "titi.example.com."


############
############
+ Test DHCP6 Option - Relay Supplied Option

= DHCP6OptRelaySuppliedOpt - Basic Instantiation
raw(DHCP6OptRelaySuppliedOpt()) == b'\x00B\x00\x00'

= DHCP6OptRelaySuppliedOpt - Basic Dissection
a = DHCP6OptRelaySuppliedOpt(b'\x00B\x00\x00')
a.optcode == 66 and a.optlen == 0 and a.relaysupplied == []

= DHCP6OptRelaySuppliedOpt - Instantiation with specific values
raw(DHCP6OptRelaySuppliedOpt(relaysupplied=DHCP6OptERPDomain(erpdomain=["toto.example.com."]))) == b'\x00B\x00\x16\x00A\x00\x12\x04toto\x07example\x03com\x00'

= DHCP6OptRelaySuppliedOpt - Dissection with specific values
a = DHCP6OptRelaySuppliedOpt(b'\x00B\x00\x16\x00A\x00\x12\x04toto\x07example\x03com\x00')
a.optcode == 66 and a.optlen == 22 and len(a.relaysupplied) == 1 and isinstance(a.relaysupplied[0], DHCP6OptERPDomain) and a.relaysupplied[0].erpdomain[0] == "toto.example.com."


############
############
+ Test DHCP6 Option Client Link Layer address

= Basic build & dissect
s = raw(DHCP6OptClientLinkLayerAddr())
assert(s == b"\x00O\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00")

p = DHCP6OptClientLinkLayerAddr(s)
assert(p.clladdr == "00:00:00:00:00:00")

r = b"\x00O\x00\x08\x00\x01\x00\x01\x02\x03\x04\x05"
p = DHCP6OptClientLinkLayerAddr(r)
assert(p.clladdr == "00:01:02:03:04:05")


############
############
+ Test DHCP6 Option MUD URL

= Basic build & dissect
s = raw(DHCP6OptMudUrl())
assert(s == b"\x00p\x00\x00")

p = DHCP6OptMudUrl(s)
assert(p.mudstring == b"")

r = b'\x00p\x00\x13https://example.org'
p = DHCP6OptMudUrl(r)
assert(p.mudstring == b"https://example.org")
assert(p.optlen == 19)


############
############
+ Test DHCP6 Option Virtual Subnet Selection

= Basic build & dissect
s = raw(DHCP6OptVSS())
assert(s == b"\x00D\x00\x01\xff")

p = DHCP6OptVSS(s)
assert(p.type == 255)


############
############
+ Test DHCP6 Messages - DHCP6_Solicit

= DHCP6_Solicit - Basic Instantiation
raw(DHCP6_Solicit()) == b'\x01\x00\x00\x00'

= DHCP6_Solicit - Basic Dissection
a = DHCP6_Solicit(b'\x01\x00\x00\x00')
a.msgtype == 1 and a.trid == 0

= DHCP6_Solicit - Basic test of DHCP6_solicit.hashret() 
DHCP6_Solicit().hashret() == b'\x00\x00\x00'

= DHCP6_Solicit - Test of DHCP6_solicit.hashret() with specific values
DHCP6_Solicit(trid=0xbbccdd).hashret() == b'\xbb\xcc\xdd'

= DHCP6_Solicit - UDP ports overload
a=UDP()/DHCP6_Solicit()
a.sport == 546 and a.dport == 547

= DHCP6_Solicit - Dispatch based on UDP port 
a=UDP(raw(UDP()/DHCP6_Solicit()))
isinstance(a.payload, DHCP6_Solicit)


############
############
+ Test DHCP6 Messages - DHCP6_Advertise

= DHCP6_Advertise - Basic Instantiation
raw(DHCP6_Advertise()) == b'\x02\x00\x00\x00'

= DHCP6_Advertise - Basic test of DHCP6_solicit.hashret() 
DHCP6_Advertise().hashret() == b'\x00\x00\x00'

= DHCP6_Advertise - Test of DHCP6_Advertise.hashret() with specific values
DHCP6_Advertise(trid=0xbbccdd).hashret() == b'\xbb\xcc\xdd'

= DHCP6_Advertise - Basic test of answers() with solicit message
a = DHCP6_Solicit()
b = DHCP6_Advertise()
a > b

= DHCP6_Advertise - Test of answers() with solicit message
a = DHCP6_Solicit(trid=0xbbccdd)
b = DHCP6_Advertise(trid=0xbbccdd)
a > b

= DHCP6_Advertise - UDP ports overload
a=UDP()/DHCP6_Advertise()
a.sport == 547 and a.dport == 546


############
############
+ Test DHCP6 Messages - DHCP6_Request

= DHCP6_Request - Basic Instantiation
raw(DHCP6_Request()) == b'\x03\x00\x00\x00'

= DHCP6_Request - Basic Dissection
a=DHCP6_Request(b'\x03\x00\x00\x00')
a.msgtype == 3 and a.trid == 0 

= DHCP6_Request - UDP ports overload
a=UDP()/DHCP6_Request()
a.sport == 546 and a.dport == 547


############
############
+ Test DHCP6 Messages - DHCP6_Confirm

= DHCP6_Confirm - Basic Instantiation
raw(DHCP6_Confirm()) == b'\x04\x00\x00\x00'

= DHCP6_Confirm - Basic Dissection
a=DHCP6_Confirm(b'\x04\x00\x00\x00')
a.msgtype == 4 and a.trid == 0

= DHCP6_Confirm - UDP ports overload
a=UDP()/DHCP6_Confirm()
a.sport == 546 and a.dport == 547


############
############
+ Test DHCP6 Messages - DHCP6_Renew

= DHCP6_Renew - Basic Instantiation
raw(DHCP6_Renew()) == b'\x05\x00\x00\x00'

= DHCP6_Renew - Basic Dissection
a=DHCP6_Renew(b'\x05\x00\x00\x00')
a.msgtype == 5 and a.trid == 0

= DHCP6_Renew - UDP ports overload
a=UDP()/DHCP6_Renew()
a.sport == 546 and a.dport == 547


############
############
+ Test DHCP6 Messages - DHCP6_Rebind

= DHCP6_Rebind - Basic Instantiation
raw(DHCP6_Rebind()) == b'\x06\x00\x00\x00'

= DHCP6_Rebind - Basic Dissection
a=DHCP6_Rebind(b'\x06\x00\x00\x00')
a.msgtype == 6 and a.trid == 0

= DHCP6_Rebind - UDP ports overload
a=UDP()/DHCP6_Rebind()
a.sport == 546 and a.dport == 547


############
############
+ Test DHCP6 Messages - DHCP6_Reply

= DHCP6_Reply - Basic Instantiation
raw(DHCP6_Reply()) == b'\x07\x00\x00\x00'

= DHCP6_Reply - Basic Dissection
a=DHCP6_Reply(b'\x07\x00\x00\x00')
a.msgtype == 7 and a.trid == 0

= DHCP6_Reply - UDP ports overload
a=UDP()/DHCP6_Reply()
a.sport == 547 and a.dport == 546

= DHCP6_Reply - Answers

assert not DHCP6_Reply(trid=0).answers(DHCP6_Request(trid=1))
assert DHCP6_Reply(trid=1).answers(DHCP6_Request(trid=1))


############
############
+ Test DHCP6 Messages - DHCP6_Release

= DHCP6_Release - Basic Instantiation
raw(DHCP6_Release()) == b'\x08\x00\x00\x00'

= DHCP6_Release - Basic Dissection
a=DHCP6_Release(b'\x08\x00\x00\x00')
a.msgtype == 8 and a.trid == 0

= DHCP6_Release - UDP ports overload
a=UDP()/DHCP6_Release()
a.sport == 546 and a.dport == 547


############
############
+ Test DHCP6 Messages - DHCP6_Decline

= DHCP6_Decline - Basic Instantiation
raw(DHCP6_Decline()) == b'\x09\x00\x00\x00'

= DHCP6_Confirm - Basic Dissection
a=DHCP6_Confirm(b'\x09\x00\x00\x00')
a.msgtype == 9 and a.trid == 0

= DHCP6_Decline - UDP ports overload
a=UDP()/DHCP6_Decline()
a.sport == 546 and a.dport == 547


############
############
+ Test DHCP6 Messages - DHCP6_Reconf

= DHCP6_Reconf - Basic Instantiation
raw(DHCP6_Reconf()) == b'\x0A\x00\x00\x00'

= DHCP6_Reconf - Basic Dissection
a=DHCP6_Reconf(b'\x0A\x00\x00\x00')
a.msgtype == 10 and a.trid == 0

= DHCP6_Reconf - UDP ports overload
a=UDP()/DHCP6_Reconf()
a.sport == 547 and a.dport == 546


############
############
+ Test DHCP6 Messages - DHCP6_InfoRequest

= DHCP6_InfoRequest - Basic Instantiation
raw(DHCP6_InfoRequest()) == b'\x0B\x00\x00\x00'

= DHCP6_InfoRequest - Basic Dissection
a=DHCP6_InfoRequest(b'\x0B\x00\x00\x00')
a.msgtype == 11 and a.trid == 0

= DHCP6_InfoRequest - UDP ports overload
a=UDP()/DHCP6_InfoRequest()
a.sport == 546 and a.dport == 547


############
############
+ Test DHCP6 Messages - DHCP6_RelayForward

= DHCP6_RelayForward - Basic Instantiation
raw(DHCP6_RelayForward()) == b'\x0c\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\x00\x00\x00\x00\x00\x00\x00'

= DHCP6_RelayForward - Basic Dissection
a=DHCP6_RelayForward(b'\x0c\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\x00\x00\x00\x00\x00\x00\x00')
a.msgtype == 12 and a.hopcount == 0 and a.linkaddr == "::" and a.peeraddr == "::"

= DHCP6_RelayForward - Dissection with options
a = DHCP6_RelayForward(b'\x0c\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\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x04\x03\x01\x00\x00')
a.msgtype == 12 and DHCP6OptRelayMsg in a and isinstance(a.message, DHCP6_Request)

= DHCP6_RelayForward - Advanced dissection
s = b'`\x00\x00\x00\x002\x11@\xfe\x80\x00\x00\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\x01\x00\x02\x02#\x02#\x002\xf0\xaf\x0c\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\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x04\x01\x00\x00\x00'
p = IPv6(s)
assert DHCP6OptRelayMsg in p and isinstance(p.message, DHCP6_Solicit)


############
############
+ Test DHCP6 Messages - DHCP6OptRelayMsg

= DHCP6OptRelayMsg - Basic Instantiation
raw(DHCP6OptRelayMsg(optcode=37)) == b'\x00%\x00\x04\x00\x00\x00\x00'

= DHCP6OptRelayMsg - Basic Dissection
a = DHCP6OptRelayMsg(b'\x00\r\x00\x00')
a.optcode == 13 and a.optlen == 0 and isinstance(a.message, DHCP6)

= DHCP6OptRelayMsg - Embedded DHCP6 packet Instantiation
raw(DHCP6OptRelayMsg(message=DHCP6_Solicit())) == b'\x00\t\x00\x04\x01\x00\x00\x00'

= DHCP6OptRelayMsg - Embedded DHCP6 packet Dissection
p = DHCP6OptRelayMsg(b'\x00\t\x00\x04\x01\x00\x00\x00')
isinstance(p.message, DHCP6_Solicit)


############
############
+ Test DHCP6 Messages - DHCP6_RelayReply

= DHCP6_RelayReply - Basic Instantiation
raw(DHCP6_RelayReply()) == b'\r\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\x00\x00\x00\x00\x00\x00\x00'

= DHCP6_RelayReply - Basic Dissection
a=DHCP6_RelayReply(b'\r\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\x00\x00\x00\x00\x00\x00\x00')
a.msgtype == 13 and a.hopcount == 0 and a.linkaddr == "::" and a.peeraddr == "::"


