Improve binapi generator
[govpp.git] / binapi / span / span.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2 // versions:
3 //  binapi-generator: v0.4.0-dev
4 //  VPP:              20.05-release
5 // source: /usr/share/vpp/api/core/span.api.json
6
7 // Package span contains generated bindings for API file span.api.
8 //
9 // Contents:
10 //   1 enum
11 //   4 messages
12 //
13 package span
14
15 import (
16         api "git.fd.io/govpp.git/api"
17         interface_types "git.fd.io/govpp.git/binapi/interface_types"
18         codec "git.fd.io/govpp.git/codec"
19         "strconv"
20 )
21
22 // This is a compile-time assertion to ensure that this generated file
23 // is compatible with the GoVPP api package it is being compiled against.
24 // A compilation error at this line likely means your copy of the
25 // GoVPP api package needs to be updated.
26 const _ = api.GoVppAPIPackageIsVersion2
27
28 const (
29         APIFile    = "span"
30         APIVersion = "2.0.0"
31         VersionCrc = 0x9f4dec7c
32 )
33
34 // SpanState defines enum 'span_state'.
35 type SpanState uint32
36
37 const (
38         SPAN_STATE_API_DISABLED SpanState = 0
39         SPAN_STATE_API_RX       SpanState = 1
40         SPAN_STATE_API_TX       SpanState = 2
41         SPAN_STATE_API_RX_TX    SpanState = 3
42 )
43
44 var (
45         SpanState_name = map[uint32]string{
46                 0: "SPAN_STATE_API_DISABLED",
47                 1: "SPAN_STATE_API_RX",
48                 2: "SPAN_STATE_API_TX",
49                 3: "SPAN_STATE_API_RX_TX",
50         }
51         SpanState_value = map[string]uint32{
52                 "SPAN_STATE_API_DISABLED": 0,
53                 "SPAN_STATE_API_RX":       1,
54                 "SPAN_STATE_API_TX":       2,
55                 "SPAN_STATE_API_RX_TX":    3,
56         }
57 )
58
59 func (x SpanState) String() string {
60         s, ok := SpanState_name[uint32(x)]
61         if ok {
62                 return s
63         }
64         return "SpanState(" + strconv.Itoa(int(x)) + ")"
65 }
66
67 // SwInterfaceSpanDetails defines message 'sw_interface_span_details'.
68 type SwInterfaceSpanDetails struct {
69         SwIfIndexFrom interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index_from" json:"sw_if_index_from,omitempty"`
70         SwIfIndexTo   interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index_to" json:"sw_if_index_to,omitempty"`
71         State         SpanState                      `binapi:"span_state,name=state" json:"state,omitempty"`
72         IsL2          bool                           `binapi:"bool,name=is_l2" json:"is_l2,omitempty"`
73 }
74
75 func (m *SwInterfaceSpanDetails) Reset()               { *m = SwInterfaceSpanDetails{} }
76 func (*SwInterfaceSpanDetails) GetMessageName() string { return "sw_interface_span_details" }
77 func (*SwInterfaceSpanDetails) GetCrcString() string   { return "055643fc" }
78 func (*SwInterfaceSpanDetails) GetMessageType() api.MessageType {
79         return api.ReplyMessage
80 }
81
82 func (m *SwInterfaceSpanDetails) Size() int {
83         if m == nil {
84                 return 0
85         }
86         var size int
87         size += 4 // m.SwIfIndexFrom
88         size += 4 // m.SwIfIndexTo
89         size += 4 // m.State
90         size += 1 // m.IsL2
91         return size
92 }
93 func (m *SwInterfaceSpanDetails) Marshal(b []byte) ([]byte, error) {
94         var buf *codec.Buffer
95         if b == nil {
96                 buf = codec.NewBuffer(make([]byte, m.Size()))
97         } else {
98                 buf = codec.NewBuffer(b)
99         }
100         buf.EncodeUint32(uint32(m.SwIfIndexFrom))
101         buf.EncodeUint32(uint32(m.SwIfIndexTo))
102         buf.EncodeUint32(uint32(m.State))
103         buf.EncodeBool(m.IsL2)
104         return buf.Bytes(), nil
105 }
106 func (m *SwInterfaceSpanDetails) Unmarshal(b []byte) error {
107         buf := codec.NewBuffer(b)
108         m.SwIfIndexFrom = interface_types.InterfaceIndex(buf.DecodeUint32())
109         m.SwIfIndexTo = interface_types.InterfaceIndex(buf.DecodeUint32())
110         m.State = SpanState(buf.DecodeUint32())
111         m.IsL2 = buf.DecodeBool()
112         return nil
113 }
114
115 // SwInterfaceSpanDump defines message 'sw_interface_span_dump'.
116 type SwInterfaceSpanDump struct {
117         IsL2 bool `binapi:"bool,name=is_l2" json:"is_l2,omitempty"`
118 }
119
120 func (m *SwInterfaceSpanDump) Reset()               { *m = SwInterfaceSpanDump{} }
121 func (*SwInterfaceSpanDump) GetMessageName() string { return "sw_interface_span_dump" }
122 func (*SwInterfaceSpanDump) GetCrcString() string   { return "d6cf0c3d" }
123 func (*SwInterfaceSpanDump) GetMessageType() api.MessageType {
124         return api.RequestMessage
125 }
126
127 func (m *SwInterfaceSpanDump) Size() int {
128         if m == nil {
129                 return 0
130         }
131         var size int
132         size += 1 // m.IsL2
133         return size
134 }
135 func (m *SwInterfaceSpanDump) Marshal(b []byte) ([]byte, error) {
136         var buf *codec.Buffer
137         if b == nil {
138                 buf = codec.NewBuffer(make([]byte, m.Size()))
139         } else {
140                 buf = codec.NewBuffer(b)
141         }
142         buf.EncodeBool(m.IsL2)
143         return buf.Bytes(), nil
144 }
145 func (m *SwInterfaceSpanDump) Unmarshal(b []byte) error {
146         buf := codec.NewBuffer(b)
147         m.IsL2 = buf.DecodeBool()
148         return nil
149 }
150
151 // SwInterfaceSpanEnableDisable defines message 'sw_interface_span_enable_disable'.
152 type SwInterfaceSpanEnableDisable struct {
153         SwIfIndexFrom interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index_from" json:"sw_if_index_from,omitempty"`
154         SwIfIndexTo   interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index_to" json:"sw_if_index_to,omitempty"`
155         State         SpanState                      `binapi:"span_state,name=state" json:"state,omitempty"`
156         IsL2          bool                           `binapi:"bool,name=is_l2" json:"is_l2,omitempty"`
157 }
158
159 func (m *SwInterfaceSpanEnableDisable) Reset() { *m = SwInterfaceSpanEnableDisable{} }
160 func (*SwInterfaceSpanEnableDisable) GetMessageName() string {
161         return "sw_interface_span_enable_disable"
162 }
163 func (*SwInterfaceSpanEnableDisable) GetCrcString() string { return "acc8fea1" }
164 func (*SwInterfaceSpanEnableDisable) GetMessageType() api.MessageType {
165         return api.RequestMessage
166 }
167
168 func (m *SwInterfaceSpanEnableDisable) Size() int {
169         if m == nil {
170                 return 0
171         }
172         var size int
173         size += 4 // m.SwIfIndexFrom
174         size += 4 // m.SwIfIndexTo
175         size += 4 // m.State
176         size += 1 // m.IsL2
177         return size
178 }
179 func (m *SwInterfaceSpanEnableDisable) Marshal(b []byte) ([]byte, error) {
180         var buf *codec.Buffer
181         if b == nil {
182                 buf = codec.NewBuffer(make([]byte, m.Size()))
183         } else {
184                 buf = codec.NewBuffer(b)
185         }
186         buf.EncodeUint32(uint32(m.SwIfIndexFrom))
187         buf.EncodeUint32(uint32(m.SwIfIndexTo))
188         buf.EncodeUint32(uint32(m.State))
189         buf.EncodeBool(m.IsL2)
190         return buf.Bytes(), nil
191 }
192 func (m *SwInterfaceSpanEnableDisable) Unmarshal(b []byte) error {
193         buf := codec.NewBuffer(b)
194         m.SwIfIndexFrom = interface_types.InterfaceIndex(buf.DecodeUint32())
195         m.SwIfIndexTo = interface_types.InterfaceIndex(buf.DecodeUint32())
196         m.State = SpanState(buf.DecodeUint32())
197         m.IsL2 = buf.DecodeBool()
198         return nil
199 }
200
201 // SwInterfaceSpanEnableDisableReply defines message 'sw_interface_span_enable_disable_reply'.
202 type SwInterfaceSpanEnableDisableReply struct {
203         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
204 }
205
206 func (m *SwInterfaceSpanEnableDisableReply) Reset() { *m = SwInterfaceSpanEnableDisableReply{} }
207 func (*SwInterfaceSpanEnableDisableReply) GetMessageName() string {
208         return "sw_interface_span_enable_disable_reply"
209 }
210 func (*SwInterfaceSpanEnableDisableReply) GetCrcString() string { return "e8d4e804" }
211 func (*SwInterfaceSpanEnableDisableReply) GetMessageType() api.MessageType {
212         return api.ReplyMessage
213 }
214
215 func (m *SwInterfaceSpanEnableDisableReply) Size() int {
216         if m == nil {
217                 return 0
218         }
219         var size int
220         size += 4 // m.Retval
221         return size
222 }
223 func (m *SwInterfaceSpanEnableDisableReply) Marshal(b []byte) ([]byte, error) {
224         var buf *codec.Buffer
225         if b == nil {
226                 buf = codec.NewBuffer(make([]byte, m.Size()))
227         } else {
228                 buf = codec.NewBuffer(b)
229         }
230         buf.EncodeUint32(uint32(m.Retval))
231         return buf.Bytes(), nil
232 }
233 func (m *SwInterfaceSpanEnableDisableReply) Unmarshal(b []byte) error {
234         buf := codec.NewBuffer(b)
235         m.Retval = int32(buf.DecodeUint32())
236         return nil
237 }
238
239 func init() { file_span_binapi_init() }
240 func file_span_binapi_init() {
241         api.RegisterMessage((*SwInterfaceSpanDetails)(nil), "sw_interface_span_details_055643fc")
242         api.RegisterMessage((*SwInterfaceSpanDump)(nil), "sw_interface_span_dump_d6cf0c3d")
243         api.RegisterMessage((*SwInterfaceSpanEnableDisable)(nil), "sw_interface_span_enable_disable_acc8fea1")
244         api.RegisterMessage((*SwInterfaceSpanEnableDisableReply)(nil), "sw_interface_span_enable_disable_reply_e8d4e804")
245 }
246
247 // Messages returns list of all messages in this module.
248 func AllMessages() []api.Message {
249         return []api.Message{
250                 (*SwInterfaceSpanDetails)(nil),
251                 (*SwInterfaceSpanDump)(nil),
252                 (*SwInterfaceSpanEnableDisable)(nil),
253                 (*SwInterfaceSpanEnableDisableReply)(nil),
254         }
255 }