summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-08-25 10:52:13 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-09-06 08:14:14 +0900
commit208e3d5e87be225b464122da82023e99430067a5 (patch)
tree442d8c5ec145bac343c6cc49e21e87d961f29446
parent489aa616f05fcd086bd0c44ff2cc90119572fac6 (diff)
zebra/zapi: Missing "Destination" in InterfaceAddressUpdateBody
This patch fixes to parse the missing "Destination" field in InterfaceAddressUpdateBody message. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r--zebra/zapi.go10
-rw-r--r--zebra/zapi_test.go16
2 files changed, 16 insertions, 10 deletions
diff --git a/zebra/zapi.go b/zebra/zapi.go
index 6a74ddc3..573f11cc 100644
--- a/zebra/zapi.go
+++ b/zebra/zapi.go
@@ -650,10 +650,11 @@ func (b *InterfaceUpdateBody) String() string {
}
type InterfaceAddressUpdateBody struct {
- Index uint32
- Flags uint8
- Prefix net.IP
- Length uint8
+ Index uint32
+ Flags uint8
+ Prefix net.IP
+ Length uint8
+ Destination net.IP
}
func (b *InterfaceAddressUpdateBody) DecodeFromBytes(data []byte, version uint8) error {
@@ -671,6 +672,7 @@ func (b *InterfaceAddressUpdateBody) DecodeFromBytes(data []byte, version uint8)
}
b.Prefix = data[6 : 6+addrlen]
b.Length = data[6+addrlen]
+ b.Destination = data[7+addrlen : 7+addrlen*2]
return nil
}
diff --git a/zebra/zapi_test.go b/zebra/zapi_test.go
index 46dc6c38..fe1ffc80 100644
--- a/zebra/zapi_test.go
+++ b/zebra/zapi_test.go
@@ -95,18 +95,21 @@ func Test_InterfaceAddressUpdateBody(t *testing.T) {
assert := assert.New(t)
//DecodeFromBytes
- buf := make([]byte, 11)
+ buf := make([]byte, 15)
pos := 0
- binary.BigEndian.PutUint32(buf[pos:], 0)
+ binary.BigEndian.PutUint32(buf[pos:], 0) // index
pos += 4
- buf[pos] = 0x01
+ buf[pos] = 0x01 // flags
pos += 1
- buf[pos] = 0x2
+ buf[pos] = 0x2 // family
pos += 1
- ip := net.ParseIP("192.168.100.1").To4()
+ ip := net.ParseIP("192.168.100.1").To4() // prefix
copy(buf[pos:pos+4], []byte(ip))
pos += 4
- buf[pos] = byte(24)
+ buf[pos] = byte(24) // prefix len
+ pos += 1
+ dst := net.ParseIP("192.168.100.255").To4() // destination
+ copy(buf[pos:pos+4], []byte(dst))
b := &InterfaceAddressUpdateBody{}
err := b.DecodeFromBytes(buf, 2)
@@ -114,6 +117,7 @@ func Test_InterfaceAddressUpdateBody(t *testing.T) {
assert.Equal(uint8(1), b.Flags)
assert.Equal("192.168.100.1", b.Prefix.String())
assert.Equal(uint8(24), b.Length)
+ assert.Equal("192.168.100.255", b.Destination.String())
// af invalid
buf[5] = 0x4