summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp/bgp_test.go
diff options
context:
space:
mode:
authorLamanna <jlamanna@gmail.com>2017-05-29 21:46:53 -0400
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-06-01 12:46:40 +0900
commit52a0f719875dbe968e5943c8eacdaba2192855d4 (patch)
tree93f5edf2cca7b9261ec0bbb6473a37d059a04b69 /packet/bgp/bgp_test.go
parent99336372ab2ae8a3b61af63abbcbd70223a1dfe1 (diff)
Fix RouteDistinguisher parsing and VPNV6 VRF rib parsing
Diffstat (limited to 'packet/bgp/bgp_test.go')
-rw-r--r--packet/bgp/bgp_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/packet/bgp/bgp_test.go b/packet/bgp/bgp_test.go
index 362c8fb8..8fedf5fe 100644
--- a/packet/bgp/bgp_test.go
+++ b/packet/bgp/bgp_test.go
@@ -812,3 +812,34 @@ func Test_MpReachNLRIWithIPv4PrefixWithIPv6Nexthop(t *testing.T) {
// Test serialised value
assert.Equal(bufin, bufout)
}
+
+func Test_ParseRouteDistingusher(t *testing.T) {
+ assert := assert.New(t)
+
+ rd, _ := ParseRouteDistinguisher("100:1000")
+ rdType0, ok := rd.(*RouteDistinguisherTwoOctetAS)
+ if !ok {
+ t.Fatal("Type of RD interface is not RouteDistinguisherTwoOctetAS")
+ }
+
+ assert.Equal(uint16(100), rdType0.Admin)
+ assert.Equal(uint32(1000), rdType0.Assigned)
+
+ rd, _ = ParseRouteDistinguisher("10.0.0.0:100")
+ rdType1, ok := rd.(*RouteDistinguisherIPAddressAS)
+ if !ok {
+ t.Fatal("Type of RD interface is not RouteDistinguisherIPAddressAS")
+ }
+
+ assert.Equal("10.0.0.0", rdType1.Admin.String())
+ assert.Equal(uint16(100), rdType1.Assigned)
+
+ rd, _ = ParseRouteDistinguisher("100.1000:10000")
+ rdType2, ok := rd.(*RouteDistinguisherFourOctetAS)
+ if !ok {
+ t.Fatal("Type of RD interface is not RouteDistinguisherFourOctetAS")
+ }
+
+ assert.Equal(uint32((100<<16)|1000), rdType2.Admin)
+ assert.Equal(uint16(10000), rdType2.Assigned)
+}