Update generated binapi to v22.02 & makefile changes
[govpp.git] / internal / testbinapi / binapi2001 / igmp / igmp.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/plugins/igmp.api.json
6
7 // Package igmp contains generated bindings for API file igmp.api.
8 //
9 // Contents:
10 //   6 aliases
11 //  12 enums
12 //   8 structs
13 //   1 union
14 //  19 messages
15 //
16 package igmp
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    = "igmp"
36         APIVersion = "1.0.0"
37         VersionCrc = 0xfd1fef7b
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 // FilterMode defines enum 'filter_mode'.
68 type FilterMode uint32
69
70 const (
71         EXCLUDE FilterMode = 0
72         INCLUDE FilterMode = 1
73 )
74
75 var (
76         FilterMode_name = map[uint32]string{
77                 0: "EXCLUDE",
78                 1: "INCLUDE",
79         }
80         FilterMode_value = map[string]uint32{
81                 "EXCLUDE": 0,
82                 "INCLUDE": 1,
83         }
84 )
85
86 func (x FilterMode) String() string {
87         s, ok := FilterMode_name[uint32(x)]
88         if ok {
89                 return s
90         }
91         return "FilterMode(" + strconv.Itoa(int(x)) + ")"
92 }
93
94 // GroupPrefixType defines enum 'group_prefix_type'.
95 type GroupPrefixType uint32
96
97 const (
98         ASM GroupPrefixType = 0
99         SSM GroupPrefixType = 1
100 )
101
102 var (
103         GroupPrefixType_name = map[uint32]string{
104                 0: "ASM",
105                 1: "SSM",
106         }
107         GroupPrefixType_value = map[string]uint32{
108                 "ASM": 0,
109                 "SSM": 1,
110         }
111 )
112
113 func (x GroupPrefixType) String() string {
114         s, ok := GroupPrefixType_name[uint32(x)]
115         if ok {
116                 return s
117         }
118         return "GroupPrefixType(" + strconv.Itoa(int(x)) + ")"
119 }
120
121 // IfStatusFlags defines enum 'if_status_flags'.
122 type IfStatusFlags uint32
123
124 const (
125         IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1
126         IF_STATUS_API_FLAG_LINK_UP  IfStatusFlags = 2
127 )
128
129 var (
130         IfStatusFlags_name = map[uint32]string{
131                 1: "IF_STATUS_API_FLAG_ADMIN_UP",
132                 2: "IF_STATUS_API_FLAG_LINK_UP",
133         }
134         IfStatusFlags_value = map[string]uint32{
135                 "IF_STATUS_API_FLAG_ADMIN_UP": 1,
136                 "IF_STATUS_API_FLAG_LINK_UP":  2,
137         }
138 )
139
140 func (x IfStatusFlags) String() string {
141         s, ok := IfStatusFlags_name[uint32(x)]
142         if ok {
143                 return s
144         }
145         str := func(n uint32) string {
146                 s, ok := IfStatusFlags_name[uint32(n)]
147                 if ok {
148                         return s
149                 }
150                 return "IfStatusFlags(" + strconv.Itoa(int(n)) + ")"
151         }
152         for i := uint32(0); i <= 32; i++ {
153                 val := uint32(x)
154                 if val&(1<<i) != 0 {
155                         if s != "" {
156                                 s += "|"
157                         }
158                         s += str(1 << i)
159                 }
160         }
161         if s == "" {
162                 return str(uint32(x))
163         }
164         return s
165 }
166
167 // IfType defines enum 'if_type'.
168 type IfType uint32
169
170 const (
171         IF_API_TYPE_HARDWARE IfType = 1
172         IF_API_TYPE_SUB      IfType = 2
173         IF_API_TYPE_P2P      IfType = 3
174         IF_API_TYPE_PIPE     IfType = 4
175 )
176
177 var (
178         IfType_name = map[uint32]string{
179                 1: "IF_API_TYPE_HARDWARE",
180                 2: "IF_API_TYPE_SUB",
181                 3: "IF_API_TYPE_P2P",
182                 4: "IF_API_TYPE_PIPE",
183         }
184         IfType_value = map[string]uint32{
185                 "IF_API_TYPE_HARDWARE": 1,
186                 "IF_API_TYPE_SUB":      2,
187                 "IF_API_TYPE_P2P":      3,
188                 "IF_API_TYPE_PIPE":     4,
189         }
190 )
191
192 func (x IfType) String() string {
193         s, ok := IfType_name[uint32(x)]
194         if ok {
195                 return s
196         }
197         return "IfType(" + strconv.Itoa(int(x)) + ")"
198 }
199
200 // IPDscp defines enum 'ip_dscp'.
201 type IPDscp uint8
202
203 const (
204         IP_API_DSCP_CS0  IPDscp = 0
205         IP_API_DSCP_CS1  IPDscp = 8
206         IP_API_DSCP_AF11 IPDscp = 10
207         IP_API_DSCP_AF12 IPDscp = 12
208         IP_API_DSCP_AF13 IPDscp = 14
209         IP_API_DSCP_CS2  IPDscp = 16
210         IP_API_DSCP_AF21 IPDscp = 18
211         IP_API_DSCP_AF22 IPDscp = 20
212         IP_API_DSCP_AF23 IPDscp = 22
213         IP_API_DSCP_CS3  IPDscp = 24
214         IP_API_DSCP_AF31 IPDscp = 26
215         IP_API_DSCP_AF32 IPDscp = 28
216         IP_API_DSCP_AF33 IPDscp = 30
217         IP_API_DSCP_CS4  IPDscp = 32
218         IP_API_DSCP_AF41 IPDscp = 34
219         IP_API_DSCP_AF42 IPDscp = 36
220         IP_API_DSCP_AF43 IPDscp = 38
221         IP_API_DSCP_CS5  IPDscp = 40
222         IP_API_DSCP_EF   IPDscp = 46
223         IP_API_DSCP_CS6  IPDscp = 48
224         IP_API_DSCP_CS7  IPDscp = 50
225 )
226
227 var (
228         IPDscp_name = map[uint8]string{
229                 0:  "IP_API_DSCP_CS0",
230                 8:  "IP_API_DSCP_CS1",
231                 10: "IP_API_DSCP_AF11",
232                 12: "IP_API_DSCP_AF12",
233                 14: "IP_API_DSCP_AF13",
234                 16: "IP_API_DSCP_CS2",
235                 18: "IP_API_DSCP_AF21",
236                 20: "IP_API_DSCP_AF22",
237                 22: "IP_API_DSCP_AF23",
238                 24: "IP_API_DSCP_CS3",
239                 26: "IP_API_DSCP_AF31",
240                 28: "IP_API_DSCP_AF32",
241                 30: "IP_API_DSCP_AF33",
242                 32: "IP_API_DSCP_CS4",
243                 34: "IP_API_DSCP_AF41",
244                 36: "IP_API_DSCP_AF42",
245                 38: "IP_API_DSCP_AF43",
246                 40: "IP_API_DSCP_CS5",
247                 46: "IP_API_DSCP_EF",
248                 48: "IP_API_DSCP_CS6",
249                 50: "IP_API_DSCP_CS7",
250         }
251         IPDscp_value = map[string]uint8{
252                 "IP_API_DSCP_CS0":  0,
253                 "IP_API_DSCP_CS1":  8,
254                 "IP_API_DSCP_AF11": 10,
255                 "IP_API_DSCP_AF12": 12,
256                 "IP_API_DSCP_AF13": 14,
257                 "IP_API_DSCP_CS2":  16,
258                 "IP_API_DSCP_AF21": 18,
259                 "IP_API_DSCP_AF22": 20,
260                 "IP_API_DSCP_AF23": 22,
261                 "IP_API_DSCP_CS3":  24,
262                 "IP_API_DSCP_AF31": 26,
263                 "IP_API_DSCP_AF32": 28,
264                 "IP_API_DSCP_AF33": 30,
265                 "IP_API_DSCP_CS4":  32,
266                 "IP_API_DSCP_AF41": 34,
267                 "IP_API_DSCP_AF42": 36,
268                 "IP_API_DSCP_AF43": 38,
269                 "IP_API_DSCP_CS5":  40,
270                 "IP_API_DSCP_EF":   46,
271                 "IP_API_DSCP_CS6":  48,
272                 "IP_API_DSCP_CS7":  50,
273         }
274 )
275
276 func (x IPDscp) String() string {
277         s, ok := IPDscp_name[uint8(x)]
278         if ok {
279                 return s
280         }
281         return "IPDscp(" + strconv.Itoa(int(x)) + ")"
282 }
283
284 // IPEcn defines enum 'ip_ecn'.
285 type IPEcn uint8
286
287 const (
288         IP_API_ECN_NONE IPEcn = 0
289         IP_API_ECN_ECT0 IPEcn = 1
290         IP_API_ECN_ECT1 IPEcn = 2
291         IP_API_ECN_CE   IPEcn = 3
292 )
293
294 var (
295         IPEcn_name = map[uint8]string{
296                 0: "IP_API_ECN_NONE",
297                 1: "IP_API_ECN_ECT0",
298                 2: "IP_API_ECN_ECT1",
299                 3: "IP_API_ECN_CE",
300         }
301         IPEcn_value = map[string]uint8{
302                 "IP_API_ECN_NONE": 0,
303                 "IP_API_ECN_ECT0": 1,
304                 "IP_API_ECN_ECT1": 2,
305                 "IP_API_ECN_CE":   3,
306         }
307 )
308
309 func (x IPEcn) String() string {
310         s, ok := IPEcn_name[uint8(x)]
311         if ok {
312                 return s
313         }
314         return "IPEcn(" + strconv.Itoa(int(x)) + ")"
315 }
316
317 // IPProto defines enum 'ip_proto'.
318 type IPProto uint32
319
320 const (
321         IP_API_PROTO_HOPOPT   IPProto = 0
322         IP_API_PROTO_ICMP     IPProto = 1
323         IP_API_PROTO_IGMP     IPProto = 2
324         IP_API_PROTO_TCP      IPProto = 6
325         IP_API_PROTO_UDP      IPProto = 17
326         IP_API_PROTO_GRE      IPProto = 47
327         IP_API_PROTO_AH       IPProto = 50
328         IP_API_PROTO_ESP      IPProto = 51
329         IP_API_PROTO_EIGRP    IPProto = 88
330         IP_API_PROTO_OSPF     IPProto = 89
331         IP_API_PROTO_SCTP     IPProto = 132
332         IP_API_PROTO_RESERVED IPProto = 255
333 )
334
335 var (
336         IPProto_name = map[uint32]string{
337                 0:   "IP_API_PROTO_HOPOPT",
338                 1:   "IP_API_PROTO_ICMP",
339                 2:   "IP_API_PROTO_IGMP",
340                 6:   "IP_API_PROTO_TCP",
341                 17:  "IP_API_PROTO_UDP",
342                 47:  "IP_API_PROTO_GRE",
343                 50:  "IP_API_PROTO_AH",
344                 51:  "IP_API_PROTO_ESP",
345                 88:  "IP_API_PROTO_EIGRP",
346                 89:  "IP_API_PROTO_OSPF",
347                 132: "IP_API_PROTO_SCTP",
348                 255: "IP_API_PROTO_RESERVED",
349         }
350         IPProto_value = map[string]uint32{
351                 "IP_API_PROTO_HOPOPT":   0,
352                 "IP_API_PROTO_ICMP":     1,
353                 "IP_API_PROTO_IGMP":     2,
354                 "IP_API_PROTO_TCP":      6,
355                 "IP_API_PROTO_UDP":      17,
356                 "IP_API_PROTO_GRE":      47,
357                 "IP_API_PROTO_AH":       50,
358                 "IP_API_PROTO_ESP":      51,
359                 "IP_API_PROTO_EIGRP":    88,
360                 "IP_API_PROTO_OSPF":     89,
361                 "IP_API_PROTO_SCTP":     132,
362                 "IP_API_PROTO_RESERVED": 255,
363         }
364 )
365
366 func (x IPProto) String() string {
367         s, ok := IPProto_name[uint32(x)]
368         if ok {
369                 return s
370         }
371         return "IPProto(" + strconv.Itoa(int(x)) + ")"
372 }
373
374 // LinkDuplex defines enum 'link_duplex'.
375 type LinkDuplex uint32
376
377 const (
378         LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0
379         LINK_DUPLEX_API_HALF    LinkDuplex = 1
380         LINK_DUPLEX_API_FULL    LinkDuplex = 2
381 )
382
383 var (
384         LinkDuplex_name = map[uint32]string{
385                 0: "LINK_DUPLEX_API_UNKNOWN",
386                 1: "LINK_DUPLEX_API_HALF",
387                 2: "LINK_DUPLEX_API_FULL",
388         }
389         LinkDuplex_value = map[string]uint32{
390                 "LINK_DUPLEX_API_UNKNOWN": 0,
391                 "LINK_DUPLEX_API_HALF":    1,
392                 "LINK_DUPLEX_API_FULL":    2,
393         }
394 )
395
396 func (x LinkDuplex) String() string {
397         s, ok := LinkDuplex_name[uint32(x)]
398         if ok {
399                 return s
400         }
401         return "LinkDuplex(" + strconv.Itoa(int(x)) + ")"
402 }
403
404 // MtuProto defines enum 'mtu_proto'.
405 type MtuProto uint32
406
407 const (
408         MTU_PROTO_API_L3   MtuProto = 1
409         MTU_PROTO_API_IP4  MtuProto = 2
410         MTU_PROTO_API_IP6  MtuProto = 3
411         MTU_PROTO_API_MPLS MtuProto = 4
412         MTU_PROTO_API_N    MtuProto = 5
413 )
414
415 var (
416         MtuProto_name = map[uint32]string{
417                 1: "MTU_PROTO_API_L3",
418                 2: "MTU_PROTO_API_IP4",
419                 3: "MTU_PROTO_API_IP6",
420                 4: "MTU_PROTO_API_MPLS",
421                 5: "MTU_PROTO_API_N",
422         }
423         MtuProto_value = map[string]uint32{
424                 "MTU_PROTO_API_L3":   1,
425                 "MTU_PROTO_API_IP4":  2,
426                 "MTU_PROTO_API_IP6":  3,
427                 "MTU_PROTO_API_MPLS": 4,
428                 "MTU_PROTO_API_N":    5,
429         }
430 )
431
432 func (x MtuProto) String() string {
433         s, ok := MtuProto_name[uint32(x)]
434         if ok {
435                 return s
436         }
437         return "MtuProto(" + strconv.Itoa(int(x)) + ")"
438 }
439
440 // RxMode defines enum 'rx_mode'.
441 type RxMode uint32
442
443 const (
444         RX_MODE_API_UNKNOWN   RxMode = 0
445         RX_MODE_API_POLLING   RxMode = 1
446         RX_MODE_API_INTERRUPT RxMode = 2
447         RX_MODE_API_ADAPTIVE  RxMode = 3
448         RX_MODE_API_DEFAULT   RxMode = 4
449 )
450
451 var (
452         RxMode_name = map[uint32]string{
453                 0: "RX_MODE_API_UNKNOWN",
454                 1: "RX_MODE_API_POLLING",
455                 2: "RX_MODE_API_INTERRUPT",
456                 3: "RX_MODE_API_ADAPTIVE",
457                 4: "RX_MODE_API_DEFAULT",
458         }
459         RxMode_value = map[string]uint32{
460                 "RX_MODE_API_UNKNOWN":   0,
461                 "RX_MODE_API_POLLING":   1,
462                 "RX_MODE_API_INTERRUPT": 2,
463                 "RX_MODE_API_ADAPTIVE":  3,
464                 "RX_MODE_API_DEFAULT":   4,
465         }
466 )
467
468 func (x RxMode) String() string {
469         s, ok := RxMode_name[uint32(x)]
470         if ok {
471                 return s
472         }
473         return "RxMode(" + strconv.Itoa(int(x)) + ")"
474 }
475
476 // SubIfFlags defines enum 'sub_if_flags'.
477 type SubIfFlags uint32
478
479 const (
480         SUB_IF_API_FLAG_NO_TAGS           SubIfFlags = 1
481         SUB_IF_API_FLAG_ONE_TAG           SubIfFlags = 2
482         SUB_IF_API_FLAG_TWO_TAGS          SubIfFlags = 4
483         SUB_IF_API_FLAG_DOT1AD            SubIfFlags = 8
484         SUB_IF_API_FLAG_EXACT_MATCH       SubIfFlags = 16
485         SUB_IF_API_FLAG_DEFAULT           SubIfFlags = 32
486         SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY SubIfFlags = 64
487         SUB_IF_API_FLAG_INNER_VLAN_ID_ANY SubIfFlags = 128
488         SUB_IF_API_FLAG_MASK_VNET         SubIfFlags = 254
489         SUB_IF_API_FLAG_DOT1AH            SubIfFlags = 256
490 )
491
492 var (
493         SubIfFlags_name = map[uint32]string{
494                 1:   "SUB_IF_API_FLAG_NO_TAGS",
495                 2:   "SUB_IF_API_FLAG_ONE_TAG",
496                 4:   "SUB_IF_API_FLAG_TWO_TAGS",
497                 8:   "SUB_IF_API_FLAG_DOT1AD",
498                 16:  "SUB_IF_API_FLAG_EXACT_MATCH",
499                 32:  "SUB_IF_API_FLAG_DEFAULT",
500                 64:  "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY",
501                 128: "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY",
502                 254: "SUB_IF_API_FLAG_MASK_VNET",
503                 256: "SUB_IF_API_FLAG_DOT1AH",
504         }
505         SubIfFlags_value = map[string]uint32{
506                 "SUB_IF_API_FLAG_NO_TAGS":           1,
507                 "SUB_IF_API_FLAG_ONE_TAG":           2,
508                 "SUB_IF_API_FLAG_TWO_TAGS":          4,
509                 "SUB_IF_API_FLAG_DOT1AD":            8,
510                 "SUB_IF_API_FLAG_EXACT_MATCH":       16,
511                 "SUB_IF_API_FLAG_DEFAULT":           32,
512                 "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY": 64,
513                 "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY": 128,
514                 "SUB_IF_API_FLAG_MASK_VNET":         254,
515                 "SUB_IF_API_FLAG_DOT1AH":            256,
516         }
517 )
518
519 func (x SubIfFlags) String() string {
520         s, ok := SubIfFlags_name[uint32(x)]
521         if ok {
522                 return s
523         }
524         str := func(n uint32) string {
525                 s, ok := SubIfFlags_name[uint32(n)]
526                 if ok {
527                         return s
528                 }
529                 return "SubIfFlags(" + strconv.Itoa(int(n)) + ")"
530         }
531         for i := uint32(0); i <= 32; i++ {
532                 val := uint32(x)
533                 if val&(1<<i) != 0 {
534                         if s != "" {
535                                 s += "|"
536                         }
537                         s += str(1 << i)
538                 }
539         }
540         if s == "" {
541                 return str(uint32(x))
542         }
543         return s
544 }
545
546 // AddressWithPrefix defines alias 'address_with_prefix'.
547 type AddressWithPrefix Prefix
548
549 func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) {
550         prefix, err := ParsePrefix(s)
551         if err != nil {
552                 return AddressWithPrefix{}, err
553         }
554         return AddressWithPrefix(prefix), nil
555 }
556
557 func (x AddressWithPrefix) String() string {
558         return Prefix(x).String()
559 }
560
561 func (x *AddressWithPrefix) MarshalText() ([]byte, error) {
562         return []byte(x.String()), nil
563 }
564
565 func (x *AddressWithPrefix) UnmarshalText(text []byte) error {
566         prefix, err := ParseAddressWithPrefix(string(text))
567         if err != nil {
568                 return err
569         }
570         *x = prefix
571         return nil
572 }
573
574 // InterfaceIndex defines alias 'interface_index'.
575 type InterfaceIndex uint32
576
577 // IP4Address defines alias 'ip4_address'.
578 type IP4Address [4]uint8
579
580 func ParseIP4Address(s string) (IP4Address, error) {
581         ip := net.ParseIP(s).To4()
582         if ip == nil {
583                 return IP4Address{}, fmt.Errorf("invalid IP address: %s", s)
584         }
585         var ipaddr IP4Address
586         copy(ipaddr[:], ip.To4())
587         return ipaddr, nil
588 }
589
590 func (x IP4Address) ToIP() net.IP {
591         return net.IP(x[:]).To4()
592 }
593
594 func (x IP4Address) String() string {
595         return x.ToIP().String()
596 }
597
598 func (x *IP4Address) MarshalText() ([]byte, error) {
599         return []byte(x.String()), nil
600 }
601
602 func (x *IP4Address) UnmarshalText(text []byte) error {
603         ipaddr, err := ParseIP4Address(string(text))
604         if err != nil {
605                 return err
606         }
607         *x = ipaddr
608         return nil
609 }
610
611 // IP4AddressWithPrefix defines alias 'ip4_address_with_prefix'.
612 type IP4AddressWithPrefix IP4Prefix
613
614 // IP6Address defines alias 'ip6_address'.
615 type IP6Address [16]uint8
616
617 func ParseIP6Address(s string) (IP6Address, error) {
618         ip := net.ParseIP(s).To16()
619         if ip == nil {
620                 return IP6Address{}, fmt.Errorf("invalid IP address: %s", s)
621         }
622         var ipaddr IP6Address
623         copy(ipaddr[:], ip.To16())
624         return ipaddr, nil
625 }
626
627 func (x IP6Address) ToIP() net.IP {
628         return net.IP(x[:]).To16()
629 }
630
631 func (x IP6Address) String() string {
632         return x.ToIP().String()
633 }
634
635 func (x *IP6Address) MarshalText() ([]byte, error) {
636         return []byte(x.String()), nil
637 }
638
639 func (x *IP6Address) UnmarshalText(text []byte) error {
640         ipaddr, err := ParseIP6Address(string(text))
641         if err != nil {
642                 return err
643         }
644         *x = ipaddr
645         return nil
646 }
647
648 // IP6AddressWithPrefix defines alias 'ip6_address_with_prefix'.
649 type IP6AddressWithPrefix IP6Prefix
650
651 // Address defines type 'address'.
652 type Address struct {
653         Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
654         Un AddressUnion  `binapi:"address_union,name=un" json:"un,omitempty"`
655 }
656
657 func ParseAddress(s string) (Address, error) {
658         ip := net.ParseIP(s)
659         if ip == nil {
660                 return Address{}, fmt.Errorf("invalid address: %s", s)
661         }
662         return AddressFromIP(ip), nil
663 }
664
665 func AddressFromIP(ip net.IP) Address {
666         var addr Address
667         if ip.To4() == nil {
668                 addr.Af = ADDRESS_IP6
669                 var ip6 IP6Address
670                 copy(ip6[:], ip.To16())
671                 addr.Un.SetIP6(ip6)
672         } else {
673                 addr.Af = ADDRESS_IP4
674                 var ip4 IP4Address
675                 copy(ip4[:], ip.To4())
676                 addr.Un.SetIP4(ip4)
677         }
678         return addr
679 }
680
681 func (x Address) ToIP() net.IP {
682         if x.Af == ADDRESS_IP6 {
683                 ip6 := x.Un.GetIP6()
684                 return net.IP(ip6[:]).To16()
685         } else {
686                 ip4 := x.Un.GetIP4()
687                 return net.IP(ip4[:]).To4()
688         }
689 }
690
691 func (x Address) String() string {
692         return x.ToIP().String()
693 }
694
695 func (x *Address) MarshalText() ([]byte, error) {
696         return []byte(x.String()), nil
697 }
698
699 func (x *Address) UnmarshalText(text []byte) error {
700         addr, err := ParseAddress(string(text))
701         if err != nil {
702                 return err
703         }
704         *x = addr
705         return nil
706 }
707
708 // GroupPrefix defines type 'group_prefix'.
709 type GroupPrefix struct {
710         Type   GroupPrefixType `binapi:"group_prefix_type,name=type" json:"type,omitempty"`
711         Prefix Prefix          `binapi:"prefix,name=prefix" json:"prefix,omitempty"`
712 }
713
714 // IgmpGroup defines type 'igmp_group'.
715 type IgmpGroup struct {
716         Filter    FilterMode     `binapi:"filter_mode,name=filter" json:"filter,omitempty"`
717         NSrcs     uint8          `binapi:"u8,name=n_srcs" json:"-"`
718         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
719         Gaddr     IP4Address     `binapi:"ip4_address,name=gaddr" json:"gaddr,omitempty"`
720         Saddrs    []IP4Address   `binapi:"ip4_address[n_srcs],name=saddrs" json:"saddrs,omitempty"`
721 }
722
723 // IP4Prefix defines type 'ip4_prefix'.
724 type IP4Prefix struct {
725         Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"`
726         Len     uint8      `binapi:"u8,name=len" json:"len,omitempty"`
727 }
728
729 func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) {
730         hasPrefix := strings.Contains(s, "/")
731         if hasPrefix {
732                 ip, network, err := net.ParseCIDR(s)
733                 if err != nil {
734                         return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
735                 }
736                 maskSize, _ := network.Mask.Size()
737                 prefix.Len = byte(maskSize)
738                 prefix.Address, err = ParseIP4Address(ip.String())
739                 if err != nil {
740                         return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
741                 }
742         } else {
743                 ip := net.ParseIP(s)
744                 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
745                 if ip.To4() == nil {
746                         defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
747                 }
748                 prefix.Len = byte(defaultMaskSize)
749                 prefix.Address, err = ParseIP4Address(ip.String())
750                 if err != nil {
751                         return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
752                 }
753         }
754         return prefix, nil
755 }
756
757 func (x IP4Prefix) ToIPNet() *net.IPNet {
758         mask := net.CIDRMask(int(x.Len), 32)
759         ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
760         return ipnet
761 }
762
763 func (x IP4Prefix) String() string {
764         ip := x.Address.String()
765         return ip + "/" + strconv.Itoa(int(x.Len))
766 }
767
768 func (x *IP4Prefix) MarshalText() ([]byte, error) {
769         return []byte(x.String()), nil
770 }
771
772 func (x *IP4Prefix) UnmarshalText(text []byte) error {
773         prefix, err := ParseIP4Prefix(string(text))
774         if err != nil {
775                 return err
776         }
777         *x = prefix
778         return nil
779 }
780
781 // IP6Prefix defines type 'ip6_prefix'.
782 type IP6Prefix struct {
783         Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"`
784         Len     uint8      `binapi:"u8,name=len" json:"len,omitempty"`
785 }
786
787 func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) {
788         hasPrefix := strings.Contains(s, "/")
789         if hasPrefix {
790                 ip, network, err := net.ParseCIDR(s)
791                 if err != nil {
792                         return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
793                 }
794                 maskSize, _ := network.Mask.Size()
795                 prefix.Len = byte(maskSize)
796                 prefix.Address, err = ParseIP6Address(ip.String())
797                 if err != nil {
798                         return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
799                 }
800         } else {
801                 ip := net.ParseIP(s)
802                 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
803                 if ip.To4() == nil {
804                         defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
805                 }
806                 prefix.Len = byte(defaultMaskSize)
807                 prefix.Address, err = ParseIP6Address(ip.String())
808                 if err != nil {
809                         return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
810                 }
811         }
812         return prefix, nil
813 }
814
815 func (x IP6Prefix) ToIPNet() *net.IPNet {
816         mask := net.CIDRMask(int(x.Len), 128)
817         ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
818         return ipnet
819 }
820
821 func (x IP6Prefix) String() string {
822         ip := x.Address.String()
823         return ip + "/" + strconv.Itoa(int(x.Len))
824 }
825
826 func (x *IP6Prefix) MarshalText() ([]byte, error) {
827         return []byte(x.String()), nil
828 }
829
830 func (x *IP6Prefix) UnmarshalText(text []byte) error {
831         prefix, err := ParseIP6Prefix(string(text))
832         if err != nil {
833                 return err
834         }
835         *x = prefix
836         return nil
837 }
838
839 // Mprefix defines type 'mprefix'.
840 type Mprefix struct {
841         Af               AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
842         GrpAddressLength uint16        `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"`
843         GrpAddress       AddressUnion  `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"`
844         SrcAddress       AddressUnion  `binapi:"address_union,name=src_address" json:"src_address,omitempty"`
845 }
846
847 // Prefix defines type 'prefix'.
848 type Prefix struct {
849         Address Address `binapi:"address,name=address" json:"address,omitempty"`
850         Len     uint8   `binapi:"u8,name=len" json:"len,omitempty"`
851 }
852
853 func ParsePrefix(ip string) (prefix Prefix, err error) {
854         hasPrefix := strings.Contains(ip, "/")
855         if hasPrefix {
856                 netIP, network, err := net.ParseCIDR(ip)
857                 if err != nil {
858                         return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
859                 }
860                 maskSize, _ := network.Mask.Size()
861                 prefix.Len = byte(maskSize)
862                 prefix.Address, err = ParseAddress(netIP.String())
863                 if err != nil {
864                         return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
865                 }
866         } else {
867                 netIP := net.ParseIP(ip)
868                 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
869                 if netIP.To4() == nil {
870                         defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
871                 }
872                 prefix.Len = byte(defaultMaskSize)
873                 prefix.Address, err = ParseAddress(netIP.String())
874                 if err != nil {
875                         return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
876                 }
877         }
878         return prefix, nil
879 }
880
881 func (x Prefix) ToIPNet() *net.IPNet {
882         var mask net.IPMask
883         if x.Address.Af == ADDRESS_IP4 {
884                 mask = net.CIDRMask(int(x.Len), 32)
885         } else {
886                 mask = net.CIDRMask(int(x.Len), 128)
887         }
888         ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
889         return ipnet
890 }
891
892 func (x Prefix) String() string {
893         ip := x.Address.String()
894         return ip + "/" + strconv.Itoa(int(x.Len))
895 }
896
897 func (x *Prefix) MarshalText() ([]byte, error) {
898         return []byte(x.String()), nil
899 }
900
901 func (x *Prefix) UnmarshalText(text []byte) error {
902         prefix, err := ParsePrefix(string(text))
903         if err != nil {
904                 return err
905         }
906         *x = prefix
907         return nil
908 }
909
910 // PrefixMatcher defines type 'prefix_matcher'.
911 type PrefixMatcher struct {
912         Le uint8 `binapi:"u8,name=le" json:"le,omitempty"`
913         Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"`
914 }
915
916 // AddressUnion defines union 'address_union'.
917 type AddressUnion struct {
918         // AddressUnion can be one of:
919         // - IP4 *IP4Address
920         // - IP6 *IP6Address
921         XXX_UnionData [16]byte
922 }
923
924 func AddressUnionIP4(a IP4Address) (u AddressUnion) {
925         u.SetIP4(a)
926         return
927 }
928 func (u *AddressUnion) SetIP4(a IP4Address) {
929         buf := codec.NewBuffer(u.XXX_UnionData[:])
930         buf.EncodeBytes(a[:], 4)
931 }
932 func (u *AddressUnion) GetIP4() (a IP4Address) {
933         buf := codec.NewBuffer(u.XXX_UnionData[:])
934         copy(a[:], buf.DecodeBytes(4))
935         return
936 }
937
938 func AddressUnionIP6(a IP6Address) (u AddressUnion) {
939         u.SetIP6(a)
940         return
941 }
942 func (u *AddressUnion) SetIP6(a IP6Address) {
943         buf := codec.NewBuffer(u.XXX_UnionData[:])
944         buf.EncodeBytes(a[:], 16)
945 }
946 func (u *AddressUnion) GetIP6() (a IP6Address) {
947         buf := codec.NewBuffer(u.XXX_UnionData[:])
948         copy(a[:], buf.DecodeBytes(16))
949         return
950 }
951
952 // IgmpClearInterface defines message 'igmp_clear_interface'.
953 type IgmpClearInterface struct {
954         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
955 }
956
957 func (m *IgmpClearInterface) Reset()               { *m = IgmpClearInterface{} }
958 func (*IgmpClearInterface) GetMessageName() string { return "igmp_clear_interface" }
959 func (*IgmpClearInterface) GetCrcString() string   { return "f9e6675e" }
960 func (*IgmpClearInterface) GetMessageType() api.MessageType {
961         return api.RequestMessage
962 }
963
964 func (m *IgmpClearInterface) Size() (size int) {
965         if m == nil {
966                 return 0
967         }
968         size += 4 // m.SwIfIndex
969         return size
970 }
971 func (m *IgmpClearInterface) Marshal(b []byte) ([]byte, error) {
972         if b == nil {
973                 b = make([]byte, m.Size())
974         }
975         buf := codec.NewBuffer(b)
976         buf.EncodeUint32(uint32(m.SwIfIndex))
977         return buf.Bytes(), nil
978 }
979 func (m *IgmpClearInterface) Unmarshal(b []byte) error {
980         buf := codec.NewBuffer(b)
981         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
982         return nil
983 }
984
985 // IgmpClearInterfaceReply defines message 'igmp_clear_interface_reply'.
986 type IgmpClearInterfaceReply struct {
987         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
988 }
989
990 func (m *IgmpClearInterfaceReply) Reset()               { *m = IgmpClearInterfaceReply{} }
991 func (*IgmpClearInterfaceReply) GetMessageName() string { return "igmp_clear_interface_reply" }
992 func (*IgmpClearInterfaceReply) GetCrcString() string   { return "e8d4e804" }
993 func (*IgmpClearInterfaceReply) GetMessageType() api.MessageType {
994         return api.ReplyMessage
995 }
996
997 func (m *IgmpClearInterfaceReply) Size() (size int) {
998         if m == nil {
999                 return 0
1000         }
1001         size += 4 // m.Retval
1002         return size
1003 }
1004 func (m *IgmpClearInterfaceReply) Marshal(b []byte) ([]byte, error) {
1005         if b == nil {
1006                 b = make([]byte, m.Size())
1007         }
1008         buf := codec.NewBuffer(b)
1009         buf.EncodeInt32(m.Retval)
1010         return buf.Bytes(), nil
1011 }
1012 func (m *IgmpClearInterfaceReply) Unmarshal(b []byte) error {
1013         buf := codec.NewBuffer(b)
1014         m.Retval = buf.DecodeInt32()
1015         return nil
1016 }
1017
1018 // IgmpDetails defines message 'igmp_details'.
1019 type IgmpDetails struct {
1020         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1021         Saddr     IP4Address     `binapi:"ip4_address,name=saddr" json:"saddr,omitempty"`
1022         Gaddr     IP4Address     `binapi:"ip4_address,name=gaddr" json:"gaddr,omitempty"`
1023 }
1024
1025 func (m *IgmpDetails) Reset()               { *m = IgmpDetails{} }
1026 func (*IgmpDetails) GetMessageName() string { return "igmp_details" }
1027 func (*IgmpDetails) GetCrcString() string   { return "52f12a89" }
1028 func (*IgmpDetails) GetMessageType() api.MessageType {
1029         return api.ReplyMessage
1030 }
1031
1032 func (m *IgmpDetails) Size() (size int) {
1033         if m == nil {
1034                 return 0
1035         }
1036         size += 4     // m.SwIfIndex
1037         size += 1 * 4 // m.Saddr
1038         size += 1 * 4 // m.Gaddr
1039         return size
1040 }
1041 func (m *IgmpDetails) Marshal(b []byte) ([]byte, error) {
1042         if b == nil {
1043                 b = make([]byte, m.Size())
1044         }
1045         buf := codec.NewBuffer(b)
1046         buf.EncodeUint32(uint32(m.SwIfIndex))
1047         buf.EncodeBytes(m.Saddr[:], 4)
1048         buf.EncodeBytes(m.Gaddr[:], 4)
1049         return buf.Bytes(), nil
1050 }
1051 func (m *IgmpDetails) Unmarshal(b []byte) error {
1052         buf := codec.NewBuffer(b)
1053         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1054         copy(m.Saddr[:], buf.DecodeBytes(4))
1055         copy(m.Gaddr[:], buf.DecodeBytes(4))
1056         return nil
1057 }
1058
1059 // IgmpDump defines message 'igmp_dump'.
1060 type IgmpDump struct {
1061         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1062 }
1063
1064 func (m *IgmpDump) Reset()               { *m = IgmpDump{} }
1065 func (*IgmpDump) GetMessageName() string { return "igmp_dump" }
1066 func (*IgmpDump) GetCrcString() string   { return "f9e6675e" }
1067 func (*IgmpDump) GetMessageType() api.MessageType {
1068         return api.RequestMessage
1069 }
1070
1071 func (m *IgmpDump) Size() (size int) {
1072         if m == nil {
1073                 return 0
1074         }
1075         size += 4 // m.SwIfIndex
1076         return size
1077 }
1078 func (m *IgmpDump) Marshal(b []byte) ([]byte, error) {
1079         if b == nil {
1080                 b = make([]byte, m.Size())
1081         }
1082         buf := codec.NewBuffer(b)
1083         buf.EncodeUint32(uint32(m.SwIfIndex))
1084         return buf.Bytes(), nil
1085 }
1086 func (m *IgmpDump) Unmarshal(b []byte) error {
1087         buf := codec.NewBuffer(b)
1088         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1089         return nil
1090 }
1091
1092 // IgmpEnableDisable defines message 'igmp_enable_disable'.
1093 type IgmpEnableDisable struct {
1094         Enable    bool           `binapi:"bool,name=enable" json:"enable,omitempty"`
1095         Mode      uint8          `binapi:"u8,name=mode" json:"mode,omitempty"`
1096         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1097 }
1098
1099 func (m *IgmpEnableDisable) Reset()               { *m = IgmpEnableDisable{} }
1100 func (*IgmpEnableDisable) GetMessageName() string { return "igmp_enable_disable" }
1101 func (*IgmpEnableDisable) GetCrcString() string   { return "b1edfb96" }
1102 func (*IgmpEnableDisable) GetMessageType() api.MessageType {
1103         return api.RequestMessage
1104 }
1105
1106 func (m *IgmpEnableDisable) Size() (size int) {
1107         if m == nil {
1108                 return 0
1109         }
1110         size += 1 // m.Enable
1111         size += 1 // m.Mode
1112         size += 4 // m.SwIfIndex
1113         return size
1114 }
1115 func (m *IgmpEnableDisable) Marshal(b []byte) ([]byte, error) {
1116         if b == nil {
1117                 b = make([]byte, m.Size())
1118         }
1119         buf := codec.NewBuffer(b)
1120         buf.EncodeBool(m.Enable)
1121         buf.EncodeUint8(m.Mode)
1122         buf.EncodeUint32(uint32(m.SwIfIndex))
1123         return buf.Bytes(), nil
1124 }
1125 func (m *IgmpEnableDisable) Unmarshal(b []byte) error {
1126         buf := codec.NewBuffer(b)
1127         m.Enable = buf.DecodeBool()
1128         m.Mode = buf.DecodeUint8()
1129         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1130         return nil
1131 }
1132
1133 // IgmpEnableDisableReply defines message 'igmp_enable_disable_reply'.
1134 type IgmpEnableDisableReply struct {
1135         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
1136 }
1137
1138 func (m *IgmpEnableDisableReply) Reset()               { *m = IgmpEnableDisableReply{} }
1139 func (*IgmpEnableDisableReply) GetMessageName() string { return "igmp_enable_disable_reply" }
1140 func (*IgmpEnableDisableReply) GetCrcString() string   { return "e8d4e804" }
1141 func (*IgmpEnableDisableReply) GetMessageType() api.MessageType {
1142         return api.ReplyMessage
1143 }
1144
1145 func (m *IgmpEnableDisableReply) Size() (size int) {
1146         if m == nil {
1147                 return 0
1148         }
1149         size += 4 // m.Retval
1150         return size
1151 }
1152 func (m *IgmpEnableDisableReply) Marshal(b []byte) ([]byte, error) {
1153         if b == nil {
1154                 b = make([]byte, m.Size())
1155         }
1156         buf := codec.NewBuffer(b)
1157         buf.EncodeInt32(m.Retval)
1158         return buf.Bytes(), nil
1159 }
1160 func (m *IgmpEnableDisableReply) Unmarshal(b []byte) error {
1161         buf := codec.NewBuffer(b)
1162         m.Retval = buf.DecodeInt32()
1163         return nil
1164 }
1165
1166 // IgmpEvent defines message 'igmp_event'.
1167 type IgmpEvent struct {
1168         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1169         Filter    FilterMode     `binapi:"filter_mode,name=filter" json:"filter,omitempty"`
1170         Saddr     IP4Address     `binapi:"ip4_address,name=saddr" json:"saddr,omitempty"`
1171         Gaddr     IP4Address     `binapi:"ip4_address,name=gaddr" json:"gaddr,omitempty"`
1172 }
1173
1174 func (m *IgmpEvent) Reset()               { *m = IgmpEvent{} }
1175 func (*IgmpEvent) GetMessageName() string { return "igmp_event" }
1176 func (*IgmpEvent) GetCrcString() string   { return "d7696eaf" }
1177 func (*IgmpEvent) GetMessageType() api.MessageType {
1178         return api.OtherMessage
1179 }
1180
1181 func (m *IgmpEvent) Size() (size int) {
1182         if m == nil {
1183                 return 0
1184         }
1185         size += 4     // m.SwIfIndex
1186         size += 4     // m.Filter
1187         size += 1 * 4 // m.Saddr
1188         size += 1 * 4 // m.Gaddr
1189         return size
1190 }
1191 func (m *IgmpEvent) Marshal(b []byte) ([]byte, error) {
1192         if b == nil {
1193                 b = make([]byte, m.Size())
1194         }
1195         buf := codec.NewBuffer(b)
1196         buf.EncodeUint32(uint32(m.SwIfIndex))
1197         buf.EncodeUint32(uint32(m.Filter))
1198         buf.EncodeBytes(m.Saddr[:], 4)
1199         buf.EncodeBytes(m.Gaddr[:], 4)
1200         return buf.Bytes(), nil
1201 }
1202 func (m *IgmpEvent) Unmarshal(b []byte) error {
1203         buf := codec.NewBuffer(b)
1204         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1205         m.Filter = FilterMode(buf.DecodeUint32())
1206         copy(m.Saddr[:], buf.DecodeBytes(4))
1207         copy(m.Gaddr[:], buf.DecodeBytes(4))
1208         return nil
1209 }
1210
1211 // IgmpGroupPrefixDetails defines message 'igmp_group_prefix_details'.
1212 type IgmpGroupPrefixDetails struct {
1213         Gp GroupPrefix `binapi:"group_prefix,name=gp" json:"gp,omitempty"`
1214 }
1215
1216 func (m *IgmpGroupPrefixDetails) Reset()               { *m = IgmpGroupPrefixDetails{} }
1217 func (*IgmpGroupPrefixDetails) GetMessageName() string { return "igmp_group_prefix_details" }
1218 func (*IgmpGroupPrefixDetails) GetCrcString() string   { return "c3b3c526" }
1219 func (*IgmpGroupPrefixDetails) GetMessageType() api.MessageType {
1220         return api.ReplyMessage
1221 }
1222
1223 func (m *IgmpGroupPrefixDetails) Size() (size int) {
1224         if m == nil {
1225                 return 0
1226         }
1227         size += 4      // m.Gp.Type
1228         size += 4      // m.Gp.Prefix.Address.Af
1229         size += 1 * 16 // m.Gp.Prefix.Address.Un
1230         size += 1      // m.Gp.Prefix.Len
1231         return size
1232 }
1233 func (m *IgmpGroupPrefixDetails) Marshal(b []byte) ([]byte, error) {
1234         if b == nil {
1235                 b = make([]byte, m.Size())
1236         }
1237         buf := codec.NewBuffer(b)
1238         buf.EncodeUint32(uint32(m.Gp.Type))
1239         buf.EncodeUint32(uint32(m.Gp.Prefix.Address.Af))
1240         buf.EncodeBytes(m.Gp.Prefix.Address.Un.XXX_UnionData[:], 16)
1241         buf.EncodeUint8(m.Gp.Prefix.Len)
1242         return buf.Bytes(), nil
1243 }
1244 func (m *IgmpGroupPrefixDetails) Unmarshal(b []byte) error {
1245         buf := codec.NewBuffer(b)
1246         m.Gp.Type = GroupPrefixType(buf.DecodeUint32())
1247         m.Gp.Prefix.Address.Af = AddressFamily(buf.DecodeUint32())
1248         copy(m.Gp.Prefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
1249         m.Gp.Prefix.Len = buf.DecodeUint8()
1250         return nil
1251 }
1252
1253 // IgmpGroupPrefixDump defines message 'igmp_group_prefix_dump'.
1254 type IgmpGroupPrefixDump struct{}
1255
1256 func (m *IgmpGroupPrefixDump) Reset()               { *m = IgmpGroupPrefixDump{} }
1257 func (*IgmpGroupPrefixDump) GetMessageName() string { return "igmp_group_prefix_dump" }
1258 func (*IgmpGroupPrefixDump) GetCrcString() string   { return "51077d14" }
1259 func (*IgmpGroupPrefixDump) GetMessageType() api.MessageType {
1260         return api.RequestMessage
1261 }
1262
1263 func (m *IgmpGroupPrefixDump) Size() (size int) {
1264         if m == nil {
1265                 return 0
1266         }
1267         return size
1268 }
1269 func (m *IgmpGroupPrefixDump) Marshal(b []byte) ([]byte, error) {
1270         if b == nil {
1271                 b = make([]byte, m.Size())
1272         }
1273         buf := codec.NewBuffer(b)
1274         return buf.Bytes(), nil
1275 }
1276 func (m *IgmpGroupPrefixDump) Unmarshal(b []byte) error {
1277         return nil
1278 }
1279
1280 // IgmpGroupPrefixSet defines message 'igmp_group_prefix_set'.
1281 type IgmpGroupPrefixSet struct {
1282         Gp GroupPrefix `binapi:"group_prefix,name=gp" json:"gp,omitempty"`
1283 }
1284
1285 func (m *IgmpGroupPrefixSet) Reset()               { *m = IgmpGroupPrefixSet{} }
1286 func (*IgmpGroupPrefixSet) GetMessageName() string { return "igmp_group_prefix_set" }
1287 func (*IgmpGroupPrefixSet) GetCrcString() string   { return "d4f20ac5" }
1288 func (*IgmpGroupPrefixSet) GetMessageType() api.MessageType {
1289         return api.RequestMessage
1290 }
1291
1292 func (m *IgmpGroupPrefixSet) Size() (size int) {
1293         if m == nil {
1294                 return 0
1295         }
1296         size += 4      // m.Gp.Type
1297         size += 4      // m.Gp.Prefix.Address.Af
1298         size += 1 * 16 // m.Gp.Prefix.Address.Un
1299         size += 1      // m.Gp.Prefix.Len
1300         return size
1301 }
1302 func (m *IgmpGroupPrefixSet) Marshal(b []byte) ([]byte, error) {
1303         if b == nil {
1304                 b = make([]byte, m.Size())
1305         }
1306         buf := codec.NewBuffer(b)
1307         buf.EncodeUint32(uint32(m.Gp.Type))
1308         buf.EncodeUint32(uint32(m.Gp.Prefix.Address.Af))
1309         buf.EncodeBytes(m.Gp.Prefix.Address.Un.XXX_UnionData[:], 16)
1310         buf.EncodeUint8(m.Gp.Prefix.Len)
1311         return buf.Bytes(), nil
1312 }
1313 func (m *IgmpGroupPrefixSet) Unmarshal(b []byte) error {
1314         buf := codec.NewBuffer(b)
1315         m.Gp.Type = GroupPrefixType(buf.DecodeUint32())
1316         m.Gp.Prefix.Address.Af = AddressFamily(buf.DecodeUint32())
1317         copy(m.Gp.Prefix.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
1318         m.Gp.Prefix.Len = buf.DecodeUint8()
1319         return nil
1320 }
1321
1322 // IgmpGroupPrefixSetReply defines message 'igmp_group_prefix_set_reply'.
1323 type IgmpGroupPrefixSetReply struct {
1324         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
1325 }
1326
1327 func (m *IgmpGroupPrefixSetReply) Reset()               { *m = IgmpGroupPrefixSetReply{} }
1328 func (*IgmpGroupPrefixSetReply) GetMessageName() string { return "igmp_group_prefix_set_reply" }
1329 func (*IgmpGroupPrefixSetReply) GetCrcString() string   { return "e8d4e804" }
1330 func (*IgmpGroupPrefixSetReply) GetMessageType() api.MessageType {
1331         return api.ReplyMessage
1332 }
1333
1334 func (m *IgmpGroupPrefixSetReply) Size() (size int) {
1335         if m == nil {
1336                 return 0
1337         }
1338         size += 4 // m.Retval
1339         return size
1340 }
1341 func (m *IgmpGroupPrefixSetReply) Marshal(b []byte) ([]byte, error) {
1342         if b == nil {
1343                 b = make([]byte, m.Size())
1344         }
1345         buf := codec.NewBuffer(b)
1346         buf.EncodeInt32(m.Retval)
1347         return buf.Bytes(), nil
1348 }
1349 func (m *IgmpGroupPrefixSetReply) Unmarshal(b []byte) error {
1350         buf := codec.NewBuffer(b)
1351         m.Retval = buf.DecodeInt32()
1352         return nil
1353 }
1354
1355 // IgmpListen defines message 'igmp_listen'.
1356 type IgmpListen struct {
1357         Group IgmpGroup `binapi:"igmp_group,name=group" json:"group,omitempty"`
1358 }
1359
1360 func (m *IgmpListen) Reset()               { *m = IgmpListen{} }
1361 func (*IgmpListen) GetMessageName() string { return "igmp_listen" }
1362 func (*IgmpListen) GetCrcString() string   { return "3f93a51a" }
1363 func (*IgmpListen) GetMessageType() api.MessageType {
1364         return api.RequestMessage
1365 }
1366
1367 func (m *IgmpListen) Size() (size int) {
1368         if m == nil {
1369                 return 0
1370         }
1371         size += 4     // m.Group.Filter
1372         size += 1     // m.Group.NSrcs
1373         size += 4     // m.Group.SwIfIndex
1374         size += 1 * 4 // m.Group.Gaddr
1375         for j2 := 0; j2 < len(m.Group.Saddrs); j2++ {
1376                 var s2 IP4Address
1377                 _ = s2
1378                 if j2 < len(m.Group.Saddrs) {
1379                         s2 = m.Group.Saddrs[j2]
1380                 }
1381                 size += 1 * 4 // s2
1382         }
1383         return size
1384 }
1385 func (m *IgmpListen) Marshal(b []byte) ([]byte, error) {
1386         if b == nil {
1387                 b = make([]byte, m.Size())
1388         }
1389         buf := codec.NewBuffer(b)
1390         buf.EncodeUint32(uint32(m.Group.Filter))
1391         buf.EncodeUint8(uint8(len(m.Group.Saddrs)))
1392         buf.EncodeUint32(uint32(m.Group.SwIfIndex))
1393         buf.EncodeBytes(m.Group.Gaddr[:], 4)
1394         for j1 := 0; j1 < len(m.Group.Saddrs); j1++ {
1395                 var v1 IP4Address // Saddrs
1396                 if j1 < len(m.Group.Saddrs) {
1397                         v1 = m.Group.Saddrs[j1]
1398                 }
1399                 buf.EncodeBytes(v1[:], 4)
1400         }
1401         return buf.Bytes(), nil
1402 }
1403 func (m *IgmpListen) Unmarshal(b []byte) error {
1404         buf := codec.NewBuffer(b)
1405         m.Group.Filter = FilterMode(buf.DecodeUint32())
1406         m.Group.NSrcs = buf.DecodeUint8()
1407         m.Group.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1408         copy(m.Group.Gaddr[:], buf.DecodeBytes(4))
1409         m.Group.Saddrs = make([]IP4Address, m.Group.NSrcs)
1410         for j1 := 0; j1 < len(m.Group.Saddrs); j1++ {
1411                 copy(m.Group.Saddrs[j1][:], buf.DecodeBytes(4))
1412         }
1413         return nil
1414 }
1415
1416 // IgmpListenReply defines message 'igmp_listen_reply'.
1417 type IgmpListenReply struct {
1418         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
1419 }
1420
1421 func (m *IgmpListenReply) Reset()               { *m = IgmpListenReply{} }
1422 func (*IgmpListenReply) GetMessageName() string { return "igmp_listen_reply" }
1423 func (*IgmpListenReply) GetCrcString() string   { return "e8d4e804" }
1424 func (*IgmpListenReply) GetMessageType() api.MessageType {
1425         return api.ReplyMessage
1426 }
1427
1428 func (m *IgmpListenReply) Size() (size int) {
1429         if m == nil {
1430                 return 0
1431         }
1432         size += 4 // m.Retval
1433         return size
1434 }
1435 func (m *IgmpListenReply) Marshal(b []byte) ([]byte, error) {
1436         if b == nil {
1437                 b = make([]byte, m.Size())
1438         }
1439         buf := codec.NewBuffer(b)
1440         buf.EncodeInt32(m.Retval)
1441         return buf.Bytes(), nil
1442 }
1443 func (m *IgmpListenReply) Unmarshal(b []byte) error {
1444         buf := codec.NewBuffer(b)
1445         m.Retval = buf.DecodeInt32()
1446         return nil
1447 }
1448
1449 // IgmpProxyDeviceAddDel defines message 'igmp_proxy_device_add_del'.
1450 type IgmpProxyDeviceAddDel struct {
1451         Add       uint8          `binapi:"u8,name=add" json:"add,omitempty"`
1452         VrfID     uint32         `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"`
1453         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1454 }
1455
1456 func (m *IgmpProxyDeviceAddDel) Reset()               { *m = IgmpProxyDeviceAddDel{} }
1457 func (*IgmpProxyDeviceAddDel) GetMessageName() string { return "igmp_proxy_device_add_del" }
1458 func (*IgmpProxyDeviceAddDel) GetCrcString() string   { return "0b9be9ce" }
1459 func (*IgmpProxyDeviceAddDel) GetMessageType() api.MessageType {
1460         return api.RequestMessage
1461 }
1462
1463 func (m *IgmpProxyDeviceAddDel) Size() (size int) {
1464         if m == nil {
1465                 return 0
1466         }
1467         size += 1 // m.Add
1468         size += 4 // m.VrfID
1469         size += 4 // m.SwIfIndex
1470         return size
1471 }
1472 func (m *IgmpProxyDeviceAddDel) Marshal(b []byte) ([]byte, error) {
1473         if b == nil {
1474                 b = make([]byte, m.Size())
1475         }
1476         buf := codec.NewBuffer(b)
1477         buf.EncodeUint8(m.Add)
1478         buf.EncodeUint32(m.VrfID)
1479         buf.EncodeUint32(uint32(m.SwIfIndex))
1480         return buf.Bytes(), nil
1481 }
1482 func (m *IgmpProxyDeviceAddDel) Unmarshal(b []byte) error {
1483         buf := codec.NewBuffer(b)
1484         m.Add = buf.DecodeUint8()
1485         m.VrfID = buf.DecodeUint32()
1486         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1487         return nil
1488 }
1489
1490 // IgmpProxyDeviceAddDelInterface defines message 'igmp_proxy_device_add_del_interface'.
1491 type IgmpProxyDeviceAddDelInterface struct {
1492         Add       bool           `binapi:"bool,name=add" json:"add,omitempty"`
1493         VrfID     uint32         `binapi:"u32,name=vrf_id" json:"vrf_id,omitempty"`
1494         SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1495 }
1496
1497 func (m *IgmpProxyDeviceAddDelInterface) Reset() { *m = IgmpProxyDeviceAddDelInterface{} }
1498 func (*IgmpProxyDeviceAddDelInterface) GetMessageName() string {
1499         return "igmp_proxy_device_add_del_interface"
1500 }
1501 func (*IgmpProxyDeviceAddDelInterface) GetCrcString() string { return "1a9ec24a" }
1502 func (*IgmpProxyDeviceAddDelInterface) GetMessageType() api.MessageType {
1503         return api.RequestMessage
1504 }
1505
1506 func (m *IgmpProxyDeviceAddDelInterface) Size() (size int) {
1507         if m == nil {
1508                 return 0
1509         }
1510         size += 1 // m.Add
1511         size += 4 // m.VrfID
1512         size += 4 // m.SwIfIndex
1513         return size
1514 }
1515 func (m *IgmpProxyDeviceAddDelInterface) Marshal(b []byte) ([]byte, error) {
1516         if b == nil {
1517                 b = make([]byte, m.Size())
1518         }
1519         buf := codec.NewBuffer(b)
1520         buf.EncodeBool(m.Add)
1521         buf.EncodeUint32(m.VrfID)
1522         buf.EncodeUint32(uint32(m.SwIfIndex))
1523         return buf.Bytes(), nil
1524 }
1525 func (m *IgmpProxyDeviceAddDelInterface) Unmarshal(b []byte) error {
1526         buf := codec.NewBuffer(b)
1527         m.Add = buf.DecodeBool()
1528         m.VrfID = buf.DecodeUint32()
1529         m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1530         return nil
1531 }
1532
1533 // IgmpProxyDeviceAddDelInterfaceReply defines message 'igmp_proxy_device_add_del_interface_reply'.
1534 type IgmpProxyDeviceAddDelInterfaceReply struct {
1535         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
1536 }
1537
1538 func (m *IgmpProxyDeviceAddDelInterfaceReply) Reset() { *m = IgmpProxyDeviceAddDelInterfaceReply{} }
1539 func (*IgmpProxyDeviceAddDelInterfaceReply) GetMessageName() string {
1540         return "igmp_proxy_device_add_del_interface_reply"
1541 }
1542 func (*IgmpProxyDeviceAddDelInterfaceReply) GetCrcString() string { return "e8d4e804" }
1543 func (*IgmpProxyDeviceAddDelInterfaceReply) GetMessageType() api.MessageType {
1544         return api.ReplyMessage
1545 }
1546
1547 func (m *IgmpProxyDeviceAddDelInterfaceReply) Size() (size int) {
1548         if m == nil {
1549                 return 0
1550         }
1551         size += 4 // m.Retval
1552         return size
1553 }
1554 func (m *IgmpProxyDeviceAddDelInterfaceReply) Marshal(b []byte) ([]byte, error) {
1555         if b == nil {
1556                 b = make([]byte, m.Size())
1557         }
1558         buf := codec.NewBuffer(b)
1559         buf.EncodeInt32(m.Retval)
1560         return buf.Bytes(), nil
1561 }
1562 func (m *IgmpProxyDeviceAddDelInterfaceReply) Unmarshal(b []byte) error {
1563         buf := codec.NewBuffer(b)
1564         m.Retval = buf.DecodeInt32()
1565         return nil
1566 }
1567
1568 // IgmpProxyDeviceAddDelReply defines message 'igmp_proxy_device_add_del_reply'.
1569 type IgmpProxyDeviceAddDelReply struct {
1570         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
1571 }
1572
1573 func (m *IgmpProxyDeviceAddDelReply) Reset()               { *m = IgmpProxyDeviceAddDelReply{} }
1574 func (*IgmpProxyDeviceAddDelReply) GetMessageName() string { return "igmp_proxy_device_add_del_reply" }
1575 func (*IgmpProxyDeviceAddDelReply) GetCrcString() string   { return "e8d4e804" }
1576 func (*IgmpProxyDeviceAddDelReply) GetMessageType() api.MessageType {
1577         return api.ReplyMessage
1578 }
1579
1580 func (m *IgmpProxyDeviceAddDelReply) Size() (size int) {
1581         if m == nil {
1582                 return 0
1583         }
1584         size += 4 // m.Retval
1585         return size
1586 }
1587 func (m *IgmpProxyDeviceAddDelReply) Marshal(b []byte) ([]byte, error) {
1588         if b == nil {
1589                 b = make([]byte, m.Size())
1590         }
1591         buf := codec.NewBuffer(b)
1592         buf.EncodeInt32(m.Retval)
1593         return buf.Bytes(), nil
1594 }
1595 func (m *IgmpProxyDeviceAddDelReply) Unmarshal(b []byte) error {
1596         buf := codec.NewBuffer(b)
1597         m.Retval = buf.DecodeInt32()
1598         return nil
1599 }
1600
1601 // WantIgmpEvents defines message 'want_igmp_events'.
1602 type WantIgmpEvents struct {
1603         Enable uint32 `binapi:"u32,name=enable" json:"enable,omitempty"`
1604         PID    uint32 `binapi:"u32,name=pid" json:"pid,omitempty"`
1605 }
1606
1607 func (m *WantIgmpEvents) Reset()               { *m = WantIgmpEvents{} }
1608 func (*WantIgmpEvents) GetMessageName() string { return "want_igmp_events" }
1609 func (*WantIgmpEvents) GetCrcString() string   { return "cfaccc1f" }
1610 func (*WantIgmpEvents) GetMessageType() api.MessageType {
1611         return api.RequestMessage
1612 }
1613
1614 func (m *WantIgmpEvents) Size() (size int) {
1615         if m == nil {
1616                 return 0
1617         }
1618         size += 4 // m.Enable
1619         size += 4 // m.PID
1620         return size
1621 }
1622 func (m *WantIgmpEvents) Marshal(b []byte) ([]byte, error) {
1623         if b == nil {
1624                 b = make([]byte, m.Size())
1625         }
1626         buf := codec.NewBuffer(b)
1627         buf.EncodeUint32(m.Enable)
1628         buf.EncodeUint32(m.PID)
1629         return buf.Bytes(), nil
1630 }
1631 func (m *WantIgmpEvents) Unmarshal(b []byte) error {
1632         buf := codec.NewBuffer(b)
1633         m.Enable = buf.DecodeUint32()
1634         m.PID = buf.DecodeUint32()
1635         return nil
1636 }
1637
1638 // WantIgmpEventsReply defines message 'want_igmp_events_reply'.
1639 type WantIgmpEventsReply struct {
1640         Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
1641 }
1642
1643 func (m *WantIgmpEventsReply) Reset()               { *m = WantIgmpEventsReply{} }
1644 func (*WantIgmpEventsReply) GetMessageName() string { return "want_igmp_events_reply" }
1645 func (*WantIgmpEventsReply) GetCrcString() string   { return "e8d4e804" }
1646 func (*WantIgmpEventsReply) GetMessageType() api.MessageType {
1647         return api.ReplyMessage
1648 }
1649
1650 func (m *WantIgmpEventsReply) Size() (size int) {
1651         if m == nil {
1652                 return 0
1653         }
1654         size += 4 // m.Retval
1655         return size
1656 }
1657 func (m *WantIgmpEventsReply) Marshal(b []byte) ([]byte, error) {
1658         if b == nil {
1659                 b = make([]byte, m.Size())
1660         }
1661         buf := codec.NewBuffer(b)
1662         buf.EncodeInt32(m.Retval)
1663         return buf.Bytes(), nil
1664 }
1665 func (m *WantIgmpEventsReply) Unmarshal(b []byte) error {
1666         buf := codec.NewBuffer(b)
1667         m.Retval = buf.DecodeInt32()
1668         return nil
1669 }
1670
1671 func init() { file_igmp_binapi_init() }
1672 func file_igmp_binapi_init() {
1673         api.RegisterMessage((*IgmpClearInterface)(nil), "igmp_clear_interface_f9e6675e")
1674         api.RegisterMessage((*IgmpClearInterfaceReply)(nil), "igmp_clear_interface_reply_e8d4e804")
1675         api.RegisterMessage((*IgmpDetails)(nil), "igmp_details_52f12a89")
1676         api.RegisterMessage((*IgmpDump)(nil), "igmp_dump_f9e6675e")
1677         api.RegisterMessage((*IgmpEnableDisable)(nil), "igmp_enable_disable_b1edfb96")
1678         api.RegisterMessage((*IgmpEnableDisableReply)(nil), "igmp_enable_disable_reply_e8d4e804")
1679         api.RegisterMessage((*IgmpEvent)(nil), "igmp_event_d7696eaf")
1680         api.RegisterMessage((*IgmpGroupPrefixDetails)(nil), "igmp_group_prefix_details_c3b3c526")
1681         api.RegisterMessage((*IgmpGroupPrefixDump)(nil), "igmp_group_prefix_dump_51077d14")
1682         api.RegisterMessage((*IgmpGroupPrefixSet)(nil), "igmp_group_prefix_set_d4f20ac5")
1683         api.RegisterMessage((*IgmpGroupPrefixSetReply)(nil), "igmp_group_prefix_set_reply_e8d4e804")
1684         api.RegisterMessage((*IgmpListen)(nil), "igmp_listen_3f93a51a")
1685         api.RegisterMessage((*IgmpListenReply)(nil), "igmp_listen_reply_e8d4e804")
1686         api.RegisterMessage((*IgmpProxyDeviceAddDel)(nil), "igmp_proxy_device_add_del_0b9be9ce")
1687         api.RegisterMessage((*IgmpProxyDeviceAddDelInterface)(nil), "igmp_proxy_device_add_del_interface_1a9ec24a")
1688         api.RegisterMessage((*IgmpProxyDeviceAddDelInterfaceReply)(nil), "igmp_proxy_device_add_del_interface_reply_e8d4e804")
1689         api.RegisterMessage((*IgmpProxyDeviceAddDelReply)(nil), "igmp_proxy_device_add_del_reply_e8d4e804")
1690         api.RegisterMessage((*WantIgmpEvents)(nil), "want_igmp_events_cfaccc1f")
1691         api.RegisterMessage((*WantIgmpEventsReply)(nil), "want_igmp_events_reply_e8d4e804")
1692 }
1693
1694 // Messages returns list of all messages in this module.
1695 func AllMessages() []api.Message {
1696         return []api.Message{
1697                 (*IgmpClearInterface)(nil),
1698                 (*IgmpClearInterfaceReply)(nil),
1699                 (*IgmpDetails)(nil),
1700                 (*IgmpDump)(nil),
1701                 (*IgmpEnableDisable)(nil),
1702                 (*IgmpEnableDisableReply)(nil),
1703                 (*IgmpEvent)(nil),
1704                 (*IgmpGroupPrefixDetails)(nil),
1705                 (*IgmpGroupPrefixDump)(nil),
1706                 (*IgmpGroupPrefixSet)(nil),
1707                 (*IgmpGroupPrefixSetReply)(nil),
1708                 (*IgmpListen)(nil),
1709                 (*IgmpListenReply)(nil),
1710                 (*IgmpProxyDeviceAddDel)(nil),
1711                 (*IgmpProxyDeviceAddDelInterface)(nil),
1712                 (*IgmpProxyDeviceAddDelInterfaceReply)(nil),
1713                 (*IgmpProxyDeviceAddDelReply)(nil),
1714                 (*WantIgmpEvents)(nil),
1715                 (*WantIgmpEventsReply)(nil),
1716         }
1717 }