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