summaryrefslogtreecommitdiffhomepage
path: root/zebra/zapi_test.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-02-14 14:45:27 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-02-15 00:11:29 +0900
commitc0d521333f7be469e4b90877475e8fcb1333acef (patch)
tree84fa9b6de378b86afdd7863a8958ce2d1516d4b3 /zebra/zapi_test.go
parent087ea7585069481bc0cf45f658698cc3ef9f5a3e (diff)
zebra/zapi: Support NEXTHOP_REGISTER message
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'zebra/zapi_test.go')
-rw-r--r--zebra/zapi_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/zebra/zapi_test.go b/zebra/zapi_test.go
index 7d0fe29b..5fcdbcc6 100644
--- a/zebra/zapi_test.go
+++ b/zebra/zapi_test.go
@@ -452,6 +452,41 @@ func Test_ImportLookupBody(t *testing.T) {
assert.NotEqual(nil, err)
}
+func Test_NexthopRegisterBody(t *testing.T) {
+ assert := assert.New(t)
+
+ // Input binary
+ bufIn := []byte{
+ 0x01, 0x00, 0x02, 0x20, // connected(1 byte)=1, afi(2 bytes)=AF_INET, prefix_len(1 byte)=32
+ 0xc0, 0xa8, 0x01, 0x01, // prefix(4 bytes)="192.168.1.1"
+ 0x00, 0x00, 0x0a, 0x80, // connected(1 byte)=0, afi(2 bytes)=AF_INET6, prefix_len(1 byte)=128
+ 0x20, 0x01, 0x0d, 0xb8, // prefix(16 bytes)="2001:db8:1:1::1"
+ 0x00, 0x01, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ }
+
+ // Test DecodeFromBytes()
+ b := &NexthopRegisterBody{Api: NEXTHOP_REGISTER}
+ err := b.DecodeFromBytes(bufIn, 3)
+ assert.Nil(err)
+
+ // Test decoded values
+ assert.Equal(uint8(1), b.Nexthops[0].Connected)
+ assert.Equal(uint16(syscall.AF_INET), b.Nexthops[0].Family)
+ assert.Equal(net.ParseIP("192.168.1.1").To4(), b.Nexthops[0].Prefix)
+ assert.Equal(uint8(0), b.Nexthops[1].Connected)
+ assert.Equal(uint16(syscall.AF_INET6), b.Nexthops[1].Family)
+ assert.Equal(net.ParseIP("2001:db8:1:1::1").To16(), b.Nexthops[1].Prefix)
+
+ // Test Serialize()
+ bufOut, err := b.Serialize()
+ assert.Nil(err)
+
+ // Test serialised value
+ assert.Equal(bufIn, bufOut)
+}
+
func Test_NexthopUpdateBody(t *testing.T) {
assert := assert.New(t)