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 9 if WINDOWS: 10 route_add_loopback() 11 12 s = raw(Ether(src="00:01:02:04:05")/MPLS()/IP()) 13 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') 14 15 p = Ether(s) 16 assert(MPLS in p and IP in p) 17 18 19 = Build & dissect - IPv6 20 s = raw(Ether(src="00:01:02:04:05")/MPLS(s=0)/MPLS()/IPv6()) 21 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') 22 23 p = Ether(s) 24 assert(IPv6 in p and isinstance(p[MPLS].payload, MPLS)) 25