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

= 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
ngkokkee's avatar
ngkokkee committed
str(DHCP6OptIAPrefix()) == '\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'
Phil's avatar
Phil committed

#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)
p = IPv6(s)
p[ICMPv6MPAdv].type == 147 and p[ICMPv6MPAdv].cksum == 0xe8d6 and p[ICMPv6NDOptPrefixInfo].prefix == '::'

= ICMPv6MPAdv - build
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(\x07\x00*@\x00\x03\x04\x00@\xff\xff\xff\xff\x00\x00\x00\x0c\x00\x00\x00\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'
str(IPv6()/ICMPv6MPAdv(cksum=0x2807, flags=1, id=42)/ICMPv6NDOptPrefixInfo(prefix='2001:db8::1', L=0, preferredlifetime=12)) == s

= ICMPv6MPAdv - dissection
p = IPv6(s)
p[ICMPv6MPAdv].cksum == 0x2807 and p[ICMPv6MPAdv].flags == 1 and p[ICMPv6MPAdv].id == 42 and p[ICMPv6NDOptPrefixInfo].prefix == '2001:db8::1' and p[ICMPv6NDOptPrefixInfo].preferredlifetime == 12

Phil's avatar
Phil committed
+ Type 2 Routing Header

= IPv6ExtHdrRouting - type 2 - build/dissection
p = IPv6(str(IPv6(dst='2001:db8::1', src='2001:db8::2')/IPv6ExtHdrRouting(type=2, addresses=['2001:db8::3'])/ICMPv6EchoRequest()))
p.type == 2 and len(p.addresses) == 1 and p.cksum == 0x2446

Phil's avatar
Phil committed
+ Mobility Options - Binding Refresh Advice

= MIP6OptBRAdvice - build (default values)
s = '\x02\x02\x00\x00'
str(MIP6OptBRAdvice()) == s

= MIP6OptBRAdvice - dissection (default values)
p = MIP6OptBRAdvice(s)
p.otype == 2 and p.olen == 2 and p.rinter == 0

= MIP6OptBRAdvice - build
s = '\x03*\n\xf7'
str(MIP6OptBRAdvice(otype=3, olen=42, rinter=2807)) == s

= MIP6OptBRAdvice - dissection
p = MIP6OptBRAdvice(s)
p.otype == 3 and p.olen == 42 and p.rinter == 2807

Phil's avatar
Phil committed
+ Mobility Options - Alternate Care-of Address

= MIP6OptAltCoA - build (default values)
s = '\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
str(MIP6OptAltCoA()) == s

= MIP6OptAltCoA - dissection (default values)
p = MIP6OptAltCoA(s)
p.otype == 3 and p.olen == 16 and p.acoa == '::'

= MIP6OptAltCoA - build
s = '*\x08 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'
str(MIP6OptAltCoA(otype=42, olen=8, acoa='2001:db8::1')) == s

= MIP6OptAltCoA - dissection
p = MIP6OptAltCoA(s)
p.otype == 42 and p.olen == 8 and p.acoa == '2001:db8::1'

Phil's avatar
Phil committed
+ Mobility Options - Nonce Indices

= MIP6OptNonceIndices - build (default values)
s = '\x04\x10\x00\x00\x00\x00'
str(MIP6OptNonceIndices()) == s

= MIP6OptNonceIndices - dissection (default values)
p = MIP6OptNonceIndices(s)
p.otype == 4 and p.olen == 16 and p.hni == 0 and p.coni == 0

= MIP6OptNonceIndices - build
s = '\x04\x12\x00\x13\x00\x14'
str(MIP6OptNonceIndices(olen=18, hni=19, coni=20)) == s

= MIP6OptNonceIndices - dissection
p = MIP6OptNonceIndices(s)
p.hni == 19 and p.coni == 20

Phil's avatar
Phil committed
+ Mobility Options - Binding Authentication Data

= MIP6OptBindingAuthData - build (default values)
s = '\x05\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
str(MIP6OptBindingAuthData()) == s

= MIP6OptBindingAuthData - dissection (default values)
p = MIP6OptBindingAuthData(s)
p.otype == 5 and p.olen == 16 and p.authenticator == 0

= MIP6OptBindingAuthData - build
s = '\x05*\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\xf7'
str(MIP6OptBindingAuthData(olen=42, authenticator=2807)) == s

= MIP6OptBindingAuthData - dissection
p = MIP6OptBindingAuthData(s)
p.otype == 5 and p.olen == 42 and p.authenticator == 2807

Phil's avatar
Phil committed
+ Mobility Options - Mobile Network Prefix

= MIP6OptMobNetPrefix - build (default values)
s = '\x06\x12\x00@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
str(MIP6OptMobNetPrefix()) == s

= MIP6OptMobNetPrefix - dissection (default values)
p = MIP6OptMobNetPrefix(s)
p.otype == 6 and p.olen == 18 and p.plen == 64 and p.prefix == '::'

= MIP6OptMobNetPrefix - build
s = '\x06*\x02  \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
str(MIP6OptMobNetPrefix(olen=42, reserved=2, plen=32, prefix='2001:db8::')) == s

= MIP6OptMobNetPrefix - dissection
p = MIP6OptMobNetPrefix(s)
p.olen ==  42 and p.reserved  == 2 and p.plen == 32 and p.prefix == '2001:db8::'

Phil's avatar
Phil committed
+ Mobility Options - Link-Layer Address (MH-LLA)

= MIP6OptLLAddr - basic build
str(MIP6OptLLAddr()) == '\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00'

= MIP6OptLLAddr - basic dissection
p = MIP6OptLLAddr('\x07\x07\x02\x00\x00\x00\x00\x00\x00\x00')
p.otype == 7 and p.olen == 7 and p.ocode == 2 and p.pad == 0 and p.lla == "00:00:00:00:00:00"

= MIP6OptLLAddr - build with specific values
str(MIP6OptLLAddr(olen=42, ocode=4, pad=0xff, lla='EE:EE:EE:EE:EE:EE')) == '\x07*\x04\xff\xee\xee\xee\xee\xee\xee'

= MIP6OptLLAddr - dissection with specific values
p = MIP6OptLLAddr('\x07*\x04\xff\xee\xee\xee\xee\xee\xee')

str(MIP6OptLLAddr(olen=42, ocode=4, pad=0xff, lla='EE:EE:EE:EE:EE:EE'))
p.otype == 7 and p.olen == 42 and p.ocode == 4 and p.pad == 0xff and p.lla == "ee:ee:ee:ee:ee:ee"

Phil's avatar
Phil committed
+ Mobility Options - Mobile Node Identifier

= MIP6OptMNID - basic build
str(MIP6OptMNID()) == '\x08\x01\x01'

= MIP6OptMNID - basic dissection
p = MIP6OptMNID('\x08\x01\x01')
p.otype == 8 and p.olen == 1 and p.subtype == 1 and p.id == ""

= MIP6OptMNID - build with specific values
str(MIP6OptMNID(subtype=42, id="someid")) == '\x08\x07*someid'

= MIP6OptMNID - dissection with specific values
p = MIP6OptMNID('\x08\x07*someid')
p.otype == 8 and p.olen == 7 and p.subtype == 42 and p.id == "someid"


Phil's avatar
Phil committed
+ Mobility Options - Message Authentication

= MIP6OptMsgAuth - basic build
str(MIP6OptMsgAuth()) == '\x09\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA'

= MIP6OptMsgAuth - basic dissection
p = MIP6OptMsgAuth('\x09\x11\x01\x00\x00\x00\x00AAAAAAAAAAAA')
p.otype == 9 and p.olen == 17 and p.subtype == 1 and p.mspi == 0 and p.authdata == "A"*12

= MIP6OptMsgAuth - build with specific values
str(MIP6OptMsgAuth(authdata="B"*16, mspi=0xeeeeeeee, subtype=0xff)) == '\t\x15\xff\xee\xee\xee\xeeBBBBBBBBBBBBBBBB'

= MIP6OptMsgAuth - dissection with specific values
p = MIP6OptMsgAuth('\t\x15\xff\xee\xee\xee\xeeBBBBBBBBBBBBBBBB')
p.otype == 9 and p.olen == 21 and p.subtype == 255 and p.mspi == 0xeeeeeeee and p.authdata == "B"*16