Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1 | diff --git a/scapy/contrib/mpls.py b/scapy/contrib/mpls.py |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 2 | index 640a0c5..944723a 100644 |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 3 | --- a/scapy/contrib/mpls.py |
| 4 | +++ b/scapy/contrib/mpls.py |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 5 | @@ -6,6 +6,7 @@ |
| 6 | from scapy.packet import Packet, bind_layers, Padding |
| 7 | from scapy.fields import BitField,ByteField |
| 8 | from scapy.layers.inet import IP |
| 9 | +from scapy.contrib.bier import BIER |
| 10 | from scapy.layers.inet6 import IPv6 |
| 11 | from scapy.layers.l2 import Ether, GRE |
| 12 | |
| 13 | @@ -17,9 +18,12 @@ class MPLS(Packet): |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 14 | |
| 15 | def guess_payload_class(self, payload): |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 16 | - if len(payload) >= 1: |
| 17 | - ip_version = (ord(payload[0]) >> 4) & 0xF |
| 18 | - if ip_version == 4: |
| 19 | - return IP |
| 20 | - elif ip_version == 6: |
| 21 | - return IPv6 |
| 22 | - return Padding |
| 23 | + if not self.s: |
| 24 | + return MPLS |
| 25 | + ip_version = (ord(payload[0]) >> 4) & 0xF |
| 26 | + if ip_version == 4: |
| 27 | + return IP |
| 28 | + elif ip_version == 5: |
| 29 | + return BIER |
| 30 | + elif ip_version == 6: |
| 31 | + return IPv6 |
| 32 | + return Padding |
Neale Ranns | 71275e3 | 2017-05-25 12:38:58 -0700 | [diff] [blame] | 33 | @@ -27,3 +29,4 @@ class MPLS(Packet): |
| 34 | |
| 35 | bind_layers(Ether, MPLS, type=0x8847) |
| 36 | bind_layers(GRE, MPLS, proto=0x8847) |
| 37 | +bind_layers(MPLS, MPLS, s=0) |