Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame^] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
| 17 | # Imported from scapy at revision 1270:113ef25f9583 |
| 18 | # This file is not included in the Ubuntu packages of scapy, so it is checked |
| 19 | # in to our repo to simplify installation. This file is under the GPLv2. |
| 20 | |
| 21 | # http://trac.secdev.org/scapy/ticket/31 |
| 22 | |
| 23 | # scapy.contrib.description = MPLS |
| 24 | # scapy.contrib.status = loads |
| 25 | |
| 26 | from scapy.packet import Packet,bind_layers |
| 27 | from scapy.fields import BitField,ByteField |
| 28 | from scapy.layers.l2 import Ether |
| 29 | |
| 30 | class MPLS(Packet): |
| 31 | name = "MPLS" |
| 32 | fields_desc = [ BitField("label", 3, 20), |
| 33 | BitField("cos", 0, 3), |
| 34 | BitField("s", 1, 1), |
| 35 | ByteField("ttl", 0) ] |
| 36 | |
| 37 | bind_layers(Ether, MPLS, type=0x8847) |
| 38 | |
| 39 | # Not in upstream scapy |
| 40 | bind_layers(MPLS, MPLS, s=0) |