diff options
Diffstat (limited to 'zebra/zapi_test.go')
-rw-r--r-- | zebra/zapi_test.go | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/zebra/zapi_test.go b/zebra/zapi_test.go index 4de3f9b7..696374b4 100644 --- a/zebra/zapi_test.go +++ b/zebra/zapi_test.go @@ -79,13 +79,13 @@ func Test_InterfaceUpdateBody(t *testing.T) { copy(buf[pos:pos+6], []byte(mac)) pos += 4 b := &InterfaceUpdateBody{} - err := b.DecodeFromBytes(buf) + err := b.DecodeFromBytes(buf, 2) assert.Equal(nil, err) assert.Equal("01:23:45:67:89:ab", b.HardwareAddr.String()) buf = make([]byte, INTERFACE_NAMSIZ+28) b = &InterfaceUpdateBody{} - err = b.DecodeFromBytes(buf) + err = b.DecodeFromBytes(buf, 2) assert.NotEqual(nil, err) } @@ -107,7 +107,7 @@ func Test_InterfaceAddressUpdateBody(t *testing.T) { buf[pos] = byte(24) b := &InterfaceAddressUpdateBody{} - err := b.DecodeFromBytes(buf) + err := b.DecodeFromBytes(buf, 2) assert.Equal(uint32(0), b.Index) assert.Equal(uint8(1), b.Flags) assert.Equal("192.168.100.1", b.Prefix.String()) @@ -117,7 +117,7 @@ func Test_InterfaceAddressUpdateBody(t *testing.T) { buf[5] = 0x4 pos += 1 b = &InterfaceAddressUpdateBody{} - err = b.DecodeFromBytes(buf) + err = b.DecodeFromBytes(buf, 2) assert.NotEqual(nil, err) } @@ -135,7 +135,7 @@ func Test_RouterIDUpdateBody(t *testing.T) { buf[pos] = byte(32) b := &RouterIDUpdateBody{} - err := b.DecodeFromBytes(buf) + err := b.DecodeFromBytes(buf, 2) assert.Equal(nil, err) assert.Equal("192.168.100.1", b.Prefix.String()) assert.Equal(uint8(32), b.Length) @@ -144,7 +144,7 @@ func Test_RouterIDUpdateBody(t *testing.T) { buf[0] = 0x4 pos += 1 b = &RouterIDUpdateBody{} - err = b.DecodeFromBytes(buf) + err = b.DecodeFromBytes(buf, 2) assert.NotEqual(nil, err) } @@ -169,7 +169,7 @@ func Test_IPRouteBody_IPv4(t *testing.T) { buf[17] = 0 // distance binary.BigEndian.PutUint32(buf[18:], 1) r := &IPRouteBody{Api: IPV4_ROUTE_ADD} - err := r.DecodeFromBytes(buf) + err := r.DecodeFromBytes(buf, 2) assert.Equal(nil, err) assert.Equal("192.168.100.0", r.Prefix.String()) @@ -211,7 +211,7 @@ func Test_IPRouteBody_IPv4(t *testing.T) { binary.BigEndian.PutUint32(buf[13:], 1) r = &IPRouteBody{Api: IPV4_ROUTE_ADD} - err = r.DecodeFromBytes(buf) + err = r.DecodeFromBytes(buf, 2) assert.Equal("message length invalid", err.Error()) // no nexthop @@ -225,7 +225,7 @@ func Test_IPRouteBody_IPv4(t *testing.T) { buf[7] = 1 binary.BigEndian.PutUint32(buf[8:], 0) r = &IPRouteBody{Api: IPV6_ROUTE_ADD} - err = r.DecodeFromBytes(buf) + err = r.DecodeFromBytes(buf, 2) assert.Equal(nil, err) } @@ -252,7 +252,7 @@ func Test_IPRouteBody_IPv6(t *testing.T) { buf[34] = 0 // distance binary.BigEndian.PutUint32(buf[35:], 1) r := &IPRouteBody{Api: IPV6_ROUTE_ADD} - err := r.DecodeFromBytes(buf) + err := r.DecodeFromBytes(buf, 2) assert.Equal(nil, err) assert.Equal("2001:db8:0:f101::", r.Prefix.String()) @@ -301,7 +301,7 @@ func Test_IPRouteBody_IPv6(t *testing.T) { binary.BigEndian.PutUint32(buf[32:], 1) r = &IPRouteBody{Api: IPV6_ROUTE_ADD} - err = r.DecodeFromBytes(buf) + err = r.DecodeFromBytes(buf, 2) assert.Equal("message length invalid", err.Error()) // no nexthop @@ -315,7 +315,7 @@ func Test_IPRouteBody_IPv6(t *testing.T) { buf[6] = 1 binary.BigEndian.PutUint32(buf[7:], 0) r = &IPRouteBody{Api: IPV6_ROUTE_ADD} - err = r.DecodeFromBytes(buf) + err = r.DecodeFromBytes(buf, 2) assert.Equal(nil, err) } @@ -341,7 +341,7 @@ func Test_NexthopLookupBody(t *testing.T) { binary.BigEndian.PutUint32(buf[pos:], 3) b := &NexthopLookupBody{Api: IPV4_NEXTHOP_LOOKUP} - err := b.DecodeFromBytes(buf) + err := b.DecodeFromBytes(buf, 2) assert.Equal(nil, err) assert.Equal("192.168.50.0", b.Addr.String()) assert.Equal(uint32(10), b.Metric) @@ -358,7 +358,7 @@ func Test_NexthopLookupBody(t *testing.T) { // length invalid buf = make([]byte, 3) b = &NexthopLookupBody{Api: IPV4_NEXTHOP_LOOKUP} - err = b.DecodeFromBytes(buf) + err = b.DecodeFromBytes(buf, 2) assert.NotEqual(nil, err) //ipv6 @@ -380,7 +380,7 @@ func Test_NexthopLookupBody(t *testing.T) { binary.BigEndian.PutUint32(buf[pos:], 3) b = &NexthopLookupBody{Api: IPV6_NEXTHOP_LOOKUP} - err = b.DecodeFromBytes(buf) + err = b.DecodeFromBytes(buf, 2) assert.Equal(nil, err) assert.Equal("2001:db8:0:f101::", b.Addr.String()) assert.Equal(uint32(10), b.Metric) @@ -397,7 +397,7 @@ func Test_NexthopLookupBody(t *testing.T) { // length invalid buf = make([]byte, 15) b = &NexthopLookupBody{Api: IPV6_NEXTHOP_LOOKUP} - err = b.DecodeFromBytes(buf) + err = b.DecodeFromBytes(buf, 2) assert.NotEqual(nil, err) } @@ -422,7 +422,7 @@ func Test_ImportLookupBody(t *testing.T) { binary.BigEndian.PutUint32(buf[pos:], 3) b := &ImportLookupBody{Api: IPV4_IMPORT_LOOKUP} - err := b.DecodeFromBytes(buf) + err := b.DecodeFromBytes(buf, 2) assert.Equal(nil, err) assert.Equal("192.168.50.0", b.Addr.String()) assert.Equal(uint32(10), b.Metric) @@ -441,6 +441,6 @@ func Test_ImportLookupBody(t *testing.T) { // length invalid buf = make([]byte, 3) b = &ImportLookupBody{Api: IPV4_IMPORT_LOOKUP} - err = b.DecodeFromBytes(buf) + err = b.DecodeFromBytes(buf, 2) assert.NotEqual(nil, err) } |