aboutsummaryrefslogtreecommitdiffstats
path: root/codec/msg_codec.go
diff options
context:
space:
mode:
Diffstat (limited to 'codec/msg_codec.go')
-rw-r--r--codec/msg_codec.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/codec/msg_codec.go b/codec/msg_codec.go
index 6534e7d..68c495b 100644
--- a/codec/msg_codec.go
+++ b/codec/msg_codec.go
@@ -19,7 +19,7 @@ import (
"errors"
"fmt"
- "git.fd.io/govpp.git/api"
+ "go.fd.io/govpp/api"
)
var DefaultCodec = new(MsgCodec)
@@ -30,8 +30,8 @@ func EncodeMsg(msg api.Message, msgID uint16) (data []byte, err error) {
func DecodeMsg(data []byte, msg api.Message) (err error) {
return DefaultCodec.DecodeMsg(data, msg)
}
-func DecodeMsgContext(data []byte, msg api.Message) (context uint32, err error) {
- return DefaultCodec.DecodeMsgContext(data, msg)
+func DecodeMsgContext(data []byte, msgType api.MessageType) (context uint32, err error) {
+ return DefaultCodec.DecodeMsgContext(data, msgType)
}
// MsgCodec provides encoding and decoding functionality of `api.Message` structs into/from
@@ -106,12 +106,8 @@ func (*MsgCodec) DecodeMsg(data []byte, msg api.Message) (err error) {
return nil
}
-func (*MsgCodec) DecodeMsgContext(data []byte, msg api.Message) (context uint32, err error) {
- if msg == nil {
- return 0, errors.New("nil message passed in")
- }
-
- switch msg.GetMessageType() {
+func (*MsgCodec) DecodeMsgContext(data []byte, msgType api.MessageType) (context uint32, err error) {
+ switch msgType {
case api.RequestMessage:
return binary.BigEndian.Uint32(data[6:10]), nil
case api.ReplyMessage: