aboutsummaryrefslogtreecommitdiffstats
path: root/binapi/feature
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/feature
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/feature')
-rw-r--r--binapi/feature/feature.ba.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/binapi/feature/feature.ba.go b/binapi/feature/feature.ba.go
index 4d16ce8..cc54364 100644
--- a/binapi/feature/feature.ba.go
+++ b/binapi/feature/feature.ba.go
@@ -44,11 +44,10 @@ func (*FeatureEnableDisable) GetMessageType() api.MessageType {
return api.RequestMessage
}
-func (m *FeatureEnableDisable) Size() int {
+func (m *FeatureEnableDisable) Size() (size int) {
if m == nil {
return 0
}
- var size int
size += 4 // m.SwIfIndex
size += 1 // m.Enable
size += 64 // m.ArcName
@@ -56,12 +55,10 @@ func (m *FeatureEnableDisable) Size() int {
return size
}
func (m *FeatureEnableDisable) 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.Enable)
buf.EncodeString(m.ArcName, 64)
@@ -89,27 +86,24 @@ func (*FeatureEnableDisableReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
-func (m *FeatureEnableDisableReply) Size() int {
+func (m *FeatureEnableDisableReply) Size() (size int) {
if m == nil {
return 0
}
- var size int
size += 4 // m.Retval
return size
}
func (m *FeatureEnableDisableReply) 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 *FeatureEnableDisableReply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
- m.Retval = int32(buf.DecodeUint32())
+ m.Retval = buf.DecodeInt32()
return nil
}