1 # This file is part of Scapy 2 # Scapy is free software: you can redistribute it and/or modify 3 # it under the terms of the GNU General Public License as published by 4 # the Free Software Foundation, either version 2 of the License, or 5 # any later version. 6 # 7 # Scapy is distributed in the hope that it will be useful, 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # GNU General Public License for more details. 11 # 12 # You should have received a copy of the GNU General Public License 13 # along with Scapy. If not, see <http://www.gnu.org/licenses/>. 14 15 # IEEE 802.1aq - Shorest Path Bridging Mac-in-mac (SPBM): 16 # Ethernet based link state protocol that enables Layer 2 Unicast, Layer 2 Multicast, Layer 3 Unicast, and Layer 3 Multicast virtualized services 17 # https://en.wikipedia.org/wiki/IEEE_802.1aq 18 # Modeled after the scapy VXLAN contribution 19 20 # scapy.contrib.description = SBPM 21 # scapy.contrib.status = loads 22 23 """ 24 Example SPB Frame Creation 25 26 Note the outer Dot1Q Ethertype marking (0x88e7) 27 28 backboneEther = Ether(dst='00:bb:00:00:90:00', src='00:bb:00:00:40:00', type=0x8100) 29 backboneDot1Q = Dot1Q(vlan=4051,type=0x88e7) 30 backboneServiceID = SPBM(prio=1,isid=20011) 31 customerEther = Ether(dst='00:1b:4f:5e:ca:00',src='00:00:00:00:00:01',type=0x8100) 32 customerDot1Q = Dot1Q(prio=1,vlan=11,type=0x0800) 33 customerIP = IP(src='10.100.11.10',dst='10.100.12.10',id=0x0629,len=106) 34 customerUDP = UDP(sport=1024,dport=1025,chksum=0,len=86) 35 36 spb_example = backboneEther/backboneDot1Q/backboneServiceID/customerEther/customerDot1Q/customerIP/customerUDP/"Payload" 37 """ 38 39 from scapy.packet import Packet, bind_layers 40 from scapy.fields import * 41 from scapy.layers.l2 import Ether, Dot1Q 42 43 class SPBM(Packet): 44 name = "SPBM" 45 fields_desc = [ BitField("prio", 0, 3), 46 BitField("dei", 0, 1), 47 BitField("nca", 0, 1), 48 BitField("res1", 0, 1), 49 BitField("res2", 0, 2), 50 ThreeBytesField("isid", 0)] 51 52 def mysummary(self): 53 return self.sprintf("SPBM (isid=%SPBM.isid%") 54 55 bind_layers(Dot1Q, SPBM, type=0x88e7) 56 bind_layers(SPBM, Ether) 57