Update generated binapi to v22.02 & makefile changes
[govpp.git] / internal / testbinapi / binapi2001 / punt / punt.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2 // versions:
3 //  binapi-generator: v0.5.0-dev
4 //  VPP:              20.01
5 // source: .vppapi/core/punt.api.json
6
7 // Package punt contains generated bindings for API file punt.api.
8 //
9 // Contents:
10 //   5 aliases
11 //   5 enums
12 //  11 structs
13 //   2 unions
14 //  10 messages
15 //
16 package punt
17
18 import (
19         "fmt"
20         "net"
21         "strconv"
22         "strings"
23
24         api "git.fd.io/govpp.git/api"
25         codec "git.fd.io/govpp.git/codec"
26 )
27
28 // This is a compile-time assertion to ensure that this generated file
29 // is compatible with the GoVPP api package it is being compiled against.
30 // A compilation error at this line likely means your copy of the
31 // GoVPP api package needs to be updated.
32 const _ = api.GoVppAPIPackageIsVersion2
33
34 const (
35         APIFile    = "punt"
36         APIVersion = "2.2.1"
37         VersionCrc = 0x51716f7f
38 )
39
40 // AddressFamily defines enum 'address_family'.
41 type AddressFamily uint32
42
43 const (
44         ADDRESS_IP4 AddressFamily = 0
45         ADDRESS_IP6 AddressFamily = 1
46 )
47
48 var (
49         AddressFamily_name = map[uint32]string{
50                 0: "ADDRESS_IP4",
51                 1: "ADDRESS_IP6",
52         }
53         AddressFamily_value = map[string]uint32{
54                 "ADDRESS_IP4": 0,
55                 "ADDRESS_IP6": 1,
56         }
57 )
58
59 func (x AddressFamily) String() string {
60         s, ok := AddressFamily_name[uint32(x)]
61         if ok {
62                 return s
63         }
64         return "AddressFamily(" + strconv.Itoa(int(x)) + ")"
65 }
66
67 // IPDscp defines enum 'ip_dscp'.
68 type IPDscp uint8
69
70 const (
71         IP_API_DSCP_CS0  IPDscp = 0
72         IP_API_DSCP_CS1  IPDscp = 8
73         IP_API_DSCP_AF11 IPDscp = 10
74         IP_API_DSCP_AF12 IPDscp = 12
75         IP_API_DSCP_AF13 IPDscp = 14
76         IP_API_DSCP_CS2  IPDscp = 16
77         IP_API_DSCP_AF21 IPDscp = 18
78         IP_API_DSCP_AF22 IPDscp = 20
79         IP_API_DSCP_AF23 IPDscp = 22
80         IP_API_DSCP_CS3  IPDscp = 24
81         IP_API_DSCP_AF31 IPDscp = 26
82         IP_API_DSCP_AF32 IPDscp = 28
83         IP_API_DSCP_AF33 IPDscp = 30
84         IP_API_DSCP_CS4  IPDscp = 32
85         IP_API_DSCP_AF41 IPDscp = 34
86         IP_API_DSCP_AF42 IPDscp = 36
87         IP_API_DSCP_AF43 IPDscp = 38
88         IP_API_DSCP_CS5  IPDscp = 40
89         IP_API_DSCP_EF   IPDscp = 46
90         IP_API_DSCP_CS6  IPDscp = 48
91         IP_API_DSCP_CS7  IPDscp = 50
92 )
93
94 var (
95         IPDscp_name = map[uint8]string{
96                 0:  "IP_API_DSCP_CS0",
97                 8:  "IP_API_DSCP_CS1",
98                 10: "IP_API_DSCP_AF11",
99                 12: "IP_API_DSCP_AF12",
100                 14: "IP_API_DSCP_AF13",
101                 16: "IP_API_DSCP_CS2",
102                 18: "IP_API_DSCP_AF21",
103                 20: "IP_API_DSCP_AF22",
104                 22: "IP_API_DSCP_AF23",
105                 24: "IP_API_DSCP_CS3",
106                 26: "IP_API_DSCP_AF31",
107                 28: "IP_API_DSCP_AF32",
108                 30: "IP_API_DSCP_AF33",
109                 32: "IP_API_DSCP_CS4",
110                 34: "IP_API_DSCP_AF41",
111                 36: "IP_API_DSCP_AF42",
112                 38: "IP_API_DSCP_AF43",
113                 40: "IP_API_DSCP_CS5",
114                 46: "IP_API_DSCP_EF",
115                 48: "IP_API_DSCP_CS6",
116                 50: "IP_API_DSCP_CS7",
117         }
118         IPDscp_value = map[string]uint8{
119                 "IP_API_DSCP_CS0":  0,
120                 "IP_API_DSCP_CS1":  8,
121                 "IP_API_DSCP_AF11": 10,
122                 "IP_API_DSCP_AF12": 12,
123                 "IP_API_DSCP_AF13": 14,
124                 "IP_API_DSCP_CS2":  16,
125                 "IP_API_DSCP_AF21": 18,
126                 "IP_API_DSCP_AF22": 20,
127                 "IP_API_DSCP_AF23": 22,
128                 "IP_API_DSCP_CS3":  24,
129                 "IP_API_DSCP_AF31": 26,
130                 "IP_API_DSCP_AF32": 28,
131                 "IP_API_DSCP_AF33": 30,
132                 "IP_API_DSCP_CS4":  32,
133                 "IP_API_DSCP_AF41": 34,
134                 "IP_API_DSCP_AF42": 36,
135                 "IP_API_DSCP_AF43": 38,
136                 "IP_API_DSCP_CS5":  40,
137                 "IP_API_DSCP_EF":   46,
138                 "IP_API_DSCP_CS6":  48,
139                 "IP_API_DSCP_CS7":  50,
140         }
141 )
142
143 func (x IPDscp) String() string {
144         s, ok := IPDscp_name[uint8(x)]
145         if ok {
146                 return s
147         }
148         return "IPDscp(" + strconv.Itoa(int(x)) + ")"
149 }
150
151 // IPEcn defines enum 'ip_ecn'.
152 type IPEcn uint8
153
154 const (
155         IP_API_ECN_NONE IPEcn = 0
156         IP_API_ECN_ECT0 IPEcn = 1
157         IP_API_ECN_ECT1 IPEcn = 2
158         IP_API_ECN_CE   IPEcn = 3
159 )
160
161 var (
162         IPEcn_name = map[uint8]string{
163                 0: "IP_API_ECN_NONE",
164                 1: "IP_API_ECN_ECT0",
165                 2: "IP_API_ECN_ECT1",
166                 3: "IP_API_ECN_CE",
167         }
168         IPEcn_value = map[string]uint8{
169                 "IP_API_ECN_NONE": 0,
170                 "IP_API_ECN_ECT0": 1,
171                 "IP_API_ECN_ECT1": 2,
172                 "IP_API_ECN_CE":   3,
173         }
174 )
175
176 func (x IPEcn) String() string {
177         s, ok := IPEcn_name[uint8(x)]
178         if ok {
179                 return s
180         }
181         return "IPEcn(" + strconv.Itoa(int(x)) + ")"
182 }
183
184 // IPProto defines enum 'ip_proto'.
185 type IPProto uint32
186
187 const (
188         IP_API_PROTO_HOPOPT   IPProto = 0
189         IP_API_PROTO_ICMP     IPProto = 1
190         IP_API_PROTO_IGMP     IPProto = 2
191         IP_API_PROTO_TCP      IPProto = 6
192         IP_API_PROTO_UDP      IPProto = 17
193         IP_API_PROTO_GRE      IPProto = 47
194         IP_API_PROTO_AH       IPProto = 50
195         IP_API_PROTO_ESP      IPProto = 51
196         IP_API_PROTO_EIGRP    IPProto = 88
197         IP_API_PROTO_OSPF     IPProto = 89
198         IP_API_PROTO_SCTP     IPProto = 132
199         IP_API_PROTO_RESERVED IPProto = 255
200 )
201
202 var (
203         IPProto_name = map[uint32]string{
204                 0:   "IP_API_PROTO_HOPOPT",
205                 1:   "IP_API_PROTO_ICMP",
206                 2:   "IP_API_PROTO_IGMP",
207                 6:   "IP_API_PROTO_TCP",
208                 17:  "IP_API_PROTO_UDP",
209                 47:  "IP_API_PROTO_GRE",
210                 50:  "IP_API_PROTO_AH",
211                 51:  "IP_API_PROTO_ESP",
212                 88:  "IP_API_PROTO_EIGRP",
213                 89:  "IP_API_PROTO_OSPF",
214                 132: "IP_API_PROTO_SCTP",
215                 255: "IP_API_PROTO_RESERVED",
216         }
217         IPProto_value = map[string]uint32{
218                 "IP_API_PROTO_HOPOPT":   0,
219                 "IP_API_PROTO_ICMP":     1,
220                 "IP_API_PROTO_IGMP":     2,
221                 "IP_API_PROTO_TCP":      6,
222                 "IP_API_PROTO_UDP":      17,
223                 "IP_API_PROTO_GRE":      47,
224                 "IP_API_PROTO_AH":       50,
225                 "IP_API_PROTO_ESP":      51,
226                 "IP_API_PROTO_EIGRP":    88,
227                 "IP_API_PROTO_OSPF":     89,
228                 "IP_API_PROTO_SCTP":     132,
229                 "IP_API_PROTO_RESERVED": 255,
230         }
231 )
232
233 func (x IPProto) String() string {
234         s, ok := IPProto_name[uint32(x)]
235         if ok {
236                 return s
237         }
238         return "IPProto(" + strconv.Itoa(int(x)) + ")"
239 }
240
241 // PuntType defines enum 'punt_type'.
242 type PuntType uint32
243
244 const (
245         PUNT_API_TYPE_L4        PuntType = 1
246         PUNT_API_TYPE_IP_PROTO  PuntType = 2
247         PUNT_API_TYPE_EXCEPTION PuntType = 3
248 )
249
250 var (
251         PuntType_name = map[uint32]string{
252                 1: "PUNT_API_TYPE_L4",
253                 2: "PUNT_API_TYPE_IP_PROTO",
254                 3: "PUNT_API_TYPE_EXCEPTION",
255         }
256         PuntType_value = map[string]uint32{
257                 "PUNT_API_TYPE_L4":        1,
258                 "PUNT_API_TYPE_IP_PROTO":  2,
259                 "PUNT_API_TYPE_EXCEPTION": 3,
260         }
261 )
262
263 func (x PuntType) String() string {
264         s, ok := PuntType_name[uint32(x)]
265         if ok {
266                 return s
267         }
268         return "PuntType(" + strconv.Itoa(int(x)) + ")"
269 }
270
271 // AddressWithPrefix defines alias 'address_with_prefix'.
272 type AddressWithPrefix Prefix
273
274 func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) {
275         prefix, err := ParsePrefix(s)
276         if err != nil {
277                 return AddressWithPrefix{}, err
278         }
279         return AddressWithPrefix(prefix), nil
280 }
281
282 func (x AddressWithPrefix) String() string {
283         return Prefix(x).String()
284 }
285
286 func (x *AddressWithPrefix) MarshalText() ([]byte, error) {
287         return []byte(x.String()), nil
288 }
289
290 func (x *AddressWithPrefix) UnmarshalText(text []byte) error {
291         prefix, err := ParseAddressWithPrefix(string(text))
292         if err != nil {
293                 return err
294         }
295         *x = prefix
296         return nil
297 }
298
299 // IP4Address defines alias 'ip4_address'.
300 type IP4Address [4]uint8
301
302 func ParseIP4Address(s string) (IP4Address, error) {
303         ip := net.ParseIP(s).To4()
304         if ip == nil {
305                 return IP4Address{}, fmt.Errorf("invalid IP address: %s", s)
306         }
307         var ipaddr IP4Address
308         copy(ipaddr[:], ip.To4())
309         return ipaddr, nil
310 }
311
312 func (x IP4Address) ToIP() net.IP {
313         return net.IP(x[:]).To4()
314 }
315
316 func (x IP4Address) String() string {
317         return x.ToIP().String()
318 }
319
320 func (x *IP4Address) MarshalText() ([]byte, error) {
321         return []byte(x.String()), nil
322 }
323
324 func (x *IP4Address) UnmarshalText(text []byte) error {
325         ipaddr, err := ParseIP4Address(string(text))
326         if err != nil {
327                 return err
328         }
329         *x = ipaddr
330         return nil
331 }
332
333 // IP4AddressWithPrefix defines alias 'ip4_address_with_prefix'.
334 type IP4AddressWithPrefix IP4Prefix
335
336 // IP6Address defines alias 'ip6_address'.
337 type IP6Address [16]uint8
338
339 func ParseIP6Address(s string) (IP6Address, error) {
340         ip := net.ParseIP(s).To16()
341         if ip == nil {
342                 return IP6Address{}, fmt.Errorf("invalid IP address: %s", s)
343         }
344         var ipaddr IP6Address
345         copy(ipaddr[:], ip.To16())
346         return ipaddr, nil
347 }
348
349 func (x IP6Address) ToIP() net.IP {
350         return net.IP(x[:]).To16()
351 }
352
353 func (x IP6Address) String() string {
354         return x.ToIP().String()
355 }
356
357 func (x *IP6Address) MarshalText() ([]byte, error) {
358         return []byte(x.String()), nil
359 }
360
361 func (x *IP6Address) UnmarshalText(text []byte) error {
362         ipaddr, err := ParseIP6Address(string(text))
363         if err != nil {
364                 return err
365         }
366         *x = ipaddr
367         return nil
368 }
369
370 // IP6AddressWithPrefix defines alias 'ip6_address_with_prefix'.
371 type IP6AddressWithPrefix IP6Prefix
372
373 // Address defines type 'address'.
374 type Address struct {
375         Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
376         Un AddressUnion  `binapi:"address_union,name=un" json:"un,omitempty"`
377 }
378
379 func ParseAddress(s string) (Address, error) {
380         ip := net.ParseIP(s)
381         if ip == nil {
382                 return Address{}, fmt.Errorf("invalid address: %s", s)
383         }
384         return AddressFromIP(ip), nil
385 }
386
387 func AddressFromIP(ip net.IP) Address {
388         var addr Address
389         if ip.To4() == nil {
390                 addr.Af = ADDRESS_IP6
391                 var ip6 IP6Address
392                 copy(ip6[:], ip.To16())
393                 addr.Un.SetIP6(ip6)
394         } else {
395                 addr.Af = ADDRESS_IP4
396                 var ip4 IP4Address
397                 copy(ip4[:], ip.To4())
398                 addr.Un.SetIP4(ip4)
399         }
400         return addr
401 }
402
403 func (x Address) ToIP() net.IP {
404         if x.Af == ADDRESS_IP6 {
405                 ip6 := x.Un.GetIP6()
406                 return net.IP(ip6[:]).To16()
407         } else {
408                 ip4 := x.Un.GetIP4()
409                 return net.IP(ip4[:]).To4()
410         }
411 }
412
413 func (x Address) String() string {
414         return x.ToIP().String()
415 }
416
417 func (x *Address) MarshalText() ([]byte, error) {
418         return []byte(x.String()), nil
419 }
420
421 func (x *Address) UnmarshalText(text []byte) error {
422         addr, err := ParseAddress(string(text))
423         if err != nil {
424                 return err
425         }
426         *x = addr
427         return nil
428 }
429
430 // IP4Prefix defines type 'ip4_prefix'.
431 type IP4Prefix struct {
432         Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"`
433         Len     uint8      `binapi:"u8,name=len" json:"len,omitempty"`
434 }
435
436 func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) {
437         hasPrefix := strings.Contains(s, "/")
438         if hasPrefix {
439                 ip, network, err := net.ParseCIDR(s)
440                 if err != nil {
441                         return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
442                 }
443                 maskSize, _ := network.Mask.Size()
444                 prefix.Len = byte(maskSize)
445                 prefix.Address, err = ParseIP4Address(ip.String())
446                 if err != nil {
447                         return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
448                 }
449         } else {
450                 ip := net.ParseIP(s)
451                 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
452                 if ip.To4() == nil {
453                         defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
454                 }
455                 prefix.Len = byte(defaultMaskSize)
456                 prefix.Address, err = ParseIP4Address(ip.String())
457                 if err != nil {
458                         return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
459                 }
460         }
461         return prefix, nil
462 }
463
464 func (x IP4Prefix) ToIPNet() *net.IPNet {
465         mask := net.CIDRMask(int(x.Len), 32)
466         ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
467         return ipnet
468 }
469
470 func (x IP4Prefix) String() string {
471         ip := x.Address.String()
472         return ip + "/" + strconv.Itoa(int(x.Len))
473 }
474
475 func (x *IP4Prefix) MarshalText() ([]byte, error) {
476         return []byte(x.String()), nil
477 }
478
479 func (x *IP4Prefix) UnmarshalText(text []byte) error {
480         prefix, err := ParseIP4Prefix(string(text))
481         if err != nil {
482                 return err
483         }
484         *x = prefix
485         return nil
486 }
487
488 // IP6Prefix defines type 'ip6_prefix'.
489 type IP6Prefix struct {
490         Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"`
491         Len     uint8      `binapi:"u8,name=len" json:"len,omitempty"`
492 }
493
494 func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) {
495         hasPrefix := strings.Contains(s, "/")
496         if hasPrefix {
497                 ip, network, err := net.ParseCIDR(s)
498                 if err != nil {
499                         return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
500                 }
501                 maskSize, _ := network.Mask.Size()
502                 prefix.Len = byte(maskSize)
503                 prefix.Address, err = ParseIP6Address(ip.String())
504                 if err != nil {
505                         return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
506                 }
507         } else {
508                 ip := net.ParseIP(s)
509                 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
510                 if ip.To4() == nil {
511                         defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
512                 }
513                 prefix.Len = byte(defaultMaskSize)
514                 prefix.Address, err = ParseIP6Address(ip.String())
515                 if err != nil {
516                         return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
517                 }
518         }
519         return prefix, nil
520 }
521
522 func (x IP6Prefix) ToIPNet() *net.IPNet {
523         mask := net.CIDRMask(int(x.Len), 128)
524         ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
525         return ipnet
526 }
527
528 func (x IP6Prefix) String() string {
529         ip := x.Address.String()
530         return ip + "/" + strconv.Itoa(int(x.Len))
531 }
532
533 func (x *IP6Prefix) MarshalText() ([]byte, error) {
534         return []byte(x.String()), nil
535 }
536
537 func (x *IP6Prefix) UnmarshalText(text []byte) error {
538         prefix, err := ParseIP6Prefix(string(text))
539         if err != nil {
540                 return err
541         }
542         *x = prefix
543         return nil
544 }
545
546 // Mprefix defines type 'mprefix'.
547 type Mprefix struct {
548         Af               AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
549         GrpAddressLength uint16        `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"`
550         GrpAddress       AddressUnion  `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"`
551         SrcAddress       AddressUnion  `binapi:"address_union,name=src_address" json:"src_address,omitempty"`
552 }
553
554 // Prefix defines type 'prefix'.
555 type Prefix struct {
556         Address Address `binapi:"address,name=address" json:"address,omitempty"`
557         Len     uint8   `binapi:"u8,name=len" json:"len,omitempty"`
558 }
559
560 func ParsePrefix(ip string) (prefix Prefix, err error) {
561         hasPrefix := strings.Contains(ip, "/")
562         if hasPrefix {
563                 netIP, network, err := net.ParseCIDR(ip)
564                 if err != nil {
565                         return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
566                 }
567                 maskSize, _ := network.Mask.Size()
568                 prefix.Len = byte(maskSize)
569                 prefix.Address, err = ParseAddress(netIP.String())
570                 if err != nil {
571                         return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
572                 }
573         } else {
574                 netIP := net.ParseIP(ip)
575                 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
576                 if netIP.To4() == nil {
577                         defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
578                 }
579                 prefix.Len = byte(defaultMaskSize)
580                 prefix.Address, err = ParseAddress(netIP.String())
581                 if err != nil {
582                         return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
583                 }
584         }
585         return prefix, nil
586 }
587
588 func (x Prefix) ToIPNet() *net.IPNet {
589         var mask net.IPMask
590         if x.Address.Af == ADDRESS_IP4 {
591                 mask = net.CIDRMask(int(x.Len), 32)
592         } else {
593                 mask = net.CIDRMask(int(x.Len), 128)
594         }
595         ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
596         return ipnet
597 }
598
599 func (x Prefix) String() string {
600         ip := x.Address.String()
601         return ip + "/" + strconv.Itoa(int(x.Len))
602 }
603
604 func (x *Prefix) MarshalText() ([]byte, error) {
605         return []byte(x.String()), nil
606 }
607
608 func (x *Prefix) UnmarshalText(text []byte) error {
609         prefix, err := ParsePrefix(string(text))
610         if err != nil {
611                 return err
612         }
613         *x = prefix
614         return nil
615 }
616
617 // PrefixMatcher defines type 'prefix_matcher'.
618 type PrefixMatcher struct {
619         Le uint8 `binapi:"u8,name=le" json:"le,omitempty"`
620         Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"`
621 }
622
623 // Punt defines type 'punt'.
624 type Punt struct {
625         Type PuntType  `binapi:"punt_type,name=type" json:"type,omitempty"`
626         Punt PuntUnion `binapi:"punt_union,name=punt" json:"punt,omitempty"`
627 }
628
629 // PuntException defines type 'punt_exception'.
630 type PuntException struct {
631         ID uint32 `binapi:"u32,name=id" json:"id,omitempty"`
632 }
633
634 // PuntIPProto defines type 'punt_ip_proto'.
635 type PuntIPProto struct {
636         Af       AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
637         Protocol IPProto       `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"`
638 }
639
640 // PuntL4 defines type 'punt_l4'.
641 type PuntL4 struct {
642         Af       AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
643         Protocol IPProto       `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"`
644         Port     uint16        `binapi:"u16,name=port" json:"port,omitempty"`
645 }
646
647 // PuntReason defines type 'punt_reason'.
648 type PuntReason struct {
649         ID   uint32 `binapi:"u32,name=id" json:"id,omitempty"`
650         Name string `binapi:"string[],name=name" json:"name,omitempty"`
651 }
652
653 // AddressUnion defines union 'address_union'.
654 type AddressUnion struct {
655         // AddressUnion can be one of:
656         // - IP4 *IP4Address
657         // - IP6 *IP6Address
658         XXX_UnionData [16]byte
659 }
660
661 func AddressUnionIP4(a IP4Address) (u AddressUnion) {
662         u.SetIP4(a)
663         return
664 }
665 func (u *AddressUnion) SetIP4(a IP4Address) {
666         buf := codec.NewBuffer(u.XXX_UnionData[:])
667         buf.EncodeBytes(a[:], 4)
668 }
669 func (u *AddressUnion) GetIP4() (a IP4Address) {
670         buf := codec.NewBuffer(u.XXX_UnionData[:])
671         copy(a[:], buf.DecodeBytes(4))
672         return
673 }
674
675 func AddressUnionIP6(a IP6Address) (u AddressUnion) {
676         u.SetIP6(a)
677         return
678 }
679 func (u *AddressUnion) SetIP6(a IP6Address) {
680         buf := codec.NewBuffer(u.XXX_UnionData[:])
681         buf.EncodeBytes(a[:], 16)
682 }
683 func (u *AddressUnion) GetIP6() (a IP6Address) {
684         buf := codec.NewBuffer(u.XXX_UnionData[:])
685         copy(a[:], buf.DecodeBytes(16))
686         return
687 }
688
689 // PuntUnion defines union 'punt_union'.
690 type PuntUnion struct {
691         // PuntUnion can be one of:
692         // - Exception *PuntException
693         // - L4 *PuntL4
694         // - IPProto *PuntIPProto
695         XXX_UnionData [10]byte
696 }
697
698 func PuntUnionException(a PuntException) (u PuntUnion) {
699         u.SetException(a)
700         return
701 }
702 func (u *PuntUnion) SetException(a PuntException) {
703         buf := codec.NewBuffer(u.XXX_UnionData[:])
704         buf.EncodeUint32(a.ID)
705 }
706 func (u *PuntUnion) GetException() (a PuntException) {
707         buf := codec.NewBuffer(u.XXX_UnionData[:])
708         a.ID = buf.DecodeUint32()
709         return
710 }
711
712 func PuntUnionL4(a PuntL4) (u PuntUnion) {
713         u.SetL4(a)
714         return
715 }
716 func (u *PuntUnion) SetL4(a PuntL4) {
717         buf := codec.NewBuffer(u.XXX_UnionData[:])
718         buf.EncodeUint32(uint32(a.Af))
719         buf.EncodeUint32(uint32(a.Protocol))
720         buf.EncodeUint16(a.Port)
721 }
722 func (u *PuntUnion) GetL4() (a PuntL4) {
723         buf := codec.NewBuffer(u.XXX_UnionData[:])
724         a.Af = AddressFamily(buf.DecodeUint32())
725         a.Protocol = IPProto(buf.DecodeUint32())
726         a.Port = buf.DecodeUint16()
727         return
728 }
729
730 func PuntUnionIPProto(a PuntIPProto) (u PuntUnion) {
731         u.SetIPProto(a)
732         return
733 }
734 func (u *PuntUnion) SetIPProto(a PuntIPProto) {
735         buf := codec.NewBuffer(u.XXX_UnionData[:])
736         buf.EncodeUint32(uint32(a.Af))
737         buf.EncodeUint32(uint32(a.Protocol))
738 }
739 func (u *PuntUnion) GetIPProto() (a PuntIPProto) {
740         buf := codec.NewBuffer(u.XXX_UnionData[:])
741         a.Af = AddressFamily(buf.DecodeUint32())
742         a.Protocol = IPProto(buf.DecodeUint32())
743         return
744 }
745
746 // PuntReasonDetails defines message 'punt_reason_details'.
747 type PuntReasonDetails struct {
748         Reason PuntReason `binapi:"punt_reason,name=reason" json:"reason,omitempty"`
749 }
750
751 func (m *PuntReasonDetails) Reset()               { *m = PuntReasonDetails{} }
752 func (*PuntReasonDetails) GetMessageName() string { return "punt_reason_details" }
753 func (*PuntReasonDetails) GetCrcString() string   { return "2c9d4a40" }
754 func (*PuntReasonDetails) GetMessageType() api.MessageType {
755         return api.ReplyMessage
756 }
757
758 func (m *PuntReasonDetails) Size() (size int) {
759         if m == nil {
760                 return 0
761         }
762         size += 4                      // m.Reason.ID
763         size += 4 + len(m.Reason.Name) // m.Reason.Name
764         return size
765 }
766 func (m *PuntReasonDetails) Marshal(b []byte) ([]byte, error) {
767         if b == nil {
768                 b = make([]byte, m.Size())
769         }
770         buf := codec.NewBuffer(b)
771         buf.EncodeUint32(m.Reason.ID)
772         buf.EncodeString(m.Reason.Name, 0)
773         return buf.Bytes(), nil
774 }
775 func (m *PuntReasonDetails) Unmarshal(b []byte) error {
776         buf := codec.NewBuffer(b)
777         m.Reason.ID = buf.DecodeUint32()
778         m.Reason.Name = buf.DecodeString(0)
779         return nil
780 }
781
782 // PuntReasonDump defines message 'punt_reason_dump'.
783 type PuntReasonDump struct {
784         Reason PuntReason `binapi:"punt_reason,name=reason" json:"reason,omitempty"`
785 }
786
787 func (m *PuntReasonDump) Reset()               { *m = PuntReasonDump{} }
788 func (*PuntReasonDump) GetMessageName() string { return "punt_reason_dump" }
789 func (*PuntReasonDump) GetCrcString() string   { return "5c0dd4fe" }
790 func (*PuntReasonDump) GetMessageType() api.MessageType {
791         return api.RequestMessage
792 }
793
794 func (m *PuntReasonDump) Size() (size int) {
795         if m == nil {
796                 return 0
797         }
798         size += 4                      // m.Reason.ID
799         size += 4 + len(m.Reason.Name) // m.Reason.Name
800         return size
801 }
802 func (m *PuntReasonDump) Marshal(b []byte) ([]byte, error) {
803         if b == nil {
804                 b = make([]byte, m.Size())
805         }
806         buf := codec.NewBuffer(b)
807         buf.EncodeUint32(m.Reason.ID)
808         buf.EncodeString(m.Reason.Name, 0)
809         return buf.Bytes(), nil
810 }
811 func (m *PuntReasonDump) Unmarshal(b []byte) error {
812         buf := codec.NewBuffer(b)
813         m.Reason.ID = buf.DecodeUint32()
814         m.Reason.Name = buf.DecodeString(0)
815         return nil
816 }
817
818 // PuntSocketDeregister defines message 'punt_socket_deregister'.
819 type PuntSocketDeregister struct {
820         Punt Punt `binapi:"punt,name=punt" json:"punt,omitempty"`
821 }
822
823 func (m *PuntSocketDeregister) Reset()               { *m = PuntSocketDeregister{} }
824 func (*PuntSocketDeregister) GetMessageName() string { return "punt_socket_deregister" }
825 func (*PuntSocketDeregister) GetCrcString() string   { return "98a444f4" }
826 func (*PuntSocketDeregister) GetMessageType() api.MessageType {
827         return api.RequestMessage
828 }
829
830 func (m *PuntSocketDeregister) Size() (size int) {
831         if m == nil {
832                 return 0
833         }
834         size += 4      // m.Punt.Type
835         size += 1 * 10 // m.Punt.Punt
836         return size
837 }
838 func (m *PuntSocketDeregister) Marshal(b []byte) ([]byte, error) {
839         if b == nil {
840                 b = make([]byte, m.Size())
841         }
842         buf := codec.NewBuffer(b)
843         buf.EncodeUint32(uint32(m.Punt.Type))
844         buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 10)
845         return buf.Bytes(), nil
846 }
847 func (m *PuntSocketDeregister) Unmarshal(b []byte) error {
848         buf := codec.NewBuffer(b)
849         m.Punt.Type = PuntType(buf.DecodeUint32())
850         copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(10))
851         return nil
852 }
853
854 // PuntSocketDeregisterReply defines message 'punt_socket_deregister_reply'.
855 type PuntSocketDeregisterReply struct {
856         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
857 }
858
859 func (m *PuntSocketDeregisterReply) Reset()               { *m = PuntSocketDeregisterReply{} }
860 func (*PuntSocketDeregisterReply) GetMessageName() string { return "punt_socket_deregister_reply" }
861 func (*PuntSocketDeregisterReply) GetCrcString() string   { return "e8d4e804" }
862 func (*PuntSocketDeregisterReply) GetMessageType() api.MessageType {
863         return api.ReplyMessage
864 }
865
866 func (m *PuntSocketDeregisterReply) Size() (size int) {
867         if m == nil {
868                 return 0
869         }
870         size += 4 // m.Retval
871         return size
872 }
873 func (m *PuntSocketDeregisterReply) Marshal(b []byte) ([]byte, error) {
874         if b == nil {
875                 b = make([]byte, m.Size())
876         }
877         buf := codec.NewBuffer(b)
878         buf.EncodeInt32(m.Retval)
879         return buf.Bytes(), nil
880 }
881 func (m *PuntSocketDeregisterReply) Unmarshal(b []byte) error {
882         buf := codec.NewBuffer(b)
883         m.Retval = buf.DecodeInt32()
884         return nil
885 }
886
887 // PuntSocketDetails defines message 'punt_socket_details'.
888 type PuntSocketDetails struct {
889         Punt     Punt   `binapi:"punt,name=punt" json:"punt,omitempty"`
890         Pathname string `binapi:"string[108],name=pathname" json:"pathname,omitempty"`
891 }
892
893 func (m *PuntSocketDetails) Reset()               { *m = PuntSocketDetails{} }
894 func (*PuntSocketDetails) GetMessageName() string { return "punt_socket_details" }
895 func (*PuntSocketDetails) GetCrcString() string   { return "1de0ce75" }
896 func (*PuntSocketDetails) GetMessageType() api.MessageType {
897         return api.ReplyMessage
898 }
899
900 func (m *PuntSocketDetails) Size() (size int) {
901         if m == nil {
902                 return 0
903         }
904         size += 4      // m.Punt.Type
905         size += 1 * 10 // m.Punt.Punt
906         size += 108    // m.Pathname
907         return size
908 }
909 func (m *PuntSocketDetails) Marshal(b []byte) ([]byte, error) {
910         if b == nil {
911                 b = make([]byte, m.Size())
912         }
913         buf := codec.NewBuffer(b)
914         buf.EncodeUint32(uint32(m.Punt.Type))
915         buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 10)
916         buf.EncodeString(m.Pathname, 108)
917         return buf.Bytes(), nil
918 }
919 func (m *PuntSocketDetails) Unmarshal(b []byte) error {
920         buf := codec.NewBuffer(b)
921         m.Punt.Type = PuntType(buf.DecodeUint32())
922         copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(10))
923         m.Pathname = buf.DecodeString(108)
924         return nil
925 }
926
927 // PuntSocketDump defines message 'punt_socket_dump'.
928 type PuntSocketDump struct {
929         Type PuntType `binapi:"punt_type,name=type" json:"type,omitempty"`
930 }
931
932 func (m *PuntSocketDump) Reset()               { *m = PuntSocketDump{} }
933 func (*PuntSocketDump) GetMessageName() string { return "punt_socket_dump" }
934 func (*PuntSocketDump) GetCrcString() string   { return "52974935" }
935 func (*PuntSocketDump) GetMessageType() api.MessageType {
936         return api.RequestMessage
937 }
938
939 func (m *PuntSocketDump) Size() (size int) {
940         if m == nil {
941                 return 0
942         }
943         size += 4 // m.Type
944         return size
945 }
946 func (m *PuntSocketDump) Marshal(b []byte) ([]byte, error) {
947         if b == nil {
948                 b = make([]byte, m.Size())
949         }
950         buf := codec.NewBuffer(b)
951         buf.EncodeUint32(uint32(m.Type))
952         return buf.Bytes(), nil
953 }
954 func (m *PuntSocketDump) Unmarshal(b []byte) error {
955         buf := codec.NewBuffer(b)
956         m.Type = PuntType(buf.DecodeUint32())
957         return nil
958 }
959
960 // PuntSocketRegister defines message 'punt_socket_register'.
961 type PuntSocketRegister struct {
962         HeaderVersion uint32 `binapi:"u32,name=header_version" json:"header_version,omitempty"`
963         Punt          Punt   `binapi:"punt,name=punt" json:"punt,omitempty"`
964         Pathname      string `binapi:"string[108],name=pathname" json:"pathname,omitempty"`
965 }
966
967 func (m *PuntSocketRegister) Reset()               { *m = PuntSocketRegister{} }
968 func (*PuntSocketRegister) GetMessageName() string { return "punt_socket_register" }
969 func (*PuntSocketRegister) GetCrcString() string   { return "c8cd10fa" }
970 func (*PuntSocketRegister) GetMessageType() api.MessageType {
971         return api.RequestMessage
972 }
973
974 func (m *PuntSocketRegister) Size() (size int) {
975         if m == nil {
976                 return 0
977         }
978         size += 4      // m.HeaderVersion
979         size += 4      // m.Punt.Type
980         size += 1 * 10 // m.Punt.Punt
981         size += 108    // m.Pathname
982         return size
983 }
984 func (m *PuntSocketRegister) Marshal(b []byte) ([]byte, error) {
985         if b == nil {
986                 b = make([]byte, m.Size())
987         }
988         buf := codec.NewBuffer(b)
989         buf.EncodeUint32(m.HeaderVersion)
990         buf.EncodeUint32(uint32(m.Punt.Type))
991         buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 10)
992         buf.EncodeString(m.Pathname, 108)
993         return buf.Bytes(), nil
994 }
995 func (m *PuntSocketRegister) Unmarshal(b []byte) error {
996         buf := codec.NewBuffer(b)
997         m.HeaderVersion = buf.DecodeUint32()
998         m.Punt.Type = PuntType(buf.DecodeUint32())
999         copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(10))
1000         m.Pathname = buf.DecodeString(108)
1001         return nil
1002 }
1003
1004 // PuntSocketRegisterReply defines message 'punt_socket_register_reply'.
1005 type PuntSocketRegisterReply struct {
1006         Retval   int32  `binapi:"i32,name=retval" json:"retval,omitempty"`
1007         Pathname string `binapi:"string[108],name=pathname" json:"pathname,omitempty"`
1008 }
1009
1010 func (m *PuntSocketRegisterReply) Reset()               { *m = PuntSocketRegisterReply{} }
1011 func (*PuntSocketRegisterReply) GetMessageName() string { return "punt_socket_register_reply" }
1012 func (*PuntSocketRegisterReply) GetCrcString() string   { return "bd30ae90" }
1013 func (*PuntSocketRegisterReply) GetMessageType() api.MessageType {
1014         return api.ReplyMessage
1015 }
1016
1017 func (m *PuntSocketRegisterReply) Size() (size int) {
1018         if m == nil {
1019                 return 0
1020         }
1021         size += 4   // m.Retval
1022         size += 108 // m.Pathname
1023         return size
1024 }
1025 func (m *PuntSocketRegisterReply) Marshal(b []byte) ([]byte, error) {
1026         if b == nil {
1027                 b = make([]byte, m.Size())
1028         }
1029         buf := codec.NewBuffer(b)
1030         buf.EncodeInt32(m.Retval)
1031         buf.EncodeString(m.Pathname, 108)
1032         return buf.Bytes(), nil
1033 }
1034 func (m *PuntSocketRegisterReply) Unmarshal(b []byte) error {
1035         buf := codec.NewBuffer(b)
1036         m.Retval = buf.DecodeInt32()
1037         m.Pathname = buf.DecodeString(108)
1038         return nil
1039 }
1040
1041 // SetPunt defines message 'set_punt'.
1042 type SetPunt struct {
1043         IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"`
1044         Punt  Punt `binapi:"punt,name=punt" json:"punt,omitempty"`
1045 }
1046
1047 func (m *SetPunt) Reset()               { *m = SetPunt{} }
1048 func (*SetPunt) GetMessageName() string { return "set_punt" }
1049 func (*SetPunt) GetCrcString() string   { return "83799618" }
1050 func (*SetPunt) GetMessageType() api.MessageType {
1051         return api.RequestMessage
1052 }
1053
1054 func (m *SetPunt) Size() (size int) {
1055         if m == nil {
1056                 return 0
1057         }
1058         size += 1      // m.IsAdd
1059         size += 4      // m.Punt.Type
1060         size += 1 * 10 // m.Punt.Punt
1061         return size
1062 }
1063 func (m *SetPunt) Marshal(b []byte) ([]byte, error) {
1064         if b == nil {
1065                 b = make([]byte, m.Size())
1066         }
1067         buf := codec.NewBuffer(b)
1068         buf.EncodeBool(m.IsAdd)
1069         buf.EncodeUint32(uint32(m.Punt.Type))
1070         buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 10)
1071         return buf.Bytes(), nil
1072 }
1073 func (m *SetPunt) Unmarshal(b []byte) error {
1074         buf := codec.NewBuffer(b)
1075         m.IsAdd = buf.DecodeBool()
1076         m.Punt.Type = PuntType(buf.DecodeUint32())
1077         copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(10))
1078         return nil
1079 }
1080
1081 // SetPuntReply defines message 'set_punt_reply'.
1082 type SetPuntReply struct {
1083         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
1084 }
1085
1086 func (m *SetPuntReply) Reset()               { *m = SetPuntReply{} }
1087 func (*SetPuntReply) GetMessageName() string { return "set_punt_reply" }
1088 func (*SetPuntReply) GetCrcString() string   { return "e8d4e804" }
1089 func (*SetPuntReply) GetMessageType() api.MessageType {
1090         return api.ReplyMessage
1091 }
1092
1093 func (m *SetPuntReply) Size() (size int) {
1094         if m == nil {
1095                 return 0
1096         }
1097         size += 4 // m.Retval
1098         return size
1099 }
1100 func (m *SetPuntReply) Marshal(b []byte) ([]byte, error) {
1101         if b == nil {
1102                 b = make([]byte, m.Size())
1103         }
1104         buf := codec.NewBuffer(b)
1105         buf.EncodeInt32(m.Retval)
1106         return buf.Bytes(), nil
1107 }
1108 func (m *SetPuntReply) Unmarshal(b []byte) error {
1109         buf := codec.NewBuffer(b)
1110         m.Retval = buf.DecodeInt32()
1111         return nil
1112 }
1113
1114 func init() { file_punt_binapi_init() }
1115 func file_punt_binapi_init() {
1116         api.RegisterMessage((*PuntReasonDetails)(nil), "punt_reason_details_2c9d4a40")
1117         api.RegisterMessage((*PuntReasonDump)(nil), "punt_reason_dump_5c0dd4fe")
1118         api.RegisterMessage((*PuntSocketDeregister)(nil), "punt_socket_deregister_98a444f4")
1119         api.RegisterMessage((*PuntSocketDeregisterReply)(nil), "punt_socket_deregister_reply_e8d4e804")
1120         api.RegisterMessage((*PuntSocketDetails)(nil), "punt_socket_details_1de0ce75")
1121         api.RegisterMessage((*PuntSocketDump)(nil), "punt_socket_dump_52974935")
1122         api.RegisterMessage((*PuntSocketRegister)(nil), "punt_socket_register_c8cd10fa")
1123         api.RegisterMessage((*PuntSocketRegisterReply)(nil), "punt_socket_register_reply_bd30ae90")
1124         api.RegisterMessage((*SetPunt)(nil), "set_punt_83799618")
1125         api.RegisterMessage((*SetPuntReply)(nil), "set_punt_reply_e8d4e804")
1126 }
1127
1128 // Messages returns list of all messages in this module.
1129 func AllMessages() []api.Message {
1130         return []api.Message{
1131                 (*PuntReasonDetails)(nil),
1132                 (*PuntReasonDump)(nil),
1133                 (*PuntSocketDeregister)(nil),
1134                 (*PuntSocketDeregisterReply)(nil),
1135                 (*PuntSocketDetails)(nil),
1136                 (*PuntSocketDump)(nil),
1137                 (*PuntSocketRegister)(nil),
1138                 (*PuntSocketRegisterReply)(nil),
1139                 (*SetPunt)(nil),
1140                 (*SetPuntReply)(nil),
1141         }
1142 }