Update generated binapi to v22.02 & makefile changes
[govpp.git] / internal / testbinapi / binapi2001 / ipip / ipip.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/ipip.api.json
6
7 // Package ipip contains generated bindings for API file ipip.api.
8 //
9 // Contents:
10 //   6 aliases
11 //  11 enums
12 //   7 structs
13 //   1 union
14 //  10 messages
15 //
16 package ipip
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    = "ipip"
36         APIVersion = "2.0.0"
37         VersionCrc = 0xf108649c
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 // IpipTunnelFlags defines enum 'ipip_tunnel_flags'.
321 type IpipTunnelFlags uint8
322
323 const (
324         IPIP_TUNNEL_API_FLAG_NONE            IpipTunnelFlags = 0
325         IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DF   IpipTunnelFlags = 1
326         IPIP_TUNNEL_API_FLAG_ENCAP_SET_DF    IpipTunnelFlags = 2
327         IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DSCP IpipTunnelFlags = 4
328         IPIP_TUNNEL_API_FLAG_ENCAP_COPY_ECN  IpipTunnelFlags = 8
329         IPIP_TUNNEL_API_FLAG_DECAP_COPY_ECN  IpipTunnelFlags = 16
330 )
331
332 var (
333         IpipTunnelFlags_name = map[uint8]string{
334                 0:  "IPIP_TUNNEL_API_FLAG_NONE",
335                 1:  "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DF",
336                 2:  "IPIP_TUNNEL_API_FLAG_ENCAP_SET_DF",
337                 4:  "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DSCP",
338                 8:  "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_ECN",
339                 16: "IPIP_TUNNEL_API_FLAG_DECAP_COPY_ECN",
340         }
341         IpipTunnelFlags_value = map[string]uint8{
342                 "IPIP_TUNNEL_API_FLAG_NONE":            0,
343                 "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DF":   1,
344                 "IPIP_TUNNEL_API_FLAG_ENCAP_SET_DF":    2,
345                 "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DSCP": 4,
346                 "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_ECN":  8,
347                 "IPIP_TUNNEL_API_FLAG_DECAP_COPY_ECN":  16,
348         }
349 )
350
351 func (x IpipTunnelFlags) String() string {
352         s, ok := IpipTunnelFlags_name[uint8(x)]
353         if ok {
354                 return s
355         }
356         str := func(n uint8) string {
357                 s, ok := IpipTunnelFlags_name[uint8(n)]
358                 if ok {
359                         return s
360                 }
361                 return "IpipTunnelFlags(" + strconv.Itoa(int(n)) + ")"
362         }
363         for i := uint8(0); i <= 8; i++ {
364                 val := uint8(x)
365                 if val&(1<<i) != 0 {
366                         if s != "" {
367                                 s += "|"
368                         }
369                         s += str(1 << i)
370                 }
371         }
372         if s == "" {
373                 return str(uint8(x))
374         }
375         return s
376 }
377
378 // LinkDuplex defines enum 'link_duplex'.
379 type LinkDuplex uint32
380
381 const (
382         LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0
383         LINK_DUPLEX_API_HALF    LinkDuplex = 1
384         LINK_DUPLEX_API_FULL    LinkDuplex = 2
385 )
386
387 var (
388         LinkDuplex_name = map[uint32]string{
389                 0: "LINK_DUPLEX_API_UNKNOWN",
390                 1: "LINK_DUPLEX_API_HALF",
391                 2: "LINK_DUPLEX_API_FULL",
392         }
393         LinkDuplex_value = map[string]uint32{
394                 "LINK_DUPLEX_API_UNKNOWN": 0,
395                 "LINK_DUPLEX_API_HALF":    1,
396                 "LINK_DUPLEX_API_FULL":    2,
397         }
398 )
399
400 func (x LinkDuplex) String() string {
401         s, ok := LinkDuplex_name[uint32(x)]
402         if ok {
403                 return s
404         }
405         return "LinkDuplex(" + strconv.Itoa(int(x)) + ")"
406 }
407
408 // MtuProto defines enum 'mtu_proto'.
409 type MtuProto uint32
410
411 const (
412         MTU_PROTO_API_L3   MtuProto = 1
413         MTU_PROTO_API_IP4  MtuProto = 2
414         MTU_PROTO_API_IP6  MtuProto = 3
415         MTU_PROTO_API_MPLS MtuProto = 4
416         MTU_PROTO_API_N    MtuProto = 5
417 )
418
419 var (
420         MtuProto_name = map[uint32]string{
421                 1: "MTU_PROTO_API_L3",
422                 2: "MTU_PROTO_API_IP4",
423                 3: "MTU_PROTO_API_IP6",
424                 4: "MTU_PROTO_API_MPLS",
425                 5: "MTU_PROTO_API_N",
426         }
427         MtuProto_value = map[string]uint32{
428                 "MTU_PROTO_API_L3":   1,
429                 "MTU_PROTO_API_IP4":  2,
430                 "MTU_PROTO_API_IP6":  3,
431                 "MTU_PROTO_API_MPLS": 4,
432                 "MTU_PROTO_API_N":    5,
433         }
434 )
435
436 func (x MtuProto) String() string {
437         s, ok := MtuProto_name[uint32(x)]
438         if ok {
439                 return s
440         }
441         return "MtuProto(" + strconv.Itoa(int(x)) + ")"
442 }
443
444 // RxMode defines enum 'rx_mode'.
445 type RxMode uint32
446
447 const (
448         RX_MODE_API_UNKNOWN   RxMode = 0
449         RX_MODE_API_POLLING   RxMode = 1
450         RX_MODE_API_INTERRUPT RxMode = 2
451         RX_MODE_API_ADAPTIVE  RxMode = 3
452         RX_MODE_API_DEFAULT   RxMode = 4
453 )
454
455 var (
456         RxMode_name = map[uint32]string{
457                 0: "RX_MODE_API_UNKNOWN",
458                 1: "RX_MODE_API_POLLING",
459                 2: "RX_MODE_API_INTERRUPT",
460                 3: "RX_MODE_API_ADAPTIVE",
461                 4: "RX_MODE_API_DEFAULT",
462         }
463         RxMode_value = map[string]uint32{
464                 "RX_MODE_API_UNKNOWN":   0,
465                 "RX_MODE_API_POLLING":   1,
466                 "RX_MODE_API_INTERRUPT": 2,
467                 "RX_MODE_API_ADAPTIVE":  3,
468                 "RX_MODE_API_DEFAULT":   4,
469         }
470 )
471
472 func (x RxMode) String() string {
473         s, ok := RxMode_name[uint32(x)]
474         if ok {
475                 return s
476         }
477         return "RxMode(" + strconv.Itoa(int(x)) + ")"
478 }
479
480 // SubIfFlags defines enum 'sub_if_flags'.
481 type SubIfFlags uint32
482
483 const (
484         SUB_IF_API_FLAG_NO_TAGS           SubIfFlags = 1
485         SUB_IF_API_FLAG_ONE_TAG           SubIfFlags = 2
486         SUB_IF_API_FLAG_TWO_TAGS          SubIfFlags = 4
487         SUB_IF_API_FLAG_DOT1AD            SubIfFlags = 8
488         SUB_IF_API_FLAG_EXACT_MATCH       SubIfFlags = 16
489         SUB_IF_API_FLAG_DEFAULT           SubIfFlags = 32
490         SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY SubIfFlags = 64
491         SUB_IF_API_FLAG_INNER_VLAN_ID_ANY SubIfFlags = 128
492         SUB_IF_API_FLAG_MASK_VNET         SubIfFlags = 254
493         SUB_IF_API_FLAG_DOT1AH            SubIfFlags = 256
494 )
495
496 var (
497         SubIfFlags_name = map[uint32]string{
498                 1:   "SUB_IF_API_FLAG_NO_TAGS",
499                 2:   "SUB_IF_API_FLAG_ONE_TAG",
500                 4:   "SUB_IF_API_FLAG_TWO_TAGS",
501                 8:   "SUB_IF_API_FLAG_DOT1AD",
502                 16:  "SUB_IF_API_FLAG_EXACT_MATCH",
503                 32:  "SUB_IF_API_FLAG_DEFAULT",
504                 64:  "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY",
505                 128: "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY",
506                 254: "SUB_IF_API_FLAG_MASK_VNET",
507                 256: "SUB_IF_API_FLAG_DOT1AH",
508         }
509         SubIfFlags_value = map[string]uint32{
510                 "SUB_IF_API_FLAG_NO_TAGS":           1,
511                 "SUB_IF_API_FLAG_ONE_TAG":           2,
512                 "SUB_IF_API_FLAG_TWO_TAGS":          4,
513                 "SUB_IF_API_FLAG_DOT1AD":            8,
514                 "SUB_IF_API_FLAG_EXACT_MATCH":       16,
515                 "SUB_IF_API_FLAG_DEFAULT":           32,
516                 "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY": 64,
517                 "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY": 128,
518                 "SUB_IF_API_FLAG_MASK_VNET":         254,
519                 "SUB_IF_API_FLAG_DOT1AH":            256,
520         }
521 )
522
523 func (x SubIfFlags) String() string {
524         s, ok := SubIfFlags_name[uint32(x)]
525         if ok {
526                 return s
527         }
528         str := func(n uint32) string {
529                 s, ok := SubIfFlags_name[uint32(n)]
530                 if ok {
531                         return s
532                 }
533                 return "SubIfFlags(" + strconv.Itoa(int(n)) + ")"
534         }
535         for i := uint32(0); i <= 32; i++ {
536                 val := uint32(x)
537                 if val&(1<<i) != 0 {
538                         if s != "" {
539                                 s += "|"
540                         }
541                         s += str(1 << i)
542                 }
543         }
544         if s == "" {
545                 return str(uint32(x))
546         }
547         return s
548 }
549
550 // AddressWithPrefix defines alias 'address_with_prefix'.
551 type AddressWithPrefix Prefix
552
553 func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) {
554         prefix, err := ParsePrefix(s)
555         if err != nil {
556                 return AddressWithPrefix{}, err
557         }
558         return AddressWithPrefix(prefix), nil
559 }
560
561 func (x AddressWithPrefix) String() string {
562         return Prefix(x).String()
563 }
564
565 func (x *AddressWithPrefix) MarshalText() ([]byte, error) {
566         return []byte(x.String()), nil
567 }
568
569 func (x *AddressWithPrefix) UnmarshalText(text []byte) error {
570         prefix, err := ParseAddressWithPrefix(string(text))
571         if err != nil {
572                 return err
573         }
574         *x = prefix
575         return nil
576 }
577
578 // InterfaceIndex defines alias 'interface_index'.
579 type InterfaceIndex uint32
580
581 // IP4Address defines alias 'ip4_address'.
582 type IP4Address [4]uint8
583
584 func ParseIP4Address(s string) (IP4Address, error) {
585         ip := net.ParseIP(s).To4()
586         if ip == nil {
587                 return IP4Address{}, fmt.Errorf("invalid IP address: %s", s)
588         }
589         var ipaddr IP4Address
590         copy(ipaddr[:], ip.To4())
591         return ipaddr, nil
592 }
593
594 func (x IP4Address) ToIP() net.IP {
595         return net.IP(x[:]).To4()
596 }
597
598 func (x IP4Address) String() string {
599         return x.ToIP().String()
600 }
601
602 func (x *IP4Address) MarshalText() ([]byte, error) {
603         return []byte(x.String()), nil
604 }
605
606 func (x *IP4Address) UnmarshalText(text []byte) error {
607         ipaddr, err := ParseIP4Address(string(text))
608         if err != nil {
609                 return err
610         }
611         *x = ipaddr
612         return nil
613 }
614
615 // IP4AddressWithPrefix defines alias 'ip4_address_with_prefix'.
616 type IP4AddressWithPrefix IP4Prefix
617
618 // IP6Address defines alias 'ip6_address'.
619 type IP6Address [16]uint8
620
621 func ParseIP6Address(s string) (IP6Address, error) {
622         ip := net.ParseIP(s).To16()
623         if ip == nil {
624                 return IP6Address{}, fmt.Errorf("invalid IP address: %s", s)
625         }
626         var ipaddr IP6Address
627         copy(ipaddr[:], ip.To16())
628         return ipaddr, nil
629 }
630
631 func (x IP6Address) ToIP() net.IP {
632         return net.IP(x[:]).To16()
633 }
634
635 func (x IP6Address) String() string {
636         return x.ToIP().String()
637 }
638
639 func (x *IP6Address) MarshalText() ([]byte, error) {
640         return []byte(x.String()), nil
641 }
642
643 func (x *IP6Address) UnmarshalText(text []byte) error {
644         ipaddr, err := ParseIP6Address(string(text))
645         if err != nil {
646                 return err
647         }
648         *x = ipaddr
649         return nil
650 }
651
652 // IP6AddressWithPrefix defines alias 'ip6_address_with_prefix'.
653 type IP6AddressWithPrefix IP6Prefix
654
655 // Address defines type 'address'.
656 type Address struct {
657         Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
658         Un AddressUnion  `binapi:"address_union,name=un" json:"un,omitempty"`
659 }
660
661 func ParseAddress(s string) (Address, error) {
662         ip := net.ParseIP(s)
663         if ip == nil {
664                 return Address{}, fmt.Errorf("invalid address: %s", s)
665         }
666         return AddressFromIP(ip), nil
667 }
668
669 func AddressFromIP(ip net.IP) Address {
670         var addr Address
671         if ip.To4() == nil {
672                 addr.Af = ADDRESS_IP6
673                 var ip6 IP6Address
674                 copy(ip6[:], ip.To16())
675                 addr.Un.SetIP6(ip6)
676         } else {
677                 addr.Af = ADDRESS_IP4
678                 var ip4 IP4Address
679                 copy(ip4[:], ip.To4())
680                 addr.Un.SetIP4(ip4)
681         }
682         return addr
683 }
684
685 func (x Address) ToIP() net.IP {
686         if x.Af == ADDRESS_IP6 {
687                 ip6 := x.Un.GetIP6()
688                 return net.IP(ip6[:]).To16()
689         } else {
690                 ip4 := x.Un.GetIP4()
691                 return net.IP(ip4[:]).To4()
692         }
693 }
694
695 func (x Address) String() string {
696         return x.ToIP().String()
697 }
698
699 func (x *Address) MarshalText() ([]byte, error) {
700         return []byte(x.String()), nil
701 }
702
703 func (x *Address) UnmarshalText(text []byte) error {
704         addr, err := ParseAddress(string(text))
705         if err != nil {
706                 return err
707         }
708         *x = addr
709         return nil
710 }
711
712 // IP4Prefix defines type 'ip4_prefix'.
713 type IP4Prefix struct {
714         Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"`
715         Len     uint8      `binapi:"u8,name=len" json:"len,omitempty"`
716 }
717
718 func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) {
719         hasPrefix := strings.Contains(s, "/")
720         if hasPrefix {
721                 ip, network, err := net.ParseCIDR(s)
722                 if err != nil {
723                         return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
724                 }
725                 maskSize, _ := network.Mask.Size()
726                 prefix.Len = byte(maskSize)
727                 prefix.Address, err = ParseIP4Address(ip.String())
728                 if err != nil {
729                         return IP4Prefix{}, 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 = ParseIP4Address(ip.String())
739                 if err != nil {
740                         return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
741                 }
742         }
743         return prefix, nil
744 }
745
746 func (x IP4Prefix) ToIPNet() *net.IPNet {
747         mask := net.CIDRMask(int(x.Len), 32)
748         ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
749         return ipnet
750 }
751
752 func (x IP4Prefix) String() string {
753         ip := x.Address.String()
754         return ip + "/" + strconv.Itoa(int(x.Len))
755 }
756
757 func (x *IP4Prefix) MarshalText() ([]byte, error) {
758         return []byte(x.String()), nil
759 }
760
761 func (x *IP4Prefix) UnmarshalText(text []byte) error {
762         prefix, err := ParseIP4Prefix(string(text))
763         if err != nil {
764                 return err
765         }
766         *x = prefix
767         return nil
768 }
769
770 // IP6Prefix defines type 'ip6_prefix'.
771 type IP6Prefix struct {
772         Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"`
773         Len     uint8      `binapi:"u8,name=len" json:"len,omitempty"`
774 }
775
776 func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) {
777         hasPrefix := strings.Contains(s, "/")
778         if hasPrefix {
779                 ip, network, err := net.ParseCIDR(s)
780                 if err != nil {
781                         return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
782                 }
783                 maskSize, _ := network.Mask.Size()
784                 prefix.Len = byte(maskSize)
785                 prefix.Address, err = ParseIP6Address(ip.String())
786                 if err != nil {
787                         return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
788                 }
789         } else {
790                 ip := net.ParseIP(s)
791                 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
792                 if ip.To4() == nil {
793                         defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
794                 }
795                 prefix.Len = byte(defaultMaskSize)
796                 prefix.Address, err = ParseIP6Address(ip.String())
797                 if err != nil {
798                         return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
799                 }
800         }
801         return prefix, nil
802 }
803
804 func (x IP6Prefix) ToIPNet() *net.IPNet {
805         mask := net.CIDRMask(int(x.Len), 128)
806         ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
807         return ipnet
808 }
809
810 func (x IP6Prefix) String() string {
811         ip := x.Address.String()
812         return ip + "/" + strconv.Itoa(int(x.Len))
813 }
814
815 func (x *IP6Prefix) MarshalText() ([]byte, error) {
816         return []byte(x.String()), nil
817 }
818
819 func (x *IP6Prefix) UnmarshalText(text []byte) error {
820         prefix, err := ParseIP6Prefix(string(text))
821         if err != nil {
822                 return err
823         }
824         *x = prefix
825         return nil
826 }
827
828 // IpipTunnel defines type 'ipip_tunnel'.
829 type IpipTunnel struct {
830         Instance  uint32          `binapi:"u32,name=instance" json:"instance,omitempty"`
831         Src       Address         `binapi:"address,name=src" json:"src,omitempty"`
832         Dst       Address         `binapi:"address,name=dst" json:"dst,omitempty"`
833         SwIfIndex InterfaceIndex  `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
834         TableID   uint32          `binapi:"u32,name=table_id" json:"table_id,omitempty"`
835         Flags     IpipTunnelFlags `binapi:"ipip_tunnel_flags,name=flags" json:"flags,omitempty"`
836         Dscp      IPDscp          `binapi:"ip_dscp,name=dscp" json:"dscp,omitempty"`
837 }
838
839 // Mprefix defines type 'mprefix'.
840 type Mprefix struct {
841         Af               AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
842         GrpAddressLength uint16        `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"`
843         GrpAddress       AddressUnion  `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"`
844         SrcAddress       AddressUnion  `binapi:"address_union,name=src_address" json:"src_address,omitempty"`
845 }
846
847 // Prefix defines type 'prefix'.
848 type Prefix struct {
849         Address Address `binapi:"address,name=address" json:"address,omitempty"`
850         Len     uint8   `binapi:"u8,name=len" json:"len,omitempty"`
851 }
852
853 func ParsePrefix(ip string) (prefix Prefix, err error) {
854         hasPrefix := strings.Contains(ip, "/")
855         if hasPrefix {
856                 netIP, network, err := net.ParseCIDR(ip)
857                 if err != nil {
858                         return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
859                 }
860                 maskSize, _ := network.Mask.Size()
861                 prefix.Len = byte(maskSize)
862                 prefix.Address, err = ParseAddress(netIP.String())
863                 if err != nil {
864                         return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
865                 }
866         } else {
867                 netIP := net.ParseIP(ip)
868                 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
869                 if netIP.To4() == nil {
870                         defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
871                 }
872                 prefix.Len = byte(defaultMaskSize)
873                 prefix.Address, err = ParseAddress(netIP.String())
874                 if err != nil {
875                         return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
876                 }
877         }
878         return prefix, nil
879 }
880
881 func (x Prefix) ToIPNet() *net.IPNet {
882         var mask net.IPMask
883         if x.Address.Af == ADDRESS_IP4 {
884                 mask = net.CIDRMask(int(x.Len), 32)
885         } else {
886                 mask = net.CIDRMask(int(x.Len), 128)
887         }
888         ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
889         return ipnet
890 }
891
892 func (x Prefix) String() string {
893         ip := x.Address.String()
894         return ip + "/" + strconv.Itoa(int(x.Len))
895 }
896
897 func (x *Prefix) MarshalText() ([]byte, error) {
898         return []byte(x.String()), nil
899 }
900
901 func (x *Prefix) UnmarshalText(text []byte) error {
902         prefix, err := ParsePrefix(string(text))
903         if err != nil {
904                 return err
905         }
906         *x = prefix
907         return nil
908 }
909
910 // PrefixMatcher defines type 'prefix_matcher'.
911 type PrefixMatcher struct {
912         Le uint8 `binapi:"u8,name=le" json:"le,omitempty"`
913         Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"`
914 }
915
916 // AddressUnion defines union 'address_union'.
917 type AddressUnion struct {
918         // AddressUnion can be one of:
919         // - IP4 *IP4Address
920         // - IP6 *IP6Address
921         XXX_UnionData [16]byte
922 }
923
924 func AddressUnionIP4(a IP4Address) (u AddressUnion) {
925         u.SetIP4(a)
926         return
927 }
928 func (u *AddressUnion) SetIP4(a IP4Address) {
929         buf := codec.NewBuffer(u.XXX_UnionData[:])
930         buf.EncodeBytes(a[:], 4)
931 }
932 func (u *AddressUnion) GetIP4() (a IP4Address) {
933         buf := codec.NewBuffer(u.XXX_UnionData[:])
934         copy(a[:], buf.DecodeBytes(4))
935         return
936 }
937
938 func AddressUnionIP6(a IP6Address) (u AddressUnion) {
939         u.SetIP6(a)
940         return
941 }
942 func (u *AddressUnion) SetIP6(a IP6Address) {
943         buf := codec.NewBuffer(u.XXX_UnionData[:])
944         buf.EncodeBytes(a[:], 16)
945 }
946 func (u *AddressUnion) GetIP6() (a IP6Address) {
947         buf := codec.NewBuffer(u.XXX_UnionData[:])
948         copy(a[:], buf.DecodeBytes(16))
949         return
950 }
951
952 // Ipip6rdAddTunnel defines message 'ipip_6rd_add_tunnel'.
953 type Ipip6rdAddTunnel struct {
954         IP6TableID    uint32     `binapi:"u32,name=ip6_table_id" json:"ip6_table_id,omitempty"`
955         IP4TableID    uint32     `binapi:"u32,name=ip4_table_id" json:"ip4_table_id,omitempty"`
956         IP6Prefix     IP6Prefix  `binapi:"ip6_prefix,name=ip6_prefix" json:"ip6_prefix,omitempty"`
957         IP4Prefix     IP4Prefix  `binapi:"ip4_prefix,name=ip4_prefix" json:"ip4_prefix,omitempty"`
958         IP4Src        IP4Address `binapi:"ip4_address,name=ip4_src" json:"ip4_src,omitempty"`
959         SecurityCheck bool       `binapi:"bool,name=security_check" json:"security_check,omitempty"`
960         TcTos         uint8      `binapi:"u8,name=tc_tos" json:"tc_tos,omitempty"`
961 }
962
963 func (m *Ipip6rdAddTunnel) Reset()               { *m = Ipip6rdAddTunnel{} }
964 func (*Ipip6rdAddTunnel) GetMessageName() string { return "ipip_6rd_add_tunnel" }
965 func (*Ipip6rdAddTunnel) GetCrcString() string   { return "56e93cc0" }
966 func (*Ipip6rdAddTunnel) GetMessageType() api.MessageType {
967         return api.RequestMessage
968 }
969
970 func (m *Ipip6rdAddTunnel) Size() (size int) {
971         if m == nil {
972                 return 0
973         }
974         size += 4      // m.IP6TableID
975         size += 4      // m.IP4TableID
976         size += 1 * 16 // m.IP6Prefix.Address
977         size += 1      // m.IP6Prefix.Len
978         size += 1 * 4  // m.IP4Prefix.Address
979         size += 1      // m.IP4Prefix.Len
980         size += 1 * 4  // m.IP4Src
981         size += 1      // m.SecurityCheck
982         size += 1      // m.TcTos
983         return size
984 }
985 func (m *Ipip6rdAddTunnel) Marshal(b []byte) ([]byte, error) {
986         if b == nil {
987                 b = make([]byte, m.Size())
988         }
989         buf := codec.NewBuffer(b)
990         buf.EncodeUint32(m.IP6TableID)
991         buf.EncodeUint32(m.IP4TableID)
992         buf.EncodeBytes(m.IP6Prefix.Address[:], 16)
993         buf.EncodeUint8(m.IP6Prefix.Len)
994         buf.EncodeBytes(m.IP4Prefix.Address[:], 4)
995         buf.EncodeUint8(m.IP4Prefix.Len)
996         buf.EncodeBytes(m.IP4Src[:], 4)
997         buf.EncodeBool(m.SecurityCheck)
998         buf.EncodeUint8(m.TcTos)
999         return buf.Bytes(), nil
1000 }
1001 func (m *Ipip6rdAddTunnel) Unmarshal(b []byte) error {
1002         buf := codec.NewBuffer(b)
1003         m.IP6TableID = buf.DecodeUint32()
1004         m.IP4TableID = buf.DecodeUint32()
1005         copy(m.IP6Prefix.Address[:], buf.DecodeBytes(16))
1006         m.IP6Prefix.Len = buf.DecodeUint8()
1007         copy(m.IP4Prefix.Address[:], buf.DecodeBytes(4))
1008         m.IP4Prefix.Len = buf.DecodeUint8()
1009         copy(m.IP4Src[:], buf.DecodeBytes(4))
1010         m.SecurityCheck = buf.DecodeBool()
1011         m.TcTos = buf.DecodeUint8()
1012         return nil
1013 }
1014
1015 // Ipip6rdAddTunnelReply defines message 'ipip_6rd_add_tunnel_reply'.
1016 type Ipip6rdAddTunnelReply struct {
1017         Retval    int32          `binapi:"i32,name=retval" json:"retval,omitempty"`
1018         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1019 }
1020
1021 func (m *Ipip6rdAddTunnelReply) Reset()               { *m = Ipip6rdAddTunnelReply{} }
1022 func (*Ipip6rdAddTunnelReply) GetMessageName() string { return "ipip_6rd_add_tunnel_reply" }
1023 func (*Ipip6rdAddTunnelReply) GetCrcString() string   { return "5383d31f" }
1024 func (*Ipip6rdAddTunnelReply) GetMessageType() api.MessageType {
1025         return api.ReplyMessage
1026 }
1027
1028 func (m *Ipip6rdAddTunnelReply) Size() (size int) {
1029         if m == nil {
1030                 return 0
1031         }
1032         size += 4 // m.Retval
1033         size += 4 // m.SwIfIndex
1034         return size
1035 }
1036 func (m *Ipip6rdAddTunnelReply) Marshal(b []byte) ([]byte, error) {
1037         if b == nil {
1038                 b = make([]byte, m.Size())
1039         }
1040         buf := codec.NewBuffer(b)
1041         buf.EncodeInt32(m.Retval)
1042         buf.EncodeUint32(uint32(m.SwIfIndex))
1043         return buf.Bytes(), nil
1044 }
1045 func (m *Ipip6rdAddTunnelReply) Unmarshal(b []byte) error {
1046         buf := codec.NewBuffer(b)
1047         m.Retval = buf.DecodeInt32()
1048         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1049         return nil
1050 }
1051
1052 // Ipip6rdDelTunnel defines message 'ipip_6rd_del_tunnel'.
1053 type Ipip6rdDelTunnel struct {
1054         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1055 }
1056
1057 func (m *Ipip6rdDelTunnel) Reset()               { *m = Ipip6rdDelTunnel{} }
1058 func (*Ipip6rdDelTunnel) GetMessageName() string { return "ipip_6rd_del_tunnel" }
1059 func (*Ipip6rdDelTunnel) GetCrcString() string   { return "f9e6675e" }
1060 func (*Ipip6rdDelTunnel) GetMessageType() api.MessageType {
1061         return api.RequestMessage
1062 }
1063
1064 func (m *Ipip6rdDelTunnel) Size() (size int) {
1065         if m == nil {
1066                 return 0
1067         }
1068         size += 4 // m.SwIfIndex
1069         return size
1070 }
1071 func (m *Ipip6rdDelTunnel) 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         return buf.Bytes(), nil
1078 }
1079 func (m *Ipip6rdDelTunnel) Unmarshal(b []byte) error {
1080         buf := codec.NewBuffer(b)
1081         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1082         return nil
1083 }
1084
1085 // Ipip6rdDelTunnelReply defines message 'ipip_6rd_del_tunnel_reply'.
1086 type Ipip6rdDelTunnelReply struct {
1087         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
1088 }
1089
1090 func (m *Ipip6rdDelTunnelReply) Reset()               { *m = Ipip6rdDelTunnelReply{} }
1091 func (*Ipip6rdDelTunnelReply) GetMessageName() string { return "ipip_6rd_del_tunnel_reply" }
1092 func (*Ipip6rdDelTunnelReply) GetCrcString() string   { return "e8d4e804" }
1093 func (*Ipip6rdDelTunnelReply) GetMessageType() api.MessageType {
1094         return api.ReplyMessage
1095 }
1096
1097 func (m *Ipip6rdDelTunnelReply) Size() (size int) {
1098         if m == nil {
1099                 return 0
1100         }
1101         size += 4 // m.Retval
1102         return size
1103 }
1104 func (m *Ipip6rdDelTunnelReply) Marshal(b []byte) ([]byte, error) {
1105         if b == nil {
1106                 b = make([]byte, m.Size())
1107         }
1108         buf := codec.NewBuffer(b)
1109         buf.EncodeInt32(m.Retval)
1110         return buf.Bytes(), nil
1111 }
1112 func (m *Ipip6rdDelTunnelReply) Unmarshal(b []byte) error {
1113         buf := codec.NewBuffer(b)
1114         m.Retval = buf.DecodeInt32()
1115         return nil
1116 }
1117
1118 // IpipAddTunnel defines message 'ipip_add_tunnel'.
1119 type IpipAddTunnel struct {
1120         Tunnel IpipTunnel `binapi:"ipip_tunnel,name=tunnel" json:"tunnel,omitempty"`
1121 }
1122
1123 func (m *IpipAddTunnel) Reset()               { *m = IpipAddTunnel{} }
1124 func (*IpipAddTunnel) GetMessageName() string { return "ipip_add_tunnel" }
1125 func (*IpipAddTunnel) GetCrcString() string   { return "ef93caab" }
1126 func (*IpipAddTunnel) GetMessageType() api.MessageType {
1127         return api.RequestMessage
1128 }
1129
1130 func (m *IpipAddTunnel) Size() (size int) {
1131         if m == nil {
1132                 return 0
1133         }
1134         size += 4      // m.Tunnel.Instance
1135         size += 4      // m.Tunnel.Src.Af
1136         size += 1 * 16 // m.Tunnel.Src.Un
1137         size += 4      // m.Tunnel.Dst.Af
1138         size += 1 * 16 // m.Tunnel.Dst.Un
1139         size += 4      // m.Tunnel.SwIfIndex
1140         size += 4      // m.Tunnel.TableID
1141         size += 1      // m.Tunnel.Flags
1142         size += 1      // m.Tunnel.Dscp
1143         return size
1144 }
1145 func (m *IpipAddTunnel) Marshal(b []byte) ([]byte, error) {
1146         if b == nil {
1147                 b = make([]byte, m.Size())
1148         }
1149         buf := codec.NewBuffer(b)
1150         buf.EncodeUint32(m.Tunnel.Instance)
1151         buf.EncodeUint32(uint32(m.Tunnel.Src.Af))
1152         buf.EncodeBytes(m.Tunnel.Src.Un.XXX_UnionData[:], 16)
1153         buf.EncodeUint32(uint32(m.Tunnel.Dst.Af))
1154         buf.EncodeBytes(m.Tunnel.Dst.Un.XXX_UnionData[:], 16)
1155         buf.EncodeUint32(uint32(m.Tunnel.SwIfIndex))
1156         buf.EncodeUint32(m.Tunnel.TableID)
1157         buf.EncodeUint8(uint8(m.Tunnel.Flags))
1158         buf.EncodeUint8(uint8(m.Tunnel.Dscp))
1159         return buf.Bytes(), nil
1160 }
1161 func (m *IpipAddTunnel) Unmarshal(b []byte) error {
1162         buf := codec.NewBuffer(b)
1163         m.Tunnel.Instance = buf.DecodeUint32()
1164         m.Tunnel.Src.Af = AddressFamily(buf.DecodeUint32())
1165         copy(m.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16))
1166         m.Tunnel.Dst.Af = AddressFamily(buf.DecodeUint32())
1167         copy(m.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16))
1168         m.Tunnel.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1169         m.Tunnel.TableID = buf.DecodeUint32()
1170         m.Tunnel.Flags = IpipTunnelFlags(buf.DecodeUint8())
1171         m.Tunnel.Dscp = IPDscp(buf.DecodeUint8())
1172         return nil
1173 }
1174
1175 // IpipAddTunnelReply defines message 'ipip_add_tunnel_reply'.
1176 type IpipAddTunnelReply struct {
1177         Retval    int32          `binapi:"i32,name=retval" json:"retval,omitempty"`
1178         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1179 }
1180
1181 func (m *IpipAddTunnelReply) Reset()               { *m = IpipAddTunnelReply{} }
1182 func (*IpipAddTunnelReply) GetMessageName() string { return "ipip_add_tunnel_reply" }
1183 func (*IpipAddTunnelReply) GetCrcString() string   { return "5383d31f" }
1184 func (*IpipAddTunnelReply) GetMessageType() api.MessageType {
1185         return api.ReplyMessage
1186 }
1187
1188 func (m *IpipAddTunnelReply) Size() (size int) {
1189         if m == nil {
1190                 return 0
1191         }
1192         size += 4 // m.Retval
1193         size += 4 // m.SwIfIndex
1194         return size
1195 }
1196 func (m *IpipAddTunnelReply) Marshal(b []byte) ([]byte, error) {
1197         if b == nil {
1198                 b = make([]byte, m.Size())
1199         }
1200         buf := codec.NewBuffer(b)
1201         buf.EncodeInt32(m.Retval)
1202         buf.EncodeUint32(uint32(m.SwIfIndex))
1203         return buf.Bytes(), nil
1204 }
1205 func (m *IpipAddTunnelReply) Unmarshal(b []byte) error {
1206         buf := codec.NewBuffer(b)
1207         m.Retval = buf.DecodeInt32()
1208         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1209         return nil
1210 }
1211
1212 // IpipDelTunnel defines message 'ipip_del_tunnel'.
1213 type IpipDelTunnel struct {
1214         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1215 }
1216
1217 func (m *IpipDelTunnel) Reset()               { *m = IpipDelTunnel{} }
1218 func (*IpipDelTunnel) GetMessageName() string { return "ipip_del_tunnel" }
1219 func (*IpipDelTunnel) GetCrcString() string   { return "f9e6675e" }
1220 func (*IpipDelTunnel) GetMessageType() api.MessageType {
1221         return api.RequestMessage
1222 }
1223
1224 func (m *IpipDelTunnel) Size() (size int) {
1225         if m == nil {
1226                 return 0
1227         }
1228         size += 4 // m.SwIfIndex
1229         return size
1230 }
1231 func (m *IpipDelTunnel) Marshal(b []byte) ([]byte, error) {
1232         if b == nil {
1233                 b = make([]byte, m.Size())
1234         }
1235         buf := codec.NewBuffer(b)
1236         buf.EncodeUint32(uint32(m.SwIfIndex))
1237         return buf.Bytes(), nil
1238 }
1239 func (m *IpipDelTunnel) Unmarshal(b []byte) error {
1240         buf := codec.NewBuffer(b)
1241         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1242         return nil
1243 }
1244
1245 // IpipDelTunnelReply defines message 'ipip_del_tunnel_reply'.
1246 type IpipDelTunnelReply struct {
1247         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
1248 }
1249
1250 func (m *IpipDelTunnelReply) Reset()               { *m = IpipDelTunnelReply{} }
1251 func (*IpipDelTunnelReply) GetMessageName() string { return "ipip_del_tunnel_reply" }
1252 func (*IpipDelTunnelReply) GetCrcString() string   { return "e8d4e804" }
1253 func (*IpipDelTunnelReply) GetMessageType() api.MessageType {
1254         return api.ReplyMessage
1255 }
1256
1257 func (m *IpipDelTunnelReply) Size() (size int) {
1258         if m == nil {
1259                 return 0
1260         }
1261         size += 4 // m.Retval
1262         return size
1263 }
1264 func (m *IpipDelTunnelReply) Marshal(b []byte) ([]byte, error) {
1265         if b == nil {
1266                 b = make([]byte, m.Size())
1267         }
1268         buf := codec.NewBuffer(b)
1269         buf.EncodeInt32(m.Retval)
1270         return buf.Bytes(), nil
1271 }
1272 func (m *IpipDelTunnelReply) Unmarshal(b []byte) error {
1273         buf := codec.NewBuffer(b)
1274         m.Retval = buf.DecodeInt32()
1275         return nil
1276 }
1277
1278 // IpipTunnelDetails defines message 'ipip_tunnel_details'.
1279 type IpipTunnelDetails struct {
1280         Tunnel IpipTunnel `binapi:"ipip_tunnel,name=tunnel" json:"tunnel,omitempty"`
1281 }
1282
1283 func (m *IpipTunnelDetails) Reset()               { *m = IpipTunnelDetails{} }
1284 func (*IpipTunnelDetails) GetMessageName() string { return "ipip_tunnel_details" }
1285 func (*IpipTunnelDetails) GetCrcString() string   { return "7f7b5b85" }
1286 func (*IpipTunnelDetails) GetMessageType() api.MessageType {
1287         return api.ReplyMessage
1288 }
1289
1290 func (m *IpipTunnelDetails) Size() (size int) {
1291         if m == nil {
1292                 return 0
1293         }
1294         size += 4      // m.Tunnel.Instance
1295         size += 4      // m.Tunnel.Src.Af
1296         size += 1 * 16 // m.Tunnel.Src.Un
1297         size += 4      // m.Tunnel.Dst.Af
1298         size += 1 * 16 // m.Tunnel.Dst.Un
1299         size += 4      // m.Tunnel.SwIfIndex
1300         size += 4      // m.Tunnel.TableID
1301         size += 1      // m.Tunnel.Flags
1302         size += 1      // m.Tunnel.Dscp
1303         return size
1304 }
1305 func (m *IpipTunnelDetails) Marshal(b []byte) ([]byte, error) {
1306         if b == nil {
1307                 b = make([]byte, m.Size())
1308         }
1309         buf := codec.NewBuffer(b)
1310         buf.EncodeUint32(m.Tunnel.Instance)
1311         buf.EncodeUint32(uint32(m.Tunnel.Src.Af))
1312         buf.EncodeBytes(m.Tunnel.Src.Un.XXX_UnionData[:], 16)
1313         buf.EncodeUint32(uint32(m.Tunnel.Dst.Af))
1314         buf.EncodeBytes(m.Tunnel.Dst.Un.XXX_UnionData[:], 16)
1315         buf.EncodeUint32(uint32(m.Tunnel.SwIfIndex))
1316         buf.EncodeUint32(m.Tunnel.TableID)
1317         buf.EncodeUint8(uint8(m.Tunnel.Flags))
1318         buf.EncodeUint8(uint8(m.Tunnel.Dscp))
1319         return buf.Bytes(), nil
1320 }
1321 func (m *IpipTunnelDetails) Unmarshal(b []byte) error {
1322         buf := codec.NewBuffer(b)
1323         m.Tunnel.Instance = buf.DecodeUint32()
1324         m.Tunnel.Src.Af = AddressFamily(buf.DecodeUint32())
1325         copy(m.Tunnel.Src.Un.XXX_UnionData[:], buf.DecodeBytes(16))
1326         m.Tunnel.Dst.Af = AddressFamily(buf.DecodeUint32())
1327         copy(m.Tunnel.Dst.Un.XXX_UnionData[:], buf.DecodeBytes(16))
1328         m.Tunnel.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1329         m.Tunnel.TableID = buf.DecodeUint32()
1330         m.Tunnel.Flags = IpipTunnelFlags(buf.DecodeUint8())
1331         m.Tunnel.Dscp = IPDscp(buf.DecodeUint8())
1332         return nil
1333 }
1334
1335 // IpipTunnelDump defines message 'ipip_tunnel_dump'.
1336 type IpipTunnelDump struct {
1337         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1338 }
1339
1340 func (m *IpipTunnelDump) Reset()               { *m = IpipTunnelDump{} }
1341 func (*IpipTunnelDump) GetMessageName() string { return "ipip_tunnel_dump" }
1342 func (*IpipTunnelDump) GetCrcString() string   { return "f9e6675e" }
1343 func (*IpipTunnelDump) GetMessageType() api.MessageType {
1344         return api.RequestMessage
1345 }
1346
1347 func (m *IpipTunnelDump) Size() (size int) {
1348         if m == nil {
1349                 return 0
1350         }
1351         size += 4 // m.SwIfIndex
1352         return size
1353 }
1354 func (m *IpipTunnelDump) Marshal(b []byte) ([]byte, error) {
1355         if b == nil {
1356                 b = make([]byte, m.Size())
1357         }
1358         buf := codec.NewBuffer(b)
1359         buf.EncodeUint32(uint32(m.SwIfIndex))
1360         return buf.Bytes(), nil
1361 }
1362 func (m *IpipTunnelDump) Unmarshal(b []byte) error {
1363         buf := codec.NewBuffer(b)
1364         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1365         return nil
1366 }
1367
1368 func init() { file_ipip_binapi_init() }
1369 func file_ipip_binapi_init() {
1370         api.RegisterMessage((*Ipip6rdAddTunnel)(nil), "ipip_6rd_add_tunnel_56e93cc0")
1371         api.RegisterMessage((*Ipip6rdAddTunnelReply)(nil), "ipip_6rd_add_tunnel_reply_5383d31f")
1372         api.RegisterMessage((*Ipip6rdDelTunnel)(nil), "ipip_6rd_del_tunnel_f9e6675e")
1373         api.RegisterMessage((*Ipip6rdDelTunnelReply)(nil), "ipip_6rd_del_tunnel_reply_e8d4e804")
1374         api.RegisterMessage((*IpipAddTunnel)(nil), "ipip_add_tunnel_ef93caab")
1375         api.RegisterMessage((*IpipAddTunnelReply)(nil), "ipip_add_tunnel_reply_5383d31f")
1376         api.RegisterMessage((*IpipDelTunnel)(nil), "ipip_del_tunnel_f9e6675e")
1377         api.RegisterMessage((*IpipDelTunnelReply)(nil), "ipip_del_tunnel_reply_e8d4e804")
1378         api.RegisterMessage((*IpipTunnelDetails)(nil), "ipip_tunnel_details_7f7b5b85")
1379         api.RegisterMessage((*IpipTunnelDump)(nil), "ipip_tunnel_dump_f9e6675e")
1380 }
1381
1382 // Messages returns list of all messages in this module.
1383 func AllMessages() []api.Message {
1384         return []api.Message{
1385                 (*Ipip6rdAddTunnel)(nil),
1386                 (*Ipip6rdAddTunnelReply)(nil),
1387                 (*Ipip6rdDelTunnel)(nil),
1388                 (*Ipip6rdDelTunnelReply)(nil),
1389                 (*IpipAddTunnel)(nil),
1390                 (*IpipAddTunnelReply)(nil),
1391                 (*IpipDelTunnel)(nil),
1392                 (*IpipDelTunnelReply)(nil),
1393                 (*IpipTunnelDetails)(nil),
1394                 (*IpipTunnelDump)(nil),
1395         }
1396 }