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