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