From 58da9ac6e691a8c660eb8ca838a154e11da0db68 Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Wed, 22 Jul 2020 04:40:55 +0200 Subject: Fix binapigen decoding and minor improvements - fixed allocating byte slices before copying decoded data - simplified encoding functions - several minor improvements Change-Id: I6669424b89eb86333805cb1b57e4551169980cc2 Signed-off-by: Ondrej Fabry --- internal/testbinapi/binapi2001/punt/punt.ba.go | 1110 ++++++++++++++++++++++++ 1 file changed, 1110 insertions(+) create mode 100644 internal/testbinapi/binapi2001/punt/punt.ba.go (limited to 'internal/testbinapi/binapi2001/punt/punt.ba.go') diff --git a/internal/testbinapi/binapi2001/punt/punt.ba.go b/internal/testbinapi/binapi2001/punt/punt.ba.go new file mode 100644 index 0000000..285aaf1 --- /dev/null +++ b/internal/testbinapi/binapi2001/punt/punt.ba.go @@ -0,0 +1,1110 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-dev +// VPP: 20.01 +// source: .vppapi/core/punt.api.json + +// Package punt contains generated bindings for API file punt.api. +// +// Contents: +// 5 aliases +// 5 enums +// 11 structs +// 2 unions +// 10 messages +// +package punt + +import ( + "fmt" + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" + "net" + "strconv" + "strings" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the GoVPP api package it is being compiled against. +// A compilation error at this line likely means your copy of the +// GoVPP api package needs to be updated. +const _ = api.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "punt" + APIVersion = "2.2.1" + VersionCrc = 0x51716f7f +) + +// AddressFamily defines enum 'address_family'. +type AddressFamily uint32 + +const ( + ADDRESS_IP4 AddressFamily = 0 + ADDRESS_IP6 AddressFamily = 1 +) + +var ( + AddressFamily_name = map[uint32]string{ + 0: "ADDRESS_IP4", + 1: "ADDRESS_IP6", + } + AddressFamily_value = map[string]uint32{ + "ADDRESS_IP4": 0, + "ADDRESS_IP6": 1, + } +) + +func (x AddressFamily) String() string { + s, ok := AddressFamily_name[uint32(x)] + if ok { + return s + } + return "AddressFamily(" + strconv.Itoa(int(x)) + ")" +} + +// IPDscp defines enum 'ip_dscp'. +type IPDscp uint8 + +const ( + IP_API_DSCP_CS0 IPDscp = 0 + IP_API_DSCP_CS1 IPDscp = 8 + IP_API_DSCP_AF11 IPDscp = 10 + IP_API_DSCP_AF12 IPDscp = 12 + IP_API_DSCP_AF13 IPDscp = 14 + IP_API_DSCP_CS2 IPDscp = 16 + IP_API_DSCP_AF21 IPDscp = 18 + IP_API_DSCP_AF22 IPDscp = 20 + IP_API_DSCP_AF23 IPDscp = 22 + IP_API_DSCP_CS3 IPDscp = 24 + IP_API_DSCP_AF31 IPDscp = 26 + IP_API_DSCP_AF32 IPDscp = 28 + IP_API_DSCP_AF33 IPDscp = 30 + IP_API_DSCP_CS4 IPDscp = 32 + IP_API_DSCP_AF41 IPDscp = 34 + IP_API_DSCP_AF42 IPDscp = 36 + IP_API_DSCP_AF43 IPDscp = 38 + IP_API_DSCP_CS5 IPDscp = 40 + IP_API_DSCP_EF IPDscp = 46 + IP_API_DSCP_CS6 IPDscp = 48 + IP_API_DSCP_CS7 IPDscp = 50 +) + +var ( + IPDscp_name = map[uint8]string{ + 0: "IP_API_DSCP_CS0", + 8: "IP_API_DSCP_CS1", + 10: "IP_API_DSCP_AF11", + 12: "IP_API_DSCP_AF12", + 14: "IP_API_DSCP_AF13", + 16: "IP_API_DSCP_CS2", + 18: "IP_API_DSCP_AF21", + 20: "IP_API_DSCP_AF22", + 22: "IP_API_DSCP_AF23", + 24: "IP_API_DSCP_CS3", + 26: "IP_API_DSCP_AF31", + 28: "IP_API_DSCP_AF32", + 30: "IP_API_DSCP_AF33", + 32: "IP_API_DSCP_CS4", + 34: "IP_API_DSCP_AF41", + 36: "IP_API_DSCP_AF42", + 38: "IP_API_DSCP_AF43", + 40: "IP_API_DSCP_CS5", + 46: "IP_API_DSCP_EF", + 48: "IP_API_DSCP_CS6", + 50: "IP_API_DSCP_CS7", + } + IPDscp_value = map[string]uint8{ + "IP_API_DSCP_CS0": 0, + "IP_API_DSCP_CS1": 8, + "IP_API_DSCP_AF11": 10, + "IP_API_DSCP_AF12": 12, + "IP_API_DSCP_AF13": 14, + "IP_API_DSCP_CS2": 16, + "IP_API_DSCP_AF21": 18, + "IP_API_DSCP_AF22": 20, + "IP_API_DSCP_AF23": 22, + "IP_API_DSCP_CS3": 24, + "IP_API_DSCP_AF31": 26, + "IP_API_DSCP_AF32": 28, + "IP_API_DSCP_AF33": 30, + "IP_API_DSCP_CS4": 32, + "IP_API_DSCP_AF41": 34, + "IP_API_DSCP_AF42": 36, + "IP_API_DSCP_AF43": 38, + "IP_API_DSCP_CS5": 40, + "IP_API_DSCP_EF": 46, + "IP_API_DSCP_CS6": 48, + "IP_API_DSCP_CS7": 50, + } +) + +func (x IPDscp) String() string { + s, ok := IPDscp_name[uint8(x)] + if ok { + return s + } + return "IPDscp(" + strconv.Itoa(int(x)) + ")" +} + +// IPEcn defines enum 'ip_ecn'. +type IPEcn uint8 + +const ( + IP_API_ECN_NONE IPEcn = 0 + IP_API_ECN_ECT0 IPEcn = 1 + IP_API_ECN_ECT1 IPEcn = 2 + IP_API_ECN_CE IPEcn = 3 +) + +var ( + IPEcn_name = map[uint8]string{ + 0: "IP_API_ECN_NONE", + 1: "IP_API_ECN_ECT0", + 2: "IP_API_ECN_ECT1", + 3: "IP_API_ECN_CE", + } + IPEcn_value = map[string]uint8{ + "IP_API_ECN_NONE": 0, + "IP_API_ECN_ECT0": 1, + "IP_API_ECN_ECT1": 2, + "IP_API_ECN_CE": 3, + } +) + +func (x IPEcn) String() string { + s, ok := IPEcn_name[uint8(x)] + if ok { + return s + } + return "IPEcn(" + strconv.Itoa(int(x)) + ")" +} + +// IPProto defines enum 'ip_proto'. +type IPProto uint32 + +const ( + IP_API_PROTO_HOPOPT IPProto = 0 + IP_API_PROTO_ICMP IPProto = 1 + IP_API_PROTO_IGMP IPProto = 2 + IP_API_PROTO_TCP IPProto = 6 + IP_API_PROTO_UDP IPProto = 17 + IP_API_PROTO_GRE IPProto = 47 + IP_API_PROTO_AH IPProto = 50 + IP_API_PROTO_ESP IPProto = 51 + IP_API_PROTO_EIGRP IPProto = 88 + IP_API_PROTO_OSPF IPProto = 89 + IP_API_PROTO_SCTP IPProto = 132 + IP_API_PROTO_RESERVED IPProto = 255 +) + +var ( + IPProto_name = map[uint32]string{ + 0: "IP_API_PROTO_HOPOPT", + 1: "IP_API_PROTO_ICMP", + 2: "IP_API_PROTO_IGMP", + 6: "IP_API_PROTO_TCP", + 17: "IP_API_PROTO_UDP", + 47: "IP_API_PROTO_GRE", + 50: "IP_API_PROTO_AH", + 51: "IP_API_PROTO_ESP", + 88: "IP_API_PROTO_EIGRP", + 89: "IP_API_PROTO_OSPF", + 132: "IP_API_PROTO_SCTP", + 255: "IP_API_PROTO_RESERVED", + } + IPProto_value = map[string]uint32{ + "IP_API_PROTO_HOPOPT": 0, + "IP_API_PROTO_ICMP": 1, + "IP_API_PROTO_IGMP": 2, + "IP_API_PROTO_TCP": 6, + "IP_API_PROTO_UDP": 17, + "IP_API_PROTO_GRE": 47, + "IP_API_PROTO_AH": 50, + "IP_API_PROTO_ESP": 51, + "IP_API_PROTO_EIGRP": 88, + "IP_API_PROTO_OSPF": 89, + "IP_API_PROTO_SCTP": 132, + "IP_API_PROTO_RESERVED": 255, + } +) + +func (x IPProto) String() string { + s, ok := IPProto_name[uint32(x)] + if ok { + return s + } + return "IPProto(" + strconv.Itoa(int(x)) + ")" +} + +// PuntType defines enum 'punt_type'. +type PuntType uint32 + +const ( + PUNT_API_TYPE_L4 PuntType = 1 + PUNT_API_TYPE_IP_PROTO PuntType = 2 + PUNT_API_TYPE_EXCEPTION PuntType = 3 +) + +var ( + PuntType_name = map[uint32]string{ + 1: "PUNT_API_TYPE_L4", + 2: "PUNT_API_TYPE_IP_PROTO", + 3: "PUNT_API_TYPE_EXCEPTION", + } + PuntType_value = map[string]uint32{ + "PUNT_API_TYPE_L4": 1, + "PUNT_API_TYPE_IP_PROTO": 2, + "PUNT_API_TYPE_EXCEPTION": 3, + } +) + +func (x PuntType) String() string { + s, ok := PuntType_name[uint32(x)] + if ok { + return s + } + return "PuntType(" + strconv.Itoa(int(x)) + ")" +} + +// AddressWithPrefix defines alias 'address_with_prefix'. +type AddressWithPrefix Prefix + +func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { + prefix, err := ParsePrefix(s) + if err != nil { + return AddressWithPrefix{}, err + } + return AddressWithPrefix(prefix), nil +} +func (x AddressWithPrefix) String() string { + return Prefix(x).String() +} +func (x *AddressWithPrefix) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} +func (x *AddressWithPrefix) UnmarshalText(text []byte) error { + prefix, err := ParseAddressWithPrefix(string(text)) + if err != nil { + return err + } + *x = prefix + return nil +} + +// IP4Address defines alias 'ip4_address'. +type IP4Address [4]uint8 + +func ParseIP4Address(s string) (IP4Address, error) { + ip := net.ParseIP(s).To4() + if ip == nil { + return IP4Address{}, fmt.Errorf("invalid IP address: %s", s) + } + var ipaddr IP4Address + copy(ipaddr[:], ip.To4()) + return ipaddr, nil +} + +func (x IP4Address) ToIP() net.IP { + return net.IP(x[:]).To4() +} +func (x IP4Address) String() string { + return x.ToIP().String() +} +func (x *IP4Address) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} +func (x *IP4Address) UnmarshalText(text []byte) error { + ipaddr, err := ParseIP4Address(string(text)) + if err != nil { + return err + } + *x = ipaddr + return nil +} + +// IP4AddressWithPrefix defines alias 'ip4_address_with_prefix'. +type IP4AddressWithPrefix IP4Prefix + +// IP6Address defines alias 'ip6_address'. +type IP6Address [16]uint8 + +func ParseIP6Address(s string) (IP6Address, error) { + ip := net.ParseIP(s).To16() + if ip == nil { + return IP6Address{}, fmt.Errorf("invalid IP address: %s", s) + } + var ipaddr IP6Address + copy(ipaddr[:], ip.To16()) + return ipaddr, nil +} + +func (x IP6Address) ToIP() net.IP { + return net.IP(x[:]).To16() +} +func (x IP6Address) String() string { + return x.ToIP().String() +} +func (x *IP6Address) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} +func (x *IP6Address) UnmarshalText(text []byte) error { + ipaddr, err := ParseIP6Address(string(text)) + if err != nil { + return err + } + *x = ipaddr + return nil +} + +// IP6AddressWithPrefix defines alias 'ip6_address_with_prefix'. +type IP6AddressWithPrefix IP6Prefix + +// Address defines type 'address'. +type Address struct { + Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + Un AddressUnion `binapi:"address_union,name=un" json:"un,omitempty"` +} + +func ParseAddress(s string) (Address, error) { + ip := net.ParseIP(s) + if ip == nil { + return Address{}, fmt.Errorf("invalid address: %s", s) + } + var addr Address + if ip.To4() == nil { + addr.Af = ADDRESS_IP6 + var ip6 IP6Address + copy(ip6[:], ip.To16()) + addr.Un.SetIP6(ip6) + } else { + addr.Af = ADDRESS_IP4 + var ip4 IP4Address + copy(ip4[:], ip.To4()) + addr.Un.SetIP4(ip4) + } + return addr, nil +} +func (x Address) ToIP() net.IP { + if x.Af == ADDRESS_IP6 { + ip6 := x.Un.GetIP6() + return net.IP(ip6[:]).To16() + } else { + ip4 := x.Un.GetIP4() + return net.IP(ip4[:]).To4() + } +} +func (x Address) String() string { + return x.ToIP().String() +} +func (x *Address) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} +func (x *Address) UnmarshalText(text []byte) error { + addr, err := ParseAddress(string(text)) + if err != nil { + return err + } + *x = addr + return nil +} + +// IP4Prefix defines type 'ip4_prefix'. +type IP4Prefix struct { + Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` +} + +func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { + hasPrefix := strings.Contains(s, "/") + if hasPrefix { + ip, network, err := net.ParseCIDR(s) + if err != nil { + return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err) + } + maskSize, _ := network.Mask.Size() + prefix.Len = byte(maskSize) + prefix.Address, err = ParseIP4Address(ip.String()) + if err != nil { + return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err) + } + } else { + ip := net.ParseIP(s) + defaultMaskSize, _ := net.CIDRMask(32, 32).Size() + if ip.To4() == nil { + defaultMaskSize, _ = net.CIDRMask(128, 128).Size() + } + prefix.Len = byte(defaultMaskSize) + prefix.Address, err = ParseIP4Address(ip.String()) + if err != nil { + return IP4Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err) + } + } + return prefix, nil +} +func (x IP4Prefix) ToIPNet() *net.IPNet { + mask := net.CIDRMask(int(x.Len), 32) + ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask} + return ipnet +} +func (x IP4Prefix) String() string { + ip := x.Address.String() + return ip + "/" + strconv.Itoa(int(x.Len)) +} +func (x *IP4Prefix) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} +func (x *IP4Prefix) UnmarshalText(text []byte) error { + prefix, err := ParseIP4Prefix(string(text)) + if err != nil { + return err + } + *x = prefix + return nil +} + +// IP6Prefix defines type 'ip6_prefix'. +type IP6Prefix struct { + Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` +} + +func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { + hasPrefix := strings.Contains(s, "/") + if hasPrefix { + ip, network, err := net.ParseCIDR(s) + if err != nil { + return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err) + } + maskSize, _ := network.Mask.Size() + prefix.Len = byte(maskSize) + prefix.Address, err = ParseIP6Address(ip.String()) + if err != nil { + return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err) + } + } else { + ip := net.ParseIP(s) + defaultMaskSize, _ := net.CIDRMask(32, 32).Size() + if ip.To4() == nil { + defaultMaskSize, _ = net.CIDRMask(128, 128).Size() + } + prefix.Len = byte(defaultMaskSize) + prefix.Address, err = ParseIP6Address(ip.String()) + if err != nil { + return IP6Prefix{}, fmt.Errorf("invalid IP %s: %s", s, err) + } + } + return prefix, nil +} +func (x IP6Prefix) ToIPNet() *net.IPNet { + mask := net.CIDRMask(int(x.Len), 128) + ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask} + return ipnet +} +func (x IP6Prefix) String() string { + ip := x.Address.String() + return ip + "/" + strconv.Itoa(int(x.Len)) +} +func (x *IP6Prefix) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} +func (x *IP6Prefix) UnmarshalText(text []byte) error { + prefix, err := ParseIP6Prefix(string(text)) + if err != nil { + return err + } + *x = prefix + return nil +} + +// Mprefix defines type 'mprefix'. +type Mprefix struct { + Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + GrpAddressLength uint16 `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"` + GrpAddress AddressUnion `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"` + SrcAddress AddressUnion `binapi:"address_union,name=src_address" json:"src_address,omitempty"` +} + +// Prefix defines type 'prefix'. +type Prefix struct { + Address Address `binapi:"address,name=address" json:"address,omitempty"` + Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` +} + +func ParsePrefix(ip string) (prefix Prefix, err error) { + hasPrefix := strings.Contains(ip, "/") + if hasPrefix { + netIP, network, err := net.ParseCIDR(ip) + if err != nil { + return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err) + } + maskSize, _ := network.Mask.Size() + prefix.Len = byte(maskSize) + prefix.Address, err = ParseAddress(netIP.String()) + if err != nil { + return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err) + } + } else { + netIP := net.ParseIP(ip) + defaultMaskSize, _ := net.CIDRMask(32, 32).Size() + if netIP.To4() == nil { + defaultMaskSize, _ = net.CIDRMask(128, 128).Size() + } + prefix.Len = byte(defaultMaskSize) + prefix.Address, err = ParseAddress(netIP.String()) + if err != nil { + return Prefix{}, fmt.Errorf("invalid IP %s: %s", ip, err) + } + } + return prefix, nil +} +func (x Prefix) ToIPNet() *net.IPNet { + var mask net.IPMask + if x.Address.Af == ADDRESS_IP4 { + mask = net.CIDRMask(int(x.Len), 32) + } else { + mask = net.CIDRMask(int(x.Len), 128) + } + ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask} + return ipnet +} +func (x Prefix) String() string { + ip := x.Address.String() + return ip + "/" + strconv.Itoa(int(x.Len)) +} +func (x *Prefix) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} +func (x *Prefix) UnmarshalText(text []byte) error { + prefix, err := ParsePrefix(string(text)) + if err != nil { + return err + } + *x = prefix + return nil +} + +// PrefixMatcher defines type 'prefix_matcher'. +type PrefixMatcher struct { + Le uint8 `binapi:"u8,name=le" json:"le,omitempty"` + Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"` +} + +// Punt defines type 'punt'. +type Punt struct { + Type PuntType `binapi:"punt_type,name=type" json:"type,omitempty"` + Punt PuntUnion `binapi:"punt_union,name=punt" json:"punt,omitempty"` +} + +// PuntException defines type 'punt_exception'. +type PuntException struct { + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` +} + +// PuntIPProto defines type 'punt_ip_proto'. +type PuntIPProto struct { + Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + Protocol IPProto `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"` +} + +// PuntL4 defines type 'punt_l4'. +type PuntL4 struct { + Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` + Protocol IPProto `binapi:"ip_proto,name=protocol" json:"protocol,omitempty"` + Port uint16 `binapi:"u16,name=port" json:"port,omitempty"` +} + +// PuntReason defines type 'punt_reason'. +type PuntReason struct { + ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` + Name string `binapi:"string[],name=name" json:"name,omitempty"` +} + +// AddressUnion defines union 'address_union'. +type AddressUnion struct { + // IP4 *IP4Address + // IP6 *IP6Address + XXX_UnionData [16]byte +} + +func AddressUnionIP4(a IP4Address) (u AddressUnion) { + u.SetIP4(a) + return +} +func (u *AddressUnion) SetIP4(a IP4Address) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeBytes(a[:], 4) +} +func (u *AddressUnion) GetIP4() (a IP4Address) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + copy(a[:], buf.DecodeBytes(4)) + return +} + +func AddressUnionIP6(a IP6Address) (u AddressUnion) { + u.SetIP6(a) + return +} +func (u *AddressUnion) SetIP6(a IP6Address) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeBytes(a[:], 16) +} +func (u *AddressUnion) GetIP6() (a IP6Address) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + copy(a[:], buf.DecodeBytes(16)) + return +} + +// PuntUnion defines union 'punt_union'. +type PuntUnion struct { + // Exception *PuntException + // L4 *PuntL4 + // IPProto *PuntIPProto + XXX_UnionData [10]byte +} + +func PuntUnionException(a PuntException) (u PuntUnion) { + u.SetException(a) + return +} +func (u *PuntUnion) SetException(a PuntException) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeUint32(a.ID) +} +func (u *PuntUnion) GetException() (a PuntException) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + a.ID = buf.DecodeUint32() + return +} + +func PuntUnionL4(a PuntL4) (u PuntUnion) { + u.SetL4(a) + return +} +func (u *PuntUnion) SetL4(a PuntL4) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeUint32(uint32(a.Af)) + buf.EncodeUint32(uint32(a.Protocol)) + buf.EncodeUint16(a.Port) +} +func (u *PuntUnion) GetL4() (a PuntL4) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + a.Af = AddressFamily(buf.DecodeUint32()) + a.Protocol = IPProto(buf.DecodeUint32()) + a.Port = buf.DecodeUint16() + return +} + +func PuntUnionIPProto(a PuntIPProto) (u PuntUnion) { + u.SetIPProto(a) + return +} +func (u *PuntUnion) SetIPProto(a PuntIPProto) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + buf.EncodeUint32(uint32(a.Af)) + buf.EncodeUint32(uint32(a.Protocol)) +} +func (u *PuntUnion) GetIPProto() (a PuntIPProto) { + buf := codec.NewBuffer(u.XXX_UnionData[:]) + a.Af = AddressFamily(buf.DecodeUint32()) + a.Protocol = IPProto(buf.DecodeUint32()) + return +} + +// PuntReasonDetails defines message 'punt_reason_details'. +type PuntReasonDetails struct { + Reason PuntReason `binapi:"punt_reason,name=reason" json:"reason,omitempty"` +} + +func (m *PuntReasonDetails) Reset() { *m = PuntReasonDetails{} } +func (*PuntReasonDetails) GetMessageName() string { return "punt_reason_details" } +func (*PuntReasonDetails) GetCrcString() string { return "2c9d4a40" } +func (*PuntReasonDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PuntReasonDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Reason.ID + size += 4 + len(m.Reason.Name) // m.Reason.Name + return size +} +func (m *PuntReasonDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Reason.ID) + buf.EncodeString(m.Reason.Name, 0) + return buf.Bytes(), nil +} +func (m *PuntReasonDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Reason.ID = buf.DecodeUint32() + m.Reason.Name = buf.DecodeString(0) + return nil +} + +// PuntReasonDump defines message 'punt_reason_dump'. +type PuntReasonDump struct { + Reason PuntReason `binapi:"punt_reason,name=reason" json:"reason,omitempty"` +} + +func (m *PuntReasonDump) Reset() { *m = PuntReasonDump{} } +func (*PuntReasonDump) GetMessageName() string { return "punt_reason_dump" } +func (*PuntReasonDump) GetCrcString() string { return "5c0dd4fe" } +func (*PuntReasonDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PuntReasonDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Reason.ID + size += 4 + len(m.Reason.Name) // m.Reason.Name + return size +} +func (m *PuntReasonDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.Reason.ID) + buf.EncodeString(m.Reason.Name, 0) + return buf.Bytes(), nil +} +func (m *PuntReasonDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Reason.ID = buf.DecodeUint32() + m.Reason.Name = buf.DecodeString(0) + return nil +} + +// PuntSocketDeregister defines message 'punt_socket_deregister'. +type PuntSocketDeregister struct { + Punt Punt `binapi:"punt,name=punt" json:"punt,omitempty"` +} + +func (m *PuntSocketDeregister) Reset() { *m = PuntSocketDeregister{} } +func (*PuntSocketDeregister) GetMessageName() string { return "punt_socket_deregister" } +func (*PuntSocketDeregister) GetCrcString() string { return "98a444f4" } +func (*PuntSocketDeregister) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PuntSocketDeregister) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Punt.Type + size += 1 * 10 // m.Punt.Punt + return size +} +func (m *PuntSocketDeregister) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Punt.Type)) + buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 10) + return buf.Bytes(), nil +} +func (m *PuntSocketDeregister) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Punt.Type = PuntType(buf.DecodeUint32()) + copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(10)) + return nil +} + +// PuntSocketDeregisterReply defines message 'punt_socket_deregister_reply'. +type PuntSocketDeregisterReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PuntSocketDeregisterReply) Reset() { *m = PuntSocketDeregisterReply{} } +func (*PuntSocketDeregisterReply) GetMessageName() string { return "punt_socket_deregister_reply" } +func (*PuntSocketDeregisterReply) GetCrcString() string { return "e8d4e804" } +func (*PuntSocketDeregisterReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PuntSocketDeregisterReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PuntSocketDeregisterReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PuntSocketDeregisterReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// PuntSocketDetails defines message 'punt_socket_details'. +type PuntSocketDetails struct { + Punt Punt `binapi:"punt,name=punt" json:"punt,omitempty"` + Pathname string `binapi:"string[108],name=pathname" json:"pathname,omitempty"` +} + +func (m *PuntSocketDetails) Reset() { *m = PuntSocketDetails{} } +func (*PuntSocketDetails) GetMessageName() string { return "punt_socket_details" } +func (*PuntSocketDetails) GetCrcString() string { return "1de0ce75" } +func (*PuntSocketDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PuntSocketDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Punt.Type + size += 1 * 10 // m.Punt.Punt + size += 108 // m.Pathname + return size +} +func (m *PuntSocketDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Punt.Type)) + buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 10) + buf.EncodeString(m.Pathname, 108) + return buf.Bytes(), nil +} +func (m *PuntSocketDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Punt.Type = PuntType(buf.DecodeUint32()) + copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(10)) + m.Pathname = buf.DecodeString(108) + return nil +} + +// PuntSocketDump defines message 'punt_socket_dump'. +type PuntSocketDump struct { + Type PuntType `binapi:"punt_type,name=type" json:"type,omitempty"` +} + +func (m *PuntSocketDump) Reset() { *m = PuntSocketDump{} } +func (*PuntSocketDump) GetMessageName() string { return "punt_socket_dump" } +func (*PuntSocketDump) GetCrcString() string { return "52974935" } +func (*PuntSocketDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PuntSocketDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Type + return size +} +func (m *PuntSocketDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.Type)) + return buf.Bytes(), nil +} +func (m *PuntSocketDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Type = PuntType(buf.DecodeUint32()) + return nil +} + +// PuntSocketRegister defines message 'punt_socket_register'. +type PuntSocketRegister struct { + HeaderVersion uint32 `binapi:"u32,name=header_version" json:"header_version,omitempty"` + Punt Punt `binapi:"punt,name=punt" json:"punt,omitempty"` + Pathname string `binapi:"string[108],name=pathname" json:"pathname,omitempty"` +} + +func (m *PuntSocketRegister) Reset() { *m = PuntSocketRegister{} } +func (*PuntSocketRegister) GetMessageName() string { return "punt_socket_register" } +func (*PuntSocketRegister) GetCrcString() string { return "c8cd10fa" } +func (*PuntSocketRegister) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PuntSocketRegister) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.HeaderVersion + size += 4 // m.Punt.Type + size += 1 * 10 // m.Punt.Punt + size += 108 // m.Pathname + return size +} +func (m *PuntSocketRegister) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.HeaderVersion) + buf.EncodeUint32(uint32(m.Punt.Type)) + buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 10) + buf.EncodeString(m.Pathname, 108) + return buf.Bytes(), nil +} +func (m *PuntSocketRegister) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.HeaderVersion = buf.DecodeUint32() + m.Punt.Type = PuntType(buf.DecodeUint32()) + copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(10)) + m.Pathname = buf.DecodeString(108) + return nil +} + +// PuntSocketRegisterReply defines message 'punt_socket_register_reply'. +type PuntSocketRegisterReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Pathname string `binapi:"string[108],name=pathname" json:"pathname,omitempty"` +} + +func (m *PuntSocketRegisterReply) Reset() { *m = PuntSocketRegisterReply{} } +func (*PuntSocketRegisterReply) GetMessageName() string { return "punt_socket_register_reply" } +func (*PuntSocketRegisterReply) GetCrcString() string { return "bd30ae90" } +func (*PuntSocketRegisterReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PuntSocketRegisterReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 108 // m.Pathname + return size +} +func (m *PuntSocketRegisterReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeString(m.Pathname, 108) + return buf.Bytes(), nil +} +func (m *PuntSocketRegisterReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Pathname = buf.DecodeString(108) + return nil +} + +// SetPunt defines message 'set_punt'. +type SetPunt struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + Punt Punt `binapi:"punt,name=punt" json:"punt,omitempty"` +} + +func (m *SetPunt) Reset() { *m = SetPunt{} } +func (*SetPunt) GetMessageName() string { return "set_punt" } +func (*SetPunt) GetCrcString() string { return "83799618" } +func (*SetPunt) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *SetPunt) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.Punt.Type + size += 1 * 10 // m.Punt.Punt + return size +} +func (m *SetPunt) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(uint32(m.Punt.Type)) + buf.EncodeBytes(m.Punt.Punt.XXX_UnionData[:], 10) + return buf.Bytes(), nil +} +func (m *SetPunt) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.Punt.Type = PuntType(buf.DecodeUint32()) + copy(m.Punt.Punt.XXX_UnionData[:], buf.DecodeBytes(10)) + return nil +} + +// SetPuntReply defines message 'set_punt_reply'. +type SetPuntReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SetPuntReply) Reset() { *m = SetPuntReply{} } +func (*SetPuntReply) GetMessageName() string { return "set_punt_reply" } +func (*SetPuntReply) GetCrcString() string { return "e8d4e804" } +func (*SetPuntReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *SetPuntReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *SetPuntReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *SetPuntReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_punt_binapi_init() } +func file_punt_binapi_init() { + api.RegisterMessage((*PuntReasonDetails)(nil), "punt_reason_details_2c9d4a40") + api.RegisterMessage((*PuntReasonDump)(nil), "punt_reason_dump_5c0dd4fe") + api.RegisterMessage((*PuntSocketDeregister)(nil), "punt_socket_deregister_98a444f4") + api.RegisterMessage((*PuntSocketDeregisterReply)(nil), "punt_socket_deregister_reply_e8d4e804") + api.RegisterMessage((*PuntSocketDetails)(nil), "punt_socket_details_1de0ce75") + api.RegisterMessage((*PuntSocketDump)(nil), "punt_socket_dump_52974935") + api.RegisterMessage((*PuntSocketRegister)(nil), "punt_socket_register_c8cd10fa") + api.RegisterMessage((*PuntSocketRegisterReply)(nil), "punt_socket_register_reply_bd30ae90") + api.RegisterMessage((*SetPunt)(nil), "set_punt_83799618") + api.RegisterMessage((*SetPuntReply)(nil), "set_punt_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*PuntReasonDetails)(nil), + (*PuntReasonDump)(nil), + (*PuntSocketDeregister)(nil), + (*PuntSocketDeregisterReply)(nil), + (*PuntSocketDetails)(nil), + (*PuntSocketDump)(nil), + (*PuntSocketRegister)(nil), + (*PuntSocketRegisterReply)(nil), + (*SetPunt)(nil), + (*SetPuntReply)(nil), + } +} -- cgit 1.2.3-korg