summaryrefslogtreecommitdiffstats
path: root/binapi/ct6
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2020-07-22 04:40:55 +0200
committerOndrej Fabry <ofabry@cisco.com>2020-07-22 04:40:55 +0200
commit58da9ac6e691a8c660eb8ca838a154e11da0db68 (patch)
treea1bbda04c6d0621ce0fc20779276620f1820190b /binapi/ct6
parenta155cd438c6558da266c1c5931361ea088b35653 (diff)
Fix binapigen decoding and minor improvements
- fixed allocating byte slices before copying decoded data - simplified encoding functions - several minor improvements Change-Id: I6669424b89eb86333805cb1b57e4551169980cc2 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'binapi/ct6')
-rw-r--r--binapi/ct6/ct6.ba.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/binapi/ct6/ct6.ba.go b/binapi/ct6/ct6.ba.go
index fbcc0bc..5dc6097 100644
--- a/binapi/ct6/ct6.ba.go
+++ b/binapi/ct6/ct6.ba.go
@@ -43,23 +43,20 @@ func (*Ct6EnableDisable) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func (m *Ct6EnableDisable) Size() int {
+func (m *Ct6EnableDisable) Size() (size int) {
if m == nil {
return 0
}
- var size int
size += 1 // m.EnableDisable
size += 1 // m.IsInside
size += 4 // m.SwIfIndex
return size
}
func (m *Ct6EnableDisable) 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.EnableDisable)
buf.EncodeBool(m.IsInside)
buf.EncodeUint32(uint32(m.SwIfIndex))
@@ -85,27 +82,24 @@ func (*Ct6EnableDisableReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func (m *Ct6EnableDisableReply) Size() int {
+func (m *Ct6EnableDisableReply) Size() (size int) {
if m == nil {
return 0
}
- var size int
size += 4 // m.Retval
return size
}
func (m *Ct6EnableDisableReply) 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 *Ct6EnableDisableReply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
- m.Retval = int32(buf.DecodeUint32())
+ m.Retval = buf.DecodeInt32()
return nil
}