Improve doc & fix import ordering
[govpp.git] / binapi / vhost_user / vhost_user.ba.go
index ea3d32b..f384bac 100644 (file)
@@ -2,7 +2,6 @@
 // versions:
 //  binapi-generator: v0.4.0-dev
 //  VPP:              20.05-release
-// source: /usr/share/vpp/api/core/vhost_user.api.json
 
 // Package vhost_user contains generated bindings for API file vhost_user.api.
 //
@@ -53,11 +52,10 @@ func (*CreateVhostUserIf) GetMessageType() api.MessageType {
        return api.RequestMessage
 }
 
-func (m *CreateVhostUserIf) Size() int {
+func (m *CreateVhostUserIf) Size() (size int) {
        if m == nil {
                return 0
        }
-       var size int
        size += 1     // m.IsServer
        size += 256   // m.SockFilename
        size += 1     // m.Renumber
@@ -72,12 +70,10 @@ func (m *CreateVhostUserIf) Size() int {
        return size
 }
 func (m *CreateVhostUserIf) Marshal(b []byte) ([]byte, error) {
-       var buf *codec.Buffer
        if b == nil {
-               buf = codec.NewBuffer(make([]byte, m.Size()))
-       } else {
-               buf = codec.NewBuffer(b)
+               b = make([]byte, m.Size())
        }
+       buf := codec.NewBuffer(b)
        buf.EncodeBool(m.IsServer)
        buf.EncodeString(m.SockFilename, 256)
        buf.EncodeBool(m.Renumber)
@@ -85,7 +81,7 @@ func (m *CreateVhostUserIf) Marshal(b []byte) ([]byte, error) {
        buf.EncodeBool(m.DisableIndirectDesc)
        buf.EncodeBool(m.EnableGso)
        buf.EncodeBool(m.EnablePacked)
-       buf.EncodeUint32(uint32(m.CustomDevInstance))
+       buf.EncodeUint32(m.CustomDevInstance)
        buf.EncodeBool(m.UseCustomMac)
        buf.EncodeBytes(m.MacAddress[:], 6)
        buf.EncodeString(m.Tag, 64)
@@ -120,29 +116,26 @@ func (*CreateVhostUserIfReply) GetMessageType() api.MessageType {
        return api.ReplyMessage
 }
 
-func (m *CreateVhostUserIfReply) Size() int {
+func (m *CreateVhostUserIfReply) Size() (size int) {
        if m == nil {
                return 0
        }
-       var size int
        size += 4 // m.Retval
        size += 4 // m.SwIfIndex
        return size
 }
 func (m *CreateVhostUserIfReply) Marshal(b []byte) ([]byte, error) {
-       var buf *codec.Buffer
        if b == nil {
-               buf = codec.NewBuffer(make([]byte, m.Size()))
-       } else {
-               buf = codec.NewBuffer(b)
+               b = make([]byte, m.Size())
        }
-       buf.EncodeUint32(uint32(m.Retval))
+       buf := codec.NewBuffer(b)
+       buf.EncodeInt32(m.Retval)
        buf.EncodeUint32(uint32(m.SwIfIndex))
        return buf.Bytes(), nil
 }
 func (m *CreateVhostUserIfReply) Unmarshal(b []byte) error {
        buf := codec.NewBuffer(b)
-       m.Retval = int32(buf.DecodeUint32())
+       m.Retval = buf.DecodeInt32()
        m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
        return nil
 }
@@ -159,21 +152,18 @@ func (*DeleteVhostUserIf) GetMessageType() api.MessageType {
        return api.RequestMessage
 }
 
-func (m *DeleteVhostUserIf) Size() int {
+func (m *DeleteVhostUserIf) Size() (size int) {
        if m == nil {
                return 0
        }
-       var size int
        size += 4 // m.SwIfIndex
        return size
 }
 func (m *DeleteVhostUserIf) Marshal(b []byte) ([]byte, error) {
-       var buf *codec.Buffer
        if b == nil {
-               buf = codec.NewBuffer(make([]byte, m.Size()))
-       } else {
-               buf = codec.NewBuffer(b)
+               b = make([]byte, m.Size())
        }
+       buf := codec.NewBuffer(b)
        buf.EncodeUint32(uint32(m.SwIfIndex))
        return buf.Bytes(), nil
 }
@@ -195,27 +185,24 @@ func (*DeleteVhostUserIfReply) GetMessageType() api.MessageType {
        return api.ReplyMessage
 }
 
-func (m *DeleteVhostUserIfReply) Size() int {
+func (m *DeleteVhostUserIfReply) Size() (size int) {
        if m == nil {
                return 0
        }
-       var size int
        size += 4 // m.Retval
        return size
 }
 func (m *DeleteVhostUserIfReply) Marshal(b []byte) ([]byte, error) {
-       var buf *codec.Buffer
        if b == nil {
-               buf = codec.NewBuffer(make([]byte, m.Size()))
-       } else {
-               buf = codec.NewBuffer(b)
+               b = make([]byte, m.Size())
        }
-       buf.EncodeUint32(uint32(m.Retval))
+       buf := codec.NewBuffer(b)
+       buf.EncodeInt32(m.Retval)
        return buf.Bytes(), nil
 }
 func (m *DeleteVhostUserIfReply) Unmarshal(b []byte) error {
        buf := codec.NewBuffer(b)
-       m.Retval = int32(buf.DecodeUint32())
+       m.Retval = buf.DecodeInt32()
        return nil
 }
 
@@ -237,11 +224,10 @@ func (*ModifyVhostUserIf) GetMessageType() api.MessageType {
        return api.RequestMessage
 }
 
-func (m *ModifyVhostUserIf) Size() int {
+func (m *ModifyVhostUserIf) Size() (size int) {
        if m == nil {
                return 0
        }
-       var size int
        size += 4   // m.SwIfIndex
        size += 1   // m.IsServer
        size += 256 // m.SockFilename
@@ -252,19 +238,17 @@ func (m *ModifyVhostUserIf) Size() int {
        return size
 }
 func (m *ModifyVhostUserIf) Marshal(b []byte) ([]byte, error) {
-       var buf *codec.Buffer
        if b == nil {
-               buf = codec.NewBuffer(make([]byte, m.Size()))
-       } else {
-               buf = codec.NewBuffer(b)
+               b = make([]byte, m.Size())
        }
+       buf := codec.NewBuffer(b)
        buf.EncodeUint32(uint32(m.SwIfIndex))
        buf.EncodeBool(m.IsServer)
        buf.EncodeString(m.SockFilename, 256)
        buf.EncodeBool(m.Renumber)
        buf.EncodeBool(m.EnableGso)
        buf.EncodeBool(m.EnablePacked)
-       buf.EncodeUint32(uint32(m.CustomDevInstance))
+       buf.EncodeUint32(m.CustomDevInstance)
        return buf.Bytes(), nil
 }
 func (m *ModifyVhostUserIf) Unmarshal(b []byte) error {
@@ -291,27 +275,24 @@ func (*ModifyVhostUserIfReply) GetMessageType() api.MessageType {
        return api.ReplyMessage
 }
 
-func (m *ModifyVhostUserIfReply) Size() int {
+func (m *ModifyVhostUserIfReply) Size() (size int) {
        if m == nil {
                return 0
        }
-       var size int
        size += 4 // m.Retval
        return size
 }
 func (m *ModifyVhostUserIfReply) Marshal(b []byte) ([]byte, error) {
-       var buf *codec.Buffer
        if b == nil {
-               buf = codec.NewBuffer(make([]byte, m.Size()))
-       } else {
-               buf = codec.NewBuffer(b)
+               b = make([]byte, m.Size())
        }
-       buf.EncodeUint32(uint32(m.Retval))
+       buf := codec.NewBuffer(b)
+       buf.EncodeInt32(m.Retval)
        return buf.Bytes(), nil
 }
 func (m *ModifyVhostUserIfReply) Unmarshal(b []byte) error {
        buf := codec.NewBuffer(b)
-       m.Retval = int32(buf.DecodeUint32())
+       m.Retval = buf.DecodeInt32()
        return nil
 }
 
@@ -335,11 +316,10 @@ func (*SwInterfaceVhostUserDetails) GetMessageType() api.MessageType {
        return api.ReplyMessage
 }
 
-func (m *SwInterfaceVhostUserDetails) Size() int {
+func (m *SwInterfaceVhostUserDetails) Size() (size int) {
        if m == nil {
                return 0
        }
-       var size int
        size += 4   // m.SwIfIndex
        size += 64  // m.InterfaceName
        size += 4   // m.VirtioNetHdrSz
@@ -352,21 +332,19 @@ func (m *SwInterfaceVhostUserDetails) Size() int {
        return size
 }
 func (m *SwInterfaceVhostUserDetails) Marshal(b []byte) ([]byte, error) {
-       var buf *codec.Buffer
        if b == nil {
-               buf = codec.NewBuffer(make([]byte, m.Size()))
-       } else {
-               buf = codec.NewBuffer(b)
+               b = make([]byte, m.Size())
        }
+       buf := codec.NewBuffer(b)
        buf.EncodeUint32(uint32(m.SwIfIndex))
        buf.EncodeString(m.InterfaceName, 64)
-       buf.EncodeUint32(uint32(m.VirtioNetHdrSz))
+       buf.EncodeUint32(m.VirtioNetHdrSz)
        buf.EncodeUint32(uint32(m.FeaturesFirst32))
        buf.EncodeUint32(uint32(m.FeaturesLast32))
        buf.EncodeBool(m.IsServer)
        buf.EncodeString(m.SockFilename, 256)
-       buf.EncodeUint32(uint32(m.NumRegions))
-       buf.EncodeUint32(uint32(m.SockErrno))
+       buf.EncodeUint32(m.NumRegions)
+       buf.EncodeInt32(m.SockErrno)
        return buf.Bytes(), nil
 }
 func (m *SwInterfaceVhostUserDetails) Unmarshal(b []byte) error {
@@ -379,13 +357,13 @@ func (m *SwInterfaceVhostUserDetails) Unmarshal(b []byte) error {
        m.IsServer = buf.DecodeBool()
        m.SockFilename = buf.DecodeString(256)
        m.NumRegions = buf.DecodeUint32()
-       m.SockErrno = int32(buf.DecodeUint32())
+       m.SockErrno = buf.DecodeInt32()
        return nil
 }
 
 // SwInterfaceVhostUserDump defines message 'sw_interface_vhost_user_dump'.
 type SwInterfaceVhostUserDump struct {
-       SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=%!s(float64=4.294967295e+09)" json:"sw_if_index,omitempty"`
+       SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"`
 }
 
 func (m *SwInterfaceVhostUserDump) Reset()               { *m = SwInterfaceVhostUserDump{} }
@@ -395,21 +373,18 @@ func (*SwInterfaceVhostUserDump) GetMessageType() api.MessageType {
        return api.RequestMessage
 }
 
-func (m *SwInterfaceVhostUserDump) Size() int {
+func (m *SwInterfaceVhostUserDump) Size() (size int) {
        if m == nil {
                return 0
        }
-       var size int
        size += 4 // m.SwIfIndex
        return size
 }
 func (m *SwInterfaceVhostUserDump) Marshal(b []byte) ([]byte, error) {
-       var buf *codec.Buffer
        if b == nil {
-               buf = codec.NewBuffer(make([]byte, m.Size()))
-       } else {
-               buf = codec.NewBuffer(b)
+               b = make([]byte, m.Size())
        }
+       buf := codec.NewBuffer(b)
        buf.EncodeUint32(uint32(m.SwIfIndex))
        return buf.Bytes(), nil
 }