binapigen: fix union size
[govpp.git] / binapi / memif / memif.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/plugins/memif.api.json
6
7 // Package memif contains generated bindings for API file memif.api.
8 //
9 // Contents:
10 //   2 enums
11 //  10 messages
12 //
13 package memif
14
15 import (
16         "strconv"
17
18         api "git.fd.io/govpp.git/api"
19         ethernet_types "git.fd.io/govpp.git/binapi/ethernet_types"
20         interface_types "git.fd.io/govpp.git/binapi/interface_types"
21         codec "git.fd.io/govpp.git/codec"
22 )
23
24 // This is a compile-time assertion to ensure that this generated file
25 // is compatible with the GoVPP api package it is being compiled against.
26 // A compilation error at this line likely means your copy of the
27 // GoVPP api package needs to be updated.
28 const _ = api.GoVppAPIPackageIsVersion2
29
30 const (
31         APIFile    = "memif"
32         APIVersion = "3.0.0"
33         VersionCrc = 0x1a1c95b8
34 )
35
36 // MemifMode defines enum 'memif_mode'.
37 type MemifMode uint32
38
39 const (
40         MEMIF_MODE_API_ETHERNET    MemifMode = 0
41         MEMIF_MODE_API_IP          MemifMode = 1
42         MEMIF_MODE_API_PUNT_INJECT MemifMode = 2
43 )
44
45 var (
46         MemifMode_name = map[uint32]string{
47                 0: "MEMIF_MODE_API_ETHERNET",
48                 1: "MEMIF_MODE_API_IP",
49                 2: "MEMIF_MODE_API_PUNT_INJECT",
50         }
51         MemifMode_value = map[string]uint32{
52                 "MEMIF_MODE_API_ETHERNET":    0,
53                 "MEMIF_MODE_API_IP":          1,
54                 "MEMIF_MODE_API_PUNT_INJECT": 2,
55         }
56 )
57
58 func (x MemifMode) String() string {
59         s, ok := MemifMode_name[uint32(x)]
60         if ok {
61                 return s
62         }
63         return "MemifMode(" + strconv.Itoa(int(x)) + ")"
64 }
65
66 // MemifRole defines enum 'memif_role'.
67 type MemifRole uint32
68
69 const (
70         MEMIF_ROLE_API_MASTER MemifRole = 0
71         MEMIF_ROLE_API_SLAVE  MemifRole = 1
72 )
73
74 var (
75         MemifRole_name = map[uint32]string{
76                 0: "MEMIF_ROLE_API_MASTER",
77                 1: "MEMIF_ROLE_API_SLAVE",
78         }
79         MemifRole_value = map[string]uint32{
80                 "MEMIF_ROLE_API_MASTER": 0,
81                 "MEMIF_ROLE_API_SLAVE":  1,
82         }
83 )
84
85 func (x MemifRole) String() string {
86         s, ok := MemifRole_name[uint32(x)]
87         if ok {
88                 return s
89         }
90         return "MemifRole(" + strconv.Itoa(int(x)) + ")"
91 }
92
93 // MemifCreate defines message 'memif_create'.
94 type MemifCreate struct {
95         Role       MemifRole                 `binapi:"memif_role,name=role" json:"role,omitempty"`
96         Mode       MemifMode                 `binapi:"memif_mode,name=mode" json:"mode,omitempty"`
97         RxQueues   uint8                     `binapi:"u8,name=rx_queues" json:"rx_queues,omitempty"`
98         TxQueues   uint8                     `binapi:"u8,name=tx_queues" json:"tx_queues,omitempty"`
99         ID         uint32                    `binapi:"u32,name=id" json:"id,omitempty"`
100         SocketID   uint32                    `binapi:"u32,name=socket_id" json:"socket_id,omitempty"`
101         RingSize   uint32                    `binapi:"u32,name=ring_size" json:"ring_size,omitempty"`
102         BufferSize uint16                    `binapi:"u16,name=buffer_size" json:"buffer_size,omitempty"`
103         NoZeroCopy bool                      `binapi:"bool,name=no_zero_copy" json:"no_zero_copy,omitempty"`
104         HwAddr     ethernet_types.MacAddress `binapi:"mac_address,name=hw_addr" json:"hw_addr,omitempty"`
105         Secret     string                    `binapi:"string[24],name=secret" json:"secret,omitempty"`
106 }
107
108 func (m *MemifCreate) Reset()               { *m = MemifCreate{} }
109 func (*MemifCreate) GetMessageName() string { return "memif_create" }
110 func (*MemifCreate) GetCrcString() string   { return "b1b25061" }
111 func (*MemifCreate) GetMessageType() api.MessageType {
112         return api.RequestMessage
113 }
114
115 func (m *MemifCreate) Size() (size int) {
116         if m == nil {
117                 return 0
118         }
119         size += 4     // m.Role
120         size += 4     // m.Mode
121         size += 1     // m.RxQueues
122         size += 1     // m.TxQueues
123         size += 4     // m.ID
124         size += 4     // m.SocketID
125         size += 4     // m.RingSize
126         size += 2     // m.BufferSize
127         size += 1     // m.NoZeroCopy
128         size += 1 * 6 // m.HwAddr
129         size += 24    // m.Secret
130         return size
131 }
132 func (m *MemifCreate) Marshal(b []byte) ([]byte, error) {
133         if b == nil {
134                 b = make([]byte, m.Size())
135         }
136         buf := codec.NewBuffer(b)
137         buf.EncodeUint32(uint32(m.Role))
138         buf.EncodeUint32(uint32(m.Mode))
139         buf.EncodeUint8(m.RxQueues)
140         buf.EncodeUint8(m.TxQueues)
141         buf.EncodeUint32(m.ID)
142         buf.EncodeUint32(m.SocketID)
143         buf.EncodeUint32(m.RingSize)
144         buf.EncodeUint16(m.BufferSize)
145         buf.EncodeBool(m.NoZeroCopy)
146         buf.EncodeBytes(m.HwAddr[:], 6)
147         buf.EncodeString(m.Secret, 24)
148         return buf.Bytes(), nil
149 }
150 func (m *MemifCreate) Unmarshal(b []byte) error {
151         buf := codec.NewBuffer(b)
152         m.Role = MemifRole(buf.DecodeUint32())
153         m.Mode = MemifMode(buf.DecodeUint32())
154         m.RxQueues = buf.DecodeUint8()
155         m.TxQueues = buf.DecodeUint8()
156         m.ID = buf.DecodeUint32()
157         m.SocketID = buf.DecodeUint32()
158         m.RingSize = buf.DecodeUint32()
159         m.BufferSize = buf.DecodeUint16()
160         m.NoZeroCopy = buf.DecodeBool()
161         copy(m.HwAddr[:], buf.DecodeBytes(6))
162         m.Secret = buf.DecodeString(24)
163         return nil
164 }
165
166 // MemifCreateReply defines message 'memif_create_reply'.
167 type MemifCreateReply struct {
168         Retval    int32                          `binapi:"i32,name=retval" json:"retval,omitempty"`
169         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
170 }
171
172 func (m *MemifCreateReply) Reset()               { *m = MemifCreateReply{} }
173 func (*MemifCreateReply) GetMessageName() string { return "memif_create_reply" }
174 func (*MemifCreateReply) GetCrcString() string   { return "5383d31f" }
175 func (*MemifCreateReply) GetMessageType() api.MessageType {
176         return api.ReplyMessage
177 }
178
179 func (m *MemifCreateReply) Size() (size int) {
180         if m == nil {
181                 return 0
182         }
183         size += 4 // m.Retval
184         size += 4 // m.SwIfIndex
185         return size
186 }
187 func (m *MemifCreateReply) Marshal(b []byte) ([]byte, error) {
188         if b == nil {
189                 b = make([]byte, m.Size())
190         }
191         buf := codec.NewBuffer(b)
192         buf.EncodeInt32(m.Retval)
193         buf.EncodeUint32(uint32(m.SwIfIndex))
194         return buf.Bytes(), nil
195 }
196 func (m *MemifCreateReply) Unmarshal(b []byte) error {
197         buf := codec.NewBuffer(b)
198         m.Retval = buf.DecodeInt32()
199         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
200         return nil
201 }
202
203 // MemifDelete defines message 'memif_delete'.
204 type MemifDelete struct {
205         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
206 }
207
208 func (m *MemifDelete) Reset()               { *m = MemifDelete{} }
209 func (*MemifDelete) GetMessageName() string { return "memif_delete" }
210 func (*MemifDelete) GetCrcString() string   { return "f9e6675e" }
211 func (*MemifDelete) GetMessageType() api.MessageType {
212         return api.RequestMessage
213 }
214
215 func (m *MemifDelete) Size() (size int) {
216         if m == nil {
217                 return 0
218         }
219         size += 4 // m.SwIfIndex
220         return size
221 }
222 func (m *MemifDelete) Marshal(b []byte) ([]byte, error) {
223         if b == nil {
224                 b = make([]byte, m.Size())
225         }
226         buf := codec.NewBuffer(b)
227         buf.EncodeUint32(uint32(m.SwIfIndex))
228         return buf.Bytes(), nil
229 }
230 func (m *MemifDelete) Unmarshal(b []byte) error {
231         buf := codec.NewBuffer(b)
232         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
233         return nil
234 }
235
236 // MemifDeleteReply defines message 'memif_delete_reply'.
237 type MemifDeleteReply struct {
238         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
239 }
240
241 func (m *MemifDeleteReply) Reset()               { *m = MemifDeleteReply{} }
242 func (*MemifDeleteReply) GetMessageName() string { return "memif_delete_reply" }
243 func (*MemifDeleteReply) GetCrcString() string   { return "e8d4e804" }
244 func (*MemifDeleteReply) GetMessageType() api.MessageType {
245         return api.ReplyMessage
246 }
247
248 func (m *MemifDeleteReply) Size() (size int) {
249         if m == nil {
250                 return 0
251         }
252         size += 4 // m.Retval
253         return size
254 }
255 func (m *MemifDeleteReply) Marshal(b []byte) ([]byte, error) {
256         if b == nil {
257                 b = make([]byte, m.Size())
258         }
259         buf := codec.NewBuffer(b)
260         buf.EncodeInt32(m.Retval)
261         return buf.Bytes(), nil
262 }
263 func (m *MemifDeleteReply) Unmarshal(b []byte) error {
264         buf := codec.NewBuffer(b)
265         m.Retval = buf.DecodeInt32()
266         return nil
267 }
268
269 // MemifDetails defines message 'memif_details'.
270 type MemifDetails struct {
271         SwIfIndex  interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
272         HwAddr     ethernet_types.MacAddress      `binapi:"mac_address,name=hw_addr" json:"hw_addr,omitempty"`
273         ID         uint32                         `binapi:"u32,name=id" json:"id,omitempty"`
274         Role       MemifRole                      `binapi:"memif_role,name=role" json:"role,omitempty"`
275         Mode       MemifMode                      `binapi:"memif_mode,name=mode" json:"mode,omitempty"`
276         ZeroCopy   bool                           `binapi:"bool,name=zero_copy" json:"zero_copy,omitempty"`
277         SocketID   uint32                         `binapi:"u32,name=socket_id" json:"socket_id,omitempty"`
278         RingSize   uint32                         `binapi:"u32,name=ring_size" json:"ring_size,omitempty"`
279         BufferSize uint16                         `binapi:"u16,name=buffer_size" json:"buffer_size,omitempty"`
280         Flags      interface_types.IfStatusFlags  `binapi:"if_status_flags,name=flags" json:"flags,omitempty"`
281         IfName     string                         `binapi:"string[64],name=if_name" json:"if_name,omitempty"`
282 }
283
284 func (m *MemifDetails) Reset()               { *m = MemifDetails{} }
285 func (*MemifDetails) GetMessageName() string { return "memif_details" }
286 func (*MemifDetails) GetCrcString() string   { return "d0382c4c" }
287 func (*MemifDetails) GetMessageType() api.MessageType {
288         return api.ReplyMessage
289 }
290
291 func (m *MemifDetails) Size() (size int) {
292         if m == nil {
293                 return 0
294         }
295         size += 4     // m.SwIfIndex
296         size += 1 * 6 // m.HwAddr
297         size += 4     // m.ID
298         size += 4     // m.Role
299         size += 4     // m.Mode
300         size += 1     // m.ZeroCopy
301         size += 4     // m.SocketID
302         size += 4     // m.RingSize
303         size += 2     // m.BufferSize
304         size += 4     // m.Flags
305         size += 64    // m.IfName
306         return size
307 }
308 func (m *MemifDetails) Marshal(b []byte) ([]byte, error) {
309         if b == nil {
310                 b = make([]byte, m.Size())
311         }
312         buf := codec.NewBuffer(b)
313         buf.EncodeUint32(uint32(m.SwIfIndex))
314         buf.EncodeBytes(m.HwAddr[:], 6)
315         buf.EncodeUint32(m.ID)
316         buf.EncodeUint32(uint32(m.Role))
317         buf.EncodeUint32(uint32(m.Mode))
318         buf.EncodeBool(m.ZeroCopy)
319         buf.EncodeUint32(m.SocketID)
320         buf.EncodeUint32(m.RingSize)
321         buf.EncodeUint16(m.BufferSize)
322         buf.EncodeUint32(uint32(m.Flags))
323         buf.EncodeString(m.IfName, 64)
324         return buf.Bytes(), nil
325 }
326 func (m *MemifDetails) Unmarshal(b []byte) error {
327         buf := codec.NewBuffer(b)
328         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
329         copy(m.HwAddr[:], buf.DecodeBytes(6))
330         m.ID = buf.DecodeUint32()
331         m.Role = MemifRole(buf.DecodeUint32())
332         m.Mode = MemifMode(buf.DecodeUint32())
333         m.ZeroCopy = buf.DecodeBool()
334         m.SocketID = buf.DecodeUint32()
335         m.RingSize = buf.DecodeUint32()
336         m.BufferSize = buf.DecodeUint16()
337         m.Flags = interface_types.IfStatusFlags(buf.DecodeUint32())
338         m.IfName = buf.DecodeString(64)
339         return nil
340 }
341
342 // MemifDump defines message 'memif_dump'.
343 type MemifDump struct{}
344
345 func (m *MemifDump) Reset()               { *m = MemifDump{} }
346 func (*MemifDump) GetMessageName() string { return "memif_dump" }
347 func (*MemifDump) GetCrcString() string   { return "51077d14" }
348 func (*MemifDump) GetMessageType() api.MessageType {
349         return api.RequestMessage
350 }
351
352 func (m *MemifDump) Size() (size int) {
353         if m == nil {
354                 return 0
355         }
356         return size
357 }
358 func (m *MemifDump) Marshal(b []byte) ([]byte, error) {
359         if b == nil {
360                 b = make([]byte, m.Size())
361         }
362         buf := codec.NewBuffer(b)
363         return buf.Bytes(), nil
364 }
365 func (m *MemifDump) Unmarshal(b []byte) error {
366         return nil
367 }
368
369 // MemifSocketFilenameAddDel defines message 'memif_socket_filename_add_del'.
370 type MemifSocketFilenameAddDel struct {
371         IsAdd          bool   `binapi:"bool,name=is_add" json:"is_add,omitempty"`
372         SocketID       uint32 `binapi:"u32,name=socket_id" json:"socket_id,omitempty"`
373         SocketFilename string `binapi:"string[108],name=socket_filename" json:"socket_filename,omitempty"`
374 }
375
376 func (m *MemifSocketFilenameAddDel) Reset()               { *m = MemifSocketFilenameAddDel{} }
377 func (*MemifSocketFilenameAddDel) GetMessageName() string { return "memif_socket_filename_add_del" }
378 func (*MemifSocketFilenameAddDel) GetCrcString() string   { return "a2ce1a10" }
379 func (*MemifSocketFilenameAddDel) GetMessageType() api.MessageType {
380         return api.RequestMessage
381 }
382
383 func (m *MemifSocketFilenameAddDel) Size() (size int) {
384         if m == nil {
385                 return 0
386         }
387         size += 1   // m.IsAdd
388         size += 4   // m.SocketID
389         size += 108 // m.SocketFilename
390         return size
391 }
392 func (m *MemifSocketFilenameAddDel) Marshal(b []byte) ([]byte, error) {
393         if b == nil {
394                 b = make([]byte, m.Size())
395         }
396         buf := codec.NewBuffer(b)
397         buf.EncodeBool(m.IsAdd)
398         buf.EncodeUint32(m.SocketID)
399         buf.EncodeString(m.SocketFilename, 108)
400         return buf.Bytes(), nil
401 }
402 func (m *MemifSocketFilenameAddDel) Unmarshal(b []byte) error {
403         buf := codec.NewBuffer(b)
404         m.IsAdd = buf.DecodeBool()
405         m.SocketID = buf.DecodeUint32()
406         m.SocketFilename = buf.DecodeString(108)
407         return nil
408 }
409
410 // MemifSocketFilenameAddDelReply defines message 'memif_socket_filename_add_del_reply'.
411 type MemifSocketFilenameAddDelReply struct {
412         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
413 }
414
415 func (m *MemifSocketFilenameAddDelReply) Reset() { *m = MemifSocketFilenameAddDelReply{} }
416 func (*MemifSocketFilenameAddDelReply) GetMessageName() string {
417         return "memif_socket_filename_add_del_reply"
418 }
419 func (*MemifSocketFilenameAddDelReply) GetCrcString() string { return "e8d4e804" }
420 func (*MemifSocketFilenameAddDelReply) GetMessageType() api.MessageType {
421         return api.ReplyMessage
422 }
423
424 func (m *MemifSocketFilenameAddDelReply) Size() (size int) {
425         if m == nil {
426                 return 0
427         }
428         size += 4 // m.Retval
429         return size
430 }
431 func (m *MemifSocketFilenameAddDelReply) Marshal(b []byte) ([]byte, error) {
432         if b == nil {
433                 b = make([]byte, m.Size())
434         }
435         buf := codec.NewBuffer(b)
436         buf.EncodeInt32(m.Retval)
437         return buf.Bytes(), nil
438 }
439 func (m *MemifSocketFilenameAddDelReply) Unmarshal(b []byte) error {
440         buf := codec.NewBuffer(b)
441         m.Retval = buf.DecodeInt32()
442         return nil
443 }
444
445 // MemifSocketFilenameDetails defines message 'memif_socket_filename_details'.
446 type MemifSocketFilenameDetails struct {
447         SocketID       uint32 `binapi:"u32,name=socket_id" json:"socket_id,omitempty"`
448         SocketFilename string `binapi:"string[108],name=socket_filename" json:"socket_filename,omitempty"`
449 }
450
451 func (m *MemifSocketFilenameDetails) Reset()               { *m = MemifSocketFilenameDetails{} }
452 func (*MemifSocketFilenameDetails) GetMessageName() string { return "memif_socket_filename_details" }
453 func (*MemifSocketFilenameDetails) GetCrcString() string   { return "7ff326f7" }
454 func (*MemifSocketFilenameDetails) GetMessageType() api.MessageType {
455         return api.ReplyMessage
456 }
457
458 func (m *MemifSocketFilenameDetails) Size() (size int) {
459         if m == nil {
460                 return 0
461         }
462         size += 4   // m.SocketID
463         size += 108 // m.SocketFilename
464         return size
465 }
466 func (m *MemifSocketFilenameDetails) Marshal(b []byte) ([]byte, error) {
467         if b == nil {
468                 b = make([]byte, m.Size())
469         }
470         buf := codec.NewBuffer(b)
471         buf.EncodeUint32(m.SocketID)
472         buf.EncodeString(m.SocketFilename, 108)
473         return buf.Bytes(), nil
474 }
475 func (m *MemifSocketFilenameDetails) Unmarshal(b []byte) error {
476         buf := codec.NewBuffer(b)
477         m.SocketID = buf.DecodeUint32()
478         m.SocketFilename = buf.DecodeString(108)
479         return nil
480 }
481
482 // MemifSocketFilenameDump defines message 'memif_socket_filename_dump'.
483 type MemifSocketFilenameDump struct{}
484
485 func (m *MemifSocketFilenameDump) Reset()               { *m = MemifSocketFilenameDump{} }
486 func (*MemifSocketFilenameDump) GetMessageName() string { return "memif_socket_filename_dump" }
487 func (*MemifSocketFilenameDump) GetCrcString() string   { return "51077d14" }
488 func (*MemifSocketFilenameDump) GetMessageType() api.MessageType {
489         return api.RequestMessage
490 }
491
492 func (m *MemifSocketFilenameDump) Size() (size int) {
493         if m == nil {
494                 return 0
495         }
496         return size
497 }
498 func (m *MemifSocketFilenameDump) Marshal(b []byte) ([]byte, error) {
499         if b == nil {
500                 b = make([]byte, m.Size())
501         }
502         buf := codec.NewBuffer(b)
503         return buf.Bytes(), nil
504 }
505 func (m *MemifSocketFilenameDump) Unmarshal(b []byte) error {
506         return nil
507 }
508
509 func init() { file_memif_binapi_init() }
510 func file_memif_binapi_init() {
511         api.RegisterMessage((*MemifCreate)(nil), "memif_create_b1b25061")
512         api.RegisterMessage((*MemifCreateReply)(nil), "memif_create_reply_5383d31f")
513         api.RegisterMessage((*MemifDelete)(nil), "memif_delete_f9e6675e")
514         api.RegisterMessage((*MemifDeleteReply)(nil), "memif_delete_reply_e8d4e804")
515         api.RegisterMessage((*MemifDetails)(nil), "memif_details_d0382c4c")
516         api.RegisterMessage((*MemifDump)(nil), "memif_dump_51077d14")
517         api.RegisterMessage((*MemifSocketFilenameAddDel)(nil), "memif_socket_filename_add_del_a2ce1a10")
518         api.RegisterMessage((*MemifSocketFilenameAddDelReply)(nil), "memif_socket_filename_add_del_reply_e8d4e804")
519         api.RegisterMessage((*MemifSocketFilenameDetails)(nil), "memif_socket_filename_details_7ff326f7")
520         api.RegisterMessage((*MemifSocketFilenameDump)(nil), "memif_socket_filename_dump_51077d14")
521 }
522
523 // Messages returns list of all messages in this module.
524 func AllMessages() []api.Message {
525         return []api.Message{
526                 (*MemifCreate)(nil),
527                 (*MemifCreateReply)(nil),
528                 (*MemifDelete)(nil),
529                 (*MemifDeleteReply)(nil),
530                 (*MemifDetails)(nil),
531                 (*MemifDump)(nil),
532                 (*MemifSocketFilenameAddDel)(nil),
533                 (*MemifSocketFilenameAddDelReply)(nil),
534                 (*MemifSocketFilenameDetails)(nil),
535                 (*MemifSocketFilenameDump)(nil),
536         }
537 }