Binary API generator improvements
[govpp.git] / examples / binapi / vpe / vpe.ba.go
index 4c00c86..411a9f4 100644 (file)
@@ -1,11 +1,11 @@
 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
 // versions:
-//  binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty
-//  VPP:              20.01-45~g7a071e370~b63
+//  binapi-generator: v0.4.0-dev
+//  VPP:              20.05-release
 // source: /usr/share/vpp/api/core/vpe.api.json
 
 /*
-Package vpe contains generated code for VPP binary API defined by vpe.api (version 1.6.0).
+Package vpe contains generated code for VPP API file vpe.api (1.6.1).
 
 It consists of:
          2 aliases
@@ -19,9 +19,12 @@ import (
        "bytes"
        "context"
        "encoding/binary"
+       "fmt"
        "io"
        "math"
+       "net"
        "strconv"
+       "strings"
 
        api "git.fd.io/govpp.git/api"
        codec "git.fd.io/govpp.git/codec"
@@ -38,9 +41,9 @@ const (
        // ModuleName is the name of this module.
        ModuleName = "vpe"
        // APIVersion is the API version of this module.
-       APIVersion = "1.6.0"
+       APIVersion = "1.6.1"
        // VersionCrc is the CRC of this module.
-       VersionCrc = 0xc6c0bcf6
+       VersionCrc = 0xbd2c94f4
 )
 
 // LogLevel represents VPP binary API enum 'log_level'.
@@ -100,8 +103,8 @@ type Timestamp float64
 // ThreadData represents VPP binary API type 'thread_data'.
 type ThreadData struct {
        ID        uint32 `binapi:"u32,name=id" json:"id,omitempty"`
-       Name      []byte `binapi:"u8[64],name=name" json:"name,omitempty" struc:"[64]byte"`
-       Type      []byte `binapi:"u8[64],name=type" json:"type,omitempty" struc:"[64]byte"`
+       Name      string `binapi:"string[64],name=name" json:"name,omitempty" struc:"[64]byte"`
+       Type      string `binapi:"string[64],name=type" json:"type,omitempty" struc:"[64]byte"`
        PID       uint32 `binapi:"u32,name=pid" json:"pid,omitempty"`
        CPUID     uint32 `binapi:"u32,name=cpu_id" json:"cpu_id,omitempty"`
        Core      uint32 `binapi:"u32,name=core" json:"core,omitempty"`
@@ -123,13 +126,13 @@ func (*Version) GetTypeName() string { return "version" }
 
 // AddNodeNext represents VPP binary API message 'add_node_next'.
 type AddNodeNext struct {
-       NodeName []byte `binapi:"u8[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"`
-       NextName []byte `binapi:"u8[64],name=next_name" json:"next_name,omitempty" struc:"[64]byte"`
+       NodeName string `binapi:"string[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"`
+       NextName string `binapi:"string[64],name=next_name" json:"next_name,omitempty" struc:"[64]byte"`
 }
 
 func (m *AddNodeNext) Reset()                        { *m = AddNodeNext{} }
 func (*AddNodeNext) GetMessageName() string          { return "add_node_next" }
-func (*AddNodeNext) GetCrcString() string            { return "9ab92f7a" }
+func (*AddNodeNext) GetCrcString() string            { return "2457116d" }
 func (*AddNodeNext) GetMessageType() api.MessageType { return api.RequestMessage }
 
 func (m *AddNodeNext) Size() int {
@@ -155,23 +158,11 @@ func (m *AddNodeNext) Marshal(b []byte) ([]byte, error) {
                buf = b
        }
        // field[1] m.NodeName
-       for i := 0; i < 64; i++ {
-               var x uint8
-               if i < len(m.NodeName) {
-                       x = uint8(m.NodeName[i])
-               }
-               buf[pos] = uint8(x)
-               pos += 1
-       }
+       copy(buf[pos:pos+64], m.NodeName)
+       pos += 64
        // field[1] m.NextName
-       for i := 0; i < 64; i++ {
-               var x uint8
-               if i < len(m.NextName) {
-                       x = uint8(m.NextName[i])
-               }
-               buf[pos] = uint8(x)
-               pos += 1
-       }
+       copy(buf[pos:pos+64], m.NextName)
+       pos += 64
        return buf, nil
 }
 func (m *AddNodeNext) Unmarshal(tmp []byte) error {
@@ -180,16 +171,16 @@ func (m *AddNodeNext) Unmarshal(tmp []byte) error {
        pos := 0
        _ = pos
        // field[1] m.NodeName
-       m.NodeName = make([]uint8, 64)
-       for i := 0; i < len(m.NodeName); i++ {
-               m.NodeName[i] = uint8(tmp[pos])
-               pos += 1
+       {
+               nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
+               m.NodeName = codec.DecodeString(tmp[pos : pos+nul])
+               pos += 64
        }
        // field[1] m.NextName
-       m.NextName = make([]uint8, 64)
-       for i := 0; i < len(m.NextName); i++ {
-               m.NextName[i] = uint8(tmp[pos])
-               pos += 1
+       {
+               nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
+               m.NextName = codec.DecodeString(tmp[pos : pos+nul])
+               pos += 64
        }
        return nil
 }
@@ -769,13 +760,13 @@ func (m *GetF64IncrementByOneReply) Unmarshal(tmp []byte) error {
 
 // GetNextIndex represents VPP binary API message 'get_next_index'.
 type GetNextIndex struct {
-       NodeName []byte `binapi:"u8[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"`
-       NextName []byte `binapi:"u8[64],name=next_name" json:"next_name,omitempty" struc:"[64]byte"`
+       NodeName string `binapi:"string[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"`
+       NextName string `binapi:"string[64],name=next_name" json:"next_name,omitempty" struc:"[64]byte"`
 }
 
 func (m *GetNextIndex) Reset()                        { *m = GetNextIndex{} }
 func (*GetNextIndex) GetMessageName() string          { return "get_next_index" }
-func (*GetNextIndex) GetCrcString() string            { return "9ab92f7a" }
+func (*GetNextIndex) GetCrcString() string            { return "2457116d" }
 func (*GetNextIndex) GetMessageType() api.MessageType { return api.RequestMessage }
 
 func (m *GetNextIndex) Size() int {
@@ -801,23 +792,11 @@ func (m *GetNextIndex) Marshal(b []byte) ([]byte, error) {
                buf = b
        }
        // field[1] m.NodeName
-       for i := 0; i < 64; i++ {
-               var x uint8
-               if i < len(m.NodeName) {
-                       x = uint8(m.NodeName[i])
-               }
-               buf[pos] = uint8(x)
-               pos += 1
-       }
+       copy(buf[pos:pos+64], m.NodeName)
+       pos += 64
        // field[1] m.NextName
-       for i := 0; i < 64; i++ {
-               var x uint8
-               if i < len(m.NextName) {
-                       x = uint8(m.NextName[i])
-               }
-               buf[pos] = uint8(x)
-               pos += 1
-       }
+       copy(buf[pos:pos+64], m.NextName)
+       pos += 64
        return buf, nil
 }
 func (m *GetNextIndex) Unmarshal(tmp []byte) error {
@@ -826,16 +805,16 @@ func (m *GetNextIndex) Unmarshal(tmp []byte) error {
        pos := 0
        _ = pos
        // field[1] m.NodeName
-       m.NodeName = make([]uint8, 64)
-       for i := 0; i < len(m.NodeName); i++ {
-               m.NodeName[i] = uint8(tmp[pos])
-               pos += 1
+       {
+               nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
+               m.NodeName = codec.DecodeString(tmp[pos : pos+nul])
+               pos += 64
        }
        // field[1] m.NextName
-       m.NextName = make([]uint8, 64)
-       for i := 0; i < len(m.NextName); i++ {
-               m.NextName[i] = uint8(tmp[pos])
-               pos += 1
+       {
+               nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
+               m.NextName = codec.DecodeString(tmp[pos : pos+nul])
+               pos += 64
        }
        return nil
 }
@@ -988,12 +967,12 @@ func (m *GetNodeGraphReply) Unmarshal(tmp []byte) error {
 
 // GetNodeIndex represents VPP binary API message 'get_node_index'.
 type GetNodeIndex struct {
-       NodeName []byte `binapi:"u8[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"`
+       NodeName string `binapi:"string[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"`
 }
 
 func (m *GetNodeIndex) Reset()                        { *m = GetNodeIndex{} }
 func (*GetNodeIndex) GetMessageName() string          { return "get_node_index" }
-func (*GetNodeIndex) GetCrcString() string            { return "6c9a495d" }
+func (*GetNodeIndex) GetCrcString() string            { return "f1984c64" }
 func (*GetNodeIndex) GetMessageType() api.MessageType { return api.RequestMessage }
 
 func (m *GetNodeIndex) Size() int {
@@ -1017,14 +996,8 @@ func (m *GetNodeIndex) Marshal(b []byte) ([]byte, error) {
                buf = b
        }
        // field[1] m.NodeName
-       for i := 0; i < 64; i++ {
-               var x uint8
-               if i < len(m.NodeName) {
-                       x = uint8(m.NodeName[i])
-               }
-               buf[pos] = uint8(x)
-               pos += 1
-       }
+       copy(buf[pos:pos+64], m.NodeName)
+       pos += 64
        return buf, nil
 }
 func (m *GetNodeIndex) Unmarshal(tmp []byte) error {
@@ -1033,10 +1006,10 @@ func (m *GetNodeIndex) Unmarshal(tmp []byte) error {
        pos := 0
        _ = pos
        // field[1] m.NodeName
-       m.NodeName = make([]uint8, 64)
-       for i := 0; i < len(m.NodeName); i++ {
-               m.NodeName[i] = uint8(tmp[pos])
-               pos += 1
+       {
+               nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
+               m.NodeName = codec.DecodeString(tmp[pos : pos+nul])
+               pos += 64
        }
        return nil
 }
@@ -1266,7 +1239,7 @@ type ShowThreadsReply struct {
 
 func (m *ShowThreadsReply) Reset()                        { *m = ShowThreadsReply{} }
 func (*ShowThreadsReply) GetMessageName() string          { return "show_threads_reply" }
-func (*ShowThreadsReply) GetCrcString() string            { return "f5e0b66f" }
+func (*ShowThreadsReply) GetCrcString() string            { return "efd78e83" }
 func (*ShowThreadsReply) GetMessageType() api.MessageType { return api.ReplyMessage }
 
 func (m *ShowThreadsReply) Size() int {
@@ -1329,23 +1302,11 @@ func (m *ShowThreadsReply) Marshal(b []byte) ([]byte, error) {
                o.PutUint32(buf[pos:pos+4], uint32(v1.ID))
                pos += 4
                // field[2] v1.Name
-               for i := 0; i < 64; i++ {
-                       var x uint8
-                       if i < len(v1.Name) {
-                               x = uint8(v1.Name[i])
-                       }
-                       buf[pos] = uint8(x)
-                       pos += 1
-               }
+               copy(buf[pos:pos+64], v1.Name)
+               pos += 64
                // field[2] v1.Type
-               for i := 0; i < 64; i++ {
-                       var x uint8
-                       if i < len(v1.Type) {
-                               x = uint8(v1.Type[i])
-                       }
-                       buf[pos] = uint8(x)
-                       pos += 1
-               }
+               copy(buf[pos:pos+64], v1.Type)
+               pos += 64
                // field[2] v1.PID
                o.PutUint32(buf[pos:pos+4], uint32(v1.PID))
                pos += 4
@@ -1379,16 +1340,16 @@ func (m *ShowThreadsReply) Unmarshal(tmp []byte) error {
                m.ThreadData[j1].ID = uint32(o.Uint32(tmp[pos : pos+4]))
                pos += 4
                // field[2] m.ThreadData[j1].Name
-               m.ThreadData[j1].Name = make([]uint8, 64)
-               for i := 0; i < len(m.ThreadData[j1].Name); i++ {
-                       m.ThreadData[j1].Name[i] = uint8(tmp[pos])
-                       pos += 1
+               {
+                       nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
+                       m.ThreadData[j1].Name = codec.DecodeString(tmp[pos : pos+nul])
+                       pos += 64
                }
                // field[2] m.ThreadData[j1].Type
-               m.ThreadData[j1].Type = make([]uint8, 64)
-               for i := 0; i < len(m.ThreadData[j1].Type); i++ {
-                       m.ThreadData[j1].Type[i] = uint8(tmp[pos])
-                       pos += 1
+               {
+                       nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
+                       m.ThreadData[j1].Type = codec.DecodeString(tmp[pos : pos+nul])
+                       pos += 64
                }
                // field[2] m.ThreadData[j1].PID
                m.ThreadData[j1].PID = uint32(o.Uint32(tmp[pos : pos+4]))
@@ -1696,6 +1657,9 @@ var _ = bytes.NewBuffer
 var _ = context.Background
 var _ = io.Copy
 var _ = strconv.Itoa
+var _ = strings.Contains
 var _ = struc.Pack
 var _ = binary.BigEndian
 var _ = math.Float32bits
+var _ = net.ParseIP
+var _ = fmt.Errorf