diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-03-30 17:57:56 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-03-31 11:38:17 +0900 |
commit | 051621bf3aecbe0fd6292a3b4ee41ab42169eea1 (patch) | |
tree | dafa1b882570e059d57692c14e8a9537ff8c6f07 /packet/bgp_test.go | |
parent | 63788325a04d2c1956f79713fabcb00d68782f37 (diff) |
*: 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>
Diffstat (limited to 'packet/bgp_test.go')
-rw-r--r-- | packet/bgp_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
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) +} |