binapigen: fix union size
[govpp.git] / 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 // Package af_packet contains generated bindings for API file af_packet.api.
8 //
9 // Contents:
10 //   8 messages
11 //
12 package af_packet
13
14 import (
15         api "git.fd.io/govpp.git/api"
16         ethernet_types "git.fd.io/govpp.git/binapi/ethernet_types"
17         interface_types "git.fd.io/govpp.git/binapi/interface_types"
18         codec "git.fd.io/govpp.git/codec"
19 )
20
21 // This is a compile-time assertion to ensure that this generated file
22 // is compatible with the GoVPP api package it is being compiled against.
23 // A compilation error at this line likely means your copy of the
24 // GoVPP api package needs to be updated.
25 const _ = api.GoVppAPIPackageIsVersion2
26
27 const (
28         APIFile    = "af_packet"
29         APIVersion = "2.0.0"
30         VersionCrc = 0xe0b6c022
31 )
32
33 // AfPacketCreate defines message 'af_packet_create'.
34 type AfPacketCreate struct {
35         HwAddr          ethernet_types.MacAddress `binapi:"mac_address,name=hw_addr" json:"hw_addr,omitempty"`
36         UseRandomHwAddr bool                      `binapi:"bool,name=use_random_hw_addr" json:"use_random_hw_addr,omitempty"`
37         HostIfName      string                    `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty"`
38 }
39
40 func (m *AfPacketCreate) Reset()               { *m = AfPacketCreate{} }
41 func (*AfPacketCreate) GetMessageName() string { return "af_packet_create" }
42 func (*AfPacketCreate) GetCrcString() string   { return "a190415f" }
43 func (*AfPacketCreate) GetMessageType() api.MessageType {
44         return api.RequestMessage
45 }
46
47 func (m *AfPacketCreate) Size() (size int) {
48         if m == nil {
49                 return 0
50         }
51         size += 1 * 6 // m.HwAddr
52         size += 1     // m.UseRandomHwAddr
53         size += 64    // m.HostIfName
54         return size
55 }
56 func (m *AfPacketCreate) Marshal(b []byte) ([]byte, error) {
57         if b == nil {
58                 b = make([]byte, m.Size())
59         }
60         buf := codec.NewBuffer(b)
61         buf.EncodeBytes(m.HwAddr[:], 6)
62         buf.EncodeBool(m.UseRandomHwAddr)
63         buf.EncodeString(m.HostIfName, 64)
64         return buf.Bytes(), nil
65 }
66 func (m *AfPacketCreate) Unmarshal(b []byte) error {
67         buf := codec.NewBuffer(b)
68         copy(m.HwAddr[:], buf.DecodeBytes(6))
69         m.UseRandomHwAddr = buf.DecodeBool()
70         m.HostIfName = buf.DecodeString(64)
71         return nil
72 }
73
74 // AfPacketCreateReply defines message 'af_packet_create_reply'.
75 type AfPacketCreateReply struct {
76         Retval    int32                          `binapi:"i32,name=retval" json:"retval,omitempty"`
77         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
78 }
79
80 func (m *AfPacketCreateReply) Reset()               { *m = AfPacketCreateReply{} }
81 func (*AfPacketCreateReply) GetMessageName() string { return "af_packet_create_reply" }
82 func (*AfPacketCreateReply) GetCrcString() string   { return "5383d31f" }
83 func (*AfPacketCreateReply) GetMessageType() api.MessageType {
84         return api.ReplyMessage
85 }
86
87 func (m *AfPacketCreateReply) Size() (size int) {
88         if m == nil {
89                 return 0
90         }
91         size += 4 // m.Retval
92         size += 4 // m.SwIfIndex
93         return size
94 }
95 func (m *AfPacketCreateReply) Marshal(b []byte) ([]byte, error) {
96         if b == nil {
97                 b = make([]byte, m.Size())
98         }
99         buf := codec.NewBuffer(b)
100         buf.EncodeInt32(m.Retval)
101         buf.EncodeUint32(uint32(m.SwIfIndex))
102         return buf.Bytes(), nil
103 }
104 func (m *AfPacketCreateReply) Unmarshal(b []byte) error {
105         buf := codec.NewBuffer(b)
106         m.Retval = buf.DecodeInt32()
107         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
108         return nil
109 }
110
111 // AfPacketDelete defines message 'af_packet_delete'.
112 type AfPacketDelete struct {
113         HostIfName string `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty"`
114 }
115
116 func (m *AfPacketDelete) Reset()               { *m = AfPacketDelete{} }
117 func (*AfPacketDelete) GetMessageName() string { return "af_packet_delete" }
118 func (*AfPacketDelete) GetCrcString() string   { return "863fa648" }
119 func (*AfPacketDelete) GetMessageType() api.MessageType {
120         return api.RequestMessage
121 }
122
123 func (m *AfPacketDelete) Size() (size int) {
124         if m == nil {
125                 return 0
126         }
127         size += 64 // m.HostIfName
128         return size
129 }
130 func (m *AfPacketDelete) Marshal(b []byte) ([]byte, error) {
131         if b == nil {
132                 b = make([]byte, m.Size())
133         }
134         buf := codec.NewBuffer(b)
135         buf.EncodeString(m.HostIfName, 64)
136         return buf.Bytes(), nil
137 }
138 func (m *AfPacketDelete) Unmarshal(b []byte) error {
139         buf := codec.NewBuffer(b)
140         m.HostIfName = buf.DecodeString(64)
141         return nil
142 }
143
144 // AfPacketDeleteReply defines message 'af_packet_delete_reply'.
145 type AfPacketDeleteReply struct {
146         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
147 }
148
149 func (m *AfPacketDeleteReply) Reset()               { *m = AfPacketDeleteReply{} }
150 func (*AfPacketDeleteReply) GetMessageName() string { return "af_packet_delete_reply" }
151 func (*AfPacketDeleteReply) GetCrcString() string   { return "e8d4e804" }
152 func (*AfPacketDeleteReply) GetMessageType() api.MessageType {
153         return api.ReplyMessage
154 }
155
156 func (m *AfPacketDeleteReply) Size() (size int) {
157         if m == nil {
158                 return 0
159         }
160         size += 4 // m.Retval
161         return size
162 }
163 func (m *AfPacketDeleteReply) Marshal(b []byte) ([]byte, error) {
164         if b == nil {
165                 b = make([]byte, m.Size())
166         }
167         buf := codec.NewBuffer(b)
168         buf.EncodeInt32(m.Retval)
169         return buf.Bytes(), nil
170 }
171 func (m *AfPacketDeleteReply) Unmarshal(b []byte) error {
172         buf := codec.NewBuffer(b)
173         m.Retval = buf.DecodeInt32()
174         return nil
175 }
176
177 // AfPacketDetails defines message 'af_packet_details'.
178 type AfPacketDetails struct {
179         SwIfIndex  interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
180         HostIfName string                         `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty"`
181 }
182
183 func (m *AfPacketDetails) Reset()               { *m = AfPacketDetails{} }
184 func (*AfPacketDetails) GetMessageName() string { return "af_packet_details" }
185 func (*AfPacketDetails) GetCrcString() string   { return "58c7c042" }
186 func (*AfPacketDetails) GetMessageType() api.MessageType {
187         return api.ReplyMessage
188 }
189
190 func (m *AfPacketDetails) Size() (size int) {
191         if m == nil {
192                 return 0
193         }
194         size += 4  // m.SwIfIndex
195         size += 64 // m.HostIfName
196         return size
197 }
198 func (m *AfPacketDetails) Marshal(b []byte) ([]byte, error) {
199         if b == nil {
200                 b = make([]byte, m.Size())
201         }
202         buf := codec.NewBuffer(b)
203         buf.EncodeUint32(uint32(m.SwIfIndex))
204         buf.EncodeString(m.HostIfName, 64)
205         return buf.Bytes(), nil
206 }
207 func (m *AfPacketDetails) Unmarshal(b []byte) error {
208         buf := codec.NewBuffer(b)
209         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
210         m.HostIfName = buf.DecodeString(64)
211         return nil
212 }
213
214 // AfPacketDump defines message 'af_packet_dump'.
215 type AfPacketDump struct{}
216
217 func (m *AfPacketDump) Reset()               { *m = AfPacketDump{} }
218 func (*AfPacketDump) GetMessageName() string { return "af_packet_dump" }
219 func (*AfPacketDump) GetCrcString() string   { return "51077d14" }
220 func (*AfPacketDump) GetMessageType() api.MessageType {
221         return api.RequestMessage
222 }
223
224 func (m *AfPacketDump) Size() (size int) {
225         if m == nil {
226                 return 0
227         }
228         return size
229 }
230 func (m *AfPacketDump) Marshal(b []byte) ([]byte, error) {
231         if b == nil {
232                 b = make([]byte, m.Size())
233         }
234         buf := codec.NewBuffer(b)
235         return buf.Bytes(), nil
236 }
237 func (m *AfPacketDump) Unmarshal(b []byte) error {
238         return nil
239 }
240
241 // AfPacketSetL4CksumOffload defines message 'af_packet_set_l4_cksum_offload'.
242 type AfPacketSetL4CksumOffload struct {
243         SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
244         Set       bool                           `binapi:"bool,name=set" json:"set,omitempty"`
245 }
246
247 func (m *AfPacketSetL4CksumOffload) Reset()               { *m = AfPacketSetL4CksumOffload{} }
248 func (*AfPacketSetL4CksumOffload) GetMessageName() string { return "af_packet_set_l4_cksum_offload" }
249 func (*AfPacketSetL4CksumOffload) GetCrcString() string   { return "319cd5c8" }
250 func (*AfPacketSetL4CksumOffload) GetMessageType() api.MessageType {
251         return api.RequestMessage
252 }
253
254 func (m *AfPacketSetL4CksumOffload) Size() (size int) {
255         if m == nil {
256                 return 0
257         }
258         size += 4 // m.SwIfIndex
259         size += 1 // m.Set
260         return size
261 }
262 func (m *AfPacketSetL4CksumOffload) Marshal(b []byte) ([]byte, error) {
263         if b == nil {
264                 b = make([]byte, m.Size())
265         }
266         buf := codec.NewBuffer(b)
267         buf.EncodeUint32(uint32(m.SwIfIndex))
268         buf.EncodeBool(m.Set)
269         return buf.Bytes(), nil
270 }
271 func (m *AfPacketSetL4CksumOffload) Unmarshal(b []byte) error {
272         buf := codec.NewBuffer(b)
273         m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
274         m.Set = buf.DecodeBool()
275         return nil
276 }
277
278 // AfPacketSetL4CksumOffloadReply defines message 'af_packet_set_l4_cksum_offload_reply'.
279 type AfPacketSetL4CksumOffloadReply struct {
280         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
281 }
282
283 func (m *AfPacketSetL4CksumOffloadReply) Reset() { *m = AfPacketSetL4CksumOffloadReply{} }
284 func (*AfPacketSetL4CksumOffloadReply) GetMessageName() string {
285         return "af_packet_set_l4_cksum_offload_reply"
286 }
287 func (*AfPacketSetL4CksumOffloadReply) GetCrcString() string { return "e8d4e804" }
288 func (*AfPacketSetL4CksumOffloadReply) GetMessageType() api.MessageType {
289         return api.ReplyMessage
290 }
291
292 func (m *AfPacketSetL4CksumOffloadReply) Size() (size int) {
293         if m == nil {
294                 return 0
295         }
296         size += 4 // m.Retval
297         return size
298 }
299 func (m *AfPacketSetL4CksumOffloadReply) Marshal(b []byte) ([]byte, error) {
300         if b == nil {
301                 b = make([]byte, m.Size())
302         }
303         buf := codec.NewBuffer(b)
304         buf.EncodeInt32(m.Retval)
305         return buf.Bytes(), nil
306 }
307 func (m *AfPacketSetL4CksumOffloadReply) Unmarshal(b []byte) error {
308         buf := codec.NewBuffer(b)
309         m.Retval = buf.DecodeInt32()
310         return nil
311 }
312
313 func init() { file_af_packet_binapi_init() }
314 func file_af_packet_binapi_init() {
315         api.RegisterMessage((*AfPacketCreate)(nil), "af_packet_create_a190415f")
316         api.RegisterMessage((*AfPacketCreateReply)(nil), "af_packet_create_reply_5383d31f")
317         api.RegisterMessage((*AfPacketDelete)(nil), "af_packet_delete_863fa648")
318         api.RegisterMessage((*AfPacketDeleteReply)(nil), "af_packet_delete_reply_e8d4e804")
319         api.RegisterMessage((*AfPacketDetails)(nil), "af_packet_details_58c7c042")
320         api.RegisterMessage((*AfPacketDump)(nil), "af_packet_dump_51077d14")
321         api.RegisterMessage((*AfPacketSetL4CksumOffload)(nil), "af_packet_set_l4_cksum_offload_319cd5c8")
322         api.RegisterMessage((*AfPacketSetL4CksumOffloadReply)(nil), "af_packet_set_l4_cksum_offload_reply_e8d4e804")
323 }
324
325 // Messages returns list of all messages in this module.
326 func AllMessages() []api.Message {
327         return []api.Message{
328                 (*AfPacketCreate)(nil),
329                 (*AfPacketCreateReply)(nil),
330                 (*AfPacketDelete)(nil),
331                 (*AfPacketDeleteReply)(nil),
332                 (*AfPacketDetails)(nil),
333                 (*AfPacketDump)(nil),
334                 (*AfPacketSetL4CksumOffload)(nil),
335                 (*AfPacketSetL4CksumOffloadReply)(nil),
336         }
337 }