diff options
Diffstat (limited to 'codec')
-rw-r--r-- | codec/bench_test.go | 2 | ||||
-rw-r--r-- | codec/codec.go | 4 | ||||
-rw-r--r-- | codec/marshaler.go | 2 | ||||
-rw-r--r-- | codec/marshaler_test.go | 13 | ||||
-rw-r--r-- | codec/msg_codec.go | 14 | ||||
-rw-r--r-- | codec/msg_codec_test.go | 12 |
6 files changed, 22 insertions, 25 deletions
diff --git a/codec/bench_test.go b/codec/bench_test.go index 4b4a702..cc71390 100644 --- a/codec/bench_test.go +++ b/codec/bench_test.go @@ -18,7 +18,7 @@ package codec_test import ( "testing" - "git.fd.io/govpp.git/codec" + "go.fd.io/govpp/codec" ) var Data []byte diff --git a/codec/codec.go b/codec/codec.go index 3ae578b..21354a1 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -156,12 +156,12 @@ func (b *Buffer) DecodeInt64() int64 { } func (b *Buffer) EncodeFloat64(v float64) { - binary.BigEndian.PutUint64(b.buf[b.pos:b.pos+8], math.Float64bits(v)) + binary.LittleEndian.PutUint64(b.buf[b.pos:b.pos+8], math.Float64bits(v)) b.pos += 8 } func (b *Buffer) DecodeFloat64() float64 { - v := math.Float64frombits(binary.BigEndian.Uint64(b.buf[b.pos : b.pos+8])) + v := math.Float64frombits(binary.LittleEndian.Uint64(b.buf[b.pos : b.pos+8])) b.pos += 8 return v } diff --git a/codec/marshaler.go b/codec/marshaler.go index 803b0f5..26e6ba3 100644 --- a/codec/marshaler.go +++ b/codec/marshaler.go @@ -20,7 +20,7 @@ import ( "github.com/lunixbochs/struc" - "git.fd.io/govpp.git/api" + "go.fd.io/govpp/api" ) // Marshaler is the interface implemented by the binary API messages that can diff --git a/codec/marshaler_test.go b/codec/marshaler_test.go index 985dd31..2a9cb94 100644 --- a/codec/marshaler_test.go +++ b/codec/marshaler_test.go @@ -19,11 +19,12 @@ import ( "reflect" "testing" - "git.fd.io/govpp.git/api" - "git.fd.io/govpp.git/binapi/ip_types" - "git.fd.io/govpp.git/binapi/sr" - "git.fd.io/govpp.git/codec" - interfaces "git.fd.io/govpp.git/internal/testbinapi/binapi2001/interface" + "go.fd.io/govpp/api" + "go.fd.io/govpp/binapi/ip_types" + "go.fd.io/govpp/binapi/sr" + "go.fd.io/govpp/codec" + interfaces "go.fd.io/govpp/binapi/interface" + "go.fd.io/govpp/binapi/interface_types" ) // CliInband represents VPP binary API message 'cli_inband'. @@ -101,7 +102,7 @@ func TestWrapperDecode(t *testing.T) { func TestNewCodecEncodeDecode4(t *testing.T) { m := &interfaces.SwInterfaceSetRxMode{ - Mode: interfaces.RX_MODE_API_POLLING, + Mode: interface_types.RX_MODE_API_POLLING, QueueID: 70000, QueueIDValid: true, SwIfIndex: 300, 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: diff --git a/codec/msg_codec_test.go b/codec/msg_codec_test.go index c0f94da..46a6154 100644 --- a/codec/msg_codec_test.go +++ b/codec/msg_codec_test.go @@ -4,12 +4,12 @@ import ( "bytes" "testing" - "git.fd.io/govpp.git/api" - "git.fd.io/govpp.git/binapi/ip" - "git.fd.io/govpp.git/binapi/ip_types" - "git.fd.io/govpp.git/binapi/sr" - "git.fd.io/govpp.git/binapi/vpe" - "git.fd.io/govpp.git/codec" + "go.fd.io/govpp/api" + "go.fd.io/govpp/binapi/ip" + "go.fd.io/govpp/binapi/ip_types" + "go.fd.io/govpp/binapi/sr" + "go.fd.io/govpp/binapi/vpe" + "go.fd.io/govpp/codec" ) type MyMsg struct { |