diff --git a/scapy/contrib/mpls.uts b/scapy/contrib/mpls.uts new file mode 100644 index 0000000000000000000000000000000000000000..6057b67a3d4d75d18234891318570407646edbd0 --- /dev/null +++ b/scapy/contrib/mpls.uts @@ -0,0 +1,21 @@ +# MPLS unit tests +# +# Type the following command to launch start the tests: +# $ test/run_tests -P "load_contrib('mpls')" -t scapy/contrib/mpls.uts + ++ MPLS + += Build & dissect - IPv4 +s = str(Ether(src="00:01:02:04:05")/MPLS()/IP()) +assert(s == b'\xff\xff\xff\xff\xff\xff\x00\x01\x02\x04\x05\x00\x88G\x00\x001\x00E\x00\x00\x14\x00\x01\x00\x00@\x00|\xe7\x7f\x00\x00\x01\x7f\x00\x00\x01') + +p = Ether(s) +assert(MPLS in p and IP in p) + + += Build & dissect - IPv6 +s = str(Ether(src="00:01:02:04:05")/MPLS(s=0)/MPLS()/IPv6()) +assert(s == b'\xff\xff\xff\xff\xff\xff\x00\x01\x02\x04\x05\x00\x88G\x00\x000\x00\x00\x001\x00`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01') + +p = Ether(s) +assert(IPv6 in p and isinstance(p[MPLS].payload, MPLS)) diff --git a/scapy/layers/dhcp6.py b/scapy/layers/dhcp6.py index 36df846b4485ae6df5b85e42a96fce06f85f5980..59dc36a975c0b19f0fd70f87a2b3e4a367e8a597 100644 --- a/scapy/layers/dhcp6.py +++ b/scapy/layers/dhcp6.py @@ -845,7 +845,7 @@ class DHCP6OptRelayAgentERO(_DHCP6OptGuessPayload): # RFC4994 # "Client link-layer address type. The link-layer type MUST be a valid hardware # type assigned by the IANA, as described in [RFC0826] -class DHCP6OptClientLinkLayerAddr(_DHCP6OptGuessPayload): #RFC6939 +class DHCP6OptClientLinkLayerAddr(_DHCP6OptGuessPayload): # RFC6939 name = "DHCP6 Option - Client Link Layer address" fields_desc = [ ShortEnumField("optcode", 79, dhcp6opts), FieldLenField("optlen", None, length_of="clladdr", @@ -854,7 +854,7 @@ class DHCP6OptClientLinkLayerAddr(_DHCP6OptGuessPayload): #RFC6939 _LLAddrField("clladdr", ETHER_ANY) ] # Virtual Subnet selection -class DHCP6OptVSS(_DHCP6OptGuessPayload): #RFC6607 +class DHCP6OptVSS(_DHCP6OptGuessPayload): # RFC6607 name = "DHCP6 Option - Virtual Subnet Selection" fields_desc = [ ShortEnumField("optcode", 68, dhcp6opts), FieldLenField("optlen", None, length_of="data", @@ -863,6 +863,7 @@ class DHCP6OptVSS(_DHCP6OptGuessPayload): #RFC6607 StrLenField("data", "", length_from = lambda pkt: pkt.optlen) ] + ##################################################################### ### DHCPv6 messages ### ##################################################################### diff --git a/test/regression.uts b/test/regression.uts index be34b65d2007895cff9fd3d51c255c7182b7bcb5..27bc8b958a4513043df6943ffe4d516e273b40d0 100644 --- a/test/regression.uts +++ b/test/regression.uts @@ -1175,6 +1175,13 @@ str(Ether(src="00:00:00:00:00:00", dst="ff:ff:ff:ff:ff:ff")/IPv6()/TCP()) == b'\ a=Ether(str(Ether()/IPv6()/TCP())) a.type == 0x86dd += IPv6 Class binding with GRE - build +str(IP()/GRE()/Ether()/IP()/GRE()/IPv6()) == b'E\x00\x00f\x00\x01\x00\x00@/|f\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x00eX\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x08\x00E\x00\x00@\x00\x01\x00\x00@/|\x8c\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x00\x86\xdd`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' + += IPv6 Class binding with GRE - dissection +p = IP(str(IP()/GRE()/Ether()/IP()/GRE()/IPv6())) +GRE in p and p[GRE:1].proto == 0x6558 and p[GRE:2].proto == 0x86DD and IPv6 in p + ########### IPv6ExtHdrRouting Class ########################### @@ -3861,6 +3868,30 @@ 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 Client Link Layer address + += Basic build & dissect +s = str(DHCP6OptClientLinkLayerAddr()) +assert(s == b"\x00O\x00\x07\x00\x01\x00\x00\x00\x00\x00\x00") + +p = DHCP6OptClientLinkLayerAddr(s) +assert(p.clladdr == "00:00:00:00:00:00") + + +############ +############ ++ Test DHCP6 Option Virtual Subnet Selection + += Basic build & dissect +s = str(DHCP6OptVSS()) +assert(s == b"\x00D\x00\x01\xff") + +p = DHCP6OptVSS(s) +assert(p.type == 255) + + ############ ############ + Test DHCP6 Messages - DHCP6_Solicit