File: mpls.uts

package info (click to toggle)
scapy 2.6.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,956 kB
  • sloc: python: 163,618; sh: 90; makefile: 11
file content (31 lines) | stat: -rw-r--r-- 984 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# MPLS unit tests
#
# Type the following command to launch start the tests:
# $ test/run_tests -P "load_contrib('mpls')" -t test/contrib/mpls.uts

+ MPLS

= Build & dissect - IPv4

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