binapigen: fix union size
[govpp.git] / binapi / punt / punt.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/punt.api.json
6
7 // Package punt contains generated bindings for API file punt.api.
8 //
9 // Contents:
10 //   1 enum
11 //   5 structs
12 //   1 union
13 //  10 messages
14 //
15 package punt
16
17 import (
18         "strconv"
19
20         api "git.fd.io/govpp.git/api"
21         ip_types "git.fd.io/govpp.git/binapi/ip_types"
22         codec "git.fd.io/govpp.git/codec"
23 )
24
25 // This is a compile-time assertion to ensure that this generated file
26 // is compatible with the GoVPP api package it is being compiled against.
27 // A compilation error at this line likely means your copy of the
28 // GoVPP api package needs to be updated.
29 const _ = api.GoVppAPIPackageIsVersion2
30
31 const (
32         APIFile    = "punt"
33         APIVersion = "2.2.1"
34         VersionCrc = 0x31354154
35 )
36
37 // PuntType defines enum 'punt_type'.
38 type PuntType uint32
39
40 const (
41         PUNT_API_TYPE_L4        PuntType = 1
42         PUNT_API_TYPE_IP_PROTO  PuntType = 2
43         PUNT_API_TYPE_EXCEPTION PuntType = 3
44 )
45
46 var (
47         PuntType_name = map[uint32]string{
48                 1: "PUNT_API_TYPE_L4",
49                 2: "PUNT_API_TYPE_IP_PROTO",
50                 3: "PUNT_API_TYPE_EXCEPTION",
51         }
52         PuntType_value = map[string]uint32{
53                 "PUNT_API_TYPE_L4":        1,
54                 "PUNT_API_TYPE_IP_PROTO":  2,
55                 "PUNT_API_TYPE_EXCEPTION": 3,
56         }
57 )
58
59 func (x PuntType) String() string {
60         s, ok := PuntType_name[uint32(x)]
61         if ok {
62                 return s
63         }
64         return "PuntType(" + strconv.Itoa(int(x)) + ")"
65 }
66
67 // Punt defines type 'punt'.
68 type Punt struct {
69         Type PuntType  `binapi:"punt_type,name=type" json:"type,omitempty"`
70         Punt PuntUnion `binapi:"punt_union,name=punt" json:"punt,omitempty"`
71 }
72
73 // PuntException defines type 'punt_exception'.
74 type PuntException struct {
75         ID uint32 `binapi:"u32,name=id" json:"id,omitempty"`
76 }
77
78 // PuntIPProto defines type 'punt_ip_proto'.
79 type PuntIPProto struct {
80         Af       ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
81         Protocol ip_types.IPProto       `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"`
82 }
83
84 // PuntL4 defines type 'punt_l4'.
85 type PuntL4 struct {
86         Af       ip_types.AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
87         Protocol ip_types.IPProto       `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"`
88         Port     uint16                 `binapi:"u16,name=port" json:"port,omitempty"`
89 }
90
91 // PuntReason defines type 'punt_reason'.
92 type PuntReason struct {
93         ID   uint32 `binapi:"u32,name=id" json:"id,omitempty"`
94         Name string `binapi:"string[],name=name" json:"name,omitempty"`
95 }
96
97 // PuntUnion defines union 'punt_union'.
98 type PuntUnion struct {
99         // PuntUnion can be one of:
100         // - Exception *PuntException
101         // - L4 *PuntL4
102         // - IPProto *PuntIPProto
103         XXX_UnionData [4]byte
104 }
105
106 func PuntUnionException(a PuntException) (u PuntUnion) {
107         u.SetException(a)
108         return
109 }
110 func (u *PuntUnion) SetException(a PuntException) {
111         buf := codec.NewBuffer(u.XXX_UnionData[:])
112         buf.EncodeUint32(a.ID)
113 }
114 func (u *PuntUnion) GetException() (a PuntException) {
115         buf := codec.NewBuffer(u.XXX_UnionData[:])
116         a.ID = buf.DecodeUint32()
117         return
118 }
119
120 func PuntUnionL4(a PuntL4) (u PuntUnion) {
121         u.SetL4(a)
122         return
123 }
124 func (u *PuntUnion) SetL4(a PuntL4) {
125         buf := codec.NewBuffer(u.XXX_UnionData[:])
126         buf.EncodeUint8(uint8(a.Af))
127         buf.EncodeUint8(uint8(a.Protocol))
128         buf.EncodeUint16(a.Port)
129 }
130 func (u *PuntUnion) GetL4() (a PuntL4) {
131         buf := codec.NewBuffer(u.XXX_UnionData[:])
132         a.Af = ip_types.AddressFamily(buf.DecodeUint8())
133         a.Protocol = ip_types.IPProto(buf.DecodeUint8())
134         a.Port = buf.DecodeUint16()
135         return
136 }
137
138 func PuntUnionIPProto(a PuntIPProto) (u PuntUnion) {
139         u.SetIPProto(a)
140         return
141 }
142 func (u *PuntUnion) SetIPProto(a PuntIPProto) {
143         buf := codec.NewBuffer(u.XXX_UnionData[:])
144         buf.EncodeUint8(uint8(a.Af))
145         buf.EncodeUint8(uint8(a.Protocol))
146 }
147 func (u *PuntUnion) GetIPProto() (a PuntIPProto) {
148         buf := codec.NewBuffer(u.XXX_UnionData[:])
149         a.Af = ip_types.AddressFamily(buf.DecodeUint8())
150         a.Protocol = ip_types.IPProto(buf.DecodeUint8())
151         return
152 }
153
154 // PuntReasonDetails defines message 'punt_reason_details'.
155 type PuntReasonDetails struct {
156         Reason PuntReason `binapi:"punt_reason,name=reason" json:"reason,omitempty"`
157 }
158
159 func (m *PuntReasonDetails) Reset()               { *m = PuntReasonDetails{} }
160 func (*PuntReasonDetails) GetMessageName() string { return "punt_reason_details" }
161 func (*PuntReasonDetails) GetCrcString() string   { return "2c9d4a40" }
162 func (*PuntReasonDetails) GetMessageType() api.MessageType {
163         return api.ReplyMessage
164 }
165
166 func (m *PuntReasonDetails) Size() (size int) {
167         if m == nil {
168                 return 0
169         }
170         size += 4                      // m.Reason.ID
171         size += 4 + len(m.Reason.Name) // m.Reason.Name
172         return size
173 }
174 func (m *PuntReasonDetails) Marshal(b []byte) ([]byte, error) {
175         if b == nil {
176                 b = make([]byte, m.Size())
177         }
178         buf := codec.NewBuffer(b)
179         buf.EncodeUint32(m.Reason.ID)
180         buf.EncodeString(m.Reason.Name, 0)
181         return buf.Bytes(), nil
182 }
183 func (m *PuntReasonDetails) Unmarshal(b []byte) error {
184         buf := codec.NewBuffer(b)
185         m.Reason.ID = buf.DecodeUint32()
186         m.Reason.Name = buf.DecodeString(0)
187         return nil
188 }
189
190 // PuntReasonDump defines message 'punt_reason_dump'.
191 type PuntReasonDump struct {
192         Reason PuntReason `binapi:"punt_reason,name=reason" json:"reason,omitempty"`
193 }
194
195 func (m *PuntReasonDump) Reset()               { *m = PuntReasonDump{} }
196 func (*PuntReasonDump) GetMessageName() string { return "punt_reason_dump" }
197 func (*PuntReasonDump) GetCrcString() string   { return "5c0dd4fe" }
198 func (*PuntReasonDump) GetMessageType() api.MessageType {
199         return api.RequestMessage
200 }
201
202 func (m *PuntReasonDump) Size() (size int) {
203         if m == nil {
204                 return 0
205         }
206         size += 4                      // m.Reason.ID
207         size += 4 + len(m.Reason.Name) // m.Reason.Name
208         return size
209 }
210 func (m *PuntReasonDump) Marshal(b []byte) ([]byte, error) {
211         if b == nil {
212                 b = make([]byte, m.Size())
213         }
214         buf := codec.NewBuffer(b)
215         buf.EncodeUint32(m.Reason.ID)
216         buf.EncodeString(m.Reason.Name, 0)
217         return buf.Bytes(), nil
218 }
219 func (m *PuntReasonDump) Unmarshal(b []byte) error {
220         buf := codec.NewBuffer(b)
221         m.Reason.ID = buf.DecodeUint32()
222         m.Reason.Name = buf.DecodeString(0)
223         return nil
224 }
225
226 // PuntSocketDeregister defines message 'punt_socket_deregister'.
227 type PuntSocketDeregister struct {
228         Punt Punt `binapi:"punt,name=punt" json:"punt,omitempty"`
229 }
230
231 func (m *PuntSocketDeregister) Reset()               { *m = PuntSocketDeregister{} }
232 func (*PuntSocketDeregister) GetMessageName() string { return "punt_socket_deregister" }
233 func (*PuntSocketDeregister) GetCrcString() string   { return "98a444f4" }
234 func (*PuntSocketDeregister) GetMessageType() api.MessageType {
235         return api.RequestMessage
236 }
237
238 func (m *PuntSocketDeregister) Size() (size int) {
239         if m == nil {
240                 return 0
241         }
242         size += 4     // m.Punt.Type
243         size += 1 * 4 // m.Punt.Punt
244         return size
245 }
246 func (m *PuntSocketDeregister) Marshal(b []byte) ([]byte, error) {
247         if b == nil {
248                 b = make([]byte, m.Size())
249         }
250         buf := codec.NewBuffer(b)
251         buf.EncodeUint32(uint32(m.Punt.Type))
252         buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 4)
253         return buf.Bytes(), nil
254 }
255 func (m *PuntSocketDeregister) Unmarshal(b []byte) error {
256         buf := codec.NewBuffer(b)
257         m.Punt.Type = PuntType(buf.DecodeUint32())
258         copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(4))
259         return nil
260 }
261
262 // PuntSocketDeregisterReply defines message 'punt_socket_deregister_reply'.
263 type PuntSocketDeregisterReply struct {
264         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
265 }
266
267 func (m *PuntSocketDeregisterReply) Reset()               { *m = PuntSocketDeregisterReply{} }
268 func (*PuntSocketDeregisterReply) GetMessageName() string { return "punt_socket_deregister_reply" }
269 func (*PuntSocketDeregisterReply) GetCrcString() string   { return "e8d4e804" }
270 func (*PuntSocketDeregisterReply) GetMessageType() api.MessageType {
271         return api.ReplyMessage
272 }
273
274 func (m *PuntSocketDeregisterReply) Size() (size int) {
275         if m == nil {
276                 return 0
277         }
278         size += 4 // m.Retval
279         return size
280 }
281 func (m *PuntSocketDeregisterReply) Marshal(b []byte) ([]byte, error) {
282         if b == nil {
283                 b = make([]byte, m.Size())
284         }
285         buf := codec.NewBuffer(b)
286         buf.EncodeInt32(m.Retval)
287         return buf.Bytes(), nil
288 }
289 func (m *PuntSocketDeregisterReply) Unmarshal(b []byte) error {
290         buf := codec.NewBuffer(b)
291         m.Retval = buf.DecodeInt32()
292         return nil
293 }
294
295 // PuntSocketDetails defines message 'punt_socket_details'.
296 type PuntSocketDetails struct {
297         Punt     Punt   `binapi:"punt,name=punt" json:"punt,omitempty"`
298         Pathname string `binapi:"string[108],name=pathname" json:"pathname,omitempty"`
299 }
300
301 func (m *PuntSocketDetails) Reset()               { *m = PuntSocketDetails{} }
302 func (*PuntSocketDetails) GetMessageName() string { return "punt_socket_details" }
303 func (*PuntSocketDetails) GetCrcString() string   { return "1de0ce75" }
304 func (*PuntSocketDetails) GetMessageType() api.MessageType {
305         return api.ReplyMessage
306 }
307
308 func (m *PuntSocketDetails) Size() (size int) {
309         if m == nil {
310                 return 0
311         }
312         size += 4     // m.Punt.Type
313         size += 1 * 4 // m.Punt.Punt
314         size += 108   // m.Pathname
315         return size
316 }
317 func (m *PuntSocketDetails) Marshal(b []byte) ([]byte, error) {
318         if b == nil {
319                 b = make([]byte, m.Size())
320         }
321         buf := codec.NewBuffer(b)
322         buf.EncodeUint32(uint32(m.Punt.Type))
323         buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 4)
324         buf.EncodeString(m.Pathname, 108)
325         return buf.Bytes(), nil
326 }
327 func (m *PuntSocketDetails) Unmarshal(b []byte) error {
328         buf := codec.NewBuffer(b)
329         m.Punt.Type = PuntType(buf.DecodeUint32())
330         copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(4))
331         m.Pathname = buf.DecodeString(108)
332         return nil
333 }
334
335 // PuntSocketDump defines message 'punt_socket_dump'.
336 type PuntSocketDump struct {
337         Type PuntType `binapi:"punt_type,name=type" json:"type,omitempty"`
338 }
339
340 func (m *PuntSocketDump) Reset()               { *m = PuntSocketDump{} }
341 func (*PuntSocketDump) GetMessageName() string { return "punt_socket_dump" }
342 func (*PuntSocketDump) GetCrcString() string   { return "52974935" }
343 func (*PuntSocketDump) GetMessageType() api.MessageType {
344         return api.RequestMessage
345 }
346
347 func (m *PuntSocketDump) Size() (size int) {
348         if m == nil {
349                 return 0
350         }
351         size += 4 // m.Type
352         return size
353 }
354 func (m *PuntSocketDump) Marshal(b []byte) ([]byte, error) {
355         if b == nil {
356                 b = make([]byte, m.Size())
357         }
358         buf := codec.NewBuffer(b)
359         buf.EncodeUint32(uint32(m.Type))
360         return buf.Bytes(), nil
361 }
362 func (m *PuntSocketDump) Unmarshal(b []byte) error {
363         buf := codec.NewBuffer(b)
364         m.Type = PuntType(buf.DecodeUint32())
365         return nil
366 }
367
368 // PuntSocketRegister defines message 'punt_socket_register'.
369 type PuntSocketRegister struct {
370         HeaderVersion uint32 `binapi:"u32,name=header_version" json:"header_version,omitempty"`
371         Punt          Punt   `binapi:"punt,name=punt" json:"punt,omitempty"`
372         Pathname      string `binapi:"string[108],name=pathname" json:"pathname,omitempty"`
373 }
374
375 func (m *PuntSocketRegister) Reset()               { *m = PuntSocketRegister{} }
376 func (*PuntSocketRegister) GetMessageName() string { return "punt_socket_register" }
377 func (*PuntSocketRegister) GetCrcString() string   { return "c8cd10fa" }
378 func (*PuntSocketRegister) GetMessageType() api.MessageType {
379         return api.RequestMessage
380 }
381
382 func (m *PuntSocketRegister) Size() (size int) {
383         if m == nil {
384                 return 0
385         }
386         size += 4     // m.HeaderVersion
387         size += 4     // m.Punt.Type
388         size += 1 * 4 // m.Punt.Punt
389         size += 108   // m.Pathname
390         return size
391 }
392 func (m *PuntSocketRegister) Marshal(b []byte) ([]byte, error) {
393         if b == nil {
394                 b = make([]byte, m.Size())
395         }
396         buf := codec.NewBuffer(b)
397         buf.EncodeUint32(m.HeaderVersion)
398         buf.EncodeUint32(uint32(m.Punt.Type))
399         buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 4)
400         buf.EncodeString(m.Pathname, 108)
401         return buf.Bytes(), nil
402 }
403 func (m *PuntSocketRegister) Unmarshal(b []byte) error {
404         buf := codec.NewBuffer(b)
405         m.HeaderVersion = buf.DecodeUint32()
406         m.Punt.Type = PuntType(buf.DecodeUint32())
407         copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(4))
408         m.Pathname = buf.DecodeString(108)
409         return nil
410 }
411
412 // PuntSocketRegisterReply defines message 'punt_socket_register_reply'.
413 type PuntSocketRegisterReply struct {
414         Retval   int32  `binapi:"i32,name=retval" json:"retval,omitempty"`
415         Pathname string `binapi:"string[108],name=pathname" json:"pathname,omitempty"`
416 }
417
418 func (m *PuntSocketRegisterReply) Reset()               { *m = PuntSocketRegisterReply{} }
419 func (*PuntSocketRegisterReply) GetMessageName() string { return "punt_socket_register_reply" }
420 func (*PuntSocketRegisterReply) GetCrcString() string   { return "bd30ae90" }
421 func (*PuntSocketRegisterReply) GetMessageType() api.MessageType {
422         return api.ReplyMessage
423 }
424
425 func (m *PuntSocketRegisterReply) Size() (size int) {
426         if m == nil {
427                 return 0
428         }
429         size += 4   // m.Retval
430         size += 108 // m.Pathname
431         return size
432 }
433 func (m *PuntSocketRegisterReply) Marshal(b []byte) ([]byte, error) {
434         if b == nil {
435                 b = make([]byte, m.Size())
436         }
437         buf := codec.NewBuffer(b)
438         buf.EncodeInt32(m.Retval)
439         buf.EncodeString(m.Pathname, 108)
440         return buf.Bytes(), nil
441 }
442 func (m *PuntSocketRegisterReply) Unmarshal(b []byte) error {
443         buf := codec.NewBuffer(b)
444         m.Retval = buf.DecodeInt32()
445         m.Pathname = buf.DecodeString(108)
446         return nil
447 }
448
449 // SetPunt defines message 'set_punt'.
450 type SetPunt struct {
451         IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"`
452         Punt  Punt `binapi:"punt,name=punt" json:"punt,omitempty"`
453 }
454
455 func (m *SetPunt) Reset()               { *m = SetPunt{} }
456 func (*SetPunt) GetMessageName() string { return "set_punt" }
457 func (*SetPunt) GetCrcString() string   { return "83799618" }
458 func (*SetPunt) GetMessageType() api.MessageType {
459         return api.RequestMessage
460 }
461
462 func (m *SetPunt) Size() (size int) {
463         if m == nil {
464                 return 0
465         }
466         size += 1     // m.IsAdd
467         size += 4     // m.Punt.Type
468         size += 1 * 4 // m.Punt.Punt
469         return size
470 }
471 func (m *SetPunt) Marshal(b []byte) ([]byte, error) {
472         if b == nil {
473                 b = make([]byte, m.Size())
474         }
475         buf := codec.NewBuffer(b)
476         buf.EncodeBool(m.IsAdd)
477         buf.EncodeUint32(uint32(m.Punt.Type))
478         buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 4)
479         return buf.Bytes(), nil
480 }
481 func (m *SetPunt) Unmarshal(b []byte) error {
482         buf := codec.NewBuffer(b)
483         m.IsAdd = buf.DecodeBool()
484         m.Punt.Type = PuntType(buf.DecodeUint32())
485         copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(4))
486         return nil
487 }
488
489 // SetPuntReply defines message 'set_punt_reply'.
490 type SetPuntReply struct {
491         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
492 }
493
494 func (m *SetPuntReply) Reset()               { *m = SetPuntReply{} }
495 func (*SetPuntReply) GetMessageName() string { return "set_punt_reply" }
496 func (*SetPuntReply) GetCrcString() string   { return "e8d4e804" }
497 func (*SetPuntReply) GetMessageType() api.MessageType {
498         return api.ReplyMessage
499 }
500
501 func (m *SetPuntReply) Size() (size int) {
502         if m == nil {
503                 return 0
504         }
505         size += 4 // m.Retval
506         return size
507 }
508 func (m *SetPuntReply) Marshal(b []byte) ([]byte, error) {
509         if b == nil {
510                 b = make([]byte, m.Size())
511         }
512         buf := codec.NewBuffer(b)
513         buf.EncodeInt32(m.Retval)
514         return buf.Bytes(), nil
515 }
516 func (m *SetPuntReply) Unmarshal(b []byte) error {
517         buf := codec.NewBuffer(b)
518         m.Retval = buf.DecodeInt32()
519         return nil
520 }
521
522 func init() { file_punt_binapi_init() }
523 func file_punt_binapi_init() {
524         api.RegisterMessage((*PuntReasonDetails)(nil), "punt_reason_details_2c9d4a40")
525         api.RegisterMessage((*PuntReasonDump)(nil), "punt_reason_dump_5c0dd4fe")
526         api.RegisterMessage((*PuntSocketDeregister)(nil), "punt_socket_deregister_98a444f4")
527         api.RegisterMessage((*PuntSocketDeregisterReply)(nil), "punt_socket_deregister_reply_e8d4e804")
528         api.RegisterMessage((*PuntSocketDetails)(nil), "punt_socket_details_1de0ce75")
529         api.RegisterMessage((*PuntSocketDump)(nil), "punt_socket_dump_52974935")
530         api.RegisterMessage((*PuntSocketRegister)(nil), "punt_socket_register_c8cd10fa")
531         api.RegisterMessage((*PuntSocketRegisterReply)(nil), "punt_socket_register_reply_bd30ae90")
532         api.RegisterMessage((*SetPunt)(nil), "set_punt_83799618")
533         api.RegisterMessage((*SetPuntReply)(nil), "set_punt_reply_e8d4e804")
534 }
535
536 // Messages returns list of all messages in this module.
537 func AllMessages() []api.Message {
538         return []api.Message{
539                 (*PuntReasonDetails)(nil),
540                 (*PuntReasonDump)(nil),
541                 (*PuntSocketDeregister)(nil),
542                 (*PuntSocketDeregisterReply)(nil),
543                 (*PuntSocketDetails)(nil),
544                 (*PuntSocketDump)(nil),
545                 (*PuntSocketRegister)(nil),
546                 (*PuntSocketRegisterReply)(nil),
547                 (*SetPunt)(nil),
548                 (*SetPuntReply)(nil),
549         }
550 }