diff options
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) +} |