34 lines
1 KiB
Text
34 lines
1 KiB
Text
|
# 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
|
||
|
if WINDOWS:
|
||
|
route_add_loopback()
|
||
|
|
||
|
s = raw(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\x00\x01\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 = raw(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\x00!\x00`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
|
||
|
|
||
|
p = Ether(s)
|
||
|
assert(IPv6 in p and isinstance(p[MPLS].payload, MPLS))
|
||
|
|
||
|
= Association on IP and IPv6
|
||
|
p = IP()/MPLS()
|
||
|
p = IP(raw(p))
|
||
|
assert p[IP].proto == 137
|
||
|
|
||
|
p2 = IPv6()/MPLS()
|
||
|
p2 = IPv6(raw(p2))
|
||
|
assert p2[IPv6].nh == 137
|