From 051621bf3aecbe0fd6292a3b4ee41ab42169eea1 Mon Sep 17 00:00:00 2001
From: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Date: Wed, 30 Mar 2016 17:57:56 +0900
Subject: *: support draft-ietf-idr-flowspec-l2vpn-03

$ gobgp g ri add -a l2vpn-flowspec match destination-mac 01:01:01:01:01:01 ether-type ipv4 vid 10 cos 20
$ gobgp g ri add -a l2vpn-flowspec match source-mac 01:01:01:01:01:01 ether-type arp inner-vid 20 inner-cos 20

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
---
 packet/bgp_test.go | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

(limited to 'packet/bgp_test.go')

diff --git a/packet/bgp_test.go b/packet/bgp_test.go
index f243a785..29aa4e69 100644
--- a/packet/bgp_test.go
+++ b/packet/bgp_test.go
@@ -3,6 +3,7 @@ package bgp
 import (
 	"bytes"
 	"encoding/binary"
+	"fmt"
 	"github.com/stretchr/testify/assert"
 	"net"
 	"reflect"
@@ -534,3 +535,31 @@ func Test_Aigp(t *testing.T) {
 		t.Log(bytes.Equal(buf1, buf2))
 	}
 }
+
+func Test_FlowSpecNlriL2(t *testing.T) {
+	assert := assert.New(t)
+	mac, _ := net.ParseMAC("01:23:45:67:89:ab")
+	cmp := make([]FlowSpecComponentInterface, 0)
+	cmp = append(cmp, NewFlowSpecDestinationMac(mac))
+	cmp = append(cmp, NewFlowSpecSourceMac(mac))
+	eq := 0x1
+	item1 := NewFlowSpecComponentItem(eq, int(IPv4))
+	cmp = append(cmp, NewFlowSpecComponent(FLOW_SPEC_TYPE_ETHERNET_TYPE, []*FlowSpecComponentItem{item1}))
+	n1 := NewFlowSpecL2VPN(cmp)
+	buf1, err := n1.Serialize()
+	assert.Nil(err)
+	n2, err := NewPrefixFromRouteFamily(RouteFamilyToAfiSafi(RF_FS_L2_VPN))
+	assert.Nil(err)
+	err = n2.DecodeFromBytes(buf1)
+	assert.Nil(err)
+	buf2, _ := n2.Serialize()
+	if reflect.DeepEqual(n1, n2) == true {
+		t.Log("OK")
+	} else {
+		t.Error("Something wrong")
+		t.Error(len(buf1), n1, buf1)
+		t.Error(len(buf2), n2, buf2)
+		t.Log(bytes.Equal(buf1, buf2))
+	}
+	fmt.Println(n1, n2)
+}
-- 
cgit v1.2.3