1# MPLS unit tests 2# 3# Type the following command to launch start the tests: 4# $ test/run_tests -P "load_contrib('mpls')" -t scapy/contrib/mpls.uts 5 6+ MPLS 7 8= Build & dissect - IPv4 9if WINDOWS: 10 route_add_loopback() 11 12s = raw(Ether(src="00:01:02:04:05")/MPLS()/IP()) 13assert(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') 14 15p = Ether(s) 16assert(MPLS in p and IP in p) 17 18 19= Build & dissect - IPv6 20s = raw(Ether(src="00:01:02:04:05")/MPLS(s=0)/MPLS()/IPv6()) 21assert(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') 22 23p = Ether(s) 24assert(IPv6 in p and isinstance(p[MPLS].payload, MPLS)) 25