blob: 04c1f2854388e9b034daea8f3cc3dd6b91369162 [file] [log] [blame]
Rich Lanea68176f2013-08-09 17:41:05 -07001# Distributed under the OpenFlow Software License (see LICENSE)
2# Copyright (c) 2010 The Board of Trustees of The Leland Stanford Junior University
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4"""
5Wrap scapy to satisfy pylint
6"""
Stephen Finucane7562d4e2014-03-13 15:10:29 +00007from oftest import config
Rich Lane720eaf22013-08-09 18:00:45 -07008import sys
Rich Lanea68176f2013-08-09 17:41:05 -07009
10try:
Rich Lane024f9d52013-08-12 15:56:39 -070011 import scapy.config
12 import scapy.route
Rich Lanea68176f2013-08-09 17:41:05 -070013 import scapy.layers.l2
14 import scapy.layers.inet
Stephen Finucane7562d4e2014-03-13 15:10:29 +000015 if not config["disable_ipv6"]:
16 import scapy.route6
17 import scapy.layers.inet6
Rich Lanea68176f2013-08-09 17:41:05 -070018except ImportError:
19 sys.exit("Need to install scapy for packet parsing")
20
21Ether = scapy.layers.l2.Ether
22LLC = scapy.layers.l2.LLC
23SNAP = scapy.layers.l2.SNAP
24Dot1Q = scapy.layers.l2.Dot1Q
25IP = scapy.layers.inet.IP
26IPOption = scapy.layers.inet.IPOption
Rich Lanea68176f2013-08-09 17:41:05 -070027ARP = scapy.layers.inet.ARP
28TCP = scapy.layers.inet.TCP
29UDP = scapy.layers.inet.UDP
30ICMP = scapy.layers.inet.ICMP
Stephen Finucane7562d4e2014-03-13 15:10:29 +000031
macauleyca2752d2015-07-27 17:41:14 +080032from scapy.fields import *
33from scapy.packet import *
34
35class ThreeBytesField(X3BytesField, ByteField):
36 def i2repr(self, pkt, x):
37 return ByteField.i2repr(self, pkt, x)
38
39class VXLAN(Packet):
40 name = "VXLAN"
41 fields_desc = [ FlagsField("flags", 0x08, 8, ['R', 'R', 'R', 'I', 'R', 'R', 'R', 'R']),
42 X3BytesField("reserved1", 0x000000),
43 ThreeBytesField("vni", 0),
44 XByteField("reserved2", 0x00)]
45
46 def mysummary(self):
47 return self.sprintf("VXLAN (vni=%VXLAN.vni%)")
48
49bind_layers(UDP, VXLAN, dport=4789)
50bind_layers(VXLAN, Ether)
51
Stephen Finucane7562d4e2014-03-13 15:10:29 +000052if not config["disable_ipv6"]:
53 IPv6 = scapy.layers.inet6.IPv6
54 ICMPv6Unknown = scapy.layers.inet6.ICMPv6Unknown
55 ICMPv6EchoRequest = scapy.layers.inet6.ICMPv6EchoRequest