1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
3 // binapi-generator: v0.5.0-dev
5 // source: .vppapi/plugins/pppoe.api.json
7 // Package pppoe contains generated bindings for API file pppoe.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 = 0xb83e4d5f
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 // AddressWithPrefix defines alias 'address_with_prefix'.
493 type AddressWithPrefix Prefix
495 func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) {
496 prefix, err := ParsePrefix(s)
498 return AddressWithPrefix{}, err
500 return AddressWithPrefix(prefix), nil
503 func (x AddressWithPrefix) String() string {
504 return Prefix(x).String()
507 func (x *AddressWithPrefix) MarshalText() ([]byte, error) {
508 return []byte(x.String()), nil
511 func (x *AddressWithPrefix) UnmarshalText(text []byte) error {
512 prefix, err := ParseAddressWithPrefix(string(text))
520 // InterfaceIndex defines alias 'interface_index'.
521 type InterfaceIndex uint32
523 // IP4Address defines alias 'ip4_address'.
524 type IP4Address [4]uint8
526 func ParseIP4Address(s string) (IP4Address, error) {
527 ip := net.ParseIP(s).To4()
529 return IP4Address{}, fmt.Errorf("invalid IP address: %s", s)
531 var ipaddr IP4Address
532 copy(ipaddr[:], ip.To4())
536 func (x IP4Address) ToIP() net.IP {
537 return net.IP(x[:]).To4()
540 func (x IP4Address) String() string {
541 return x.ToIP().String()
544 func (x *IP4Address) MarshalText() ([]byte, error) {
545 return []byte(x.String()), nil
548 func (x *IP4Address) UnmarshalText(text []byte) error {
549 ipaddr, err := ParseIP4Address(string(text))
557 // IP4AddressWithPrefix defines alias 'ip4_address_with_prefix'.
558 type IP4AddressWithPrefix IP4Prefix
560 // IP6Address defines alias 'ip6_address'.
561 type IP6Address [16]uint8
563 func ParseIP6Address(s string) (IP6Address, error) {
564 ip := net.ParseIP(s).To16()
566 return IP6Address{}, fmt.Errorf("invalid IP address: %s", s)
568 var ipaddr IP6Address
569 copy(ipaddr[:], ip.To16())
573 func (x IP6Address) ToIP() net.IP {
574 return net.IP(x[:]).To16()
577 func (x IP6Address) String() string {
578 return x.ToIP().String()
581 func (x *IP6Address) MarshalText() ([]byte, error) {
582 return []byte(x.String()), nil
585 func (x *IP6Address) UnmarshalText(text []byte) error {
586 ipaddr, err := ParseIP6Address(string(text))
594 // IP6AddressWithPrefix defines alias 'ip6_address_with_prefix'.
595 type IP6AddressWithPrefix IP6Prefix
597 // MacAddress defines alias 'mac_address'.
598 type MacAddress [6]uint8
600 func ParseMacAddress(s string) (MacAddress, error) {
601 var macaddr MacAddress
602 mac, err := net.ParseMAC(s)
606 copy(macaddr[:], mac[:])
610 func (x MacAddress) ToMAC() net.HardwareAddr {
611 return net.HardwareAddr(x[:])
614 func (x MacAddress) String() string {
615 return x.ToMAC().String()
618 func (x *MacAddress) MarshalText() ([]byte, error) {
619 return []byte(x.String()), nil
622 func (x *MacAddress) UnmarshalText(text []byte) error {
623 mac, err := ParseMacAddress(string(text))
631 // Address defines type 'address'.
632 type Address struct {
633 Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
634 Un AddressUnion `binapi:"address_union,name=un" json:"un,omitempty"`
637 func ParseAddress(s string) (Address, error) {
640 return Address{}, fmt.Errorf("invalid address: %s", s)
642 return AddressFromIP(ip), nil
645 func AddressFromIP(ip net.IP) Address {
648 addr.Af = ADDRESS_IP6
650 copy(ip6[:], ip.To16())
653 addr.Af = ADDRESS_IP4
655 copy(ip4[:], ip.To4())
661 func (x Address) ToIP() net.IP {
662 if x.Af == ADDRESS_IP6 {
664 return net.IP(ip6[:]).To16()
667 return net.IP(ip4[:]).To4()
671 func (x Address) String() string {
672 return x.ToIP().String()
675 func (x *Address) MarshalText() ([]byte, error) {
676 return []byte(x.String()), nil
679 func (x *Address) UnmarshalText(text []byte) error {
680 addr, err := ParseAddress(string(text))
688 // IP4Prefix defines type 'ip4_prefix'.
689 type IP4Prefix struct {
690 Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"`
691 Len uint8 `binapi:"u8,name=len" json:"len,omitempty"`
694 func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) {
695 hasPrefix := strings.Contains(s, "/")
697 ip, network, err := net.ParseCIDR(s)
699 return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
701 maskSize, _ := network.Mask.Size()
702 prefix.Len = byte(maskSize)
703 prefix.Address, err = ParseIP4Address(ip.String())
705 return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
709 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
711 defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
713 prefix.Len = byte(defaultMaskSize)
714 prefix.Address, err = ParseIP4Address(ip.String())
716 return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
722 func (x IP4Prefix) ToIPNet() *net.IPNet {
723 mask := net.CIDRMask(int(x.Len), 32)
724 ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
728 func (x IP4Prefix) String() string {
729 ip := x.Address.String()
730 return ip + "/" + strconv.Itoa(int(x.Len))
733 func (x *IP4Prefix) MarshalText() ([]byte, error) {
734 return []byte(x.String()), nil
737 func (x *IP4Prefix) UnmarshalText(text []byte) error {
738 prefix, err := ParseIP4Prefix(string(text))
746 // IP6Prefix defines type 'ip6_prefix'.
747 type IP6Prefix struct {
748 Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"`
749 Len uint8 `binapi:"u8,name=len" json:"len,omitempty"`
752 func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) {
753 hasPrefix := strings.Contains(s, "/")
755 ip, network, err := net.ParseCIDR(s)
757 return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
759 maskSize, _ := network.Mask.Size()
760 prefix.Len = byte(maskSize)
761 prefix.Address, err = ParseIP6Address(ip.String())
763 return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
767 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
769 defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
771 prefix.Len = byte(defaultMaskSize)
772 prefix.Address, err = ParseIP6Address(ip.String())
774 return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err)
780 func (x IP6Prefix) ToIPNet() *net.IPNet {
781 mask := net.CIDRMask(int(x.Len), 128)
782 ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
786 func (x IP6Prefix) String() string {
787 ip := x.Address.String()
788 return ip + "/" + strconv.Itoa(int(x.Len))
791 func (x *IP6Prefix) MarshalText() ([]byte, error) {
792 return []byte(x.String()), nil
795 func (x *IP6Prefix) UnmarshalText(text []byte) error {
796 prefix, err := ParseIP6Prefix(string(text))
804 // Mprefix defines type 'mprefix'.
805 type Mprefix struct {
806 Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"`
807 GrpAddressLength uint16 `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"`
808 GrpAddress AddressUnion `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"`
809 SrcAddress AddressUnion `binapi:"address_union,name=src_address" json:"src_address,omitempty"`
812 // Prefix defines type 'prefix'.
814 Address Address `binapi:"address,name=address" json:"address,omitempty"`
815 Len uint8 `binapi:"u8,name=len" json:"len,omitempty"`
818 func ParsePrefix(ip string) (prefix Prefix, err error) {
819 hasPrefix := strings.Contains(ip, "/")
821 netIP, network, err := net.ParseCIDR(ip)
823 return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
825 maskSize, _ := network.Mask.Size()
826 prefix.Len = byte(maskSize)
827 prefix.Address, err = ParseAddress(netIP.String())
829 return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
832 netIP := net.ParseIP(ip)
833 defaultMaskSize, _ := net.CIDRMask(32, 32).Size()
834 if netIP.To4() == nil {
835 defaultMaskSize, _ = net.CIDRMask(128, 128).Size()
837 prefix.Len = byte(defaultMaskSize)
838 prefix.Address, err = ParseAddress(netIP.String())
840 return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err)
846 func (x Prefix) ToIPNet() *net.IPNet {
848 if x.Address.Af == ADDRESS_IP4 {
849 mask = net.CIDRMask(int(x.Len), 32)
851 mask = net.CIDRMask(int(x.Len), 128)
853 ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask}
857 func (x Prefix) String() string {
858 ip := x.Address.String()
859 return ip + "/" + strconv.Itoa(int(x.Len))
862 func (x *Prefix) MarshalText() ([]byte, error) {
863 return []byte(x.String()), nil
866 func (x *Prefix) UnmarshalText(text []byte) error {
867 prefix, err := ParsePrefix(string(text))
875 // PrefixMatcher defines type 'prefix_matcher'.
876 type PrefixMatcher struct {
877 Le uint8 `binapi:"u8,name=le" json:"le,omitempty"`
878 Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"`
881 // AddressUnion defines union 'address_union'.
882 type AddressUnion struct {
883 // AddressUnion can be one of:
886 XXX_UnionData [16]byte
889 func AddressUnionIP4(a IP4Address) (u AddressUnion) {
893 func (u *AddressUnion) SetIP4(a IP4Address) {
894 buf := codec.NewBuffer(u.XXX_UnionData[:])
895 buf.EncodeBytes(a[:], 4)
897 func (u *AddressUnion) GetIP4() (a IP4Address) {
898 buf := codec.NewBuffer(u.XXX_UnionData[:])
899 copy(a[:], buf.DecodeBytes(4))
903 func AddressUnionIP6(a IP6Address) (u AddressUnion) {
907 func (u *AddressUnion) SetIP6(a IP6Address) {
908 buf := codec.NewBuffer(u.XXX_UnionData[:])
909 buf.EncodeBytes(a[:], 16)
911 func (u *AddressUnion) GetIP6() (a IP6Address) {
912 buf := codec.NewBuffer(u.XXX_UnionData[:])
913 copy(a[:], buf.DecodeBytes(16))
917 // PppoeAddDelSession defines message 'pppoe_add_del_session'.
918 type PppoeAddDelSession struct {
919 IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"`
920 SessionID uint16 `binapi:"u16,name=session_id" json:"session_id,omitempty"`
921 ClientIP Address `binapi:"address,name=client_ip" json:"client_ip,omitempty"`
922 DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"`
923 ClientMac MacAddress `binapi:"mac_address,name=client_mac" json:"client_mac,omitempty"`
926 func (m *PppoeAddDelSession) Reset() { *m = PppoeAddDelSession{} }
927 func (*PppoeAddDelSession) GetMessageName() string { return "pppoe_add_del_session" }
928 func (*PppoeAddDelSession) GetCrcString() string { return "46ace853" }
929 func (*PppoeAddDelSession) GetMessageType() api.MessageType {
930 return api.RequestMessage
933 func (m *PppoeAddDelSession) Size() (size int) {
938 size += 2 // m.SessionID
939 size += 4 // m.ClientIP.Af
940 size += 1 * 16 // m.ClientIP.Un
941 size += 4 // m.DecapVrfID
942 size += 1 * 6 // m.ClientMac
945 func (m *PppoeAddDelSession) Marshal(b []byte) ([]byte, error) {
947 b = make([]byte, m.Size())
949 buf := codec.NewBuffer(b)
950 buf.EncodeBool(m.IsAdd)
951 buf.EncodeUint16(m.SessionID)
952 buf.EncodeUint32(uint32(m.ClientIP.Af))
953 buf.EncodeBytes(m.ClientIP.Un.XXX_UnionData[:], 16)
954 buf.EncodeUint32(m.DecapVrfID)
955 buf.EncodeBytes(m.ClientMac[:], 6)
956 return buf.Bytes(), nil
958 func (m *PppoeAddDelSession) Unmarshal(b []byte) error {
959 buf := codec.NewBuffer(b)
960 m.IsAdd = buf.DecodeBool()
961 m.SessionID = buf.DecodeUint16()
962 m.ClientIP.Af = AddressFamily(buf.DecodeUint32())
963 copy(m.ClientIP.Un.XXX_UnionData[:], buf.DecodeBytes(16))
964 m.DecapVrfID = buf.DecodeUint32()
965 copy(m.ClientMac[:], buf.DecodeBytes(6))
969 // PppoeAddDelSessionReply defines message 'pppoe_add_del_session_reply'.
970 type PppoeAddDelSessionReply struct {
971 Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
972 SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
975 func (m *PppoeAddDelSessionReply) Reset() { *m = PppoeAddDelSessionReply{} }
976 func (*PppoeAddDelSessionReply) GetMessageName() string { return "pppoe_add_del_session_reply" }
977 func (*PppoeAddDelSessionReply) GetCrcString() string { return "5383d31f" }
978 func (*PppoeAddDelSessionReply) GetMessageType() api.MessageType {
979 return api.ReplyMessage
982 func (m *PppoeAddDelSessionReply) Size() (size int) {
986 size += 4 // m.Retval
987 size += 4 // m.SwIfIndex
990 func (m *PppoeAddDelSessionReply) Marshal(b []byte) ([]byte, error) {
992 b = make([]byte, m.Size())
994 buf := codec.NewBuffer(b)
995 buf.EncodeInt32(m.Retval)
996 buf.EncodeUint32(uint32(m.SwIfIndex))
997 return buf.Bytes(), nil
999 func (m *PppoeAddDelSessionReply) Unmarshal(b []byte) error {
1000 buf := codec.NewBuffer(b)
1001 m.Retval = buf.DecodeInt32()
1002 m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1006 // PppoeSessionDetails defines message 'pppoe_session_details'.
1007 type PppoeSessionDetails struct {
1008 SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1009 SessionID uint16 `binapi:"u16,name=session_id" json:"session_id,omitempty"`
1010 ClientIP Address `binapi:"address,name=client_ip" json:"client_ip,omitempty"`
1011 EncapIfIndex InterfaceIndex `binapi:"interface_index,name=encap_if_index" json:"encap_if_index,omitempty"`
1012 DecapVrfID uint32 `binapi:"u32,name=decap_vrf_id" json:"decap_vrf_id,omitempty"`
1013 LocalMac MacAddress `binapi:"mac_address,name=local_mac" json:"local_mac,omitempty"`
1014 ClientMac MacAddress `binapi:"mac_address,name=client_mac" json:"client_mac,omitempty"`
1017 func (m *PppoeSessionDetails) Reset() { *m = PppoeSessionDetails{} }
1018 func (*PppoeSessionDetails) GetMessageName() string { return "pppoe_session_details" }
1019 func (*PppoeSessionDetails) GetCrcString() string { return "332bc742" }
1020 func (*PppoeSessionDetails) GetMessageType() api.MessageType {
1021 return api.ReplyMessage
1024 func (m *PppoeSessionDetails) Size() (size int) {
1028 size += 4 // m.SwIfIndex
1029 size += 2 // m.SessionID
1030 size += 4 // m.ClientIP.Af
1031 size += 1 * 16 // m.ClientIP.Un
1032 size += 4 // m.EncapIfIndex
1033 size += 4 // m.DecapVrfID
1034 size += 1 * 6 // m.LocalMac
1035 size += 1 * 6 // m.ClientMac
1038 func (m *PppoeSessionDetails) Marshal(b []byte) ([]byte, error) {
1040 b = make([]byte, m.Size())
1042 buf := codec.NewBuffer(b)
1043 buf.EncodeUint32(uint32(m.SwIfIndex))
1044 buf.EncodeUint16(m.SessionID)
1045 buf.EncodeUint32(uint32(m.ClientIP.Af))
1046 buf.EncodeBytes(m.ClientIP.Un.XXX_UnionData[:], 16)
1047 buf.EncodeUint32(uint32(m.EncapIfIndex))
1048 buf.EncodeUint32(m.DecapVrfID)
1049 buf.EncodeBytes(m.LocalMac[:], 6)
1050 buf.EncodeBytes(m.ClientMac[:], 6)
1051 return buf.Bytes(), nil
1053 func (m *PppoeSessionDetails) Unmarshal(b []byte) error {
1054 buf := codec.NewBuffer(b)
1055 m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1056 m.SessionID = buf.DecodeUint16()
1057 m.ClientIP.Af = AddressFamily(buf.DecodeUint32())
1058 copy(m.ClientIP.Un.XXX_UnionData[:], buf.DecodeBytes(16))
1059 m.EncapIfIndex = InterfaceIndex(buf.DecodeUint32())
1060 m.DecapVrfID = buf.DecodeUint32()
1061 copy(m.LocalMac[:], buf.DecodeBytes(6))
1062 copy(m.ClientMac[:], buf.DecodeBytes(6))
1066 // PppoeSessionDump defines message 'pppoe_session_dump'.
1067 type PppoeSessionDump struct {
1068 SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
1071 func (m *PppoeSessionDump) Reset() { *m = PppoeSessionDump{} }
1072 func (*PppoeSessionDump) GetMessageName() string { return "pppoe_session_dump" }
1073 func (*PppoeSessionDump) GetCrcString() string { return "f9e6675e" }
1074 func (*PppoeSessionDump) GetMessageType() api.MessageType {
1075 return api.RequestMessage
1078 func (m *PppoeSessionDump) Size() (size int) {
1082 size += 4 // m.SwIfIndex
1085 func (m *PppoeSessionDump) Marshal(b []byte) ([]byte, error) {
1087 b = make([]byte, m.Size())
1089 buf := codec.NewBuffer(b)
1090 buf.EncodeUint32(uint32(m.SwIfIndex))
1091 return buf.Bytes(), nil
1093 func (m *PppoeSessionDump) Unmarshal(b []byte) error {
1094 buf := codec.NewBuffer(b)
1095 m.SwIfIndex = InterfaceIndex(buf.DecodeUint32())
1099 func init() { file_pppoe_binapi_init() }
1100 func file_pppoe_binapi_init() {
1101 api.RegisterMessage((*PppoeAddDelSession)(nil), "pppoe_add_del_session_46ace853")
1102 api.RegisterMessage((*PppoeAddDelSessionReply)(nil), "pppoe_add_del_session_reply_5383d31f")
1103 api.RegisterMessage((*PppoeSessionDetails)(nil), "pppoe_session_details_332bc742")
1104 api.RegisterMessage((*PppoeSessionDump)(nil), "pppoe_session_dump_f9e6675e")
1107 // Messages returns list of all messages in this module.
1108 func AllMessages() []api.Message {
1109 return []api.Message{
1110 (*PppoeAddDelSession)(nil),
1111 (*PppoeAddDelSessionReply)(nil),
1112 (*PppoeSessionDetails)(nil),
1113 (*PppoeSessionDump)(nil),