From 58da9ac6e691a8c660eb8ca838a154e11da0db68 Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Wed, 22 Jul 2020 04:40:55 +0200 Subject: 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 --- internal/testbinapi/binapi2001/span/span.ba.go | 207 +++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 internal/testbinapi/binapi2001/span/span.ba.go (limited to 'internal/testbinapi/binapi2001/span/span.ba.go') diff --git a/internal/testbinapi/binapi2001/span/span.ba.go b/internal/testbinapi/binapi2001/span/span.ba.go new file mode 100644 index 0000000..31e9044 --- /dev/null +++ b/internal/testbinapi/binapi2001/span/span.ba.go @@ -0,0 +1,207 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-dev +// VPP: 20.01 +// source: .vppapi/core/span.api.json + +// Package span contains generated bindings for API file span.api. +// +// Contents: +// 4 messages +// +package span + +import ( + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the GoVPP api package it is being compiled against. +// A compilation error at this line likely means your copy of the +// GoVPP api package needs to be updated. +const _ = api.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "span" + APIVersion = "1.0.0" + VersionCrc = 0x10769b5 +) + +// SwInterfaceSpanDetails defines message 'sw_interface_span_details'. +type SwInterfaceSpanDetails struct { + SwIfIndexFrom uint32 `binapi:"u32,name=sw_if_index_from" json:"sw_if_index_from,omitempty"` + SwIfIndexTo uint32 `binapi:"u32,name=sw_if_index_to" json:"sw_if_index_to,omitempty"` + State uint8 `binapi:"u8,name=state" json:"state,omitempty"` + IsL2 uint8 `binapi:"u8,name=is_l2" json:"is_l2,omitempty"` +} + +func (m *SwInterfaceSpanDetails) Reset() { *m = SwInterfaceSpanDetails{} } +func (*SwInterfaceSpanDetails) GetMessageName() string { return "sw_interface_span_details" } +func (*SwInterfaceSpanDetails) GetCrcString() string { return "23966371" } +func (*SwInterfaceSpanDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceSpanDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndexFrom + size += 4 // m.SwIfIndexTo + size += 1 // m.State + size += 1 // m.IsL2 + return size +} +func (m *SwInterfaceSpanDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SwIfIndexFrom) + buf.EncodeUint32(m.SwIfIndexTo) + buf.EncodeUint8(m.State) + buf.EncodeUint8(m.IsL2) + return buf.Bytes(), nil +} +func (m *SwInterfaceSpanDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndexFrom = buf.DecodeUint32() + m.SwIfIndexTo = buf.DecodeUint32() + m.State = buf.DecodeUint8() + m.IsL2 = buf.DecodeUint8() + return nil +} + +// SwInterfaceSpanDump defines message 'sw_interface_span_dump'. +type SwInterfaceSpanDump struct { + IsL2 uint8 `binapi:"u8,name=is_l2" json:"is_l2,omitempty"` +} + +func (m *SwInterfaceSpanDump) Reset() { *m = SwInterfaceSpanDump{} } +func (*SwInterfaceSpanDump) GetMessageName() string { return "sw_interface_span_dump" } +func (*SwInterfaceSpanDump) GetCrcString() string { return "67c54650" } +func (*SwInterfaceSpanDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSpanDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsL2 + return size +} +func (m *SwInterfaceSpanDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(m.IsL2) + return buf.Bytes(), nil +} +func (m *SwInterfaceSpanDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsL2 = buf.DecodeUint8() + return nil +} + +// SwInterfaceSpanEnableDisable defines message 'sw_interface_span_enable_disable'. +type SwInterfaceSpanEnableDisable struct { + SwIfIndexFrom uint32 `binapi:"u32,name=sw_if_index_from" json:"sw_if_index_from,omitempty"` + SwIfIndexTo uint32 `binapi:"u32,name=sw_if_index_to" json:"sw_if_index_to,omitempty"` + State uint8 `binapi:"u8,name=state" json:"state,omitempty"` + IsL2 uint8 `binapi:"u8,name=is_l2" json:"is_l2,omitempty"` +} + +func (m *SwInterfaceSpanEnableDisable) Reset() { *m = SwInterfaceSpanEnableDisable{} } +func (*SwInterfaceSpanEnableDisable) GetMessageName() string { + return "sw_interface_span_enable_disable" +} +func (*SwInterfaceSpanEnableDisable) GetCrcString() string { return "7216258d" } +func (*SwInterfaceSpanEnableDisable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SwInterfaceSpanEnableDisable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndexFrom + size += 4 // m.SwIfIndexTo + size += 1 // m.State + size += 1 // m.IsL2 + return size +} +func (m *SwInterfaceSpanEnableDisable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SwIfIndexFrom) + buf.EncodeUint32(m.SwIfIndexTo) + buf.EncodeUint8(m.State) + buf.EncodeUint8(m.IsL2) + return buf.Bytes(), nil +} +func (m *SwInterfaceSpanEnableDisable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndexFrom = buf.DecodeUint32() + m.SwIfIndexTo = buf.DecodeUint32() + m.State = buf.DecodeUint8() + m.IsL2 = buf.DecodeUint8() + return nil +} + +// SwInterfaceSpanEnableDisableReply defines message 'sw_interface_span_enable_disable_reply'. +type SwInterfaceSpanEnableDisableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SwInterfaceSpanEnableDisableReply) Reset() { *m = SwInterfaceSpanEnableDisableReply{} } +func (*SwInterfaceSpanEnableDisableReply) GetMessageName() string { + return "sw_interface_span_enable_disable_reply" +} +func (*SwInterfaceSpanEnableDisableReply) GetCrcString() string { return "e8d4e804" } +func (*SwInterfaceSpanEnableDisableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SwInterfaceSpanEnableDisableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SwInterfaceSpanEnableDisableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SwInterfaceSpanEnableDisableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_span_binapi_init() } +func file_span_binapi_init() { + api.RegisterMessage((*SwInterfaceSpanDetails)(nil), "sw_interface_span_details_23966371") + api.RegisterMessage((*SwInterfaceSpanDump)(nil), "sw_interface_span_dump_67c54650") + api.RegisterMessage((*SwInterfaceSpanEnableDisable)(nil), "sw_interface_span_enable_disable_7216258d") + api.RegisterMessage((*SwInterfaceSpanEnableDisableReply)(nil), "sw_interface_span_enable_disable_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*SwInterfaceSpanDetails)(nil), + (*SwInterfaceSpanDump)(nil), + (*SwInterfaceSpanEnableDisable)(nil), + (*SwInterfaceSpanEnableDisableReply)(nil), + } +} -- cgit 1.2.3-korg