1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
3 // binapi-generator: v0.5.0-dev
5 // source: .vppapi/core/tapv2.api.json
7 // Package tapv2 contains generated bindings for API file tapv2.api.
24 api "git.fd.io/govpp.git/api"
25 codec "git.fd.io/govpp.git/codec"
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
37 VersionCrc = 0x7d58f9a4
40 // AddressFamily defines enum 'address_family'.
41 type AddressFamily uint32
44 ADDRESS_IP4 AddressFamily = 0
45 ADDRESS_IP6 AddressFamily = 1
49 AddressFamily_name = map[uint32]string{
53 AddressFamily_value = map[string]uint32{
59 func (x AddressFamily) String() string {
60 s, ok := AddressFamily_name[uint32(x)]
64 return "AddressFamily(" + strconv.Itoa(int(x)) + ")"
67 // IfStatusFlags defines enum 'if_status_flags'.
68 type IfStatusFlags uint32
71 IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1
72 IF_STATUS_API_FLAG_LINK_UP IfStatusFlags = 2
76 IfStatusFlags_name = map[uint32]string{
77 1: "IF_STATUS_API_FLAG_ADMIN_UP",
78 2: "IF_STATUS_API_FLAG_LINK_UP",
80 IfStatusFlags_value = map[string]uint32{
81 "IF_STATUS_API_FLAG_ADMIN_UP": 1,
82 "IF_STATUS_API_FLAG_LINK_UP": 2,
86 func (x IfStatusFlags) String() string {
87 s, ok := IfStatusFlags_name[uint32(x)]
91 str := func(n uint32) string {
92 s, ok := IfStatusFlags_name[uint32(n)]
96 return "IfStatusFlags(" + strconv.Itoa(int(n)) + ")"
98 for i := uint32(0); i <= 32; i++ {
108 return str(uint32(x))
113 // IfType defines enum 'if_type'.
117 IF_API_TYPE_HARDWARE IfType = 1
118 IF_API_TYPE_SUB IfType = 2
119 IF_API_TYPE_P2P IfType = 3
120 IF_API_TYPE_PIPE IfType = 4
124 IfType_name = map[uint32]string{
125 1: "IF_API_TYPE_HARDWARE",
126 2: "IF_API_TYPE_SUB",
127 3: "IF_API_TYPE_P2P",
128 4: "IF_API_TYPE_PIPE",
130 IfType_value = map[string]uint32{
131 "IF_API_TYPE_HARDWARE": 1,
132 "IF_API_TYPE_SUB": 2,
133 "IF_API_TYPE_P2P": 3,
134 "IF_API_TYPE_PIPE": 4,
138 func (x IfType) String() string {
139 s, ok := IfType_name[uint32(x)]
143 return "IfType(" + strconv.Itoa(int(x)) + ")"
146 // IPDscp defines enum 'ip_dscp'.
150 IP_API_DSCP_CS0 IPDscp = 0
151 IP_API_DSCP_CS1 IPDscp = 8
152 IP_API_DSCP_AF11 IPDscp = 10
153 IP_API_DSCP_AF12 IPDscp = 12
154 IP_API_DSCP_AF13 IPDscp = 14
155 IP_API_DSCP_CS2 IPDscp = 16
156 IP_API_DSCP_AF21 IPDscp = 18
157 IP_API_DSCP_AF22 IPDscp = 20
158 IP_API_DSCP_AF23 IPDscp = 22
159 IP_API_DSCP_CS3 IPDscp = 24
160 IP_API_DSCP_AF31 IPDscp = 26
161 IP_API_DSCP_AF32 IPDscp = 28
162 IP_API_DSCP_AF33 IPDscp = 30
163 IP_API_DSCP_CS4 IPDscp = 32
164 IP_API_DSCP_AF41 IPDscp = 34
165 IP_API_DSCP_AF42 IPDscp = 36
166 IP_API_DSCP_AF43 IPDscp = 38
167 IP_API_DSCP_CS5 IPDscp = 40
168 IP_API_DSCP_EF IPDscp = 46
169 IP_API_DSCP_CS6 IPDscp = 48
170 IP_API_DSCP_CS7 IPDscp = 50
174 IPDscp_name = map[uint8]string{
175 0: "IP_API_DSCP_CS0",
176 8: "IP_API_DSCP_CS1",
177 10: "IP_API_DSCP_AF11",
178 12: "IP_API_DSCP_AF12",
179 14: "IP_API_DSCP_AF13",
180 16: "IP_API_DSCP_CS2",
181 18: "IP_API_DSCP_AF21",
182 20: "IP_API_DSCP_AF22",
183 22: "IP_API_DSCP_AF23",
184 24: "IP_API_DSCP_CS3",
185 26: "IP_API_DSCP_AF31",
186 28: "IP_API_DSCP_AF32",
187 30: "IP_API_DSCP_AF33",
188 32: "IP_API_DSCP_CS4",
189 34: "IP_API_DSCP_AF41",
190 36: "IP_API_DSCP_AF42",
191 38: "IP_API_DSCP_AF43",
192 40: "IP_API_DSCP_CS5",
193 46: "IP_API_DSCP_EF",
194 48: "IP_API_DSCP_CS6",
195 50: "IP_API_DSCP_CS7",
197 IPDscp_value = map[string]uint8{
198 "IP_API_DSCP_CS0": 0,
199 "IP_API_DSCP_CS1": 8,
200 "IP_API_DSCP_AF11": 10,
201 "IP_API_DSCP_AF12": 12,
202 "IP_API_DSCP_AF13": 14,
203 "IP_API_DSCP_CS2": 16,
204 "IP_API_DSCP_AF21": 18,
205 "IP_API_DSCP_AF22": 20,
206 "IP_API_DSCP_AF23": 22,
207 "IP_API_DSCP_CS3": 24,
208 "IP_API_DSCP_AF31": 26,
209 "IP_API_DSCP_AF32": 28,
210 "IP_API_DSCP_AF33": 30,
211 "IP_API_DSCP_CS4": 32,
212 "IP_API_DSCP_AF41": 34,
213 "IP_API_DSCP_AF42": 36,
214 "IP_API_DSCP_AF43": 38,
215 "IP_API_DSCP_CS5": 40,
216 "IP_API_DSCP_EF": 46,
217 "IP_API_DSCP_CS6": 48,
218 "IP_API_DSCP_CS7": 50,
222 func (x IPDscp) String() string {
223 s, ok := IPDscp_name[uint8(x)]
227 return "IPDscp(" + strconv.Itoa(int(x)) + ")"
230 // IPEcn defines enum 'ip_ecn'.
234 IP_API_ECN_NONE IPEcn = 0
235 IP_API_ECN_ECT0 IPEcn = 1
236 IP_API_ECN_ECT1 IPEcn = 2
237 IP_API_ECN_CE IPEcn = 3
241 IPEcn_name = map[uint8]string{
242 0: "IP_API_ECN_NONE",
243 1: "IP_API_ECN_ECT0",
244 2: "IP_API_ECN_ECT1",
247 IPEcn_value = map[string]uint8{
248 "IP_API_ECN_NONE": 0,
249 "IP_API_ECN_ECT0": 1,
250 "IP_API_ECN_ECT1": 2,
255 func (x IPEcn) String() string {
256 s, ok := IPEcn_name[uint8(x)]
260 return "IPEcn(" + strconv.Itoa(int(x)) + ")"
263 // IPProto defines enum 'ip_proto'.
267 IP_API_PROTO_HOPOPT IPProto = 0
268 IP_API_PROTO_ICMP IPProto = 1
269 IP_API_PROTO_IGMP IPProto = 2
270 IP_API_PROTO_TCP IPProto = 6
271 IP_API_PROTO_UDP IPProto = 17
272 IP_API_PROTO_GRE IPProto = 47
273 IP_API_PROTO_AH IPProto = 50
274 IP_API_PROTO_ESP IPProto = 51
275 IP_API_PROTO_EIGRP IPProto = 88
276 IP_API_PROTO_OSPF IPProto = 89
277 IP_API_PROTO_SCTP IPProto = 132
278 IP_API_PROTO_RESERVED IPProto = 255
282 IPProto_name = map[uint32]string{
283 0: "IP_API_PROTO_HOPOPT",
284 1: "IP_API_PROTO_ICMP",
285 2: "IP_API_PROTO_IGMP",
286 6: "IP_API_PROTO_TCP",
287 17: "IP_API_PROTO_UDP",
288 47: "IP_API_PROTO_GRE",
289 50: "IP_API_PROTO_AH",
290 51: "IP_API_PROTO_ESP",
291 88: "IP_API_PROTO_EIGRP",
292 89: "IP_API_PROTO_OSPF",
293 132: "IP_API_PROTO_SCTP",
294 255: "IP_API_PROTO_RESERVED",
296 IPProto_value = map[string]uint32{
297 "IP_API_PROTO_HOPOPT": 0,
298 "IP_API_PROTO_ICMP": 1,
299 "IP_API_PROTO_IGMP": 2,
300 "IP_API_PROTO_TCP": 6,
301 "IP_API_PROTO_UDP": 17,
302 "IP_API_PROTO_GRE": 47,
303 "IP_API_PROTO_AH": 50,
304 "IP_API_PROTO_ESP": 51,
305 "IP_API_PROTO_EIGRP": 88,
306 "IP_API_PROTO_OSPF": 89,
307 "IP_API_PROTO_SCTP": 132,
308 "IP_API_PROTO_RESERVED": 255,
312 func (x IPProto) String() string {
313 s, ok := IPProto_name[uint32(x)]
317 return "IPProto(" + strconv.Itoa(int(x)) + ")"
320 // LinkDuplex defines enum 'link_duplex'.
321 type LinkDuplex uint32
324 LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0
325 LINK_DUPLEX_API_HALF LinkDuplex = 1
326 LINK_DUPLEX_API_FULL LinkDuplex = 2
330 LinkDuplex_name = map[uint32]string{
331 0: "LINK_DUPLEX_API_UNKNOWN",
332 1: "LINK_DUPLEX_API_HALF",
333 2: "LINK_DUPLEX_API_FULL",
335 LinkDuplex_value = map[string]uint32{
336 "LINK_DUPLEX_API_UNKNOWN": 0,
337 "LINK_DUPLEX_API_HALF": 1,
338 "LINK_DUPLEX_API_FULL": 2,
342 func (x LinkDuplex) String() string {
343 s, ok := LinkDuplex_name[uint32(x)]
347 return "LinkDuplex(" + strconv.Itoa(int(x)) + ")"
350 // MtuProto defines enum 'mtu_proto'.
354 MTU_PROTO_API_L3 MtuProto = 1
355 MTU_PROTO_API_IP4 MtuProto = 2
356 MTU_PROTO_API_IP6 MtuProto = 3
357 MTU_PROTO_API_MPLS MtuProto = 4
358 MTU_PROTO_API_N MtuProto = 5
362 MtuProto_name = map[uint32]string{
363 1: "MTU_PROTO_API_L3",
364 2: "MTU_PROTO_API_IP4",
365 3: "MTU_PROTO_API_IP6",
366 4: "MTU_PROTO_API_MPLS",
367 5: "MTU_PROTO_API_N",
369 MtuProto_value = map[string]uint32{
370 "MTU_PROTO_API_L3": 1,
371 "MTU_PROTO_API_IP4": 2,
372 "MTU_PROTO_API_IP6": 3,
373 "MTU_PROTO_API_MPLS": 4,
374 "MTU_PROTO_API_N": 5,
378 func (x MtuProto) String() string {
379 s, ok := MtuProto_name[uint32(x)]
383 return "MtuProto(" + strconv.Itoa(int(x)) + ")"
386 // RxMode defines enum 'rx_mode'.
390 RX_MODE_API_UNKNOWN RxMode = 0
391 RX_MODE_API_POLLING RxMode = 1
392 RX_MODE_API_INTERRUPT RxMode = 2
393 RX_MODE_API_ADAPTIVE RxMode = 3
394 RX_MODE_API_DEFAULT RxMode = 4
398 RxMode_name = map[uint32]string{
399 0: "RX_MODE_API_UNKNOWN",
400 1: "RX_MODE_API_POLLING",
401 2: "RX_MODE_API_INTERRUPT",
402 3: "RX_MODE_API_ADAPTIVE",
403 4: "RX_MODE_API_DEFAULT",
405 RxMode_value = map[string]uint32{
406 "RX_MODE_API_UNKNOWN": 0,
407 "RX_MODE_API_POLLING": 1,
408 "RX_MODE_API_INTERRUPT": 2,
409 "RX_MODE_API_ADAPTIVE": 3,
410 "RX_MODE_API_DEFAULT": 4,
414 func (x RxMode) String() string {
415 s, ok := RxMode_name[uint32(x)]
419 return "RxMode(" + strconv.Itoa(int(x)) + ")"
422 // SubIfFlags defines enum 'sub_if_flags'.
423 type SubIfFlags uint32
426 SUB_IF_API_FLAG_NO_TAGS SubIfFlags = 1
427 SUB_IF_API_FLAG_ONE_TAG SubIfFlags = 2
428 SUB_IF_API_FLAG_TWO_TAGS SubIfFlags = 4
429 SUB_IF_API_FLAG_DOT1AD SubIfFlags = 8
430 SUB_IF_API_FLAG_EXACT_MATCH SubIfFlags = 16
431 SUB_IF_API_FLAG_DEFAULT SubIfFlags = 32
432 SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY SubIfFlags = 64
433 SUB_IF_API_FLAG_INNER_VLAN_ID_ANY SubIfFlags = 128
434 SUB_IF_API_FLAG_MASK_VNET SubIfFlags = 254
435 SUB_IF_API_FLAG_DOT1AH SubIfFlags = 256
439 SubIfFlags_name = map[uint32]string{
440 1: "SUB_IF_API_FLAG_NO_TAGS",
441 2: "SUB_IF_API_FLAG_ONE_TAG",
442 4: "SUB_IF_API_FLAG_TWO_TAGS",
443 8: "SUB_IF_API_FLAG_DOT1AD",
444 16: "SUB_IF_API_FLAG_EXACT_MATCH",
445 32: "SUB_IF_API_FLAG_DEFAULT",
446 64: "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY",
447 128: "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY",
448 254: "SUB_IF_API_FLAG_MASK_VNET",
449 256: "SUB_IF_API_FLAG_DOT1AH",
451 SubIfFlags_value = map[string]uint32{
452 "SUB_IF_API_FLAG_NO_TAGS": 1,
453 "SUB_IF_API_FLAG_ONE_TAG": 2,
454 "SUB_IF_API_FLAG_TWO_TAGS": 4,
455 "SUB_IF_API_FLAG_DOT1AD": 8,
456 "SUB_IF_API_FLAG_EXACT_MATCH": 16,
457 "SUB_IF_API_FLAG_DEFAULT": 32,
458 "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY": 64,
459 "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY": 128,
460 "SUB_IF_API_FLAG_MASK_VNET": 254,
461 "SUB_IF_API_FLAG_DOT1AH": 256,
465 func (x SubIfFlags) String() string {
466 s, ok := SubIfFlags_name[uint32(x)]
470 str := func(n uint32) string {
471 s, ok := SubIfFlags_name[uint32(n)]
475 return "SubIfFlags(" + strconv.Itoa(int(n)) + ")"
477 for i := uint32(0); i <= 32; i++ {
487 return str(uint32(x))
492 // TapFlags defines enum 'tap_flags'.
496 TAP_FLAG_GSO TapFlags = 1
497 TAP_FLAG_CSUM_OFFLOAD TapFlags = 2
501 TapFlags_name = map[uint32]string{
503 2: "TAP_FLAG_CSUM_OFFLOAD",
505 TapFlags_value = map[string]uint32{
507 "TAP_FLAG_CSUM_OFFLOAD": 2,
511 func (x TapFlags) String() string {
512 s, ok := TapFlags_name[uint32(x)]
516 str := func(n uint32) string {
517 s, ok := TapFlags_name[uint32(n)]
521 return "TapFlags(" + strconv.Itoa(int(n)) + ")"
523 for i := uint32(0); i <= 32; i++ {
533 return str(uint32(x))
538 // AddressWithPrefix defines alias 'address_with_prefix'.
539 type AddressWithPrefix Prefix
541 func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) {
542 prefix, err := ParsePrefix(s)
544 return AddressWithPrefix{}, err
546 return AddressWithPrefix(prefix), nil
549 func (x AddressWithPrefix) String() string {
550 return Prefix(x).String()
553 func (x *AddressWithPrefix) MarshalText() ([]byte, error) {
554 return []byte(x.String()), nil
557 func (x *AddressWithPrefix) UnmarshalText(text []byte) error {
558 prefix, err := ParseAddressWithPrefix(string(text))
566 // InterfaceIndex defines alias 'interface_index'.
567 type InterfaceIndex uint32
569 // IP4Address defines alias 'ip4_address'.
570 type IP4Address [4]uint8
572 func ParseIP4Address(s string) (IP4Address, error) {
573 ip := net.ParseIP(s).To4()
575 return IP4Address{}, fmt.Errorf("invalid IP address: %s", s)
577 var ipaddr IP4Address
578 copy(ipaddr[:], ip.To4())
582 func (x IP4Address) ToIP() net.IP {
583 return net.IP(x[:]).To4()
586 func (x IP4Address) String() string {
587 return x.ToIP().String()
590 func (x *IP4Address) MarshalText() ([]byte, error) {
591 return []byte(x.String()), nil
594 func (x *IP4Address) UnmarshalText(text []byte) error {
595 ipaddr, err := ParseIP4Address(string(text))
603 // IP4AddressWithPrefix defines alias 'ip4_address_with_prefix'.
604 type IP4AddressWithPrefix IP4Prefix
606 // IP6Address defines alias 'ip6_address'.
607 type IP6Address [16]uint8
609 func ParseIP6Address(s string) (IP6Address, error) {
610 ip := net.ParseIP(s).To16()
612 return IP6Address{}, fmt.Errorf("invalid IP address: %s", s)
614 var ipaddr IP6Address
615 copy(ipaddr[:], ip.To16())
619 func (x IP6Address) ToIP() net.IP {
620 return net.IP(x[:]).To16()
623 func (x IP6Address) String() string {
624 return x.ToIP().String()
627 func (x *IP6Address) MarshalText() ([]byte, error) {
628 return []byte(x.String()), nil
631 func (x *IP6Address) UnmarshalText(text []byte) error {
632 ipaddr, err := ParseIP6Address(string(text))
640 // IP6AddressWithPrefix defines alias 'ip6_address_with_prefix'.
641 type IP6AddressWithPrefix IP6Prefix
643 // MacAddress defines alias 'mac_address'.
644 type MacAddress [6]uint8
646 func ParseMacAddress(s string) (MacAddress, error) {
647 var macaddr MacAddress
648 mac, err := net.ParseMAC(s)
652 copy(macaddr[:], mac[:])
656 func (x MacAddress) ToMAC() net.HardwareAddr {
657 return net.HardwareAddr(x[:])
660 func (x MacAddress) String() string {
661 return x.ToMAC().String()
664 func (x *MacAddress) MarshalText() ([]byte, error) {
665 return []byte(x.String()), nil
668 func (x *MacAddress) UnmarshalText(text []byte) error {
669 mac, err := ParseMacAddress(string(text))
677 // Address defines type 'address'.
678 type Address struct {
679 Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
680 Un AddressUnion `binapi:"address_union,name=un" json:"un,omitempty"`
683 func ParseAddress(s string) (Address, error) {
686 return Address{}, fmt.Errorf("invalid address: %s", s)
688 return AddressFromIP(ip), nil
691 func AddressFromIP(ip net.IP) Address {
694 addr.Af = ADDRESS_IP6
696 copy(ip6[:], ip.To16())
699 addr.Af = ADDRESS_IP4
701 copy(ip4[:], ip.To4())
707 func (x Address) ToIP() net.IP {
708 if x.Af == ADDRESS_IP6 {
710 return net.IP(ip6[:]).To16()
713 return net.IP(ip4[:]).To4()
717 func (x Address) String() string {
718 return x.ToIP().String()
721 func (x *Address) MarshalText() ([]byte, error) {
722 return []byte(x.String()), nil
725 func (x *Address) UnmarshalText(text []byte) error {
726 addr, err := ParseAddress(string(text))
734 // IP4Prefix defines type 'ip4_prefix'.
735 type IP4Prefix struct {
736 Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"`
737 Len uint8 `binapi:"u8,name=len" json:"len,omitempty"`
740 func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) {
741 hasPrefix := strings.Contains(s, "/")
743 ip, network, err := net.ParseCIDR(s)
745 return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
747 maskSize, _ := network.Mask.Size()
748 prefix.Len = byte(maskSize)
749 prefix.Address, err = ParseIP4Address(ip.String())
751 return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
755 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
757 defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
759 prefix.Len = byte(defaultMaskSize)
760 prefix.Address, err = ParseIP4Address(ip.String())
762 return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
768 func (x IP4Prefix) ToIPNet() *net.IPNet {
769 mask := net.CIDRMask(int(x.Len), 32)
770 ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
774 func (x IP4Prefix) String() string {
775 ip := x.Address.String()
776 return ip + "/" + strconv.Itoa(int(x.Len))
779 func (x *IP4Prefix) MarshalText() ([]byte, error) {
780 return []byte(x.String()), nil
783 func (x *IP4Prefix) UnmarshalText(text []byte) error {
784 prefix, err := ParseIP4Prefix(string(text))
792 // IP6Prefix defines type 'ip6_prefix'.
793 type IP6Prefix struct {
794 Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"`
795 Len uint8 `binapi:"u8,name=len" json:"len,omitempty"`
798 func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) {
799 hasPrefix := strings.Contains(s, "/")
801 ip, network, err := net.ParseCIDR(s)
803 return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
805 maskSize, _ := network.Mask.Size()
806 prefix.Len = byte(maskSize)
807 prefix.Address, err = ParseIP6Address(ip.String())
809 return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
813 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
815 defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
817 prefix.Len = byte(defaultMaskSize)
818 prefix.Address, err = ParseIP6Address(ip.String())
820 return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
826 func (x IP6Prefix) ToIPNet() *net.IPNet {
827 mask := net.CIDRMask(int(x.Len), 128)
828 ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
832 func (x IP6Prefix) String() string {
833 ip := x.Address.String()
834 return ip + "/" + strconv.Itoa(int(x.Len))
837 func (x *IP6Prefix) MarshalText() ([]byte, error) {
838 return []byte(x.String()), nil
841 func (x *IP6Prefix) UnmarshalText(text []byte) error {
842 prefix, err := ParseIP6Prefix(string(text))
850 // Mprefix defines type 'mprefix'.
851 type Mprefix struct {
852 Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
853 GrpAddressLength uint16 `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"`
854 GrpAddress AddressUnion `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"`
855 SrcAddress AddressUnion `binapi:"address_union,name=src_address" json:"src_address,omitempty"`
858 // Prefix defines type 'prefix'.
860 Address Address `binapi:"address,name=address" json:"address,omitempty"`
861 Len uint8 `binapi:"u8,name=len" json:"len,omitempty"`
864 func ParsePrefix(ip string) (prefix Prefix, err error) {
865 hasPrefix := strings.Contains(ip, "/")
867 netIP, network, err := net.ParseCIDR(ip)
869 return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
871 maskSize, _ := network.Mask.Size()
872 prefix.Len = byte(maskSize)
873 prefix.Address, err = ParseAddress(netIP.String())
875 return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
878 netIP := net.ParseIP(ip)
879 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
880 if netIP.To4() == nil {
881 defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
883 prefix.Len = byte(defaultMaskSize)
884 prefix.Address, err = ParseAddress(netIP.String())
886 return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
892 func (x Prefix) ToIPNet() *net.IPNet {
894 if x.Address.Af == ADDRESS_IP4 {
895 mask = net.CIDRMask(int(x.Len), 32)
897 mask = net.CIDRMask(int(x.Len), 128)
899 ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
903 func (x Prefix) String() string {
904 ip := x.Address.String()
905 return ip + "/" + strconv.Itoa(int(x.Len))
908 func (x *Prefix) MarshalText() ([]byte, error) {
909 return []byte(x.String()), nil
912 func (x *Prefix) UnmarshalText(text []byte) error {
913 prefix, err := ParsePrefix(string(text))
921 // PrefixMatcher defines type 'prefix_matcher'.
922 type PrefixMatcher struct {
923 Le uint8 `binapi:"u8,name=le" json:"le,omitempty"`
924 Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"`
927 // AddressUnion defines union 'address_union'.
928 type AddressUnion struct {
929 // AddressUnion can be one of:
932 XXX_UnionData [16]byte
935 func AddressUnionIP4(a IP4Address) (u AddressUnion) {
939 func (u *AddressUnion) SetIP4(a IP4Address) {
940 buf := codec.NewBuffer(u.XXX_UnionData[:])
941 buf.EncodeBytes(a[:], 4)
943 func (u *AddressUnion) GetIP4() (a IP4Address) {
944 buf := codec.NewBuffer(u.XXX_UnionData[:])
945 copy(a[:], buf.DecodeBytes(4))
949 func AddressUnionIP6(a IP6Address) (u AddressUnion) {
953 func (u *AddressUnion) SetIP6(a IP6Address) {
954 buf := codec.NewBuffer(u.XXX_UnionData[:])
955 buf.EncodeBytes(a[:], 16)
957 func (u *AddressUnion) GetIP6() (a IP6Address) {
958 buf := codec.NewBuffer(u.XXX_UnionData[:])
959 copy(a[:], buf.DecodeBytes(16))
963 // SwInterfaceTapV2Details defines message 'sw_interface_tap_v2_details'.
964 type SwInterfaceTapV2Details struct {
965 SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"`
966 ID uint32 `binapi:"u32,name=id" json:"id,omitempty"`
967 TxRingSz uint16 `binapi:"u16,name=tx_ring_sz" json:"tx_ring_sz,omitempty"`
968 RxRingSz uint16 `binapi:"u16,name=rx_ring_sz" json:"rx_ring_sz,omitempty"`
969 HostMtuSize uint32 `binapi:"u32,name=host_mtu_size" json:"host_mtu_size,omitempty"`
970 HostMacAddr MacAddress `binapi:"mac_address,name=host_mac_addr" json:"host_mac_addr,omitempty"`
971 HostIP4Prefix IP4AddressWithPrefix `binapi:"ip4_address_with_prefix,name=host_ip4_prefix" json:"host_ip4_prefix,omitempty"`
972 HostIP6Prefix IP6AddressWithPrefix `binapi:"ip6_address_with_prefix,name=host_ip6_prefix" json:"host_ip6_prefix,omitempty"`
973 TapFlags TapFlags `binapi:"tap_flags,name=tap_flags" json:"tap_flags,omitempty"`
974 DevName string `binapi:"string[64],name=dev_name" json:"dev_name,omitempty"`
975 HostIfName string `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty"`
976 HostNamespace string `binapi:"string[64],name=host_namespace" json:"host_namespace,omitempty"`
977 HostBridge string `binapi:"string[64],name=host_bridge" json:"host_bridge,omitempty"`
980 func (m *SwInterfaceTapV2Details) Reset() { *m = SwInterfaceTapV2Details{} }
981 func (*SwInterfaceTapV2Details) GetMessageName() string { return "sw_interface_tap_v2_details" }
982 func (*SwInterfaceTapV2Details) GetCrcString() string { return "e53c16de" }
983 func (*SwInterfaceTapV2Details) GetMessageType() api.MessageType {
984 return api.ReplyMessage
987 func (m *SwInterfaceTapV2Details) Size() (size int) {
991 size += 4 // m.SwIfIndex
993 size += 2 // m.TxRingSz
994 size += 2 // m.RxRingSz
995 size += 4 // m.HostMtuSize
996 size += 1 * 6 // m.HostMacAddr
997 size += 1 * 4 // m.HostIP4Prefix.Address
998 size += 1 // m.HostIP4Prefix.Len
999 size += 1 * 16 // m.HostIP6Prefix.Address
1000 size += 1 // m.HostIP6Prefix.Len
1001 size += 4 // m.TapFlags
1002 size += 64 // m.DevName
1003 size += 64 // m.HostIfName
1004 size += 64 // m.HostNamespace
1005 size += 64 // m.HostBridge
1008 func (m *SwInterfaceTapV2Details) Marshal(b []byte) ([]byte, error) {
1010 b = make([]byte, m.Size())
1012 buf := codec.NewBuffer(b)
1013 buf.EncodeUint32(m.SwIfIndex)
1014 buf.EncodeUint32(m.ID)
1015 buf.EncodeUint16(m.TxRingSz)
1016 buf.EncodeUint16(m.RxRingSz)
1017 buf.EncodeUint32(m.HostMtuSize)
1018 buf.EncodeBytes(m.HostMacAddr[:], 6)
1019 buf.EncodeBytes(m.HostIP4Prefix.Address[:], 4)
1020 buf.EncodeUint8(m.HostIP4Prefix.Len)
1021 buf.EncodeBytes(m.HostIP6Prefix.Address[:], 16)
1022 buf.EncodeUint8(m.HostIP6Prefix.Len)
1023 buf.EncodeUint32(uint32(m.TapFlags))
1024 buf.EncodeString(m.DevName, 64)
1025 buf.EncodeString(m.HostIfName, 64)
1026 buf.EncodeString(m.HostNamespace, 64)
1027 buf.EncodeString(m.HostBridge, 64)
1028 return buf.Bytes(), nil
1030 func (m *SwInterfaceTapV2Details) Unmarshal(b []byte) error {
1031 buf := codec.NewBuffer(b)
1032 m.SwIfIndex = buf.DecodeUint32()
1033 m.ID = buf.DecodeUint32()
1034 m.TxRingSz = buf.DecodeUint16()
1035 m.RxRingSz = buf.DecodeUint16()
1036 m.HostMtuSize = buf.DecodeUint32()
1037 copy(m.HostMacAddr[:], buf.DecodeBytes(6))
1038 copy(m.HostIP4Prefix.Address[:], buf.DecodeBytes(4))
1039 m.HostIP4Prefix.Len = buf.DecodeUint8()
1040 copy(m.HostIP6Prefix.Address[:], buf.DecodeBytes(16))
1041 m.HostIP6Prefix.Len = buf.DecodeUint8()
1042 m.TapFlags = TapFlags(buf.DecodeUint32())
1043 m.DevName = buf.DecodeString(64)
1044 m.HostIfName = buf.DecodeString(64)
1045 m.HostNamespace = buf.DecodeString(64)
1046 m.HostBridge = buf.DecodeString(64)
1050 // SwInterfaceTapV2Dump defines message 'sw_interface_tap_v2_dump'.
1051 type SwInterfaceTapV2Dump struct {
1052 SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"`
1055 func (m *SwInterfaceTapV2Dump) Reset() { *m = SwInterfaceTapV2Dump{} }
1056 func (*SwInterfaceTapV2Dump) GetMessageName() string { return "sw_interface_tap_v2_dump" }
1057 func (*SwInterfaceTapV2Dump) GetCrcString() string { return "f9e6675e" }
1058 func (*SwInterfaceTapV2Dump) GetMessageType() api.MessageType {
1059 return api.RequestMessage
1062 func (m *SwInterfaceTapV2Dump) Size() (size int) {
1066 size += 4 // m.SwIfIndex
1069 func (m *SwInterfaceTapV2Dump) Marshal(b []byte) ([]byte, error) {
1071 b = make([]byte, m.Size())
1073 buf := codec.NewBuffer(b)
1074 buf.EncodeUint32(uint32(m.SwIfIndex))
1075 return buf.Bytes(), nil
1077 func (m *SwInterfaceTapV2Dump) Unmarshal(b []byte) error {
1078 buf := codec.NewBuffer(b)
1079 m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1083 // TapCreateV2 defines message 'tap_create_v2'.
1084 type TapCreateV2 struct {
1085 ID uint32 `binapi:"u32,name=id,default=4294967295" json:"id,omitempty"`
1086 UseRandomMac bool `binapi:"bool,name=use_random_mac,default=true" json:"use_random_mac,omitempty"`
1087 MacAddress MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"`
1088 NumRxQueues uint8 `binapi:"u8,name=num_rx_queues,default=1" json:"num_rx_queues,omitempty"`
1089 TxRingSz uint16 `binapi:"u16,name=tx_ring_sz" json:"tx_ring_sz,omitempty"`
1090 RxRingSz uint16 `binapi:"u16,name=rx_ring_sz" json:"rx_ring_sz,omitempty"`
1091 HostMtuSet bool `binapi:"bool,name=host_mtu_set" json:"host_mtu_set,omitempty"`
1092 HostMtuSize uint32 `binapi:"u32,name=host_mtu_size" json:"host_mtu_size,omitempty"`
1093 HostMacAddrSet bool `binapi:"bool,name=host_mac_addr_set" json:"host_mac_addr_set,omitempty"`
1094 HostMacAddr MacAddress `binapi:"mac_address,name=host_mac_addr" json:"host_mac_addr,omitempty"`
1095 HostIP4PrefixSet bool `binapi:"bool,name=host_ip4_prefix_set" json:"host_ip4_prefix_set,omitempty"`
1096 HostIP4Prefix IP4AddressWithPrefix `binapi:"ip4_address_with_prefix,name=host_ip4_prefix" json:"host_ip4_prefix,omitempty"`
1097 HostIP6PrefixSet bool `binapi:"bool,name=host_ip6_prefix_set" json:"host_ip6_prefix_set,omitempty"`
1098 HostIP6Prefix IP6AddressWithPrefix `binapi:"ip6_address_with_prefix,name=host_ip6_prefix" json:"host_ip6_prefix,omitempty"`
1099 HostIP4GwSet bool `binapi:"bool,name=host_ip4_gw_set" json:"host_ip4_gw_set,omitempty"`
1100 HostIP4Gw IP4Address `binapi:"ip4_address,name=host_ip4_gw" json:"host_ip4_gw,omitempty"`
1101 HostIP6GwSet bool `binapi:"bool,name=host_ip6_gw_set" json:"host_ip6_gw_set,omitempty"`
1102 HostIP6Gw IP6Address `binapi:"ip6_address,name=host_ip6_gw" json:"host_ip6_gw,omitempty"`
1103 TapFlags TapFlags `binapi:"tap_flags,name=tap_flags" json:"tap_flags,omitempty"`
1104 HostNamespaceSet bool `binapi:"bool,name=host_namespace_set" json:"host_namespace_set,omitempty"`
1105 HostNamespace string `binapi:"string[64],name=host_namespace" json:"host_namespace,omitempty"`
1106 HostIfNameSet bool `binapi:"bool,name=host_if_name_set" json:"host_if_name_set,omitempty"`
1107 HostIfName string `binapi:"string[64],name=host_if_name" json:"host_if_name,omitempty"`
1108 HostBridgeSet bool `binapi:"bool,name=host_bridge_set" json:"host_bridge_set,omitempty"`
1109 HostBridge string `binapi:"string[64],name=host_bridge" json:"host_bridge,omitempty"`
1110 Tag string `binapi:"string[],name=tag" json:"tag,omitempty"`
1113 func (m *TapCreateV2) Reset() { *m = TapCreateV2{} }
1114 func (*TapCreateV2) GetMessageName() string { return "tap_create_v2" }
1115 func (*TapCreateV2) GetCrcString() string { return "445835fd" }
1116 func (*TapCreateV2) GetMessageType() api.MessageType {
1117 return api.RequestMessage
1120 func (m *TapCreateV2) Size() (size int) {
1125 size += 1 // m.UseRandomMac
1126 size += 1 * 6 // m.MacAddress
1127 size += 1 // m.NumRxQueues
1128 size += 2 // m.TxRingSz
1129 size += 2 // m.RxRingSz
1130 size += 1 // m.HostMtuSet
1131 size += 4 // m.HostMtuSize
1132 size += 1 // m.HostMacAddrSet
1133 size += 1 * 6 // m.HostMacAddr
1134 size += 1 // m.HostIP4PrefixSet
1135 size += 1 * 4 // m.HostIP4Prefix.Address
1136 size += 1 // m.HostIP4Prefix.Len
1137 size += 1 // m.HostIP6PrefixSet
1138 size += 1 * 16 // m.HostIP6Prefix.Address
1139 size += 1 // m.HostIP6Prefix.Len
1140 size += 1 // m.HostIP4GwSet
1141 size += 1 * 4 // m.HostIP4Gw
1142 size += 1 // m.HostIP6GwSet
1143 size += 1 * 16 // m.HostIP6Gw
1144 size += 4 // m.TapFlags
1145 size += 1 // m.HostNamespaceSet
1146 size += 64 // m.HostNamespace
1147 size += 1 // m.HostIfNameSet
1148 size += 64 // m.HostIfName
1149 size += 1 // m.HostBridgeSet
1150 size += 64 // m.HostBridge
1151 size += 4 + len(m.Tag) // m.Tag
1154 func (m *TapCreateV2) Marshal(b []byte) ([]byte, error) {
1156 b = make([]byte, m.Size())
1158 buf := codec.NewBuffer(b)
1159 buf.EncodeUint32(m.ID)
1160 buf.EncodeBool(m.UseRandomMac)
1161 buf.EncodeBytes(m.MacAddress[:], 6)
1162 buf.EncodeUint8(m.NumRxQueues)
1163 buf.EncodeUint16(m.TxRingSz)
1164 buf.EncodeUint16(m.RxRingSz)
1165 buf.EncodeBool(m.HostMtuSet)
1166 buf.EncodeUint32(m.HostMtuSize)
1167 buf.EncodeBool(m.HostMacAddrSet)
1168 buf.EncodeBytes(m.HostMacAddr[:], 6)
1169 buf.EncodeBool(m.HostIP4PrefixSet)
1170 buf.EncodeBytes(m.HostIP4Prefix.Address[:], 4)
1171 buf.EncodeUint8(m.HostIP4Prefix.Len)
1172 buf.EncodeBool(m.HostIP6PrefixSet)
1173 buf.EncodeBytes(m.HostIP6Prefix.Address[:], 16)
1174 buf.EncodeUint8(m.HostIP6Prefix.Len)
1175 buf.EncodeBool(m.HostIP4GwSet)
1176 buf.EncodeBytes(m.HostIP4Gw[:], 4)
1177 buf.EncodeBool(m.HostIP6GwSet)
1178 buf.EncodeBytes(m.HostIP6Gw[:], 16)
1179 buf.EncodeUint32(uint32(m.TapFlags))
1180 buf.EncodeBool(m.HostNamespaceSet)
1181 buf.EncodeString(m.HostNamespace, 64)
1182 buf.EncodeBool(m.HostIfNameSet)
1183 buf.EncodeString(m.HostIfName, 64)
1184 buf.EncodeBool(m.HostBridgeSet)
1185 buf.EncodeString(m.HostBridge, 64)
1186 buf.EncodeString(m.Tag, 0)
1187 return buf.Bytes(), nil
1189 func (m *TapCreateV2) Unmarshal(b []byte) error {
1190 buf := codec.NewBuffer(b)
1191 m.ID = buf.DecodeUint32()
1192 m.UseRandomMac = buf.DecodeBool()
1193 copy(m.MacAddress[:], buf.DecodeBytes(6))
1194 m.NumRxQueues = buf.DecodeUint8()
1195 m.TxRingSz = buf.DecodeUint16()
1196 m.RxRingSz = buf.DecodeUint16()
1197 m.HostMtuSet = buf.DecodeBool()
1198 m.HostMtuSize = buf.DecodeUint32()
1199 m.HostMacAddrSet = buf.DecodeBool()
1200 copy(m.HostMacAddr[:], buf.DecodeBytes(6))
1201 m.HostIP4PrefixSet = buf.DecodeBool()
1202 copy(m.HostIP4Prefix.Address[:], buf.DecodeBytes(4))
1203 m.HostIP4Prefix.Len = buf.DecodeUint8()
1204 m.HostIP6PrefixSet = buf.DecodeBool()
1205 copy(m.HostIP6Prefix.Address[:], buf.DecodeBytes(16))
1206 m.HostIP6Prefix.Len = buf.DecodeUint8()
1207 m.HostIP4GwSet = buf.DecodeBool()
1208 copy(m.HostIP4Gw[:], buf.DecodeBytes(4))
1209 m.HostIP6GwSet = buf.DecodeBool()
1210 copy(m.HostIP6Gw[:], buf.DecodeBytes(16))
1211 m.TapFlags = TapFlags(buf.DecodeUint32())
1212 m.HostNamespaceSet = buf.DecodeBool()
1213 m.HostNamespace = buf.DecodeString(64)
1214 m.HostIfNameSet = buf.DecodeBool()
1215 m.HostIfName = buf.DecodeString(64)
1216 m.HostBridgeSet = buf.DecodeBool()
1217 m.HostBridge = buf.DecodeString(64)
1218 m.Tag = buf.DecodeString(0)
1222 // TapCreateV2Reply defines message 'tap_create_v2_reply'.
1223 type TapCreateV2Reply struct {
1224 Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
1225 SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1228 func (m *TapCreateV2Reply) Reset() { *m = TapCreateV2Reply{} }
1229 func (*TapCreateV2Reply) GetMessageName() string { return "tap_create_v2_reply" }
1230 func (*TapCreateV2Reply) GetCrcString() string { return "5383d31f" }
1231 func (*TapCreateV2Reply) GetMessageType() api.MessageType {
1232 return api.ReplyMessage
1235 func (m *TapCreateV2Reply) Size() (size int) {
1239 size += 4 // m.Retval
1240 size += 4 // m.SwIfIndex
1243 func (m *TapCreateV2Reply) Marshal(b []byte) ([]byte, error) {
1245 b = make([]byte, m.Size())
1247 buf := codec.NewBuffer(b)
1248 buf.EncodeInt32(m.Retval)
1249 buf.EncodeUint32(uint32(m.SwIfIndex))
1250 return buf.Bytes(), nil
1252 func (m *TapCreateV2Reply) Unmarshal(b []byte) error {
1253 buf := codec.NewBuffer(b)
1254 m.Retval = buf.DecodeInt32()
1255 m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1259 // TapDeleteV2 defines message 'tap_delete_v2'.
1260 type TapDeleteV2 struct {
1261 SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1264 func (m *TapDeleteV2) Reset() { *m = TapDeleteV2{} }
1265 func (*TapDeleteV2) GetMessageName() string { return "tap_delete_v2" }
1266 func (*TapDeleteV2) GetCrcString() string { return "f9e6675e" }
1267 func (*TapDeleteV2) GetMessageType() api.MessageType {
1268 return api.RequestMessage
1271 func (m *TapDeleteV2) Size() (size int) {
1275 size += 4 // m.SwIfIndex
1278 func (m *TapDeleteV2) Marshal(b []byte) ([]byte, error) {
1280 b = make([]byte, m.Size())
1282 buf := codec.NewBuffer(b)
1283 buf.EncodeUint32(uint32(m.SwIfIndex))
1284 return buf.Bytes(), nil
1286 func (m *TapDeleteV2) Unmarshal(b []byte) error {
1287 buf := codec.NewBuffer(b)
1288 m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1292 // TapDeleteV2Reply defines message 'tap_delete_v2_reply'.
1293 type TapDeleteV2Reply struct {
1294 Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
1297 func (m *TapDeleteV2Reply) Reset() { *m = TapDeleteV2Reply{} }
1298 func (*TapDeleteV2Reply) GetMessageName() string { return "tap_delete_v2_reply" }
1299 func (*TapDeleteV2Reply) GetCrcString() string { return "e8d4e804" }
1300 func (*TapDeleteV2Reply) GetMessageType() api.MessageType {
1301 return api.ReplyMessage
1304 func (m *TapDeleteV2Reply) Size() (size int) {
1308 size += 4 // m.Retval
1311 func (m *TapDeleteV2Reply) Marshal(b []byte) ([]byte, error) {
1313 b = make([]byte, m.Size())
1315 buf := codec.NewBuffer(b)
1316 buf.EncodeInt32(m.Retval)
1317 return buf.Bytes(), nil
1319 func (m *TapDeleteV2Reply) Unmarshal(b []byte) error {
1320 buf := codec.NewBuffer(b)
1321 m.Retval = buf.DecodeInt32()
1325 func init() { file_tapv2_binapi_init() }
1326 func file_tapv2_binapi_init() {
1327 api.RegisterMessage((*SwInterfaceTapV2Details)(nil), "sw_interface_tap_v2_details_e53c16de")
1328 api.RegisterMessage((*SwInterfaceTapV2Dump)(nil), "sw_interface_tap_v2_dump_f9e6675e")
1329 api.RegisterMessage((*TapCreateV2)(nil), "tap_create_v2_445835fd")
1330 api.RegisterMessage((*TapCreateV2Reply)(nil), "tap_create_v2_reply_5383d31f")
1331 api.RegisterMessage((*TapDeleteV2)(nil), "tap_delete_v2_f9e6675e")
1332 api.RegisterMessage((*TapDeleteV2Reply)(nil), "tap_delete_v2_reply_e8d4e804")
1335 // Messages returns list of all messages in this module.
1336 func AllMessages() []api.Message {
1337 return []api.Message{
1338 (*SwInterfaceTapV2Details)(nil),
1339 (*SwInterfaceTapV2Dump)(nil),
1340 (*TapCreateV2)(nil),
1341 (*TapCreateV2Reply)(nil),
1342 (*TapDeleteV2)(nil),
1343 (*TapDeleteV2Reply)(nil),