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