vpp/test/patches/scapy-2.3.3/gre-layers.patch
John Lo 2bf8b8154d Fix ERSPAN encap to set EN bits in the header and add test case
For ERSPAN encap, both bits in the EN field of the header should
be set to indicate any VLAN tag in the original Ethernet frame is
preserved.
Added SPAN L2 test case where the mirrored packet output is a GRE
ERSPAN tunnel.

Change-Id: Ie7a40992a9278469c24aa6fa9e122b4505797d10
Signed-off-by: John Lo <loj@cisco.com>
2018-03-01 13:09:57 +00:00

54 lines
2.2 KiB
Diff

diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py
index 03b80ec..a7e1e0f 100644
--- a/scapy/layers/inet6.py
+++ b/scapy/layers/inet6.py
@@ -3722,6 +3722,7 @@ conf.l2types.register(31, IPv6)
bind_layers(Ether, IPv6, type = 0x86dd )
bind_layers(CookedLinux, IPv6, proto = 0x86dd )
+bind_layers(GRE, IPv6, proto = 0x86dd )
bind_layers(IPerror6, TCPerror, nh = socket.IPPROTO_TCP )
bind_layers(IPerror6, UDPerror, nh = socket.IPPROTO_UDP )
bind_layers(IPv6, TCP, nh = socket.IPPROTO_TCP )
diff --git a/scapy/layers/l2.py b/scapy/layers/l2.py
index 4f491d2..661a5da 100644
--- a/scapy/layers/l2.py
+++ b/scapy/layers/l2.py
@@ -570,6 +570,20 @@
return getmacbyip(l3.pdst)
conf.neighbor.register_l3(Ether, ARP, l2_register_l3_arp)
+
+class ERSPAN(Packet):
+ name = "ERSPAN"
+ fields_desc = [ BitField("ver",0,4),
+ BitField("vlan",0,12),
+ BitField("cos",0,3),
+ BitField("en",0,2),
+ BitField("t",0,1),
+ BitField("session_id",0,10),
+ BitField("reserved",0,12),
+ BitField("index",0,20),
+ ]
+
+
class GRErouting(Packet):
name = "GRE routing informations"
fields_desc = [ ShortField("address_family",0),
@@ -628,12 +642,14 @@ bind_layers( CookedLinux, EAPOL, proto=34958)
bind_layers( GRE, LLC, proto=122)
bind_layers( GRE, Dot1Q, proto=33024)
bind_layers( GRE, Dot1AD, type=0x88a8)
-bind_layers( GRE, Ether, proto=1)
+bind_layers( GRE, Ether, proto=0x6558)
+bind_layers( GRE, ERSPAN, proto=0x88be, seqnum_present=1)
bind_layers( GRE, ARP, proto=2054)
bind_layers( GRE, EAPOL, proto=34958)
bind_layers( GRE, GRErouting, { "routing_present" : 1 } )
bind_layers( GRErouting, conf.raw_layer,{ "address_family" : 0, "SRE_len" : 0 })
bind_layers( GRErouting, GRErouting, { } )
+bind_layers( ERSPAN, Ether)
bind_layers( EAPOL, EAP, type=0)
bind_layers(EAP, EAP_TLS, type=13)
bind_layers(EAP, EAP_FAST, type=43)