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