1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
3 // binapi-generator: v0.4.0-dev
5 // source: .vppapi/plugins/pppoe.api.json
7 // Package pppoe contains generated bindings for API file pppoe.api.
20 api "git.fd.io/govpp.git/api"
21 codec "git.fd.io/govpp.git/codec"
27 // This is a compile-time assertion to ensure that this generated file
28 // is compatible with the GoVPP api package it is being compiled against.
29 // A compilation error at this line likely means your copy of the
30 // GoVPP api package needs to be updated.
31 const _ = api.GoVppAPIPackageIsVersion2
36 VersionCrc = 0xb83e4d5f
39 // AddressFamily defines enum 'address_family'.
40 type AddressFamily uint32
43 ADDRESS_IP4 AddressFamily = 0
44 ADDRESS_IP6 AddressFamily = 1
48 AddressFamily_name = map[uint32]string{
52 AddressFamily_value = map[string]uint32{
58 func (x AddressFamily) String() string {
59 s, ok := AddressFamily_name[uint32(x)]
63 return "AddressFamily(" + strconv.Itoa(int(x)) + ")"
66 // IfStatusFlags defines enum 'if_status_flags'.
67 type IfStatusFlags uint32
70 IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1
71 IF_STATUS_API_FLAG_LINK_UP IfStatusFlags = 2
75 IfStatusFlags_name = map[uint32]string{
76 1: "IF_STATUS_API_FLAG_ADMIN_UP",
77 2: "IF_STATUS_API_FLAG_LINK_UP",
79 IfStatusFlags_value = map[string]uint32{
80 "IF_STATUS_API_FLAG_ADMIN_UP": 1,
81 "IF_STATUS_API_FLAG_LINK_UP": 2,
85 func (x IfStatusFlags) String() string {
86 s, ok := IfStatusFlags_name[uint32(x)]
90 str := func(n uint32) string {
91 s, ok := IfStatusFlags_name[uint32(n)]
95 return "IfStatusFlags(" + strconv.Itoa(int(n)) + ")"
97 for i := uint32(0); i <= 32; i++ {
107 return str(uint32(x))
112 // IfType defines enum 'if_type'.
116 IF_API_TYPE_HARDWARE IfType = 1
117 IF_API_TYPE_SUB IfType = 2
118 IF_API_TYPE_P2P IfType = 3
119 IF_API_TYPE_PIPE IfType = 4
123 IfType_name = map[uint32]string{
124 1: "IF_API_TYPE_HARDWARE",
125 2: "IF_API_TYPE_SUB",
126 3: "IF_API_TYPE_P2P",
127 4: "IF_API_TYPE_PIPE",
129 IfType_value = map[string]uint32{
130 "IF_API_TYPE_HARDWARE": 1,
131 "IF_API_TYPE_SUB": 2,
132 "IF_API_TYPE_P2P": 3,
133 "IF_API_TYPE_PIPE": 4,
137 func (x IfType) String() string {
138 s, ok := IfType_name[uint32(x)]
142 return "IfType(" + strconv.Itoa(int(x)) + ")"
145 // IPDscp defines enum 'ip_dscp'.
149 IP_API_DSCP_CS0 IPDscp = 0
150 IP_API_DSCP_CS1 IPDscp = 8
151 IP_API_DSCP_AF11 IPDscp = 10
152 IP_API_DSCP_AF12 IPDscp = 12
153 IP_API_DSCP_AF13 IPDscp = 14
154 IP_API_DSCP_CS2 IPDscp = 16
155 IP_API_DSCP_AF21 IPDscp = 18
156 IP_API_DSCP_AF22 IPDscp = 20
157 IP_API_DSCP_AF23 IPDscp = 22
158 IP_API_DSCP_CS3 IPDscp = 24
159 IP_API_DSCP_AF31 IPDscp = 26
160 IP_API_DSCP_AF32 IPDscp = 28
161 IP_API_DSCP_AF33 IPDscp = 30
162 IP_API_DSCP_CS4 IPDscp = 32
163 IP_API_DSCP_AF41 IPDscp = 34
164 IP_API_DSCP_AF42 IPDscp = 36
165 IP_API_DSCP_AF43 IPDscp = 38
166 IP_API_DSCP_CS5 IPDscp = 40
167 IP_API_DSCP_EF IPDscp = 46
168 IP_API_DSCP_CS6 IPDscp = 48
169 IP_API_DSCP_CS7 IPDscp = 50
173 IPDscp_name = map[uint8]string{
174 0: "IP_API_DSCP_CS0",
175 8: "IP_API_DSCP_CS1",
176 10: "IP_API_DSCP_AF11",
177 12: "IP_API_DSCP_AF12",
178 14: "IP_API_DSCP_AF13",
179 16: "IP_API_DSCP_CS2",
180 18: "IP_API_DSCP_AF21",
181 20: "IP_API_DSCP_AF22",
182 22: "IP_API_DSCP_AF23",
183 24: "IP_API_DSCP_CS3",
184 26: "IP_API_DSCP_AF31",
185 28: "IP_API_DSCP_AF32",
186 30: "IP_API_DSCP_AF33",
187 32: "IP_API_DSCP_CS4",
188 34: "IP_API_DSCP_AF41",
189 36: "IP_API_DSCP_AF42",
190 38: "IP_API_DSCP_AF43",
191 40: "IP_API_DSCP_CS5",
192 46: "IP_API_DSCP_EF",
193 48: "IP_API_DSCP_CS6",
194 50: "IP_API_DSCP_CS7",
196 IPDscp_value = map[string]uint8{
197 "IP_API_DSCP_CS0": 0,
198 "IP_API_DSCP_CS1": 8,
199 "IP_API_DSCP_AF11": 10,
200 "IP_API_DSCP_AF12": 12,
201 "IP_API_DSCP_AF13": 14,
202 "IP_API_DSCP_CS2": 16,
203 "IP_API_DSCP_AF21": 18,
204 "IP_API_DSCP_AF22": 20,
205 "IP_API_DSCP_AF23": 22,
206 "IP_API_DSCP_CS3": 24,
207 "IP_API_DSCP_AF31": 26,
208 "IP_API_DSCP_AF32": 28,
209 "IP_API_DSCP_AF33": 30,
210 "IP_API_DSCP_CS4": 32,
211 "IP_API_DSCP_AF41": 34,
212 "IP_API_DSCP_AF42": 36,
213 "IP_API_DSCP_AF43": 38,
214 "IP_API_DSCP_CS5": 40,
215 "IP_API_DSCP_EF": 46,
216 "IP_API_DSCP_CS6": 48,
217 "IP_API_DSCP_CS7": 50,
221 func (x IPDscp) String() string {
222 s, ok := IPDscp_name[uint8(x)]
226 return "IPDscp(" + strconv.Itoa(int(x)) + ")"
229 // IPEcn defines enum 'ip_ecn'.
233 IP_API_ECN_NONE IPEcn = 0
234 IP_API_ECN_ECT0 IPEcn = 1
235 IP_API_ECN_ECT1 IPEcn = 2
236 IP_API_ECN_CE IPEcn = 3
240 IPEcn_name = map[uint8]string{
241 0: "IP_API_ECN_NONE",
242 1: "IP_API_ECN_ECT0",
243 2: "IP_API_ECN_ECT1",
246 IPEcn_value = map[string]uint8{
247 "IP_API_ECN_NONE": 0,
248 "IP_API_ECN_ECT0": 1,
249 "IP_API_ECN_ECT1": 2,
254 func (x IPEcn) String() string {
255 s, ok := IPEcn_name[uint8(x)]
259 return "IPEcn(" + strconv.Itoa(int(x)) + ")"
262 // IPProto defines enum 'ip_proto'.
266 IP_API_PROTO_HOPOPT IPProto = 0
267 IP_API_PROTO_ICMP IPProto = 1
268 IP_API_PROTO_IGMP IPProto = 2
269 IP_API_PROTO_TCP IPProto = 6
270 IP_API_PROTO_UDP IPProto = 17
271 IP_API_PROTO_GRE IPProto = 47
272 IP_API_PROTO_AH IPProto = 50
273 IP_API_PROTO_ESP IPProto = 51
274 IP_API_PROTO_EIGRP IPProto = 88
275 IP_API_PROTO_OSPF IPProto = 89
276 IP_API_PROTO_SCTP IPProto = 132
277 IP_API_PROTO_RESERVED IPProto = 255
281 IPProto_name = map[uint32]string{
282 0: "IP_API_PROTO_HOPOPT",
283 1: "IP_API_PROTO_ICMP",
284 2: "IP_API_PROTO_IGMP",
285 6: "IP_API_PROTO_TCP",
286 17: "IP_API_PROTO_UDP",
287 47: "IP_API_PROTO_GRE",
288 50: "IP_API_PROTO_AH",
289 51: "IP_API_PROTO_ESP",
290 88: "IP_API_PROTO_EIGRP",
291 89: "IP_API_PROTO_OSPF",
292 132: "IP_API_PROTO_SCTP",
293 255: "IP_API_PROTO_RESERVED",
295 IPProto_value = map[string]uint32{
296 "IP_API_PROTO_HOPOPT": 0,
297 "IP_API_PROTO_ICMP": 1,
298 "IP_API_PROTO_IGMP": 2,
299 "IP_API_PROTO_TCP": 6,
300 "IP_API_PROTO_UDP": 17,
301 "IP_API_PROTO_GRE": 47,
302 "IP_API_PROTO_AH": 50,
303 "IP_API_PROTO_ESP": 51,
304 "IP_API_PROTO_EIGRP": 88,
305 "IP_API_PROTO_OSPF": 89,
306 "IP_API_PROTO_SCTP": 132,
307 "IP_API_PROTO_RESERVED": 255,
311 func (x IPProto) String() string {
312 s, ok := IPProto_name[uint32(x)]
316 return "IPProto(" + strconv.Itoa(int(x)) + ")"
319 // LinkDuplex defines enum 'link_duplex'.
320 type LinkDuplex uint32
323 LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0
324 LINK_DUPLEX_API_HALF LinkDuplex = 1
325 LINK_DUPLEX_API_FULL LinkDuplex = 2
329 LinkDuplex_name = map[uint32]string{
330 0: "LINK_DUPLEX_API_UNKNOWN",
331 1: "LINK_DUPLEX_API_HALF",
332 2: "LINK_DUPLEX_API_FULL",
334 LinkDuplex_value = map[string]uint32{
335 "LINK_DUPLEX_API_UNKNOWN": 0,
336 "LINK_DUPLEX_API_HALF": 1,
337 "LINK_DUPLEX_API_FULL": 2,
341 func (x LinkDuplex) String() string {
342 s, ok := LinkDuplex_name[uint32(x)]
346 return "LinkDuplex(" + strconv.Itoa(int(x)) + ")"
349 // MtuProto defines enum 'mtu_proto'.
353 MTU_PROTO_API_L3 MtuProto = 1
354 MTU_PROTO_API_IP4 MtuProto = 2
355 MTU_PROTO_API_IP6 MtuProto = 3
356 MTU_PROTO_API_MPLS MtuProto = 4
357 MTU_PROTO_API_N MtuProto = 5
361 MtuProto_name = map[uint32]string{
362 1: "MTU_PROTO_API_L3",
363 2: "MTU_PROTO_API_IP4",
364 3: "MTU_PROTO_API_IP6",
365 4: "MTU_PROTO_API_MPLS",
366 5: "MTU_PROTO_API_N",
368 MtuProto_value = map[string]uint32{
369 "MTU_PROTO_API_L3": 1,
370 "MTU_PROTO_API_IP4": 2,
371 "MTU_PROTO_API_IP6": 3,
372 "MTU_PROTO_API_MPLS": 4,
373 "MTU_PROTO_API_N": 5,
377 func (x MtuProto) String() string {
378 s, ok := MtuProto_name[uint32(x)]
382 return "MtuProto(" + strconv.Itoa(int(x)) + ")"
385 // RxMode defines enum 'rx_mode'.
389 RX_MODE_API_UNKNOWN RxMode = 0
390 RX_MODE_API_POLLING RxMode = 1
391 RX_MODE_API_INTERRUPT RxMode = 2
392 RX_MODE_API_ADAPTIVE RxMode = 3
393 RX_MODE_API_DEFAULT RxMode = 4
397 RxMode_name = map[uint32]string{
398 0: "RX_MODE_API_UNKNOWN",
399 1: "RX_MODE_API_POLLING",
400 2: "RX_MODE_API_INTERRUPT",
401 3: "RX_MODE_API_ADAPTIVE",
402 4: "RX_MODE_API_DEFAULT",
404 RxMode_value = map[string]uint32{
405 "RX_MODE_API_UNKNOWN": 0,
406 "RX_MODE_API_POLLING": 1,
407 "RX_MODE_API_INTERRUPT": 2,
408 "RX_MODE_API_ADAPTIVE": 3,
409 "RX_MODE_API_DEFAULT": 4,
413 func (x RxMode) String() string {
414 s, ok := RxMode_name[uint32(x)]
418 return "RxMode(" + strconv.Itoa(int(x)) + ")"
421 // SubIfFlags defines enum 'sub_if_flags'.
422 type SubIfFlags uint32
425 SUB_IF_API_FLAG_NO_TAGS SubIfFlags = 1
426 SUB_IF_API_FLAG_ONE_TAG SubIfFlags = 2
427 SUB_IF_API_FLAG_TWO_TAGS SubIfFlags = 4
428 SUB_IF_API_FLAG_DOT1AD SubIfFlags = 8
429 SUB_IF_API_FLAG_EXACT_MATCH SubIfFlags = 16
430 SUB_IF_API_FLAG_DEFAULT SubIfFlags = 32
431 SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY SubIfFlags = 64
432 SUB_IF_API_FLAG_INNER_VLAN_ID_ANY SubIfFlags = 128
433 SUB_IF_API_FLAG_MASK_VNET SubIfFlags = 254
434 SUB_IF_API_FLAG_DOT1AH SubIfFlags = 256
438 SubIfFlags_name = map[uint32]string{
439 1: "SUB_IF_API_FLAG_NO_TAGS",
440 2: "SUB_IF_API_FLAG_ONE_TAG",
441 4: "SUB_IF_API_FLAG_TWO_TAGS",
442 8: "SUB_IF_API_FLAG_DOT1AD",
443 16: "SUB_IF_API_FLAG_EXACT_MATCH",
444 32: "SUB_IF_API_FLAG_DEFAULT",
445 64: "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY",
446 128: "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY",
447 254: "SUB_IF_API_FLAG_MASK_VNET",
448 256: "SUB_IF_API_FLAG_DOT1AH",
450 SubIfFlags_value = map[string]uint32{
451 "SUB_IF_API_FLAG_NO_TAGS": 1,
452 "SUB_IF_API_FLAG_ONE_TAG": 2,
453 "SUB_IF_API_FLAG_TWO_TAGS": 4,
454 "SUB_IF_API_FLAG_DOT1AD": 8,
455 "SUB_IF_API_FLAG_EXACT_MATCH": 16,
456 "SUB_IF_API_FLAG_DEFAULT": 32,
457 "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY": 64,
458 "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY": 128,
459 "SUB_IF_API_FLAG_MASK_VNET": 254,
460 "SUB_IF_API_FLAG_DOT1AH": 256,
464 func (x SubIfFlags) String() string {
465 s, ok := SubIfFlags_name[uint32(x)]
469 str := func(n uint32) string {
470 s, ok := SubIfFlags_name[uint32(n)]
474 return "SubIfFlags(" + strconv.Itoa(int(n)) + ")"
476 for i := uint32(0); i <= 32; i++ {
486 return str(uint32(x))
491 // AddressWithPrefix defines alias 'address_with_prefix'.
492 type AddressWithPrefix Prefix
494 func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) {
495 prefix, err := ParsePrefix(s)
497 return AddressWithPrefix{}, err
499 return AddressWithPrefix(prefix), nil
501 func (x AddressWithPrefix) String() string {
502 return Prefix(x).String()
504 func (x *AddressWithPrefix) MarshalText() ([]byte, error) {
505 return []byte(x.String()), nil
507 func (x *AddressWithPrefix) UnmarshalText(text []byte) error {
508 prefix, err := ParseAddressWithPrefix(string(text))
516 // InterfaceIndex defines alias 'interface_index'.
517 type InterfaceIndex uint32
519 // IP4Address defines alias 'ip4_address'.
520 type IP4Address [4]uint8
522 func ParseIP4Address(s string) (IP4Address, error) {
523 ip := net.ParseIP(s).To4()
525 return IP4Address{}, fmt.Errorf("invalid IP address: %s", s)
527 var ipaddr IP4Address
528 copy(ipaddr[:], ip.To4())
532 func (x IP4Address) ToIP() net.IP {
533 return net.IP(x[:]).To4()
535 func (x IP4Address) String() string {
536 return x.ToIP().String()
538 func (x *IP4Address) MarshalText() ([]byte, error) {
539 return []byte(x.String()), nil
541 func (x *IP4Address) UnmarshalText(text []byte) error {
542 ipaddr, err := ParseIP4Address(string(text))
550 // IP4AddressWithPrefix defines alias 'ip4_address_with_prefix'.
551 type IP4AddressWithPrefix IP4Prefix
553 // IP6Address defines alias 'ip6_address'.
554 type IP6Address [16]uint8
556 func ParseIP6Address(s string) (IP6Address, error) {
557 ip := net.ParseIP(s).To16()
559 return IP6Address{}, fmt.Errorf("invalid IP address: %s", s)
561 var ipaddr IP6Address
562 copy(ipaddr[:], ip.To16())
566 func (x IP6Address) ToIP() net.IP {
567 return net.IP(x[:]).To16()
569 func (x IP6Address) String() string {
570 return x.ToIP().String()
572 func (x *IP6Address) MarshalText() ([]byte, error) {
573 return []byte(x.String()), nil
575 func (x *IP6Address) UnmarshalText(text []byte) error {
576 ipaddr, err := ParseIP6Address(string(text))
584 // IP6AddressWithPrefix defines alias 'ip6_address_with_prefix'.
585 type IP6AddressWithPrefix IP6Prefix
587 // MacAddress defines alias 'mac_address'.
588 type MacAddress [6]uint8
590 func ParseMacAddress(s string) (MacAddress, error) {
591 var macaddr MacAddress
592 mac, err := net.ParseMAC(s)
596 copy(macaddr[:], mac[:])
599 func (x MacAddress) ToMAC() net.HardwareAddr {
600 return net.HardwareAddr(x[:])
602 func (x MacAddress) String() string {
603 return x.ToMAC().String()
605 func (x *MacAddress) MarshalText() ([]byte, error) {
606 return []byte(x.String()), nil
608 func (x *MacAddress) UnmarshalText(text []byte) error {
609 mac, err := ParseMacAddress(string(text))
617 // Address defines type 'address'.
618 type Address struct {
619 Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
620 Un AddressUnion `binapi:"address_union,name=un" json:"un,omitempty"`
623 func ParseAddress(s string) (Address, error) {
626 return Address{}, fmt.Errorf("invalid address: %s", s)
630 addr.Af = ADDRESS_IP6
632 copy(ip6[:], ip.To16())
635 addr.Af = ADDRESS_IP4
637 copy(ip4[:], ip.To4())
642 func (x Address) ToIP() net.IP {
643 if x.Af == ADDRESS_IP6 {
645 return net.IP(ip6[:]).To16()
648 return net.IP(ip4[:]).To4()
651 func (x Address) String() string {
652 return x.ToIP().String()
654 func (x *Address) MarshalText() ([]byte, error) {
655 return []byte(x.String()), nil
657 func (x *Address) UnmarshalText(text []byte) error {
658 addr, err := ParseAddress(string(text))
666 // IP4Prefix defines type 'ip4_prefix'.
667 type IP4Prefix struct {
668 Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"`
669 Len uint8 `binapi:"u8,name=len" json:"len,omitempty"`
672 func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) {
673 hasPrefix := strings.Contains(s, "/")
675 ip, network, err := net.ParseCIDR(s)
677 return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
679 maskSize, _ := network.Mask.Size()
680 prefix.Len = byte(maskSize)
681 prefix.Address, err = ParseIP4Address(ip.String())
683 return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
687 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
689 defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
691 prefix.Len = byte(defaultMaskSize)
692 prefix.Address, err = ParseIP4Address(ip.String())
694 return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
699 func (x IP4Prefix) ToIPNet() *net.IPNet {
700 mask := net.CIDRMask(int(x.Len), 32)
701 ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
704 func (x IP4Prefix) String() string {
705 ip := x.Address.String()
706 return ip + "/" + strconv.Itoa(int(x.Len))
708 func (x *IP4Prefix) MarshalText() ([]byte, error) {
709 return []byte(x.String()), nil
711 func (x *IP4Prefix) UnmarshalText(text []byte) error {
712 prefix, err := ParseIP4Prefix(string(text))
720 // IP6Prefix defines type 'ip6_prefix'.
721 type IP6Prefix struct {
722 Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"`
723 Len uint8 `binapi:"u8,name=len" json:"len,omitempty"`
726 func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) {
727 hasPrefix := strings.Contains(s, "/")
729 ip, network, err := net.ParseCIDR(s)
731 return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
733 maskSize, _ := network.Mask.Size()
734 prefix.Len = byte(maskSize)
735 prefix.Address, err = ParseIP6Address(ip.String())
737 return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
741 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
743 defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
745 prefix.Len = byte(defaultMaskSize)
746 prefix.Address, err = ParseIP6Address(ip.String())
748 return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
753 func (x IP6Prefix) ToIPNet() *net.IPNet {
754 mask := net.CIDRMask(int(x.Len), 128)
755 ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
758 func (x IP6Prefix) String() string {
759 ip := x.Address.String()
760 return ip + "/" + strconv.Itoa(int(x.Len))
762 func (x *IP6Prefix) MarshalText() ([]byte, error) {
763 return []byte(x.String()), nil
765 func (x *IP6Prefix) UnmarshalText(text []byte) error {
766 prefix, err := ParseIP6Prefix(string(text))
774 // Mprefix defines type 'mprefix'.
775 type Mprefix struct {
776 Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
777 GrpAddressLength uint16 `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"`
778 GrpAddress AddressUnion `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"`
779 SrcAddress AddressUnion `binapi:"address_union,name=src_address" json:"src_address,omitempty"`
782 // Prefix defines type 'prefix'.
784 Address Address `binapi:"address,name=address" json:"address,omitempty"`
785 Len uint8 `binapi:"u8,name=len" json:"len,omitempty"`
788 func ParsePrefix(ip string) (prefix Prefix, err error) {
789 hasPrefix := strings.Contains(ip, "/")
791 netIP, network, err := net.ParseCIDR(ip)
793 return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
795 maskSize, _ := network.Mask.Size()
796 prefix.Len = byte(maskSize)
797 prefix.Address, err = ParseAddress(netIP.String())
799 return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
802 netIP := net.ParseIP(ip)
803 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
804 if netIP.To4() == nil {
805 defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
807 prefix.Len = byte(defaultMaskSize)
808 prefix.Address, err = ParseAddress(netIP.String())
810 return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
815 func (x Prefix) ToIPNet() *net.IPNet {
817 if x.Address.Af == ADDRESS_IP4 {
818 mask = net.CIDRMask(int(x.Len), 32)
820 mask = net.CIDRMask(int(x.Len), 128)
822 ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
825 func (x Prefix) String() string {
826 ip := x.Address.String()
827 return ip + "/" + strconv.Itoa(int(x.Len))
829 func (x *Prefix) MarshalText() ([]byte, error) {
830 return []byte(x.String()), nil
832 func (x *Prefix) UnmarshalText(text []byte) error {
833 prefix, err := ParsePrefix(string(text))
841 // PrefixMatcher defines type 'prefix_matcher'.
842 type PrefixMatcher struct {
843 Le uint8 `binapi:"u8,name=le" json:"le,omitempty"`
844 Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"`
847 // AddressUnion defines union 'address_union'.
848 type AddressUnion struct {
851 XXX_UnionData [16]byte
854 func AddressUnionIP4(a IP4Address) (u AddressUnion) {
858 func (u *AddressUnion) SetIP4(a IP4Address) {
859 buf := codec.NewBuffer(u.XXX_UnionData[:])
860 buf.EncodeBytes(a[:], 4)
862 func (u *AddressUnion) GetIP4() (a IP4Address) {
863 buf := codec.NewBuffer(u.XXX_UnionData[:])
864 copy(a[:], buf.DecodeBytes(4))
868 func AddressUnionIP6(a IP6Address) (u AddressUnion) {
872 func (u *AddressUnion) SetIP6(a IP6Address) {
873 buf := codec.NewBuffer(u.XXX_UnionData[:])
874 buf.EncodeBytes(a[:], 16)
876 func (u *AddressUnion) GetIP6() (a IP6Address) {
877 buf := codec.NewBuffer(u.XXX_UnionData[:])
878 copy(a[:], buf.DecodeBytes(16))
882 // PppoeAddDelSession defines message 'pppoe_add_del_session'.
883 type PppoeAddDelSession struct {
884 IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"`
885 SessionID uint16 `binapi:"u16,name=session_id" json:"session_id,omitempty"`
886 ClientIP Address `binapi:"address,name=client_ip" json:"client_ip,omitempty"`
887 DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"`
888 ClientMac MacAddress `binapi:"mac_address,name=client_mac" json:"client_mac,omitempty"`
891 func (m *PppoeAddDelSession) Reset() { *m = PppoeAddDelSession{} }
892 func (*PppoeAddDelSession) GetMessageName() string { return "pppoe_add_del_session" }
893 func (*PppoeAddDelSession) GetCrcString() string { return "46ace853" }
894 func (*PppoeAddDelSession) GetMessageType() api.MessageType {
895 return api.RequestMessage
898 func (m *PppoeAddDelSession) Size() (size int) {
903 size += 2 // m.SessionID
904 size += 4 // m.ClientIP.Af
905 size += 1 * 16 // m.ClientIP.Un
906 size += 4 // m.DecapVrfID
907 size += 1 * 6 // m.ClientMac
910 func (m *PppoeAddDelSession) Marshal(b []byte) ([]byte, error) {
912 b = make([]byte, m.Size())
914 buf := codec.NewBuffer(b)
915 buf.EncodeBool(m.IsAdd)
916 buf.EncodeUint16(m.SessionID)
917 buf.EncodeUint32(uint32(m.ClientIP.Af))
918 buf.EncodeBytes(m.ClientIP.Un.XXX_UnionData[:], 16)
919 buf.EncodeUint32(m.DecapVrfID)
920 buf.EncodeBytes(m.ClientMac[:], 6)
921 return buf.Bytes(), nil
923 func (m *PppoeAddDelSession) Unmarshal(b []byte) error {
924 buf := codec.NewBuffer(b)
925 m.IsAdd = buf.DecodeBool()
926 m.SessionID = buf.DecodeUint16()
927 m.ClientIP.Af = AddressFamily(buf.DecodeUint32())
928 copy(m.ClientIP.Un.XXX_UnionData[:], buf.DecodeBytes(16))
929 m.DecapVrfID = buf.DecodeUint32()
930 copy(m.ClientMac[:], buf.DecodeBytes(6))
934 // PppoeAddDelSessionReply defines message 'pppoe_add_del_session_reply'.
935 type PppoeAddDelSessionReply struct {
936 Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
937 SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
940 func (m *PppoeAddDelSessionReply) Reset() { *m = PppoeAddDelSessionReply{} }
941 func (*PppoeAddDelSessionReply) GetMessageName() string { return "pppoe_add_del_session_reply" }
942 func (*PppoeAddDelSessionReply) GetCrcString() string { return "5383d31f" }
943 func (*PppoeAddDelSessionReply) GetMessageType() api.MessageType {
944 return api.ReplyMessage
947 func (m *PppoeAddDelSessionReply) Size() (size int) {
951 size += 4 // m.Retval
952 size += 4 // m.SwIfIndex
955 func (m *PppoeAddDelSessionReply) Marshal(b []byte) ([]byte, error) {
957 b = make([]byte, m.Size())
959 buf := codec.NewBuffer(b)
960 buf.EncodeInt32(m.Retval)
961 buf.EncodeUint32(uint32(m.SwIfIndex))
962 return buf.Bytes(), nil
964 func (m *PppoeAddDelSessionReply) Unmarshal(b []byte) error {
965 buf := codec.NewBuffer(b)
966 m.Retval = buf.DecodeInt32()
967 m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
971 // PppoeSessionDetails defines message 'pppoe_session_details'.
972 type PppoeSessionDetails struct {
973 SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
974 SessionID uint16 `binapi:"u16,name=session_id" json:"session_id,omitempty"`
975 ClientIP Address `binapi:"address,name=client_ip" json:"client_ip,omitempty"`
976 EncapIfIndex InterfaceIndex `binapi:"interface_index,name=encap_if_index" json:"encap_if_index,omitempty"`
977 DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"`
978 LocalMac MacAddress `binapi:"mac_address,name=local_mac" json:"local_mac,omitempty"`
979 ClientMac MacAddress `binapi:"mac_address,name=client_mac" json:"client_mac,omitempty"`
982 func (m *PppoeSessionDetails) Reset() { *m = PppoeSessionDetails{} }
983 func (*PppoeSessionDetails) GetMessageName() string { return "pppoe_session_details" }
984 func (*PppoeSessionDetails) GetCrcString() string { return "332bc742" }
985 func (*PppoeSessionDetails) GetMessageType() api.MessageType {
986 return api.ReplyMessage
989 func (m *PppoeSessionDetails) Size() (size int) {
993 size += 4 // m.SwIfIndex
994 size += 2 // m.SessionID
995 size += 4 // m.ClientIP.Af
996 size += 1 * 16 // m.ClientIP.Un
997 size += 4 // m.EncapIfIndex
998 size += 4 // m.DecapVrfID
999 size += 1 * 6 // m.LocalMac
1000 size += 1 * 6 // m.ClientMac
1003 func (m *PppoeSessionDetails) Marshal(b []byte) ([]byte, error) {
1005 b = make([]byte, m.Size())
1007 buf := codec.NewBuffer(b)
1008 buf.EncodeUint32(uint32(m.SwIfIndex))
1009 buf.EncodeUint16(m.SessionID)
1010 buf.EncodeUint32(uint32(m.ClientIP.Af))
1011 buf.EncodeBytes(m.ClientIP.Un.XXX_UnionData[:], 16)
1012 buf.EncodeUint32(uint32(m.EncapIfIndex))
1013 buf.EncodeUint32(m.DecapVrfID)
1014 buf.EncodeBytes(m.LocalMac[:], 6)
1015 buf.EncodeBytes(m.ClientMac[:], 6)
1016 return buf.Bytes(), nil
1018 func (m *PppoeSessionDetails) Unmarshal(b []byte) error {
1019 buf := codec.NewBuffer(b)
1020 m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1021 m.SessionID = buf.DecodeUint16()
1022 m.ClientIP.Af = AddressFamily(buf.DecodeUint32())
1023 copy(m.ClientIP.Un.XXX_UnionData[:], buf.DecodeBytes(16))
1024 m.EncapIfIndex = InterfaceIndex(buf.DecodeUint32())
1025 m.DecapVrfID = buf.DecodeUint32()
1026 copy(m.LocalMac[:], buf.DecodeBytes(6))
1027 copy(m.ClientMac[:], buf.DecodeBytes(6))
1031 // PppoeSessionDump defines message 'pppoe_session_dump'.
1032 type PppoeSessionDump struct {
1033 SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1036 func (m *PppoeSessionDump) Reset() { *m = PppoeSessionDump{} }
1037 func (*PppoeSessionDump) GetMessageName() string { return "pppoe_session_dump" }
1038 func (*PppoeSessionDump) GetCrcString() string { return "f9e6675e" }
1039 func (*PppoeSessionDump) GetMessageType() api.MessageType {
1040 return api.RequestMessage
1043 func (m *PppoeSessionDump) Size() (size int) {
1047 size += 4 // m.SwIfIndex
1050 func (m *PppoeSessionDump) Marshal(b []byte) ([]byte, error) {
1052 b = make([]byte, m.Size())
1054 buf := codec.NewBuffer(b)
1055 buf.EncodeUint32(uint32(m.SwIfIndex))
1056 return buf.Bytes(), nil
1058 func (m *PppoeSessionDump) Unmarshal(b []byte) error {
1059 buf := codec.NewBuffer(b)
1060 m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1064 func init() { file_pppoe_binapi_init() }
1065 func file_pppoe_binapi_init() {
1066 api.RegisterMessage((*PppoeAddDelSession)(nil), "pppoe_add_del_session_46ace853")
1067 api.RegisterMessage((*PppoeAddDelSessionReply)(nil), "pppoe_add_del_session_reply_5383d31f")
1068 api.RegisterMessage((*PppoeSessionDetails)(nil), "pppoe_session_details_332bc742")
1069 api.RegisterMessage((*PppoeSessionDump)(nil), "pppoe_session_dump_f9e6675e")
1072 // Messages returns list of all messages in this module.
1073 func AllMessages() []api.Message {
1074 return []api.Message{
1075 (*PppoeAddDelSession)(nil),
1076 (*PppoeAddDelSessionReply)(nil),
1077 (*PppoeSessionDetails)(nil),
1078 (*PppoeSessionDump)(nil),