Introduce Stream - experimental API for low-level access to VPP API
[govpp.git] / examples / binapi / af_packet / af_packet.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/af_packet.api.json
6
7 /*
8 Package af_packet contains generated code for VPP API file af_packet.api (2.0.0).
9
10 It consists of:
11           2 aliases
12           6 enums
13           8 messages
14 */
15 package af_packet
16
17 import (
18         "bytes"
19         "context"
20         "encoding/binary"
21         "io"
22         "math"
23         "strconv"
24
25         api "git.fd.io/govpp.git/api"
26         codec "git.fd.io/govpp.git/codec"
27         struc "github.com/lunixbochs/struc"
28
29         interface_types "git.fd.io/govpp.git/examples/binapi/interface_types"
30 )
31
32 // This is a compile-time assertion to ensure that this generated file
33 // is compatible with the GoVPP api package it is being compiled against.
34 // A compilation error at this line likely means your copy of the
35 // GoVPP api package needs to be updated.
36 const _ = api.GoVppAPIPackageIsVersion2 // please upgrade the GoVPP api package
37
38 const (
39         // ModuleName is the name of this module.
40         ModuleName = "af_packet"
41         // APIVersion is the API version of this module.
42         APIVersion = "2.0.0"
43         // VersionCrc is the CRC of this module.
44         VersionCrc = 0xe0b6c022
45 )
46
47 type IfStatusFlags = interface_types.IfStatusFlags
48
49 type IfType = interface_types.IfType
50
51 type LinkDuplex = interface_types.LinkDuplex
52
53 type MtuProto = interface_types.MtuProto
54
55 type RxMode = interface_types.RxMode
56
57 type SubIfFlags = interface_types.SubIfFlags
58
59 type InterfaceIndex = interface_types.InterfaceIndex
60
61 // MacAddress represents VPP binary API alias 'mac_address'.
62 type MacAddress [6]uint8
63
64 // AfPacketCreate represents VPP binary API message 'af_packet_create'.
65 type AfPacketCreate struct {
66         HwAddr          MacAddress `binapi:"mac_address,name=hw_addr" json:"hw_addr,omitempty"`
67         UseRandomHwAddr bool       `binapi:"bool,name=use_random_hw_addr" json:"use_random_hw_addr,omitempty"`
68         HostIfName      string     `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty" struc:"[64]byte"`
69 }
70
71 func (m *AfPacketCreate) Reset()                        { *m = AfPacketCreate{} }
72 func (*AfPacketCreate) GetMessageName() string          { return "af_packet_create" }
73 func (*AfPacketCreate) GetCrcString() string            { return "a190415f" }
74 func (*AfPacketCreate) GetMessageType() api.MessageType { return api.RequestMessage }
75
76 func (m *AfPacketCreate) Size() int {
77         if m == nil {
78                 return 0
79         }
80         var size int
81         // field[1] m.HwAddr
82         size += 6
83         // field[1] m.UseRandomHwAddr
84         size += 1
85         // field[1] m.HostIfName
86         size += 64
87         return size
88 }
89 func (m *AfPacketCreate) Marshal(b []byte) ([]byte, error) {
90         o := binary.BigEndian
91         _ = o
92         pos := 0
93         _ = pos
94         var buf []byte
95         if b == nil {
96                 buf = make([]byte, m.Size())
97         } else {
98                 buf = b
99         }
100         // field[1] m.HwAddr
101         for i := 0; i < 6; i++ {
102                 var x uint8
103                 if i < len(m.HwAddr) {
104                         x = uint8(m.HwAddr[i])
105                 }
106                 buf[pos] = uint8(x)
107                 pos += 1
108         }
109         // field[1] m.UseRandomHwAddr
110         if m.UseRandomHwAddr {
111                 buf[pos] = 1
112         }
113         pos += 1
114         // field[1] m.HostIfName
115         copy(buf[pos:pos+64], m.HostIfName)
116         pos += 64
117         return buf, nil
118 }
119 func (m *AfPacketCreate) Unmarshal(tmp []byte) error {
120         o := binary.BigEndian
121         _ = o
122         pos := 0
123         _ = pos
124         // field[1] m.HwAddr
125         for i := 0; i < len(m.HwAddr); i++ {
126                 m.HwAddr[i] = uint8(tmp[pos])
127                 pos += 1
128         }
129         // field[1] m.UseRandomHwAddr
130         m.UseRandomHwAddr = tmp[pos] != 0
131         pos += 1
132         // field[1] m.HostIfName
133         {
134                 nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
135                 m.HostIfName = codec.DecodeString(tmp[pos : pos+nul])
136                 pos += 64
137         }
138         return nil
139 }
140
141 // AfPacketCreateReply represents VPP binary API message 'af_packet_create_reply'.
142 type AfPacketCreateReply struct {
143         Retval    int32          `binapi:"i32,name=retval" json:"retval,omitempty"`
144         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
145 }
146
147 func (m *AfPacketCreateReply) Reset()                        { *m = AfPacketCreateReply{} }
148 func (*AfPacketCreateReply) GetMessageName() string          { return "af_packet_create_reply" }
149 func (*AfPacketCreateReply) GetCrcString() string            { return "5383d31f" }
150 func (*AfPacketCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage }
151
152 func (m *AfPacketCreateReply) Size() int {
153         if m == nil {
154                 return 0
155         }
156         var size int
157         // field[1] m.Retval
158         size += 4
159         // field[1] m.SwIfIndex
160         size += 4
161         return size
162 }
163 func (m *AfPacketCreateReply) Marshal(b []byte) ([]byte, error) {
164         o := binary.BigEndian
165         _ = o
166         pos := 0
167         _ = pos
168         var buf []byte
169         if b == nil {
170                 buf = make([]byte, m.Size())
171         } else {
172                 buf = b
173         }
174         // field[1] m.Retval
175         o.PutUint32(buf[pos:pos+4], uint32(m.Retval))
176         pos += 4
177         // field[1] m.SwIfIndex
178         o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex))
179         pos += 4
180         return buf, nil
181 }
182 func (m *AfPacketCreateReply) Unmarshal(tmp []byte) error {
183         o := binary.BigEndian
184         _ = o
185         pos := 0
186         _ = pos
187         // field[1] m.Retval
188         m.Retval = int32(o.Uint32(tmp[pos : pos+4]))
189         pos += 4
190         // field[1] m.SwIfIndex
191         m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4]))
192         pos += 4
193         return nil
194 }
195
196 // AfPacketDelete represents VPP binary API message 'af_packet_delete'.
197 type AfPacketDelete struct {
198         HostIfName string `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty" struc:"[64]byte"`
199 }
200
201 func (m *AfPacketDelete) Reset()                        { *m = AfPacketDelete{} }
202 func (*AfPacketDelete) GetMessageName() string          { return "af_packet_delete" }
203 func (*AfPacketDelete) GetCrcString() string            { return "863fa648" }
204 func (*AfPacketDelete) GetMessageType() api.MessageType { return api.RequestMessage }
205
206 func (m *AfPacketDelete) Size() int {
207         if m == nil {
208                 return 0
209         }
210         var size int
211         // field[1] m.HostIfName
212         size += 64
213         return size
214 }
215 func (m *AfPacketDelete) Marshal(b []byte) ([]byte, error) {
216         o := binary.BigEndian
217         _ = o
218         pos := 0
219         _ = pos
220         var buf []byte
221         if b == nil {
222                 buf = make([]byte, m.Size())
223         } else {
224                 buf = b
225         }
226         // field[1] m.HostIfName
227         copy(buf[pos:pos+64], m.HostIfName)
228         pos += 64
229         return buf, nil
230 }
231 func (m *AfPacketDelete) Unmarshal(tmp []byte) error {
232         o := binary.BigEndian
233         _ = o
234         pos := 0
235         _ = pos
236         // field[1] m.HostIfName
237         {
238                 nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
239                 m.HostIfName = codec.DecodeString(tmp[pos : pos+nul])
240                 pos += 64
241         }
242         return nil
243 }
244
245 // AfPacketDeleteReply represents VPP binary API message 'af_packet_delete_reply'.
246 type AfPacketDeleteReply struct {
247         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
248 }
249
250 func (m *AfPacketDeleteReply) Reset()                        { *m = AfPacketDeleteReply{} }
251 func (*AfPacketDeleteReply) GetMessageName() string          { return "af_packet_delete_reply" }
252 func (*AfPacketDeleteReply) GetCrcString() string            { return "e8d4e804" }
253 func (*AfPacketDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage }
254
255 func (m *AfPacketDeleteReply) Size() int {
256         if m == nil {
257                 return 0
258         }
259         var size int
260         // field[1] m.Retval
261         size += 4
262         return size
263 }
264 func (m *AfPacketDeleteReply) Marshal(b []byte) ([]byte, error) {
265         o := binary.BigEndian
266         _ = o
267         pos := 0
268         _ = pos
269         var buf []byte
270         if b == nil {
271                 buf = make([]byte, m.Size())
272         } else {
273                 buf = b
274         }
275         // field[1] m.Retval
276         o.PutUint32(buf[pos:pos+4], uint32(m.Retval))
277         pos += 4
278         return buf, nil
279 }
280 func (m *AfPacketDeleteReply) Unmarshal(tmp []byte) error {
281         o := binary.BigEndian
282         _ = o
283         pos := 0
284         _ = pos
285         // field[1] m.Retval
286         m.Retval = int32(o.Uint32(tmp[pos : pos+4]))
287         pos += 4
288         return nil
289 }
290
291 // AfPacketDetails represents VPP binary API message 'af_packet_details'.
292 type AfPacketDetails struct {
293         SwIfIndex  InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
294         HostIfName string         `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty" struc:"[64]byte"`
295 }
296
297 func (m *AfPacketDetails) Reset()                        { *m = AfPacketDetails{} }
298 func (*AfPacketDetails) GetMessageName() string          { return "af_packet_details" }
299 func (*AfPacketDetails) GetCrcString() string            { return "58c7c042" }
300 func (*AfPacketDetails) GetMessageType() api.MessageType { return api.ReplyMessage }
301
302 func (m *AfPacketDetails) Size() int {
303         if m == nil {
304                 return 0
305         }
306         var size int
307         // field[1] m.SwIfIndex
308         size += 4
309         // field[1] m.HostIfName
310         size += 64
311         return size
312 }
313 func (m *AfPacketDetails) Marshal(b []byte) ([]byte, error) {
314         o := binary.BigEndian
315         _ = o
316         pos := 0
317         _ = pos
318         var buf []byte
319         if b == nil {
320                 buf = make([]byte, m.Size())
321         } else {
322                 buf = b
323         }
324         // field[1] m.SwIfIndex
325         o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex))
326         pos += 4
327         // field[1] m.HostIfName
328         copy(buf[pos:pos+64], m.HostIfName)
329         pos += 64
330         return buf, nil
331 }
332 func (m *AfPacketDetails) Unmarshal(tmp []byte) error {
333         o := binary.BigEndian
334         _ = o
335         pos := 0
336         _ = pos
337         // field[1] m.SwIfIndex
338         m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4]))
339         pos += 4
340         // field[1] m.HostIfName
341         {
342                 nul := bytes.Index(tmp[pos:pos+64], []byte{0x00})
343                 m.HostIfName = codec.DecodeString(tmp[pos : pos+nul])
344                 pos += 64
345         }
346         return nil
347 }
348
349 // AfPacketDump represents VPP binary API message 'af_packet_dump'.
350 type AfPacketDump struct{}
351
352 func (m *AfPacketDump) Reset()                        { *m = AfPacketDump{} }
353 func (*AfPacketDump) GetMessageName() string          { return "af_packet_dump" }
354 func (*AfPacketDump) GetCrcString() string            { return "51077d14" }
355 func (*AfPacketDump) GetMessageType() api.MessageType { return api.RequestMessage }
356
357 func (m *AfPacketDump) Size() int {
358         if m == nil {
359                 return 0
360         }
361         var size int
362         return size
363 }
364 func (m *AfPacketDump) Marshal(b []byte) ([]byte, error) {
365         o := binary.BigEndian
366         _ = o
367         pos := 0
368         _ = pos
369         var buf []byte
370         if b == nil {
371                 buf = make([]byte, m.Size())
372         } else {
373                 buf = b
374         }
375         return buf, nil
376 }
377 func (m *AfPacketDump) Unmarshal(tmp []byte) error {
378         o := binary.BigEndian
379         _ = o
380         pos := 0
381         _ = pos
382         return nil
383 }
384
385 // AfPacketSetL4CksumOffload represents VPP binary API message 'af_packet_set_l4_cksum_offload'.
386 type AfPacketSetL4CksumOffload struct {
387         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
388         Set       bool           `binapi:"bool,name=set" json:"set,omitempty"`
389 }
390
391 func (m *AfPacketSetL4CksumOffload) Reset()                        { *m = AfPacketSetL4CksumOffload{} }
392 func (*AfPacketSetL4CksumOffload) GetMessageName() string          { return "af_packet_set_l4_cksum_offload" }
393 func (*AfPacketSetL4CksumOffload) GetCrcString() string            { return "319cd5c8" }
394 func (*AfPacketSetL4CksumOffload) GetMessageType() api.MessageType { return api.RequestMessage }
395
396 func (m *AfPacketSetL4CksumOffload) Size() int {
397         if m == nil {
398                 return 0
399         }
400         var size int
401         // field[1] m.SwIfIndex
402         size += 4
403         // field[1] m.Set
404         size += 1
405         return size
406 }
407 func (m *AfPacketSetL4CksumOffload) Marshal(b []byte) ([]byte, error) {
408         o := binary.BigEndian
409         _ = o
410         pos := 0
411         _ = pos
412         var buf []byte
413         if b == nil {
414                 buf = make([]byte, m.Size())
415         } else {
416                 buf = b
417         }
418         // field[1] m.SwIfIndex
419         o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex))
420         pos += 4
421         // field[1] m.Set
422         if m.Set {
423                 buf[pos] = 1
424         }
425         pos += 1
426         return buf, nil
427 }
428 func (m *AfPacketSetL4CksumOffload) Unmarshal(tmp []byte) error {
429         o := binary.BigEndian
430         _ = o
431         pos := 0
432         _ = pos
433         // field[1] m.SwIfIndex
434         m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4]))
435         pos += 4
436         // field[1] m.Set
437         m.Set = tmp[pos] != 0
438         pos += 1
439         return nil
440 }
441
442 // AfPacketSetL4CksumOffloadReply represents VPP binary API message 'af_packet_set_l4_cksum_offload_reply'.
443 type AfPacketSetL4CksumOffloadReply struct {
444         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
445 }
446
447 func (m *AfPacketSetL4CksumOffloadReply) Reset() { *m = AfPacketSetL4CksumOffloadReply{} }
448 func (*AfPacketSetL4CksumOffloadReply) GetMessageName() string {
449         return "af_packet_set_l4_cksum_offload_reply"
450 }
451 func (*AfPacketSetL4CksumOffloadReply) GetCrcString() string            { return "e8d4e804" }
452 func (*AfPacketSetL4CksumOffloadReply) GetMessageType() api.MessageType { return api.ReplyMessage }
453
454 func (m *AfPacketSetL4CksumOffloadReply) Size() int {
455         if m == nil {
456                 return 0
457         }
458         var size int
459         // field[1] m.Retval
460         size += 4
461         return size
462 }
463 func (m *AfPacketSetL4CksumOffloadReply) Marshal(b []byte) ([]byte, error) {
464         o := binary.BigEndian
465         _ = o
466         pos := 0
467         _ = pos
468         var buf []byte
469         if b == nil {
470                 buf = make([]byte, m.Size())
471         } else {
472                 buf = b
473         }
474         // field[1] m.Retval
475         o.PutUint32(buf[pos:pos+4], uint32(m.Retval))
476         pos += 4
477         return buf, nil
478 }
479 func (m *AfPacketSetL4CksumOffloadReply) Unmarshal(tmp []byte) error {
480         o := binary.BigEndian
481         _ = o
482         pos := 0
483         _ = pos
484         // field[1] m.Retval
485         m.Retval = int32(o.Uint32(tmp[pos : pos+4]))
486         pos += 4
487         return nil
488 }
489
490 func init() { file_af_packet_binapi_init() }
491 func file_af_packet_binapi_init() {
492         api.RegisterMessage((*AfPacketCreate)(nil), "af_packet.AfPacketCreate")
493         api.RegisterMessage((*AfPacketCreateReply)(nil), "af_packet.AfPacketCreateReply")
494         api.RegisterMessage((*AfPacketDelete)(nil), "af_packet.AfPacketDelete")
495         api.RegisterMessage((*AfPacketDeleteReply)(nil), "af_packet.AfPacketDeleteReply")
496         api.RegisterMessage((*AfPacketDetails)(nil), "af_packet.AfPacketDetails")
497         api.RegisterMessage((*AfPacketDump)(nil), "af_packet.AfPacketDump")
498         api.RegisterMessage((*AfPacketSetL4CksumOffload)(nil), "af_packet.AfPacketSetL4CksumOffload")
499         api.RegisterMessage((*AfPacketSetL4CksumOffloadReply)(nil), "af_packet.AfPacketSetL4CksumOffloadReply")
500 }
501
502 // Messages returns list of all messages in this module.
503 func AllMessages() []api.Message {
504         return []api.Message{
505                 (*AfPacketCreate)(nil),
506                 (*AfPacketCreateReply)(nil),
507                 (*AfPacketDelete)(nil),
508                 (*AfPacketDeleteReply)(nil),
509                 (*AfPacketDetails)(nil),
510                 (*AfPacketDump)(nil),
511                 (*AfPacketSetL4CksumOffload)(nil),
512                 (*AfPacketSetL4CksumOffloadReply)(nil),
513         }
514 }
515
516 // Reference imports to suppress errors if they are not otherwise used.
517 var _ = api.RegisterMessage
518 var _ = codec.DecodeString
519 var _ = bytes.NewBuffer
520 var _ = context.Background
521 var _ = io.Copy
522 var _ = strconv.Itoa
523 var _ = struc.Pack
524 var _ = binary.BigEndian
525 var _ = math.Float32bits