diff options
Diffstat (limited to 'packet/bgp/bgp_test.go')
-rw-r--r-- | packet/bgp/bgp_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/packet/bgp/bgp_test.go b/packet/bgp/bgp_test.go index e0f1a5ca..e6d38873 100644 --- a/packet/bgp/bgp_test.go +++ b/packet/bgp/bgp_test.go @@ -739,3 +739,37 @@ func Test_MpReachNLRIWithVPNv6Prefix(t *testing.T) { // Test serialised value assert.Equal(bufin, bufout) } + +func Test_MpReachNLRIWithIPv4PrefixWithIPv6Nexthop(t *testing.T) { + assert := assert.New(t) + bufin := []byte{ + 0x80, 0x0e, 0x19, // flags(1), type(1), length(1) + 0x00, 0x01, 0x01, 0x10, // afi(1), safi(1), nexthoplen(1) + 0x20, 0x01, 0x0d, 0xb8, // nexthop(32) + 0x00, 0x01, 0x00, 0x00, // = "2001:db8:1::1" + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x00, // reserved(1) + 0x18, 0xc0, 0xa8, 0x0a, // nlri(7) + } + // Test DecodeFromBytes() + p := &PathAttributeMpReachNLRI{} + err := p.DecodeFromBytes(bufin) + assert.Nil(err) + // Test decoded values + assert.Equal(BGPAttrFlag(0x80), p.Flags) + assert.Equal(BGPAttrType(0xe), p.Type) + assert.Equal(uint16(0x19), p.Length) + assert.Equal(uint16(AFI_IP), p.AFI) + assert.Equal(uint8(SAFI_UNICAST), p.SAFI) + assert.Equal(net.ParseIP("2001:db8:1::1"), p.Nexthop) + value := []AddrPrefixInterface{ + NewIPAddrPrefix(24, "192.168.10.0"), + } + assert.Equal(value, p.Value) + // Test Serialize() + bufout, err := p.Serialize() + assert.Nil(err) + // Test serialised value + assert.Equal(bufin, bufout) +} |