+// CliInband represents VPP binary API message 'cli_inband'.
+type CliInband struct {
+ XXX_CmdLen uint32 `struc:"sizeof=Cmd"`
+ Cmd string
+}
+
+func (m *CliInband) Reset() { *m = CliInband{} }
+func (*CliInband) GetMessageName() string { return "cli_inband" }
+func (*CliInband) GetCrcString() string { return "f8377302" }
+func (*CliInband) GetMessageType() api.MessageType { return api.RequestMessage }
+
+// CliInbandReply represents VPP binary API message 'cli_inband_reply'.
+type CliInbandReply struct {
+ Retval int32
+ XXX_ReplyLen uint32 `struc:"sizeof=Reply"`
+ Reply string
+}
+
+func (m *CliInbandReply) Reset() { *m = CliInbandReply{} }
+func (*CliInbandReply) GetMessageName() string { return "cli_inband_reply" }
+func (*CliInbandReply) GetCrcString() string { return "05879051" }
+func (*CliInbandReply) GetMessageType() api.MessageType { return api.ReplyMessage }
+
+func TestWrapperEncode(t *testing.T) {
+ msg := &CliInband{
+ XXX_CmdLen: 5,
+ Cmd: "abcde",
+ }
+ expectedData := []byte{
+ 0x00, 0x64,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x05,
+ 0x61, 0x62, 0x63, 0x64, 0x65,
+ }
+
+ c := codec.DefaultCodec
+
+ data, err := c.EncodeMsg(msg, 100)
+ if err != nil {
+ t.Fatalf("EncodeMsg failed: %v", err)
+ }
+ if !bytes.Equal(data, expectedData) {
+ t.Fatalf("unexpected encoded data,\nexpected: % 02x\n got: % 02x\n", expectedData, data)
+ }
+}
+
+func TestWrapperDecode(t *testing.T) {
+ data := []byte{
+ 0x00, 0x64,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x05,
+ 0x61, 0x62, 0x63, 0x64, 0x65,
+ }
+ expectedMsg := &CliInbandReply{
+ Retval: 0,
+ XXX_ReplyLen: 5,
+ Reply: "abcde",
+ }
+
+ c := codec.DefaultCodec
+
+ msg := new(CliInbandReply)
+ err := c.DecodeMsg(data, msg)
+ if err != nil {
+ t.Fatalf("DecodeMsg failed: %v", err)
+ }
+ if !reflect.DeepEqual(msg, expectedMsg) {
+ t.Fatalf("unexpected decoded msg,\nexpected: %+v\n got: %+v\n", expectedMsg, msg)
+ }
+}
+