summaryrefslogtreecommitdiffhomepage
path: root/zebra/zapi.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-08-24 17:00:42 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-09-06 08:14:14 +0900
commit402a478a66571bbab1779f244611b079347c74b3 (patch)
tree447d6acda462a19f718a5be57ac3f1df4bb6a7b3 /zebra/zapi.go
parent4d183305bda821c50db12748f27d64188ee7b4c1 (diff)
zebra/zapi: Implement unknown message body
This patch introduces a new Body structure for the unknown messages in order to avoid the disconnection when received unknown message type. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'zebra/zapi.go')
-rw-r--r--zebra/zapi.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/zebra/zapi.go b/zebra/zapi.go
index d652b60c..06b38bf2 100644
--- a/zebra/zapi.go
+++ b/zebra/zapi.go
@@ -542,6 +542,23 @@ type Body interface {
String() string
}
+type UnknownBody struct {
+ Data []byte
+}
+
+func (b *UnknownBody) DecodeFromBytes(data []byte, version uint8) error {
+ b.Data = data
+ return nil
+}
+
+func (b *UnknownBody) Serialize() ([]byte, error) {
+ return b.Data, nil
+}
+
+func (b *UnknownBody) String() string {
+ return fmt.Sprintf("data: %v", b.Data)
+}
+
type HelloBody struct {
RedistDefault ROUTE_TYPE
}
@@ -1338,7 +1355,10 @@ func ParseMessage(hdr *Header, data []byte) (*Message, error) {
"Topic": "Zebra",
}).Debugf("nexthop update message received: %v", data)
default:
- return nil, fmt.Errorf("Unknown zapi command: %d", m.Header.Command)
+ m.Body = &UnknownBody{}
+ log.WithFields(log.Fields{
+ "Topic": "Zebra",
+ }).Debugf("unknown message received: %v", data)
}
err := m.Body.DecodeFromBytes(data, m.Header.Version)
if err != nil {