Skip to content
Snippets Groups Projects
regression.uts 317 KiB
Newer Older
Phil's avatar
Phil committed

= DHCP6OptServerId dissection with specific DUID_LL as duid value
a=DHCP6OptServerId('\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('\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('\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 == ""

Phil's avatar
Phil committed
+ Test DHCP6 IA Address Option (IA_TA or IA_NA suboption)

= DHCP6OptIAAddress - Basic Instantiation
str(DHCP6OptIAAddress()) == '\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'
Phil's avatar
Phil committed

= DHCP6OptIAAddress - Basic Dissection
a = DHCP6OptIAAddress('\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 == ""
Phil's avatar
Phil committed

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

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

= DHCP6OptIAAddress - Dissection with specific values 
a = DHCP6OptIAAddress('\x00\x05\x00"""33\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00UUffffwwwwsomestring')
a.optcode == 5 and a.optlen == 34 and a.addr == "2222:3333::5555" and a.preflft == 0x66666666 and a. validlft == 0x77777777 and a.iaaddropts == "somestring"
Phil's avatar
Phil committed
+ Test DHCP6 Identity Association for Non-temporary Addresses Option

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

= DHCP6OptIA_NA - Basic Dissection
a = DHCP6OptIA_NA('\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) 
str(DHCP6OptIA_NA(iaid=0x22222222, T1=0x33333333, T2=0x44444444)) == '\x00\x03\x00\x0c""""3333DDDD'

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

= DHCP6OptIA_NA - Instantiation with a list of IA Addresses (optlen automatic computation)
str(DHCP6OptIA_NA(iaid=0x22222222, T1=0x33333333, T2=0x44444444, ianaopts=[DHCP6OptIAAddress(), DHCP6OptIAAddress()])) == '\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'
Phil's avatar
Phil committed

= DHCP6OptIA_NA - Dissection with specific values
a = DHCP6OptIA_NA('\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')
Phil's avatar
Phil committed
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)


Phil's avatar
Phil committed
+ Test DHCP6 Identity Association for Temporary Addresses Option

= DHCP6OptIA_TA - Basic Instantiation
str(DHCP6OptIA_TA()) == '\x00\x04\x00\x04\x00\x00\x00\x00'

= DHCP6OptIA_TA - Basic Dissection
a = DHCP6OptIA_TA('\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
str(DHCP6OptIA_TA(optlen=0x1111, iaid=0x22222222, iataopts=[DHCP6OptIAAddress(), DHCP6OptIAAddress()])) == '\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'
Phil's avatar
Phil committed

= DHCP6OptIA_TA - Dissection with specific values
a = DHCP6OptIA_TA('\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')
Phil's avatar
Phil committed
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)


Phil's avatar
Phil committed
+ Test DHCP6 Option Request Option

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

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

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

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

= DHCP6OptOptReq - Dissection with specific value
a=DHCP6OptOptReq('\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]


Phil's avatar
Phil committed
+ Test DHCP6 Option - Preference option

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

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

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

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - Elapsed Time

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

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

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

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - Server Unicast Address

= DHCP6OptServerUnicast - Basic Instantiation
str(DHCP6OptServerUnicast()) == '\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)
str(DHCP6OptServerUnicast(srvaddr="2001::1")) == '\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)
str(DHCP6OptServerUnicast(srvaddr="2001::1", optlen=42)) == '\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('\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('\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('\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"


Phil's avatar
Phil committed
+ Test DHCP6 Option - Status Code

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

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

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

# Add tests to verify Unicode behavior


Phil's avatar
Phil committed
+ Test DHCP6 Option - Rapid Commit

= DHCP6OptRapidCommit - Basic Instantiation
str(DHCP6OptRapidCommit()) == '\x00\x0e\x00\x00'

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - User class

= DHCP6OptUserClass - Basic Instantiation
str(DHCP6OptUserClass()) == '\x00\x0f\x00\x00'

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

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

= DHCP6OptUserClass - Dissection with one user class data structure
a = DHCP6OptUserClass('\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 == 'something'

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

= DHCP6OptUserClass - Dissection with two user class data structures
a = DHCP6OptUserClass('\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 == 'something' and a.userclassdata[1].len == 13 and a.userclassdata[1].data == 'somethingelse'


Phil's avatar
Phil committed
+ Test DHCP6 Option - Vendor class

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

= DHCP6OptVendorClass - Basic Dissection
a = DHCP6OptVendorClass('\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 structure
str(DHCP6OptVendorClass(vcdata=[VENDOR_CLASS_DATA(data="something")])) == '\x00\x10\x00\x0f\x00\x00\x00\x00\x00\tsomething'

= DHCP6OptVendorClass - Dissection with one vendor class data structure
a = DHCP6OptVendorClass('\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 == 'something'

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

= DHCP6OptVendorClass - Dissection with two vendor class data structures
a = DHCP6OptVendorClass('\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 == 'something' and a.vcdata[1].len == 13 and a.vcdata[1].data == 'somethingelse'


Phil's avatar
Phil committed
+ Test DHCP6 Option - Vendor-specific information

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

= DHCP6OptVendorSpecificInfo - Basic Dissection
a = DHCP6OptVendorSpecificInfo('\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)
str(DHCP6OptVendorSpecificInfo(enterprisenum=0xeeeeeeee, vso=[VENDOR_SPECIFIC_OPTION(optcode=43, optdata="something")])) == '\x00\x11\x00\x11\xee\xee\xee\xee\x00+\x00\tsomething'

= DHCP6OptVendorSpecificInfo - Dissection with with specific values (one option)
a = DHCP6OptVendorSpecificInfo('\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 == 'something'

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

= DHCP6OptVendorSpecificInfo - Dissection with with specific values (two options)
a = DHCP6OptVendorSpecificInfo('\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 == 'something' and a.vso[1].optlen == 13 and a.vso[1].optdata == 'somethingelse'


Phil's avatar
Phil committed
+ Test DHCP6 Option - Interface-Id 

= DHCP6OptIfaceId - Basic Instantiation
str(DHCP6OptIfaceId()) == '\x00\x12\x00\x00'

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

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

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - Reconfigure Message

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

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

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

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - Reconfigure Accept

= DHCP6OptReconfAccept - Basic Instantiation
str(DHCP6OptReconfAccept()) == '\x00\x14\x00\x00'

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

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

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - SIP Servers Domain Name List

= DHCP6OptSIPDomains - Basic Instantiation
str(DHCP6OptSIPDomains()) == '\x00\x15\x00\x00'

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

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

= DHCP6OptSIPDomains - Dissection with one domain
a = DHCP6OptSIPDomains('\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."
Phil's avatar
Phil committed

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

= DHCP6OptSIPDomains - Dissection with two domains
a = DHCP6OptSIPDomains('\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."
Phil's avatar
Phil committed

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - SIP Servers IPv6 Address List

= DHCP6OptSIPServers - Basic Instantiation
str(DHCP6OptSIPServers()) == '\x00\x16\x00\x00'

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

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - DNS Recursive Name Server

= DHCP6OptDNSServers - Basic Instantiation
str(DHCP6OptDNSServers()) == '\x00\x17\x00\x00'

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

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - DNS Domain Search List Option

= DHCP6OptDNSDomains - Basic Instantiation
str(DHCP6OptDNSDomains()) == '\x00\x18\x00\x00'

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

= DHCP6OptDNSDomains - Instantiation with specific values (1 domain) 
str(DHCP6OptDNSDomains(dnsdomains=["toto.example.com."])) == '\x00\x18\x00\x12\x04toto\x07example\x03com\x00'
Phil's avatar
Phil committed

= DHCP6OptDNSDomains - Dissection with specific values (1 domain) 
a = DHCP6OptDNSDomains('\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."
Phil's avatar
Phil committed

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

= DHCP6OptDNSDomains - Dissection with specific values (2 domains) 
a = DHCP6OptDNSDomains('\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."
Phil's avatar
Phil committed
+ Test DHCP6 Option - IA_PD Prefix Option

= DHCP6OptIAPrefix - Basic Instantiation
str(DHCP6OptIAPrefix()) == '\x00\x1a\x00\x1a\x00\x00\x00\x00\x00\x00\x00\x000 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

#TODO : finish me

Phil's avatar
Phil committed
+ Test DHCP6 Option - Identity Association for Prefix Delegation

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

#TODO : finish me

Phil's avatar
Phil committed
+ Test DHCP6 Option - NIS Servers

= DHCP6OptNISServers - Basic Instantiation
str(DHCP6OptNISServers()) == '\x00\x1b\x00\x00'

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

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

Phil's avatar
Phil committed
+ Test DHCP6 Option - NIS+ Servers

= DHCP6OptNISPServers - Basic Instantiation
str(DHCP6OptNISPServers()) == '\x00\x1c\x00\x00'

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

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

Phil's avatar
Phil committed
+ Test DHCP6 Option - NIS Domain Name

= DHCP6OptNISDomain - Basic Instantiation
str(DHCP6OptNISDomain()) == '\x00\x1d\x00\x00'

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

= DHCP6OptNISDomain - Instantiation with one domain name
Guillaume Valadon's avatar
Guillaume Valadon committed
str(DHCP6OptNISDomain(nisdomain="toto.example.org")) == '\x00\x1d\x00\x11\x04toto\x07example\x03org'
Phil's avatar
Phil committed

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

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - NIS+ Domain Name

= DHCP6OptNISPDomain - Basic Instantiation
str(DHCP6OptNISPDomain()) == '\x00\x1e\x00\x00'

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

= DHCP6OptNISPDomain - Instantiation with one domain name
Guillaume Valadon's avatar
Guillaume Valadon committed
str(DHCP6OptNISPDomain(nispdomain="toto.example.org")) == '\x00\x1e\x00\x11\x04toto\x07example\x03org'
Phil's avatar
Phil committed

= DHCP6OptNISPDomain - Dissection with one domain name
Guillaume Valadon's avatar
Guillaume Valadon committed
a = DHCP6OptNISPDomain('\x00\x1e\x00\x11\x04toto\x07example\x03org\x00')
a.optcode == 30 and a.optlen == 17 and a.nispdomain == "toto.example.org"
Phil's avatar
Phil committed

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - SNTP Servers

= DHCP6OptSNTPServers - Basic Instantiation
str(DHCP6OptSNTPServers()) == '\x00\x1f\x00\x00'

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

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

Phil's avatar
Phil committed
+ Test DHCP6 Option - Information Refresh Time

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

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

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

Phil's avatar
Phil committed
+ Test DHCP6 Option - BCMCS Servers

= DHCP6OptBCMCSServers - Basic Instantiation
str(DHCP6OptBCMCSServers()) == '\x00"\x00\x00'

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

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

Phil's avatar
Phil committed
+ Test DHCP6 Option - BCMCS Domains

= DHCP6OptBCMCSDomains - Basic Instantiation
str(DHCP6OptBCMCSDomains()) == '\x00!\x00\x00'

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

= DHCP6OptBCMCSDomains - Instantiation with specific values (1 domain) 
str(DHCP6OptBCMCSDomains(bcmcsdomains=["toto.example.com."])) == '\x00!\x00\x12\x04toto\x07example\x03com\x00'
Phil's avatar
Phil committed

= DHCP6OptBCMCSDomains - Dissection with specific values (1 domain) 
a = DHCP6OptBCMCSDomains('\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."
Phil's avatar
Phil committed

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

= DHCP6OptBCMCSDomains - Dissection with specific values (2 domains) 
a = DHCP6OptBCMCSDomains('\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."
Phil's avatar
Phil committed

Phil's avatar
Phil committed
+ Test DHCP6 Option - Relay Agent Remote-ID

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

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

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

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

Phil's avatar
Phil committed
+ Test DHCP6 Option - Subscriber ID

= DHCP6OptSubscriberID - Basic Instantiation
str(DHCP6OptSubscriberID()) == '\x00&\x00\x00'

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

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

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


Phil's avatar
Phil committed
+ Test DHCP6 Option - Client FQDN

= DHCP6OptClientFQDN - Basic Instantiation
str(DHCP6OptClientFQDN()) == "\x00'\x00\x01\x00"

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

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

= DHCP6OptClientFQDN - Instantiation with one fqdn 
Guillaume Valadon's avatar
Guillaume Valadon committed
str(DHCP6OptClientFQDN(fqdn="toto.example.org")) == "\x00'\x00\x12\x00\x04toto\x07example\x03org"
Phil's avatar
Phil committed

= DHCP6OptClientFQDN - Dissection with one fqdn 
Guillaume Valadon's avatar
Guillaume Valadon committed
a = DHCP6OptClientFQDN("\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 == "toto.example.org"
Phil's avatar
Phil committed
+ Test DHCP6 Option Relay Agent Echo Request Option

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

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

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

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

= DHCP6OptRelayAgentERO - Dissection with specific value
a=DHCP6OptRelayAgentERO('\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]


Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_Solicit

= DHCP6_Solicit - Basic Instantiation
str(DHCP6_Solicit()) == '\x01\x00\x00\x00'

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

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

= DHCP6_Solicit - Test of DHCP6_solicit.hashret() with specific values
DHCP6_Solicit(trid=0xbbccdd).hashret() == '\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(str(UDP()/DHCP6_Solicit()))
isinstance(a.payload, DHCP6_Solicit)


Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_Advertise

= DHCP6_Advertise - Basic Instantiation
str(DHCP6_Advertise()) == '\x02\x00\x00\x00'

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

= DHCP6_Advertise - Test of DHCP6_Advertise.hashret() with specific values
DHCP6_Advertise(trid=0xbbccdd).hashret() == '\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

Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_Request

= DHCP6_Request - Basic Instantiation
str(DHCP6_Request()) == '\x03\x00\x00\x00'

= DHCP6_Request - Basic Dissection
a=DHCP6_Request('\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

Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_Confirm

= DHCP6_Confirm - Basic Instantiation
str(DHCP6_Confirm()) == '\x04\x00\x00\x00'

= DHCP6_Confirm - Basic Dissection
a=DHCP6_Confirm('\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

Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_Renew

= DHCP6_Renew - Basic Instantiation
str(DHCP6_Renew()) == '\x05\x00\x00\x00'

= DHCP6_Renew - Basic Dissection
a=DHCP6_Renew('\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

Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_Rebind

= DHCP6_Rebind - Basic Instantiation
str(DHCP6_Rebind()) == '\x06\x00\x00\x00'

= DHCP6_Rebind - Basic Dissection
a=DHCP6_Rebind('\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

Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_Reply

= DHCP6_Reply - Basic Instantiation
str(DHCP6_Reply()) == '\x07\x00\x00\x00'

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

= DHCP6_Reply - UDP ports overload
a=UDP()/DHCP6_Reply()
Guillaume Valadon's avatar
Guillaume Valadon committed
a.sport == 547 and a.dport == 546
Phil's avatar
Phil committed

Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_Release

= DHCP6_Release - Basic Instantiation
str(DHCP6_Release()) == '\x08\x00\x00\x00'

= DHCP6_Release - Basic Dissection
a=DHCP6_Release('\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

Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_Decline

= DHCP6_Decline - Basic Instantiation
str(DHCP6_Decline()) == '\x09\x00\x00\x00'

= DHCP6_Confirm - Basic Dissection
a=DHCP6_Confirm('\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

Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_Reconf

= DHCP6_Reconf - Basic Instantiation
str(DHCP6_Reconf()) == '\x0A\x00\x00\x00'

= DHCP6_Reconf - Basic Dissection
a=DHCP6_Reconf('\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

Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_InfoRequest

= DHCP6_InfoRequest - Basic Instantiation
str(DHCP6_InfoRequest()) == '\x0B\x00\x00\x00'

= DHCP6_InfoRequest - Basic Dissection
a=DHCP6_InfoRequest('\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

Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_RelayForward

= DHCP6_RelayForward - Basic Instantiation
str(DHCP6_RelayForward()) == '\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('\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('\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\x00\x01\x00\x00')
a.msgtype == 12 and DHCP6OptRelayMsg in a and DHCP6OptClientId in a


Phil's avatar
Phil committed
+ Test DHCP6 Messages - DHCP6_RelayReply

= DHCP6_RelayReply - Basic Instantiation
str(DHCP6_RelayReply()) == '\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('\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 == "::"


Phil's avatar
Phil committed
+ Home Agent Address Discovery

= in6_getha()
in6_getha('2001:db8::') == '2001:db8::fdff:ffff:ffff:fffe'

= ICMPv6HAADRequest - build/dissection
p = IPv6(str(IPv6(dst=in6_getha('2001:db8::'), src='2001:db8::1')/ICMPv6HAADRequest(id=42)))
p.cksum == 0x9620 and p.dst == '2001:db8::fdff:ffff:ffff:fffe' and p.R == 1

= ICMPv6HAADReply - build/dissection
p = IPv6(str(IPv6(dst='2001:db8::1', src='2001:db8::42')/ICMPv6HAADReply(id=42, addresses=['2001:db8::2', '2001:db8::3'])))
p.cksum = 0x3747 and p.addresses == [ '2001:db8::2', '2001:db8::3' ]

= ICMPv6HAADRequest / ICMPv6HAADReply - build/dissection
a=ICMPv6HAADRequest(id=42) 
b=ICMPv6HAADReply(id=42)
not a < b and a > b

Phil's avatar
Phil committed
+ Mobile Prefix Solicitation/Advertisement

= ICMPv6MPSol - build (default values)
if WINDOWS:
    route_add_loopback()

Phil's avatar
Phil committed
s = '`\x00\x00\x00\x00\x08:@\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\x92\x00m\xbb\x00\x00\x00\x00'
str(IPv6()/ICMPv6MPSol()) == s

= ICMPv6MPSol - dissection (default values)
p = IPv6(s)
p[ICMPv6MPSol].type == 146 and p[ICMPv6MPSol].cksum == 0x6dbb and p[ICMPv6MPSol].id == 0

= ICMPv6MPSol - build
s = '`\x00\x00\x00\x00\x08:@\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\x92\x00(\x08\x00\x08\x00\x00'
str(IPv6()/ICMPv6MPSol(cksum=0x2808, id=8)) == s

= ICMPv6MPSol - dissection
p = IPv6(s)
p[ICMPv6MPSol].cksum == 0x2808 and p[ICMPv6MPSol].id == 8

= ICMPv6MPAdv - build (default values)
s = '`\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\x93\x00\xe8\xd6\x00\x00\x80\x00\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'
str(IPv6()/ICMPv6MPAdv()/ICMPv6NDOptPrefixInfo()) == s

= ICMPv6MPAdv - dissection (default values)