Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 1 | diff --git a/scapy/contrib/bier.py b/scapy/contrib/bier.py |
| 2 | new file mode 100644 |
| 3 | index 0000000..e173cdb |
| 4 | --- /dev/null |
| 5 | +++ b/scapy/contrib/bier.py |
| 6 | @@ -0,0 +1,39 @@ |
| 7 | +# http://trac.secdev.org/scapy/ticket/31 |
| 8 | + |
| 9 | +# scapy.contrib.description = MPLS |
| 10 | +# scapy.contrib.status = loads |
| 11 | + |
| 12 | +from scapy.packet import * |
| 13 | +from scapy.fields import * |
| 14 | +from scapy.layers.inet import IP |
| 15 | +from scapy.layers.inet6 import IPv6 |
| 16 | + |
| 17 | +class BIERLength: |
| 18 | + BIER_LEN_64 = 0 |
| 19 | + BIER_LEN_128 = 1 |
| 20 | + BIER_LEN_256 = 2 |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +BIERnhcls = { 1: "MPLS", |
| 25 | + 2: "MPLS", |
| 26 | + 4: "IPv4", |
| 27 | + 5: "IPv6" } |
| 28 | + |
| 29 | +class BIER(Packet): |
| 30 | + name = "BIER" |
| 31 | + fields_desc = [ BitField("id", 5, 4), |
| 32 | + BitField("version", 0, 4), |
| 33 | + BitField("length", 0, 4), |
| 34 | + BitField("entropy", 0, 20), |
| 35 | + BitField("OAM", 0, 2), |
| 36 | + BitField("RSV", 0, 2), |
| 37 | + BitField("DSCP", 0, 6), |
| 38 | + BitEnumField("Proto", 2, 6, BIERnhcls), |
| 39 | + ShortField("BFRID", 0), |
| 40 | + StrFixedLenField("BitString", |
| 41 | + chr(255)*32, 32) ] |
| 42 | + |
| 43 | + |
| 44 | +bind_layers(BIER, IP, Proto=4) |
| 45 | +bind_layers(BIER, IPv6, Proto=5) |