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