diff options
author | 2020-07-17 10:36:28 +0200 | |
---|---|---|
committer | 2020-07-17 11:43:41 +0200 | |
commit | d1f24d37bd447b64e402298bb8eb2479681facf9 (patch) | |
tree | a3fc21ba730a91d8a402c7a5bf9c614e3677c4fc /codec/msg_codec.go | |
parent | 1548c7e12531e3d055567d761c580a1c7ff0ac40 (diff) |
Improve binapi generator
- simplified Size/Marshal/Unmarshal methods
- replace struc in unions with custom marshal/unmarshal
- fix imports in generated files
- fix mock adapter
- generate rpc service using low-level stream API (dumps generate control ping or stream msg..)
- move examples/binapi to binapi and generate all API for latest release
- add binapigen.Plugin for developing custom generator plugins
- optionally generate HTTP handlers (REST API) for RPC services
- add govpp program for browsing VPP API
Change-Id: I092e9ed2b0c17972b3476463c3d4b14dd76ed42b
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'codec/msg_codec.go')
-rw-r--r-- | codec/msg_codec.go | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/codec/msg_codec.go b/codec/msg_codec.go index 920366e..68cf3b1 100644 --- a/codec/msg_codec.go +++ b/codec/msg_codec.go @@ -15,6 +15,7 @@ package codec import ( + "encoding/binary" "errors" "fmt" @@ -23,30 +24,6 @@ import ( var DefaultCodec = new(MsgCodec) -// VppRequestHeader struct contains header fields implemented by all VPP requests. -type VppRequestHeader struct { - VlMsgID uint16 - ClientIndex uint32 - Context uint32 -} - -// VppReplyHeader struct contains header fields implemented by all VPP replies. -type VppReplyHeader struct { - VlMsgID uint16 - Context uint32 -} - -// VppEventHeader struct contains header fields implemented by all VPP events. -type VppEventHeader struct { - VlMsgID uint16 - ClientIndex uint32 -} - -// VppOtherHeader struct contains header fields implemented by other VPP messages (not requests nor replies). -type VppOtherHeader struct { - VlMsgID uint16 -} - // MsgCodec provides encoding and decoding functionality of `api.Message` structs into/from // binary format as accepted by VPP. type MsgCodec struct{} @@ -126,9 +103,9 @@ func (*MsgCodec) DecodeMsgContext(data []byte, msg api.Message) (context uint32, switch msg.GetMessageType() { case api.RequestMessage: - return order.Uint32(data[6:10]), nil + return binary.BigEndian.Uint32(data[6:10]), nil case api.ReplyMessage: - return order.Uint32(data[2:6]), nil + return binary.BigEndian.Uint32(data[2:6]), nil } return 0, nil |