diff options
Diffstat (limited to 'internal/testbinapi/binapi2001')
195 files changed, 3389 insertions, 1024 deletions
diff --git a/internal/testbinapi/binapi2001/abf/abf.ba.go b/internal/testbinapi/binapi2001/abf/abf.ba.go index a7b67bd..ce80c2f 100644 --- a/internal/testbinapi/binapi2001/abf/abf.ba.go +++ b/internal/testbinapi/binapi2001/abf/abf.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/abf.api.json @@ -17,11 +17,12 @@ package abf import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -640,12 +641,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -674,12 +678,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -708,12 +715,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -753,6 +763,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -765,8 +779,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -776,12 +791,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -855,18 +873,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -909,18 +931,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -971,6 +997,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -981,13 +1008,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -1005,8 +1035,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/abf/abf_rpc.ba.go b/internal/testbinapi/binapi2001/abf/abf_rpc.ba.go index 0d98cfc..c59d448 100644 --- a/internal/testbinapi/binapi2001/abf/abf_rpc.ba.go +++ b/internal/testbinapi/binapi2001/abf/abf_rpc.ba.go @@ -5,12 +5,13 @@ package abf import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service abf. +// RPCService defines RPC service abf. type RPCService interface { AbfItfAttachAddDel(ctx context.Context, in *AbfItfAttachAddDel) (*AbfItfAttachAddDelReply, error) AbfItfAttachDump(ctx context.Context, in *AbfItfAttachDump) (RPCService_AbfItfAttachDumpClient, error) @@ -33,7 +34,7 @@ func (c *serviceClient) AbfItfAttachAddDel(ctx context.Context, in *AbfItfAttach if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) AbfItfAttachDump(ctx context.Context, in *AbfItfAttachDump) (RPCService_AbfItfAttachDumpClient, error) { @@ -69,6 +70,10 @@ func (c *serviceClient_AbfItfAttachDumpClient) Recv() (*AbfItfAttachDetails, err case *AbfItfAttachDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -90,7 +95,7 @@ func (c *serviceClient) AbfPolicyAddDel(ctx context.Context, in *AbfPolicyAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) AbfPolicyDump(ctx context.Context, in *AbfPolicyDump) (RPCService_AbfPolicyDumpClient, error) { @@ -126,6 +131,10 @@ func (c *serviceClient_AbfPolicyDumpClient) Recv() (*AbfPolicyDetails, error) { case *AbfPolicyDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/acl/acl.ba.go b/internal/testbinapi/binapi2001/acl/acl.ba.go index 091f63a..f21b2ae 100644 --- a/internal/testbinapi/binapi2001/acl/acl.ba.go +++ b/internal/testbinapi/binapi2001/acl/acl.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/acl.api.json diff --git a/internal/testbinapi/binapi2001/acl/acl_rpc.ba.go b/internal/testbinapi/binapi2001/acl/acl_rpc.ba.go index 5e23fef..ecaa865 100644 --- a/internal/testbinapi/binapi2001/acl/acl_rpc.ba.go +++ b/internal/testbinapi/binapi2001/acl/acl_rpc.ba.go @@ -5,12 +5,13 @@ package acl import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service acl. +// RPCService defines RPC service acl. type RPCService interface { ACLAddReplace(ctx context.Context, in *ACLAddReplace) (*ACLAddReplaceReply, error) ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) @@ -47,7 +48,7 @@ func (c *serviceClient) ACLAddReplace(ctx context.Context, in *ACLAddReplace) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) { @@ -56,7 +57,7 @@ func (c *serviceClient) ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, e if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ACLDump(ctx context.Context, in *ACLDump) (RPCService_ACLDumpClient, error) { @@ -92,6 +93,10 @@ func (c *serviceClient_ACLDumpClient) Recv() (*ACLDetails, error) { case *ACLDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -104,7 +109,7 @@ func (c *serviceClient) ACLInterfaceAddDel(ctx context.Context, in *ACLInterface if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ACLInterfaceEtypeWhitelistDump(ctx context.Context, in *ACLInterfaceEtypeWhitelistDump) (RPCService_ACLInterfaceEtypeWhitelistDumpClient, error) { @@ -140,6 +145,10 @@ func (c *serviceClient_ACLInterfaceEtypeWhitelistDumpClient) Recv() (*ACLInterfa case *ACLInterfaceEtypeWhitelistDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -179,6 +188,10 @@ func (c *serviceClient_ACLInterfaceListDumpClient) Recv() (*ACLInterfaceListDeta case *ACLInterfaceListDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -191,7 +204,7 @@ func (c *serviceClient) ACLInterfaceSetACLList(ctx context.Context, in *ACLInter if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ACLInterfaceSetEtypeWhitelist(ctx context.Context, in *ACLInterfaceSetEtypeWhitelist) (*ACLInterfaceSetEtypeWhitelistReply, error) { @@ -200,7 +213,7 @@ func (c *serviceClient) ACLInterfaceSetEtypeWhitelist(ctx context.Context, in *A if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ACLPluginControlPing(ctx context.Context, in *ACLPluginControlPing) (*ACLPluginControlPingReply, error) { @@ -209,7 +222,7 @@ func (c *serviceClient) ACLPluginControlPing(ctx context.Context, in *ACLPluginC if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ACLPluginGetConnTableMaxEntries(ctx context.Context, in *ACLPluginGetConnTableMaxEntries) (*ACLPluginGetConnTableMaxEntriesReply, error) { @@ -236,7 +249,7 @@ func (c *serviceClient) ACLStatsIntfCountersEnable(ctx context.Context, in *ACLS if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MacipACLAdd(ctx context.Context, in *MacipACLAdd) (*MacipACLAddReply, error) { @@ -245,7 +258,7 @@ func (c *serviceClient) MacipACLAdd(ctx context.Context, in *MacipACLAdd) (*Maci if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MacipACLAddReplace(ctx context.Context, in *MacipACLAddReplace) (*MacipACLAddReplaceReply, error) { @@ -254,7 +267,7 @@ func (c *serviceClient) MacipACLAddReplace(ctx context.Context, in *MacipACLAddR if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MacipACLDel(ctx context.Context, in *MacipACLDel) (*MacipACLDelReply, error) { @@ -263,7 +276,7 @@ func (c *serviceClient) MacipACLDel(ctx context.Context, in *MacipACLDel) (*Maci if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MacipACLDump(ctx context.Context, in *MacipACLDump) (RPCService_MacipACLDumpClient, error) { @@ -299,6 +312,10 @@ func (c *serviceClient_MacipACLDumpClient) Recv() (*MacipACLDetails, error) { case *MacipACLDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -311,7 +328,7 @@ func (c *serviceClient) MacipACLInterfaceAddDel(ctx context.Context, in *MacipAC if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MacipACLInterfaceGet(ctx context.Context, in *MacipACLInterfaceGet) (*MacipACLInterfaceGetReply, error) { @@ -356,6 +373,10 @@ func (c *serviceClient_MacipACLInterfaceListDumpClient) Recv() (*MacipACLInterfa case *MacipACLInterfaceListDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/acl_types/acl_types.ba.go b/internal/testbinapi/binapi2001/acl_types/acl_types.ba.go index 6f8d39d..e5ae659 100644 --- a/internal/testbinapi/binapi2001/acl_types/acl_types.ba.go +++ b/internal/testbinapi/binapi2001/acl_types/acl_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/acl_types.api.json @@ -21,6 +21,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "acl_types" + APIVersion = "" + VersionCrc = 0x1803336d +) + // ACLRule defines type 'acl_rule'. type ACLRule struct { IsPermit uint8 `binapi:"u8,name=is_permit" json:"is_permit,omitempty"` diff --git a/internal/testbinapi/binapi2001/af_packet/af_packet.ba.go b/internal/testbinapi/binapi2001/af_packet/af_packet.ba.go index ff82ee7..a3a8183 100644 --- a/internal/testbinapi/binapi2001/af_packet/af_packet.ba.go +++ b/internal/testbinapi/binapi2001/af_packet/af_packet.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/af_packet.api.json @@ -14,10 +14,11 @@ package af_packet import ( - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -298,15 +299,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { diff --git a/internal/testbinapi/binapi2001/af_packet/af_packet_rpc.ba.go b/internal/testbinapi/binapi2001/af_packet/af_packet_rpc.ba.go index 4b0fc7c..19355ab 100644 --- a/internal/testbinapi/binapi2001/af_packet/af_packet_rpc.ba.go +++ b/internal/testbinapi/binapi2001/af_packet/af_packet_rpc.ba.go @@ -5,12 +5,13 @@ package af_packet import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service af_packet. +// RPCService defines RPC service af_packet. type RPCService interface { AfPacketCreate(ctx context.Context, in *AfPacketCreate) (*AfPacketCreateReply, error) AfPacketDelete(ctx context.Context, in *AfPacketDelete) (*AfPacketDeleteReply, error) @@ -32,7 +33,7 @@ func (c *serviceClient) AfPacketCreate(ctx context.Context, in *AfPacketCreate) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) AfPacketDelete(ctx context.Context, in *AfPacketDelete) (*AfPacketDeleteReply, error) { @@ -41,7 +42,7 @@ func (c *serviceClient) AfPacketDelete(ctx context.Context, in *AfPacketDelete) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) AfPacketDump(ctx context.Context, in *AfPacketDump) (RPCService_AfPacketDumpClient, error) { @@ -77,6 +78,10 @@ func (c *serviceClient_AfPacketDumpClient) Recv() (*AfPacketDetails, error) { case *AfPacketDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -89,5 +94,5 @@ func (c *serviceClient) AfPacketSetL4CksumOffload(ctx context.Context, in *AfPac if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/arp/arp.ba.go b/internal/testbinapi/binapi2001/arp/arp.ba.go index 988cfb3..04b0e26 100644 --- a/internal/testbinapi/binapi2001/arp/arp.ba.go +++ b/internal/testbinapi/binapi2001/arp/arp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/arp.api.json @@ -17,11 +17,12 @@ package arp import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -596,15 +606,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { @@ -625,6 +639,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -637,8 +655,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -648,12 +667,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -696,18 +718,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -750,18 +776,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -812,6 +842,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -822,13 +853,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -853,8 +887,9 @@ type ProxyArp struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/arp/arp_rpc.ba.go b/internal/testbinapi/binapi2001/arp/arp_rpc.ba.go index 77e6a26..79b7ed8 100644 --- a/internal/testbinapi/binapi2001/arp/arp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/arp/arp_rpc.ba.go @@ -5,12 +5,13 @@ package arp import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service arp. +// RPCService defines RPC service arp. type RPCService interface { ProxyArpAddDel(ctx context.Context, in *ProxyArpAddDel) (*ProxyArpAddDelReply, error) ProxyArpDump(ctx context.Context, in *ProxyArpDump) (RPCService_ProxyArpDumpClient, error) @@ -32,7 +33,7 @@ func (c *serviceClient) ProxyArpAddDel(ctx context.Context, in *ProxyArpAddDel) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ProxyArpDump(ctx context.Context, in *ProxyArpDump) (RPCService_ProxyArpDumpClient, error) { @@ -68,6 +69,10 @@ func (c *serviceClient_ProxyArpDumpClient) Recv() (*ProxyArpDetails, error) { case *ProxyArpDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -107,6 +112,10 @@ func (c *serviceClient_ProxyArpIntfcDumpClient) Recv() (*ProxyArpIntfcDetails, e case *ProxyArpIntfcDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -119,5 +128,5 @@ func (c *serviceClient) ProxyArpIntfcEnableDisable(ctx context.Context, in *Prox if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/avf/avf.ba.go b/internal/testbinapi/binapi2001/avf/avf.ba.go index 06b17e5..da63230 100644 --- a/internal/testbinapi/binapi2001/avf/avf.ba.go +++ b/internal/testbinapi/binapi2001/avf/avf.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/avf.api.json @@ -14,9 +14,10 @@ package avf import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/avf/avf_rpc.ba.go b/internal/testbinapi/binapi2001/avf/avf_rpc.ba.go index 90f854e..5747834 100644 --- a/internal/testbinapi/binapi2001/avf/avf_rpc.ba.go +++ b/internal/testbinapi/binapi2001/avf/avf_rpc.ba.go @@ -4,10 +4,11 @@ package avf import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service avf. +// RPCService defines RPC service avf. type RPCService interface { AvfCreate(ctx context.Context, in *AvfCreate) (*AvfCreateReply, error) AvfDelete(ctx context.Context, in *AvfDelete) (*AvfDeleteReply, error) @@ -27,7 +28,7 @@ func (c *serviceClient) AvfCreate(ctx context.Context, in *AvfCreate) (*AvfCreat if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) AvfDelete(ctx context.Context, in *AvfDelete) (*AvfDeleteReply, error) { @@ -36,5 +37,5 @@ func (c *serviceClient) AvfDelete(ctx context.Context, in *AvfDelete) (*AvfDelet if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/bfd/bfd.ba.go b/internal/testbinapi/binapi2001/bfd/bfd.ba.go index 236c511..f83cc33 100644 --- a/internal/testbinapi/binapi2001/bfd/bfd.ba.go +++ b/internal/testbinapi/binapi2001/bfd/bfd.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/bfd.api.json @@ -17,11 +17,12 @@ package bfd import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -531,12 +532,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -565,12 +569,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -599,12 +606,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -628,6 +638,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -640,8 +654,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -651,12 +666,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -699,18 +717,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -753,18 +775,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -815,6 +841,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -825,13 +852,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -849,8 +879,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/bfd/bfd_rpc.ba.go b/internal/testbinapi/binapi2001/bfd/bfd_rpc.ba.go index 214b2a3..a9a9472 100644 --- a/internal/testbinapi/binapi2001/bfd/bfd_rpc.ba.go +++ b/internal/testbinapi/binapi2001/bfd/bfd_rpc.ba.go @@ -5,12 +5,13 @@ package bfd import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service bfd. +// RPCService defines RPC service bfd. type RPCService interface { BfdAuthDelKey(ctx context.Context, in *BfdAuthDelKey) (*BfdAuthDelKeyReply, error) BfdAuthKeysDump(ctx context.Context, in *BfdAuthKeysDump) (RPCService_BfdAuthKeysDumpClient, error) @@ -42,7 +43,7 @@ func (c *serviceClient) BfdAuthDelKey(ctx context.Context, in *BfdAuthDelKey) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BfdAuthKeysDump(ctx context.Context, in *BfdAuthKeysDump) (RPCService_BfdAuthKeysDumpClient, error) { @@ -78,6 +79,10 @@ func (c *serviceClient_BfdAuthKeysDumpClient) Recv() (*BfdAuthKeysDetails, error case *BfdAuthKeysDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -90,7 +95,7 @@ func (c *serviceClient) BfdAuthSetKey(ctx context.Context, in *BfdAuthSetKey) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BfdUDPAdd(ctx context.Context, in *BfdUDPAdd) (*BfdUDPAddReply, error) { @@ -99,7 +104,7 @@ func (c *serviceClient) BfdUDPAdd(ctx context.Context, in *BfdUDPAdd) (*BfdUDPAd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BfdUDPAuthActivate(ctx context.Context, in *BfdUDPAuthActivate) (*BfdUDPAuthActivateReply, error) { @@ -108,7 +113,7 @@ func (c *serviceClient) BfdUDPAuthActivate(ctx context.Context, in *BfdUDPAuthAc if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BfdUDPAuthDeactivate(ctx context.Context, in *BfdUDPAuthDeactivate) (*BfdUDPAuthDeactivateReply, error) { @@ -117,7 +122,7 @@ func (c *serviceClient) BfdUDPAuthDeactivate(ctx context.Context, in *BfdUDPAuth if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BfdUDPDel(ctx context.Context, in *BfdUDPDel) (*BfdUDPDelReply, error) { @@ -126,7 +131,7 @@ func (c *serviceClient) BfdUDPDel(ctx context.Context, in *BfdUDPDel) (*BfdUDPDe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BfdUDPDelEchoSource(ctx context.Context, in *BfdUDPDelEchoSource) (*BfdUDPDelEchoSourceReply, error) { @@ -135,7 +140,7 @@ func (c *serviceClient) BfdUDPDelEchoSource(ctx context.Context, in *BfdUDPDelEc if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BfdUDPGetEchoSource(ctx context.Context, in *BfdUDPGetEchoSource) (*BfdUDPGetEchoSourceReply, error) { @@ -144,7 +149,7 @@ func (c *serviceClient) BfdUDPGetEchoSource(ctx context.Context, in *BfdUDPGetEc if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BfdUDPMod(ctx context.Context, in *BfdUDPMod) (*BfdUDPModReply, error) { @@ -153,7 +158,7 @@ func (c *serviceClient) BfdUDPMod(ctx context.Context, in *BfdUDPMod) (*BfdUDPMo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BfdUDPSessionDump(ctx context.Context, in *BfdUDPSessionDump) (RPCService_BfdUDPSessionDumpClient, error) { @@ -189,6 +194,10 @@ func (c *serviceClient_BfdUDPSessionDumpClient) Recv() (*BfdUDPSessionDetails, e case *BfdUDPSessionDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -201,7 +210,7 @@ func (c *serviceClient) BfdUDPSessionSetFlags(ctx context.Context, in *BfdUDPSes if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BfdUDPSetEchoSource(ctx context.Context, in *BfdUDPSetEchoSource) (*BfdUDPSetEchoSourceReply, error) { @@ -210,7 +219,7 @@ func (c *serviceClient) BfdUDPSetEchoSource(ctx context.Context, in *BfdUDPSetEc if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) WantBfdEvents(ctx context.Context, in *WantBfdEvents) (*WantBfdEventsReply, error) { @@ -219,5 +228,5 @@ func (c *serviceClient) WantBfdEvents(ctx context.Context, in *WantBfdEvents) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/bier/bier.ba.go b/internal/testbinapi/binapi2001/bier/bier.ba.go index 238aa23..ed46a97 100644 --- a/internal/testbinapi/binapi2001/bier/bier.ba.go +++ b/internal/testbinapi/binapi2001/bier/bier.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/bier.api.json @@ -17,11 +17,12 @@ package bier import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -389,12 +390,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -420,12 +424,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -454,12 +461,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -483,6 +493,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -495,8 +509,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -506,12 +521,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -600,18 +618,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -654,18 +676,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -716,6 +742,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -726,13 +753,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -750,8 +780,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/bier/bier_rpc.ba.go b/internal/testbinapi/binapi2001/bier/bier_rpc.ba.go index ae6d90f..a16cb9b 100644 --- a/internal/testbinapi/binapi2001/bier/bier_rpc.ba.go +++ b/internal/testbinapi/binapi2001/bier/bier_rpc.ba.go @@ -5,12 +5,13 @@ package bier import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service bier. +// RPCService defines RPC service bier. type RPCService interface { BierDispEntryAddDel(ctx context.Context, in *BierDispEntryAddDel) (*BierDispEntryAddDelReply, error) BierDispEntryDump(ctx context.Context, in *BierDispEntryDump) (RPCService_BierDispEntryDumpClient, error) @@ -39,7 +40,7 @@ func (c *serviceClient) BierDispEntryAddDel(ctx context.Context, in *BierDispEnt if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BierDispEntryDump(ctx context.Context, in *BierDispEntryDump) (RPCService_BierDispEntryDumpClient, error) { @@ -75,6 +76,10 @@ func (c *serviceClient_BierDispEntryDumpClient) Recv() (*BierDispEntryDetails, e case *BierDispEntryDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -87,7 +92,7 @@ func (c *serviceClient) BierDispTableAddDel(ctx context.Context, in *BierDispTab if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BierDispTableDump(ctx context.Context, in *BierDispTableDump) (RPCService_BierDispTableDumpClient, error) { @@ -123,6 +128,10 @@ func (c *serviceClient_BierDispTableDumpClient) Recv() (*BierDispTableDetails, e case *BierDispTableDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -135,7 +144,7 @@ func (c *serviceClient) BierImpAdd(ctx context.Context, in *BierImpAdd) (*BierIm if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BierImpDel(ctx context.Context, in *BierImpDel) (*BierImpDelReply, error) { @@ -144,7 +153,7 @@ func (c *serviceClient) BierImpDel(ctx context.Context, in *BierImpDel) (*BierIm if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BierImpDump(ctx context.Context, in *BierImpDump) (RPCService_BierImpDumpClient, error) { @@ -180,6 +189,10 @@ func (c *serviceClient_BierImpDumpClient) Recv() (*BierImpDetails, error) { case *BierImpDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -192,7 +205,7 @@ func (c *serviceClient) BierRouteAddDel(ctx context.Context, in *BierRouteAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BierRouteDump(ctx context.Context, in *BierRouteDump) (RPCService_BierRouteDumpClient, error) { @@ -228,6 +241,10 @@ func (c *serviceClient_BierRouteDumpClient) Recv() (*BierRouteDetails, error) { case *BierRouteDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -240,7 +257,7 @@ func (c *serviceClient) BierTableAddDel(ctx context.Context, in *BierTableAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BierTableDump(ctx context.Context, in *BierTableDump) (RPCService_BierTableDumpClient, error) { @@ -276,6 +293,10 @@ func (c *serviceClient_BierTableDumpClient) Recv() (*BierTableDetails, error) { case *BierTableDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/bond/bond.ba.go b/internal/testbinapi/binapi2001/bond/bond.ba.go index acee8b8..38e81cb 100644 --- a/internal/testbinapi/binapi2001/bond/bond.ba.go +++ b/internal/testbinapi/binapi2001/bond/bond.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/bond.api.json @@ -14,10 +14,11 @@ package bond import ( - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -373,15 +374,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { diff --git a/internal/testbinapi/binapi2001/bond/bond_rpc.ba.go b/internal/testbinapi/binapi2001/bond/bond_rpc.ba.go index e59e0b0..d9625d9 100644 --- a/internal/testbinapi/binapi2001/bond/bond_rpc.ba.go +++ b/internal/testbinapi/binapi2001/bond/bond_rpc.ba.go @@ -5,12 +5,13 @@ package bond import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service bond. +// RPCService defines RPC service bond. type RPCService interface { BondCreate(ctx context.Context, in *BondCreate) (*BondCreateReply, error) BondDelete(ctx context.Context, in *BondDelete) (*BondDeleteReply, error) @@ -35,7 +36,7 @@ func (c *serviceClient) BondCreate(ctx context.Context, in *BondCreate) (*BondCr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BondDelete(ctx context.Context, in *BondDelete) (*BondDeleteReply, error) { @@ -44,7 +45,7 @@ func (c *serviceClient) BondDelete(ctx context.Context, in *BondDelete) (*BondDe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BondDetachSlave(ctx context.Context, in *BondDetachSlave) (*BondDetachSlaveReply, error) { @@ -53,7 +54,7 @@ func (c *serviceClient) BondDetachSlave(ctx context.Context, in *BondDetachSlave if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BondEnslave(ctx context.Context, in *BondEnslave) (*BondEnslaveReply, error) { @@ -62,7 +63,7 @@ func (c *serviceClient) BondEnslave(ctx context.Context, in *BondEnslave) (*Bond if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceBondDump(ctx context.Context, in *SwInterfaceBondDump) (RPCService_SwInterfaceBondDumpClient, error) { @@ -98,6 +99,10 @@ func (c *serviceClient_SwInterfaceBondDumpClient) Recv() (*SwInterfaceBondDetail case *SwInterfaceBondDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -110,7 +115,7 @@ func (c *serviceClient) SwInterfaceSetBondWeight(ctx context.Context, in *SwInte if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSlaveDump(ctx context.Context, in *SwInterfaceSlaveDump) (RPCService_SwInterfaceSlaveDumpClient, error) { @@ -146,6 +151,10 @@ func (c *serviceClient_SwInterfaceSlaveDumpClient) Recv() (*SwInterfaceSlaveDeta case *SwInterfaceSlaveDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/builtinurl/builtinurl.ba.go b/internal/testbinapi/binapi2001/builtinurl/builtinurl.ba.go index 5488027..c0f59e9 100644 --- a/internal/testbinapi/binapi2001/builtinurl/builtinurl.ba.go +++ b/internal/testbinapi/binapi2001/builtinurl/builtinurl.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/builtinurl.api.json diff --git a/internal/testbinapi/binapi2001/builtinurl/builtinurl_rpc.ba.go b/internal/testbinapi/binapi2001/builtinurl/builtinurl_rpc.ba.go index 6857de2..f44e843 100644 --- a/internal/testbinapi/binapi2001/builtinurl/builtinurl_rpc.ba.go +++ b/internal/testbinapi/binapi2001/builtinurl/builtinurl_rpc.ba.go @@ -4,10 +4,11 @@ package builtinurl import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service builtinurl. +// RPCService defines RPC service builtinurl. type RPCService interface { BuiltinurlEnable(ctx context.Context, in *BuiltinurlEnable) (*BuiltinurlEnableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) BuiltinurlEnable(ctx context.Context, in *BuiltinurlEnab if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/cdp/cdp.ba.go b/internal/testbinapi/binapi2001/cdp/cdp.ba.go index 295be82..ef5c91b 100644 --- a/internal/testbinapi/binapi2001/cdp/cdp.ba.go +++ b/internal/testbinapi/binapi2001/cdp/cdp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/cdp.api.json diff --git a/internal/testbinapi/binapi2001/cdp/cdp_rpc.ba.go b/internal/testbinapi/binapi2001/cdp/cdp_rpc.ba.go index a910833..8eac86c 100644 --- a/internal/testbinapi/binapi2001/cdp/cdp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/cdp/cdp_rpc.ba.go @@ -4,10 +4,11 @@ package cdp import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service cdp. +// RPCService defines RPC service cdp. type RPCService interface { CdpEnableDisable(ctx context.Context, in *CdpEnableDisable) (*CdpEnableDisableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) CdpEnableDisable(ctx context.Context, in *CdpEnableDisab if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/classify/classify.ba.go b/internal/testbinapi/binapi2001/classify/classify.ba.go index 9ec195e..b542382 100644 --- a/internal/testbinapi/binapi2001/classify/classify.ba.go +++ b/internal/testbinapi/binapi2001/classify/classify.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/classify.api.json @@ -14,9 +14,10 @@ package classify import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/classify/classify_rpc.ba.go b/internal/testbinapi/binapi2001/classify/classify_rpc.ba.go index fd2fcff..a2b6564 100644 --- a/internal/testbinapi/binapi2001/classify/classify_rpc.ba.go +++ b/internal/testbinapi/binapi2001/classify/classify_rpc.ba.go @@ -5,12 +5,13 @@ package classify import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service classify. +// RPCService defines RPC service classify. type RPCService interface { ClassifyAddDelSession(ctx context.Context, in *ClassifyAddDelSession) (*ClassifyAddDelSessionReply, error) ClassifyAddDelTable(ctx context.Context, in *ClassifyAddDelTable) (*ClassifyAddDelTableReply, error) @@ -42,7 +43,7 @@ func (c *serviceClient) ClassifyAddDelSession(ctx context.Context, in *ClassifyA if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifyAddDelTable(ctx context.Context, in *ClassifyAddDelTable) (*ClassifyAddDelTableReply, error) { @@ -51,7 +52,7 @@ func (c *serviceClient) ClassifyAddDelTable(ctx context.Context, in *ClassifyAdd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifySessionDump(ctx context.Context, in *ClassifySessionDump) (RPCService_ClassifySessionDumpClient, error) { @@ -87,6 +88,10 @@ func (c *serviceClient_ClassifySessionDumpClient) Recv() (*ClassifySessionDetail case *ClassifySessionDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -99,7 +104,7 @@ func (c *serviceClient) ClassifySetInterfaceIPTable(ctx context.Context, in *Cla if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifySetInterfaceL2Tables(ctx context.Context, in *ClassifySetInterfaceL2Tables) (*ClassifySetInterfaceL2TablesReply, error) { @@ -108,7 +113,7 @@ func (c *serviceClient) ClassifySetInterfaceL2Tables(ctx context.Context, in *Cl if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifyTableByInterface(ctx context.Context, in *ClassifyTableByInterface) (*ClassifyTableByInterfaceReply, error) { @@ -117,7 +122,7 @@ func (c *serviceClient) ClassifyTableByInterface(ctx context.Context, in *Classi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifyTableIds(ctx context.Context, in *ClassifyTableIds) (*ClassifyTableIdsReply, error) { @@ -126,7 +131,7 @@ func (c *serviceClient) ClassifyTableIds(ctx context.Context, in *ClassifyTableI if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifyTableInfo(ctx context.Context, in *ClassifyTableInfo) (*ClassifyTableInfoReply, error) { @@ -135,7 +140,7 @@ func (c *serviceClient) ClassifyTableInfo(ctx context.Context, in *ClassifyTable if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) FlowClassifyDump(ctx context.Context, in *FlowClassifyDump) (RPCService_FlowClassifyDumpClient, error) { @@ -171,6 +176,10 @@ func (c *serviceClient_FlowClassifyDumpClient) Recv() (*FlowClassifyDetails, err case *FlowClassifyDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -183,7 +192,7 @@ func (c *serviceClient) FlowClassifySetInterface(ctx context.Context, in *FlowCl if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) InputACLSetInterface(ctx context.Context, in *InputACLSetInterface) (*InputACLSetInterfaceReply, error) { @@ -192,7 +201,7 @@ func (c *serviceClient) InputACLSetInterface(ctx context.Context, in *InputACLSe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OutputACLSetInterface(ctx context.Context, in *OutputACLSetInterface) (*OutputACLSetInterfaceReply, error) { @@ -201,7 +210,7 @@ func (c *serviceClient) OutputACLSetInterface(ctx context.Context, in *OutputACL if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PolicerClassifyDump(ctx context.Context, in *PolicerClassifyDump) (RPCService_PolicerClassifyDumpClient, error) { @@ -237,6 +246,10 @@ func (c *serviceClient_PolicerClassifyDumpClient) Recv() (*PolicerClassifyDetail case *PolicerClassifyDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -249,5 +262,5 @@ func (c *serviceClient) PolicerClassifySetInterface(ctx context.Context, in *Pol if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/cop/cop.ba.go b/internal/testbinapi/binapi2001/cop/cop.ba.go index a65e454..d05b727 100644 --- a/internal/testbinapi/binapi2001/cop/cop.ba.go +++ b/internal/testbinapi/binapi2001/cop/cop.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/cop.api.json @@ -14,9 +14,10 @@ package cop import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/cop/cop_rpc.ba.go b/internal/testbinapi/binapi2001/cop/cop_rpc.ba.go index 9f6f84e..120613d 100644 --- a/internal/testbinapi/binapi2001/cop/cop_rpc.ba.go +++ b/internal/testbinapi/binapi2001/cop/cop_rpc.ba.go @@ -4,10 +4,11 @@ package cop import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service cop. +// RPCService defines RPC service cop. type RPCService interface { CopInterfaceEnableDisable(ctx context.Context, in *CopInterfaceEnableDisable) (*CopInterfaceEnableDisableReply, error) CopWhitelistEnableDisable(ctx context.Context, in *CopWhitelistEnableDisable) (*CopWhitelistEnableDisableReply, error) @@ -27,7 +28,7 @@ func (c *serviceClient) CopInterfaceEnableDisable(ctx context.Context, in *CopIn if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) CopWhitelistEnableDisable(ctx context.Context, in *CopWhitelistEnableDisable) (*CopWhitelistEnableDisableReply, error) { @@ -36,5 +37,5 @@ func (c *serviceClient) CopWhitelistEnableDisable(ctx context.Context, in *CopWh if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/ct6/ct6.ba.go b/internal/testbinapi/binapi2001/ct6/ct6.ba.go index d8edfbd..80727b8 100644 --- a/internal/testbinapi/binapi2001/ct6/ct6.ba.go +++ b/internal/testbinapi/binapi2001/ct6/ct6.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/ct6.api.json @@ -14,9 +14,10 @@ package ct6 import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/ct6/ct6_rpc.ba.go b/internal/testbinapi/binapi2001/ct6/ct6_rpc.ba.go index 888fd32..fcae22d 100644 --- a/internal/testbinapi/binapi2001/ct6/ct6_rpc.ba.go +++ b/internal/testbinapi/binapi2001/ct6/ct6_rpc.ba.go @@ -4,10 +4,11 @@ package ct6 import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service ct6. +// RPCService defines RPC service ct6. type RPCService interface { Ct6EnableDisable(ctx context.Context, in *Ct6EnableDisable) (*Ct6EnableDisableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) Ct6EnableDisable(ctx context.Context, in *Ct6EnableDisab if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/dhcp/dhcp.ba.go b/internal/testbinapi/binapi2001/dhcp/dhcp.ba.go index f75e7ed..a84d4da 100644 --- a/internal/testbinapi/binapi2001/dhcp/dhcp.ba.go +++ b/internal/testbinapi/binapi2001/dhcp/dhcp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/dhcp.api.json @@ -17,11 +17,12 @@ package dhcp import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -621,12 +622,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -655,12 +659,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -689,12 +696,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -719,15 +729,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { @@ -748,6 +762,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -760,8 +778,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -771,12 +790,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -869,18 +891,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -923,18 +949,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -985,6 +1015,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -995,13 +1026,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -1019,8 +1053,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/dhcp/dhcp_rpc.ba.go b/internal/testbinapi/binapi2001/dhcp/dhcp_rpc.ba.go index ae59820..25918a0 100644 --- a/internal/testbinapi/binapi2001/dhcp/dhcp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/dhcp/dhcp_rpc.ba.go @@ -5,12 +5,13 @@ package dhcp import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service dhcp. +// RPCService defines RPC service dhcp. type RPCService interface { DHCP6ClientsEnableDisable(ctx context.Context, in *DHCP6ClientsEnableDisable) (*DHCP6ClientsEnableDisableReply, error) DHCP6DuidLlSet(ctx context.Context, in *DHCP6DuidLlSet) (*DHCP6DuidLlSetReply, error) @@ -41,7 +42,7 @@ func (c *serviceClient) DHCP6ClientsEnableDisable(ctx context.Context, in *DHCP6 if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DHCP6DuidLlSet(ctx context.Context, in *DHCP6DuidLlSet) (*DHCP6DuidLlSetReply, error) { @@ -50,7 +51,7 @@ func (c *serviceClient) DHCP6DuidLlSet(ctx context.Context, in *DHCP6DuidLlSet) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DHCP6PdSendClientMessage(ctx context.Context, in *DHCP6PdSendClientMessage) (*DHCP6PdSendClientMessageReply, error) { @@ -59,7 +60,7 @@ func (c *serviceClient) DHCP6PdSendClientMessage(ctx context.Context, in *DHCP6P if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DHCP6SendClientMessage(ctx context.Context, in *DHCP6SendClientMessage) (*DHCP6SendClientMessageReply, error) { @@ -68,7 +69,7 @@ func (c *serviceClient) DHCP6SendClientMessage(ctx context.Context, in *DHCP6Sen if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DHCPClientConfig(ctx context.Context, in *DHCPClientConfig) (*DHCPClientConfigReply, error) { @@ -77,7 +78,7 @@ func (c *serviceClient) DHCPClientConfig(ctx context.Context, in *DHCPClientConf if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DHCPClientDump(ctx context.Context, in *DHCPClientDump) (RPCService_DHCPClientDumpClient, error) { @@ -113,6 +114,10 @@ func (c *serviceClient_DHCPClientDumpClient) Recv() (*DHCPClientDetails, error) case *DHCPClientDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -125,7 +130,7 @@ func (c *serviceClient) DHCPPluginControlPing(ctx context.Context, in *DHCPPlugi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DHCPPluginGetVersion(ctx context.Context, in *DHCPPluginGetVersion) (*DHCPPluginGetVersionReply, error) { @@ -143,7 +148,7 @@ func (c *serviceClient) DHCPProxyConfig(ctx context.Context, in *DHCPProxyConfig if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DHCPProxyDump(ctx context.Context, in *DHCPProxyDump) (RPCService_DHCPProxyDumpClient, error) { @@ -179,6 +184,10 @@ func (c *serviceClient_DHCPProxyDumpClient) Recv() (*DHCPProxyDetails, error) { case *DHCPProxyDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -191,7 +200,7 @@ func (c *serviceClient) DHCPProxySetVss(ctx context.Context, in *DHCPProxySetVss if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) WantDHCP6PdReplyEvents(ctx context.Context, in *WantDHCP6PdReplyEvents) (*WantDHCP6PdReplyEventsReply, error) { @@ -200,7 +209,7 @@ func (c *serviceClient) WantDHCP6PdReplyEvents(ctx context.Context, in *WantDHCP if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) WantDHCP6ReplyEvents(ctx context.Context, in *WantDHCP6ReplyEvents) (*WantDHCP6ReplyEventsReply, error) { @@ -209,5 +218,5 @@ func (c *serviceClient) WantDHCP6ReplyEvents(ctx context.Context, in *WantDHCP6R if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp.ba.go b/internal/testbinapi/binapi2001/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp.ba.go index 12059b2..7d25a0d 100644 --- a/internal/testbinapi/binapi2001/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp.ba.go +++ b/internal/testbinapi/binapi2001/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/dhcp6_ia_na_client_cp.api.json @@ -14,9 +14,10 @@ package dhcp6_ia_na_client_cp import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp_rpc.ba.go b/internal/testbinapi/binapi2001/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp_rpc.ba.go index b975236..3fbf238 100644 --- a/internal/testbinapi/binapi2001/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/dhcp6_ia_na_client_cp/dhcp6_ia_na_client_cp_rpc.ba.go @@ -4,10 +4,11 @@ package dhcp6_ia_na_client_cp import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service dhcp6_ia_na_client_cp. +// RPCService defines RPC service dhcp6_ia_na_client_cp. type RPCService interface { DHCP6ClientEnableDisable(ctx context.Context, in *DHCP6ClientEnableDisable) (*DHCP6ClientEnableDisableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) DHCP6ClientEnableDisable(ctx context.Context, in *DHCP6C if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/dhcp6_pd_client_cp/dhcp6_pd_client_cp.ba.go b/internal/testbinapi/binapi2001/dhcp6_pd_client_cp/dhcp6_pd_client_cp.ba.go index 9f9ba1d..0dc6920 100644 --- a/internal/testbinapi/binapi2001/dhcp6_pd_client_cp/dhcp6_pd_client_cp.ba.go +++ b/internal/testbinapi/binapi2001/dhcp6_pd_client_cp/dhcp6_pd_client_cp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/dhcp6_pd_client_cp.api.json @@ -17,11 +17,12 @@ package dhcp6_pd_client_cp import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -595,6 +605,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -607,8 +621,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -618,12 +633,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -666,18 +684,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -720,18 +742,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -782,6 +808,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -792,13 +819,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -816,8 +846,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/dhcp6_pd_client_cp/dhcp6_pd_client_cp_rpc.ba.go b/internal/testbinapi/binapi2001/dhcp6_pd_client_cp/dhcp6_pd_client_cp_rpc.ba.go index 7199e5a..f531408 100644 --- a/internal/testbinapi/binapi2001/dhcp6_pd_client_cp/dhcp6_pd_client_cp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/dhcp6_pd_client_cp/dhcp6_pd_client_cp_rpc.ba.go @@ -4,10 +4,11 @@ package dhcp6_pd_client_cp import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service dhcp6_pd_client_cp. +// RPCService defines RPC service dhcp6_pd_client_cp. type RPCService interface { DHCP6PdClientEnableDisable(ctx context.Context, in *DHCP6PdClientEnableDisable) (*DHCP6PdClientEnableDisableReply, error) IP6AddDelAddressUsingPrefix(ctx context.Context, in *IP6AddDelAddressUsingPrefix) (*IP6AddDelAddressUsingPrefixReply, error) @@ -27,7 +28,7 @@ func (c *serviceClient) DHCP6PdClientEnableDisable(ctx context.Context, in *DHCP if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IP6AddDelAddressUsingPrefix(ctx context.Context, in *IP6AddDelAddressUsingPrefix) (*IP6AddDelAddressUsingPrefixReply, error) { @@ -36,5 +37,5 @@ func (c *serviceClient) IP6AddDelAddressUsingPrefix(ctx context.Context, in *IP6 if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/dns/dns.ba.go b/internal/testbinapi/binapi2001/dns/dns.ba.go index c7a86e7..f6161df 100644 --- a/internal/testbinapi/binapi2001/dns/dns.ba.go +++ b/internal/testbinapi/binapi2001/dns/dns.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/dns.api.json diff --git a/internal/testbinapi/binapi2001/dns/dns_rpc.ba.go b/internal/testbinapi/binapi2001/dns/dns_rpc.ba.go index 57760ab..deb5be8 100644 --- a/internal/testbinapi/binapi2001/dns/dns_rpc.ba.go +++ b/internal/testbinapi/binapi2001/dns/dns_rpc.ba.go @@ -4,10 +4,11 @@ package dns import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service dns. +// RPCService defines RPC service dns. type RPCService interface { DNSEnableDisable(ctx context.Context, in *DNSEnableDisable) (*DNSEnableDisableReply, error) DNSNameServerAddDel(ctx context.Context, in *DNSNameServerAddDel) (*DNSNameServerAddDelReply, error) @@ -29,7 +30,7 @@ func (c *serviceClient) DNSEnableDisable(ctx context.Context, in *DNSEnableDisab if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DNSNameServerAddDel(ctx context.Context, in *DNSNameServerAddDel) (*DNSNameServerAddDelReply, error) { @@ -38,7 +39,7 @@ func (c *serviceClient) DNSNameServerAddDel(ctx context.Context, in *DNSNameServ if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DNSResolveIP(ctx context.Context, in *DNSResolveIP) (*DNSResolveIPReply, error) { @@ -47,7 +48,7 @@ func (c *serviceClient) DNSResolveIP(ctx context.Context, in *DNSResolveIP) (*DN if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DNSResolveName(ctx context.Context, in *DNSResolveName) (*DNSResolveNameReply, error) { @@ -56,5 +57,5 @@ func (c *serviceClient) DNSResolveName(ctx context.Context, in *DNSResolveName) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/ethernet_types/ethernet_types.ba.go b/internal/testbinapi/binapi2001/ethernet_types/ethernet_types.ba.go index bd6cdcd..6cb13ae 100644 --- a/internal/testbinapi/binapi2001/ethernet_types/ethernet_types.ba.go +++ b/internal/testbinapi/binapi2001/ethernet_types/ethernet_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/ethernet_types.api.json @@ -12,8 +12,9 @@ package ethernet_types import ( - api "git.fd.io/govpp.git/api" "net" + + api "git.fd.io/govpp.git/api" ) // This is a compile-time assertion to ensure that this generated file @@ -22,6 +23,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "ethernet_types" + APIVersion = "" + VersionCrc = 0xd4ff2808 +) + // MacAddress defines alias 'mac_address'. type MacAddress [6]uint8 @@ -34,15 +41,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { diff --git a/internal/testbinapi/binapi2001/feature/feature.ba.go b/internal/testbinapi/binapi2001/feature/feature.ba.go index 8ceca10..33f8f14 100644 --- a/internal/testbinapi/binapi2001/feature/feature.ba.go +++ b/internal/testbinapi/binapi2001/feature/feature.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/feature.api.json @@ -14,9 +14,10 @@ package feature import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/feature/feature_rpc.ba.go b/internal/testbinapi/binapi2001/feature/feature_rpc.ba.go index cd91188..811934b 100644 --- a/internal/testbinapi/binapi2001/feature/feature_rpc.ba.go +++ b/internal/testbinapi/binapi2001/feature/feature_rpc.ba.go @@ -4,10 +4,11 @@ package feature import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service feature. +// RPCService defines RPC service feature. type RPCService interface { FeatureEnableDisable(ctx context.Context, in *FeatureEnableDisable) (*FeatureEnableDisableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) FeatureEnableDisable(ctx context.Context, in *FeatureEna if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/fib_types/fib_types.ba.go b/internal/testbinapi/binapi2001/fib_types/fib_types.ba.go index 16fe5b8..b965cc8 100644 --- a/internal/testbinapi/binapi2001/fib_types/fib_types.ba.go +++ b/internal/testbinapi/binapi2001/fib_types/fib_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/fib_types.api.json @@ -16,11 +16,12 @@ package fib_types import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -29,6 +30,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "fib_types" + APIVersion = "2.0.0" + VersionCrc = 0x57387845 +) + // AddressFamily defines enum 'address_family'. type AddressFamily uint32 @@ -382,12 +389,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -413,12 +423,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -447,12 +460,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -476,6 +492,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -488,8 +508,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -499,12 +520,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -578,18 +602,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -632,18 +660,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -694,6 +726,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -704,13 +737,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -728,8 +764,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/flowprobe/flowprobe.ba.go b/internal/testbinapi/binapi2001/flowprobe/flowprobe.ba.go index fc610eb..158242a 100644 --- a/internal/testbinapi/binapi2001/flowprobe/flowprobe.ba.go +++ b/internal/testbinapi/binapi2001/flowprobe/flowprobe.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/flowprobe.api.json @@ -14,9 +14,10 @@ package flowprobe import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/flowprobe/flowprobe_rpc.ba.go b/internal/testbinapi/binapi2001/flowprobe/flowprobe_rpc.ba.go index 42c6887..3b0178d 100644 --- a/internal/testbinapi/binapi2001/flowprobe/flowprobe_rpc.ba.go +++ b/internal/testbinapi/binapi2001/flowprobe/flowprobe_rpc.ba.go @@ -4,10 +4,11 @@ package flowprobe import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service flowprobe. +// RPCService defines RPC service flowprobe. type RPCService interface { FlowprobeParams(ctx context.Context, in *FlowprobeParams) (*FlowprobeParamsReply, error) FlowprobeTxInterfaceAddDel(ctx context.Context, in *FlowprobeTxInterfaceAddDel) (*FlowprobeTxInterfaceAddDelReply, error) @@ -27,7 +28,7 @@ func (c *serviceClient) FlowprobeParams(ctx context.Context, in *FlowprobeParams if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) FlowprobeTxInterfaceAddDel(ctx context.Context, in *FlowprobeTxInterfaceAddDel) (*FlowprobeTxInterfaceAddDelReply, error) { @@ -36,5 +37,5 @@ func (c *serviceClient) FlowprobeTxInterfaceAddDel(ctx context.Context, in *Flow if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/gbp/gbp.ba.go b/internal/testbinapi/binapi2001/gbp/gbp.ba.go index 1f00396..27df8b5 100644 --- a/internal/testbinapi/binapi2001/gbp/gbp.ba.go +++ b/internal/testbinapi/binapi2001/gbp/gbp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/gbp.api.json @@ -17,11 +17,12 @@ package gbp import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -777,12 +778,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -814,12 +818,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -848,12 +855,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -878,15 +888,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { @@ -907,6 +921,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -919,8 +937,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -930,12 +949,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -1095,18 +1117,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -1149,18 +1175,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -1211,6 +1241,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -1221,13 +1252,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -1245,8 +1279,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/gbp/gbp_rpc.ba.go b/internal/testbinapi/binapi2001/gbp/gbp_rpc.ba.go index bad1f79..cd62e3a 100644 --- a/internal/testbinapi/binapi2001/gbp/gbp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/gbp/gbp_rpc.ba.go @@ -5,12 +5,13 @@ package gbp import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service gbp. +// RPCService defines RPC service gbp. type RPCService interface { GbpBridgeDomainAdd(ctx context.Context, in *GbpBridgeDomainAdd) (*GbpBridgeDomainAddReply, error) GbpBridgeDomainDel(ctx context.Context, in *GbpBridgeDomainDel) (*GbpBridgeDomainDelReply, error) @@ -51,7 +52,7 @@ func (c *serviceClient) GbpBridgeDomainAdd(ctx context.Context, in *GbpBridgeDom if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpBridgeDomainDel(ctx context.Context, in *GbpBridgeDomainDel) (*GbpBridgeDomainDelReply, error) { @@ -60,7 +61,7 @@ func (c *serviceClient) GbpBridgeDomainDel(ctx context.Context, in *GbpBridgeDom if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpBridgeDomainDump(ctx context.Context, in *GbpBridgeDomainDump) (RPCService_GbpBridgeDomainDumpClient, error) { @@ -96,6 +97,10 @@ func (c *serviceClient_GbpBridgeDomainDumpClient) Recv() (*GbpBridgeDomainDetail case *GbpBridgeDomainDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -108,7 +113,7 @@ func (c *serviceClient) GbpContractAddDel(ctx context.Context, in *GbpContractAd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpContractDump(ctx context.Context, in *GbpContractDump) (RPCService_GbpContractDumpClient, error) { @@ -144,6 +149,10 @@ func (c *serviceClient_GbpContractDumpClient) Recv() (*GbpContractDetails, error case *GbpContractDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -156,7 +165,7 @@ func (c *serviceClient) GbpEndpointAdd(ctx context.Context, in *GbpEndpointAdd) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpEndpointDel(ctx context.Context, in *GbpEndpointDel) (*GbpEndpointDelReply, error) { @@ -165,7 +174,7 @@ func (c *serviceClient) GbpEndpointDel(ctx context.Context, in *GbpEndpointDel) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpEndpointDump(ctx context.Context, in *GbpEndpointDump) (RPCService_GbpEndpointDumpClient, error) { @@ -201,6 +210,10 @@ func (c *serviceClient_GbpEndpointDumpClient) Recv() (*GbpEndpointDetails, error case *GbpEndpointDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -213,7 +226,7 @@ func (c *serviceClient) GbpEndpointGroupAdd(ctx context.Context, in *GbpEndpoint if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpEndpointGroupDel(ctx context.Context, in *GbpEndpointGroupDel) (*GbpEndpointGroupDelReply, error) { @@ -222,7 +235,7 @@ func (c *serviceClient) GbpEndpointGroupDel(ctx context.Context, in *GbpEndpoint if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpEndpointGroupDump(ctx context.Context, in *GbpEndpointGroupDump) (RPCService_GbpEndpointGroupDumpClient, error) { @@ -258,6 +271,10 @@ func (c *serviceClient_GbpEndpointGroupDumpClient) Recv() (*GbpEndpointGroupDeta case *GbpEndpointGroupDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -270,7 +287,7 @@ func (c *serviceClient) GbpExtItfAddDel(ctx context.Context, in *GbpExtItfAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpExtItfDump(ctx context.Context, in *GbpExtItfDump) (RPCService_GbpExtItfDumpClient, error) { @@ -306,6 +323,10 @@ func (c *serviceClient_GbpExtItfDumpClient) Recv() (*GbpExtItfDetails, error) { case *GbpExtItfDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -318,7 +339,7 @@ func (c *serviceClient) GbpRecircAddDel(ctx context.Context, in *GbpRecircAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpRecircDump(ctx context.Context, in *GbpRecircDump) (RPCService_GbpRecircDumpClient, error) { @@ -354,6 +375,10 @@ func (c *serviceClient_GbpRecircDumpClient) Recv() (*GbpRecircDetails, error) { case *GbpRecircDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -366,7 +391,7 @@ func (c *serviceClient) GbpRouteDomainAdd(ctx context.Context, in *GbpRouteDomai if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpRouteDomainDel(ctx context.Context, in *GbpRouteDomainDel) (*GbpRouteDomainDelReply, error) { @@ -375,7 +400,7 @@ func (c *serviceClient) GbpRouteDomainDel(ctx context.Context, in *GbpRouteDomai if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpRouteDomainDump(ctx context.Context, in *GbpRouteDomainDump) (RPCService_GbpRouteDomainDumpClient, error) { @@ -411,6 +436,10 @@ func (c *serviceClient_GbpRouteDomainDumpClient) Recv() (*GbpRouteDomainDetails, case *GbpRouteDomainDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -423,7 +452,7 @@ func (c *serviceClient) GbpSubnetAddDel(ctx context.Context, in *GbpSubnetAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpSubnetDump(ctx context.Context, in *GbpSubnetDump) (RPCService_GbpSubnetDumpClient, error) { @@ -459,6 +488,10 @@ func (c *serviceClient_GbpSubnetDumpClient) Recv() (*GbpSubnetDetails, error) { case *GbpSubnetDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -471,7 +504,7 @@ func (c *serviceClient) GbpVxlanTunnelAdd(ctx context.Context, in *GbpVxlanTunne if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpVxlanTunnelDel(ctx context.Context, in *GbpVxlanTunnelDel) (*GbpVxlanTunnelDelReply, error) { @@ -480,7 +513,7 @@ func (c *serviceClient) GbpVxlanTunnelDel(ctx context.Context, in *GbpVxlanTunne if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpVxlanTunnelDump(ctx context.Context, in *GbpVxlanTunnelDump) (RPCService_GbpVxlanTunnelDumpClient, error) { @@ -516,6 +549,10 @@ func (c *serviceClient_GbpVxlanTunnelDumpClient) Recv() (*GbpVxlanTunnelDetails, case *GbpVxlanTunnelDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/gen.go b/internal/testbinapi/binapi2001/gen.go index 1a348e3..60b8e97 100644 --- a/internal/testbinapi/binapi2001/gen.go +++ b/internal/testbinapi/binapi2001/gen.go @@ -14,4 +14,4 @@ package binapi2001 -//go:generate env VPP_VERSION=20.01 binapi-generator -input-dir=.vppapi -output-dir=. +//go:generate env VPP_VERSION=20.01 ../../../bin/binapi-generator -input-dir=.vppapi -output-dir=. diff --git a/internal/testbinapi/binapi2001/geneve/geneve.ba.go b/internal/testbinapi/binapi2001/geneve/geneve.ba.go index e79def2..fda3441 100644 --- a/internal/testbinapi/binapi2001/geneve/geneve.ba.go +++ b/internal/testbinapi/binapi2001/geneve/geneve.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/geneve.api.json @@ -17,11 +17,12 @@ package geneve import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -596,15 +606,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { @@ -625,6 +639,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -637,8 +655,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -648,12 +667,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -696,18 +718,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -750,18 +776,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -812,6 +842,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -822,13 +853,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -846,8 +880,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/geneve/geneve_rpc.ba.go b/internal/testbinapi/binapi2001/geneve/geneve_rpc.ba.go index fe78712..f96c316 100644 --- a/internal/testbinapi/binapi2001/geneve/geneve_rpc.ba.go +++ b/internal/testbinapi/binapi2001/geneve/geneve_rpc.ba.go @@ -5,12 +5,13 @@ package geneve import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service geneve. +// RPCService defines RPC service geneve. type RPCService interface { GeneveAddDelTunnel(ctx context.Context, in *GeneveAddDelTunnel) (*GeneveAddDelTunnelReply, error) GeneveTunnelDump(ctx context.Context, in *GeneveTunnelDump) (RPCService_GeneveTunnelDumpClient, error) @@ -31,7 +32,7 @@ func (c *serviceClient) GeneveAddDelTunnel(ctx context.Context, in *GeneveAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GeneveTunnelDump(ctx context.Context, in *GeneveTunnelDump) (RPCService_GeneveTunnelDumpClient, error) { @@ -67,6 +68,10 @@ func (c *serviceClient_GeneveTunnelDumpClient) Recv() (*GeneveTunnelDetails, err case *GeneveTunnelDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -79,5 +84,5 @@ func (c *serviceClient) SwInterfaceSetGeneveBypass(ctx context.Context, in *SwIn if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/gre/gre.ba.go b/internal/testbinapi/binapi2001/gre/gre.ba.go index 78d3720..0eeb82c 100644 --- a/internal/testbinapi/binapi2001/gre/gre.ba.go +++ b/internal/testbinapi/binapi2001/gre/gre.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/gre.api.json @@ -17,11 +17,12 @@ package gre import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -555,12 +556,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -589,12 +593,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -623,12 +630,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -652,6 +662,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -664,8 +678,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -675,12 +690,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -735,18 +753,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -789,18 +811,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -851,6 +877,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -861,13 +888,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -885,8 +915,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/gre/gre_rpc.ba.go b/internal/testbinapi/binapi2001/gre/gre_rpc.ba.go index 8ea9820..6237740 100644 --- a/internal/testbinapi/binapi2001/gre/gre_rpc.ba.go +++ b/internal/testbinapi/binapi2001/gre/gre_rpc.ba.go @@ -5,12 +5,13 @@ package gre import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service gre. +// RPCService defines RPC service gre. type RPCService interface { GreTunnelAddDel(ctx context.Context, in *GreTunnelAddDel) (*GreTunnelAddDelReply, error) GreTunnelDump(ctx context.Context, in *GreTunnelDump) (RPCService_GreTunnelDumpClient, error) @@ -30,7 +31,7 @@ func (c *serviceClient) GreTunnelAddDel(ctx context.Context, in *GreTunnelAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GreTunnelDump(ctx context.Context, in *GreTunnelDump) (RPCService_GreTunnelDumpClient, error) { @@ -66,6 +67,10 @@ func (c *serviceClient_GreTunnelDumpClient) Recv() (*GreTunnelDetails, error) { case *GreTunnelDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/gso/gso.ba.go b/internal/testbinapi/binapi2001/gso/gso.ba.go index 374191b..ed33544 100644 --- a/internal/testbinapi/binapi2001/gso/gso.ba.go +++ b/internal/testbinapi/binapi2001/gso/gso.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/gso.api.json @@ -14,9 +14,10 @@ package gso import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/gso/gso_rpc.ba.go b/internal/testbinapi/binapi2001/gso/gso_rpc.ba.go index d955acc..0d3ed10 100644 --- a/internal/testbinapi/binapi2001/gso/gso_rpc.ba.go +++ b/internal/testbinapi/binapi2001/gso/gso_rpc.ba.go @@ -4,10 +4,11 @@ package gso import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service gso. +// RPCService defines RPC service gso. type RPCService interface { FeatureGsoEnableDisable(ctx context.Context, in *FeatureGsoEnableDisable) (*FeatureGsoEnableDisableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) FeatureGsoEnableDisable(ctx context.Context, in *Feature if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/gtpu/gtpu.ba.go b/internal/testbinapi/binapi2001/gtpu/gtpu.ba.go index dd4b8c8..53b65d0 100644 --- a/internal/testbinapi/binapi2001/gtpu/gtpu.ba.go +++ b/internal/testbinapi/binapi2001/gtpu/gtpu.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/gtpu.api.json @@ -17,11 +17,12 @@ package gtpu import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -595,6 +605,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -607,8 +621,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -618,12 +633,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -666,18 +684,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -720,18 +742,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -782,6 +808,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -792,13 +819,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -816,8 +846,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/gtpu/gtpu_rpc.ba.go b/internal/testbinapi/binapi2001/gtpu/gtpu_rpc.ba.go index 6cc1d23..8328e6b 100644 --- a/internal/testbinapi/binapi2001/gtpu/gtpu_rpc.ba.go +++ b/internal/testbinapi/binapi2001/gtpu/gtpu_rpc.ba.go @@ -5,12 +5,13 @@ package gtpu import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service gtpu. +// RPCService defines RPC service gtpu. type RPCService interface { GtpuAddDelTunnel(ctx context.Context, in *GtpuAddDelTunnel) (*GtpuAddDelTunnelReply, error) GtpuTunnelDump(ctx context.Context, in *GtpuTunnelDump) (RPCService_GtpuTunnelDumpClient, error) @@ -31,7 +32,7 @@ func (c *serviceClient) GtpuAddDelTunnel(ctx context.Context, in *GtpuAddDelTunn if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GtpuTunnelDump(ctx context.Context, in *GtpuTunnelDump) (RPCService_GtpuTunnelDumpClient, error) { @@ -67,6 +68,10 @@ func (c *serviceClient_GtpuTunnelDumpClient) Recv() (*GtpuTunnelDetails, error) case *GtpuTunnelDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -79,5 +84,5 @@ func (c *serviceClient) SwInterfaceSetGtpuBypass(ctx context.Context, in *SwInte if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/http_static/http_static.ba.go b/internal/testbinapi/binapi2001/http_static/http_static.ba.go index b302380..bdd9c5b 100644 --- a/internal/testbinapi/binapi2001/http_static/http_static.ba.go +++ b/internal/testbinapi/binapi2001/http_static/http_static.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/http_static.api.json diff --git a/internal/testbinapi/binapi2001/http_static/http_static_rpc.ba.go b/internal/testbinapi/binapi2001/http_static/http_static_rpc.ba.go index 415313d..12bd4c1 100644 --- a/internal/testbinapi/binapi2001/http_static/http_static_rpc.ba.go +++ b/internal/testbinapi/binapi2001/http_static/http_static_rpc.ba.go @@ -4,10 +4,11 @@ package http_static import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service http_static. +// RPCService defines RPC service http_static. type RPCService interface { HTTPStaticEnable(ctx context.Context, in *HTTPStaticEnable) (*HTTPStaticEnableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) HTTPStaticEnable(ctx context.Context, in *HTTPStaticEnab if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/igmp/igmp.ba.go b/internal/testbinapi/binapi2001/igmp/igmp.ba.go index 5482411..0612a4b 100644 --- a/internal/testbinapi/binapi2001/igmp/igmp.ba.go +++ b/internal/testbinapi/binapi2001/igmp/igmp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/igmp.api.json @@ -17,11 +17,12 @@ package igmp import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -552,12 +553,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -586,12 +590,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -620,12 +627,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -649,6 +659,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -661,8 +675,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -672,12 +687,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -735,18 +753,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -789,18 +811,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -851,6 +877,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -861,13 +888,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -885,8 +915,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/igmp/igmp_rpc.ba.go b/internal/testbinapi/binapi2001/igmp/igmp_rpc.ba.go index 7258577..b79fdc2 100644 --- a/internal/testbinapi/binapi2001/igmp/igmp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/igmp/igmp_rpc.ba.go @@ -5,12 +5,13 @@ package igmp import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service igmp. +// RPCService defines RPC service igmp. type RPCService interface { IgmpClearInterface(ctx context.Context, in *IgmpClearInterface) (*IgmpClearInterfaceReply, error) IgmpDump(ctx context.Context, in *IgmpDump) (RPCService_IgmpDumpClient, error) @@ -37,7 +38,7 @@ func (c *serviceClient) IgmpClearInterface(ctx context.Context, in *IgmpClearInt if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IgmpDump(ctx context.Context, in *IgmpDump) (RPCService_IgmpDumpClient, error) { @@ -73,6 +74,10 @@ func (c *serviceClient_IgmpDumpClient) Recv() (*IgmpDetails, error) { case *IgmpDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -85,7 +90,7 @@ func (c *serviceClient) IgmpEnableDisable(ctx context.Context, in *IgmpEnableDis if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IgmpGroupPrefixDump(ctx context.Context, in *IgmpGroupPrefixDump) (RPCService_IgmpGroupPrefixDumpClient, error) { @@ -121,6 +126,10 @@ func (c *serviceClient_IgmpGroupPrefixDumpClient) Recv() (*IgmpGroupPrefixDetail case *IgmpGroupPrefixDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -133,7 +142,7 @@ func (c *serviceClient) IgmpGroupPrefixSet(ctx context.Context, in *IgmpGroupPre if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IgmpListen(ctx context.Context, in *IgmpListen) (*IgmpListenReply, error) { @@ -142,7 +151,7 @@ func (c *serviceClient) IgmpListen(ctx context.Context, in *IgmpListen) (*IgmpLi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IgmpProxyDeviceAddDel(ctx context.Context, in *IgmpProxyDeviceAddDel) (*IgmpProxyDeviceAddDelReply, error) { @@ -151,7 +160,7 @@ func (c *serviceClient) IgmpProxyDeviceAddDel(ctx context.Context, in *IgmpProxy if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IgmpProxyDeviceAddDelInterface(ctx context.Context, in *IgmpProxyDeviceAddDelInterface) (*IgmpProxyDeviceAddDelInterfaceReply, error) { @@ -160,7 +169,7 @@ func (c *serviceClient) IgmpProxyDeviceAddDelInterface(ctx context.Context, in * if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) WantIgmpEvents(ctx context.Context, in *WantIgmpEvents) (*WantIgmpEventsReply, error) { @@ -169,5 +178,5 @@ func (c *serviceClient) WantIgmpEvents(ctx context.Context, in *WantIgmpEvents) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/ikev2/ikev2.ba.go b/internal/testbinapi/binapi2001/ikev2/ikev2.ba.go index f7ad3c8..578cdc4 100644 --- a/internal/testbinapi/binapi2001/ikev2/ikev2.ba.go +++ b/internal/testbinapi/binapi2001/ikev2/ikev2.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/ikev2.api.json @@ -17,11 +17,12 @@ package ikev2 import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -595,6 +605,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -607,8 +621,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -618,12 +633,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -666,18 +684,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -720,18 +742,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -782,6 +808,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -792,13 +819,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -816,8 +846,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/ikev2/ikev2_rpc.ba.go b/internal/testbinapi/binapi2001/ikev2/ikev2_rpc.ba.go index 5cac5d4..41c0e61 100644 --- a/internal/testbinapi/binapi2001/ikev2/ikev2_rpc.ba.go +++ b/internal/testbinapi/binapi2001/ikev2/ikev2_rpc.ba.go @@ -4,10 +4,11 @@ package ikev2 import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service ikev2. +// RPCService defines RPC service ikev2. type RPCService interface { Ikev2InitiateDelChildSa(ctx context.Context, in *Ikev2InitiateDelChildSa) (*Ikev2InitiateDelChildSaReply, error) Ikev2InitiateDelIkeSa(ctx context.Context, in *Ikev2InitiateDelIkeSa) (*Ikev2InitiateDelIkeSaReply, error) @@ -39,7 +40,7 @@ func (c *serviceClient) Ikev2InitiateDelChildSa(ctx context.Context, in *Ikev2In if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2InitiateDelIkeSa(ctx context.Context, in *Ikev2InitiateDelIkeSa) (*Ikev2InitiateDelIkeSaReply, error) { @@ -48,7 +49,7 @@ func (c *serviceClient) Ikev2InitiateDelIkeSa(ctx context.Context, in *Ikev2Init if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2InitiateRekeyChildSa(ctx context.Context, in *Ikev2InitiateRekeyChildSa) (*Ikev2InitiateRekeyChildSaReply, error) { @@ -57,7 +58,7 @@ func (c *serviceClient) Ikev2InitiateRekeyChildSa(ctx context.Context, in *Ikev2 if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2InitiateSaInit(ctx context.Context, in *Ikev2InitiateSaInit) (*Ikev2InitiateSaInitReply, error) { @@ -66,7 +67,7 @@ func (c *serviceClient) Ikev2InitiateSaInit(ctx context.Context, in *Ikev2Initia if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2PluginGetVersion(ctx context.Context, in *Ikev2PluginGetVersion) (*Ikev2PluginGetVersionReply, error) { @@ -84,7 +85,7 @@ func (c *serviceClient) Ikev2ProfileAddDel(ctx context.Context, in *Ikev2Profile if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2ProfileSetAuth(ctx context.Context, in *Ikev2ProfileSetAuth) (*Ikev2ProfileSetAuthReply, error) { @@ -93,7 +94,7 @@ func (c *serviceClient) Ikev2ProfileSetAuth(ctx context.Context, in *Ikev2Profil if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2ProfileSetID(ctx context.Context, in *Ikev2ProfileSetID) (*Ikev2ProfileSetIDReply, error) { @@ -102,7 +103,7 @@ func (c *serviceClient) Ikev2ProfileSetID(ctx context.Context, in *Ikev2ProfileS if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2ProfileSetTs(ctx context.Context, in *Ikev2ProfileSetTs) (*Ikev2ProfileSetTsReply, error) { @@ -111,7 +112,7 @@ func (c *serviceClient) Ikev2ProfileSetTs(ctx context.Context, in *Ikev2ProfileS if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2SetEspTransforms(ctx context.Context, in *Ikev2SetEspTransforms) (*Ikev2SetEspTransformsReply, error) { @@ -120,7 +121,7 @@ func (c *serviceClient) Ikev2SetEspTransforms(ctx context.Context, in *Ikev2SetE if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2SetIkeTransforms(ctx context.Context, in *Ikev2SetIkeTransforms) (*Ikev2SetIkeTransformsReply, error) { @@ -129,7 +130,7 @@ func (c *serviceClient) Ikev2SetIkeTransforms(ctx context.Context, in *Ikev2SetI if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2SetLocalKey(ctx context.Context, in *Ikev2SetLocalKey) (*Ikev2SetLocalKeyReply, error) { @@ -138,7 +139,7 @@ func (c *serviceClient) Ikev2SetLocalKey(ctx context.Context, in *Ikev2SetLocalK if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2SetResponder(ctx context.Context, in *Ikev2SetResponder) (*Ikev2SetResponderReply, error) { @@ -147,7 +148,7 @@ func (c *serviceClient) Ikev2SetResponder(ctx context.Context, in *Ikev2SetRespo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2SetSaLifetime(ctx context.Context, in *Ikev2SetSaLifetime) (*Ikev2SetSaLifetimeReply, error) { @@ -156,5 +157,5 @@ func (c *serviceClient) Ikev2SetSaLifetime(ctx context.Context, in *Ikev2SetSaLi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/interface/interface.ba.go b/internal/testbinapi/binapi2001/interface/interface.ba.go index 94a33b8..a28c261 100644 --- a/internal/testbinapi/binapi2001/interface/interface.ba.go +++ b/internal/testbinapi/binapi2001/interface/interface.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/interface.api.json @@ -17,11 +17,12 @@ package interfaces import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -596,15 +606,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { @@ -625,6 +639,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -637,8 +655,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -648,12 +667,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -696,18 +718,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -750,18 +776,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -812,6 +842,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -822,13 +853,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -846,8 +880,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/interface/interface_rpc.ba.go b/internal/testbinapi/binapi2001/interface/interface_rpc.ba.go index f12e6eb..d7ae7c5 100644 --- a/internal/testbinapi/binapi2001/interface/interface_rpc.ba.go +++ b/internal/testbinapi/binapi2001/interface/interface_rpc.ba.go @@ -5,12 +5,13 @@ package interfaces import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service interface. +// RPCService defines RPC service interface. type RPCService interface { CollectDetailedInterfaceStats(ctx context.Context, in *CollectDetailedInterfaceStats) (*CollectDetailedInterfaceStatsReply, error) CreateLoopback(ctx context.Context, in *CreateLoopback) (*CreateLoopbackReply, error) @@ -54,7 +55,7 @@ func (c *serviceClient) CollectDetailedInterfaceStats(ctx context.Context, in *C if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) CreateLoopback(ctx context.Context, in *CreateLoopback) (*CreateLoopbackReply, error) { @@ -63,7 +64,7 @@ func (c *serviceClient) CreateLoopback(ctx context.Context, in *CreateLoopback) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) CreateLoopbackInstance(ctx context.Context, in *CreateLoopbackInstance) (*CreateLoopbackInstanceReply, error) { @@ -72,7 +73,7 @@ func (c *serviceClient) CreateLoopbackInstance(ctx context.Context, in *CreateLo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) CreateSubif(ctx context.Context, in *CreateSubif) (*CreateSubifReply, error) { @@ -81,7 +82,7 @@ func (c *serviceClient) CreateSubif(ctx context.Context, in *CreateSubif) (*Crea if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) CreateVlanSubif(ctx context.Context, in *CreateVlanSubif) (*CreateVlanSubifReply, error) { @@ -90,7 +91,7 @@ func (c *serviceClient) CreateVlanSubif(ctx context.Context, in *CreateVlanSubif if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DeleteLoopback(ctx context.Context, in *DeleteLoopback) (*DeleteLoopbackReply, error) { @@ -99,7 +100,7 @@ func (c *serviceClient) DeleteLoopback(ctx context.Context, in *DeleteLoopback) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DeleteSubif(ctx context.Context, in *DeleteSubif) (*DeleteSubifReply, error) { @@ -108,7 +109,7 @@ func (c *serviceClient) DeleteSubif(ctx context.Context, in *DeleteSubif) (*Dele if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) HwInterfaceSetMtu(ctx context.Context, in *HwInterfaceSetMtu) (*HwInterfaceSetMtuReply, error) { @@ -117,7 +118,7 @@ func (c *serviceClient) HwInterfaceSetMtu(ctx context.Context, in *HwInterfaceSe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) InterfaceNameRenumber(ctx context.Context, in *InterfaceNameRenumber) (*InterfaceNameRenumberReply, error) { @@ -126,7 +127,7 @@ func (c *serviceClient) InterfaceNameRenumber(ctx context.Context, in *Interface if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceAddDelAddress(ctx context.Context, in *SwInterfaceAddDelAddress) (*SwInterfaceAddDelAddressReply, error) { @@ -135,7 +136,7 @@ func (c *serviceClient) SwInterfaceAddDelAddress(ctx context.Context, in *SwInte if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceAddDelMacAddress(ctx context.Context, in *SwInterfaceAddDelMacAddress) (*SwInterfaceAddDelMacAddressReply, error) { @@ -144,7 +145,7 @@ func (c *serviceClient) SwInterfaceAddDelMacAddress(ctx context.Context, in *SwI if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClearStats) (*SwInterfaceClearStatsReply, error) { @@ -153,7 +154,7 @@ func (c *serviceClient) SwInterfaceClearStats(ctx context.Context, in *SwInterfa if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceDump(ctx context.Context, in *SwInterfaceDump) (RPCService_SwInterfaceDumpClient, error) { @@ -189,6 +190,10 @@ func (c *serviceClient_SwInterfaceDumpClient) Recv() (*SwInterfaceDetails, error case *SwInterfaceDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -201,7 +206,7 @@ func (c *serviceClient) SwInterfaceGetMacAddress(ctx context.Context, in *SwInte if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceGetTable(ctx context.Context, in *SwInterfaceGetTable) (*SwInterfaceGetTableReply, error) { @@ -210,7 +215,7 @@ func (c *serviceClient) SwInterfaceGetTable(ctx context.Context, in *SwInterface if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceRxPlacementDump(ctx context.Context, in *SwInterfaceRxPlacementDump) (RPCService_SwInterfaceRxPlacementDumpClient, error) { @@ -246,6 +251,10 @@ func (c *serviceClient_SwInterfaceRxPlacementDumpClient) Recv() (*SwInterfaceRxP case *SwInterfaceRxPlacementDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -258,7 +267,7 @@ func (c *serviceClient) SwInterfaceSetFlags(ctx context.Context, in *SwInterface if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSetIPDirectedBroadcast(ctx context.Context, in *SwInterfaceSetIPDirectedBroadcast) (*SwInterfaceSetIPDirectedBroadcastReply, error) { @@ -267,7 +276,7 @@ func (c *serviceClient) SwInterfaceSetIPDirectedBroadcast(ctx context.Context, i if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSetMacAddress(ctx context.Context, in *SwInterfaceSetMacAddress) (*SwInterfaceSetMacAddressReply, error) { @@ -276,7 +285,7 @@ func (c *serviceClient) SwInterfaceSetMacAddress(ctx context.Context, in *SwInte if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSetMtu(ctx context.Context, in *SwInterfaceSetMtu) (*SwInterfaceSetMtuReply, error) { @@ -285,7 +294,7 @@ func (c *serviceClient) SwInterfaceSetMtu(ctx context.Context, in *SwInterfaceSe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSetRxMode(ctx context.Context, in *SwInterfaceSetRxMode) (*SwInterfaceSetRxModeReply, error) { @@ -294,7 +303,7 @@ func (c *serviceClient) SwInterfaceSetRxMode(ctx context.Context, in *SwInterfac if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSetRxPlacement(ctx context.Context, in *SwInterfaceSetRxPlacement) (*SwInterfaceSetRxPlacementReply, error) { @@ -303,7 +312,7 @@ func (c *serviceClient) SwInterfaceSetRxPlacement(ctx context.Context, in *SwInt if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSetTable(ctx context.Context, in *SwInterfaceSetTable) (*SwInterfaceSetTableReply, error) { @@ -312,7 +321,7 @@ func (c *serviceClient) SwInterfaceSetTable(ctx context.Context, in *SwInterface if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSetUnnumbered(ctx context.Context, in *SwInterfaceSetUnnumbered) (*SwInterfaceSetUnnumberedReply, error) { @@ -321,7 +330,7 @@ func (c *serviceClient) SwInterfaceSetUnnumbered(ctx context.Context, in *SwInte if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceTagAddDel(ctx context.Context, in *SwInterfaceTagAddDel) (*SwInterfaceTagAddDelReply, error) { @@ -330,7 +339,7 @@ func (c *serviceClient) SwInterfaceTagAddDel(ctx context.Context, in *SwInterfac if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) WantInterfaceEvents(ctx context.Context, in *WantInterfaceEvents) (*WantInterfaceEventsReply, error) { @@ -339,5 +348,5 @@ func (c *serviceClient) WantInterfaceEvents(ctx context.Context, in *WantInterfa if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/interface_types/interface_types.ba.go b/internal/testbinapi/binapi2001/interface_types/interface_types.ba.go index c4ba91d..14e2766 100644 --- a/internal/testbinapi/binapi2001/interface_types/interface_types.ba.go +++ b/internal/testbinapi/binapi2001/interface_types/interface_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/interface_types.api.json @@ -13,8 +13,9 @@ package interface_types import ( - api "git.fd.io/govpp.git/api" "strconv" + + api "git.fd.io/govpp.git/api" ) // This is a compile-time assertion to ensure that this generated file @@ -23,6 +24,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "interface_types" + APIVersion = "" + VersionCrc = 0xc97be83d +) + // IfStatusFlags defines enum 'if_status_flags'. type IfStatusFlags uint32 diff --git a/internal/testbinapi/binapi2001/ioam_cache/ioam_cache.ba.go b/internal/testbinapi/binapi2001/ioam_cache/ioam_cache.ba.go index 4a453c7..c409cc9 100644 --- a/internal/testbinapi/binapi2001/ioam_cache/ioam_cache.ba.go +++ b/internal/testbinapi/binapi2001/ioam_cache/ioam_cache.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/ioam_cache.api.json diff --git a/internal/testbinapi/binapi2001/ioam_cache/ioam_cache_rpc.ba.go b/internal/testbinapi/binapi2001/ioam_cache/ioam_cache_rpc.ba.go index 33a721f..9847365 100644 --- a/internal/testbinapi/binapi2001/ioam_cache/ioam_cache_rpc.ba.go +++ b/internal/testbinapi/binapi2001/ioam_cache/ioam_cache_rpc.ba.go @@ -4,10 +4,11 @@ package ioam_cache import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service ioam_cache. +// RPCService defines RPC service ioam_cache. type RPCService interface { IoamCacheIP6EnableDisable(ctx context.Context, in *IoamCacheIP6EnableDisable) (*IoamCacheIP6EnableDisableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) IoamCacheIP6EnableDisable(ctx context.Context, in *IoamC if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/ioam_export/ioam_export.ba.go b/internal/testbinapi/binapi2001/ioam_export/ioam_export.ba.go index 5a1fef6..044b8e2 100644 --- a/internal/testbinapi/binapi2001/ioam_export/ioam_export.ba.go +++ b/internal/testbinapi/binapi2001/ioam_export/ioam_export.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/ioam_export.api.json @@ -17,11 +17,12 @@ package ioam_export import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -247,12 +248,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -278,12 +282,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -312,12 +319,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -341,6 +351,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -353,8 +367,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -364,12 +379,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -412,18 +430,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -466,18 +488,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -528,6 +554,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -538,13 +565,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -562,8 +592,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/ioam_export/ioam_export_rpc.ba.go b/internal/testbinapi/binapi2001/ioam_export/ioam_export_rpc.ba.go index 584a563..0e0da2e 100644 --- a/internal/testbinapi/binapi2001/ioam_export/ioam_export_rpc.ba.go +++ b/internal/testbinapi/binapi2001/ioam_export/ioam_export_rpc.ba.go @@ -4,10 +4,11 @@ package ioam_export import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service ioam_export. +// RPCService defines RPC service ioam_export. type RPCService interface { IoamExportIP6EnableDisable(ctx context.Context, in *IoamExportIP6EnableDisable) (*IoamExportIP6EnableDisableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) IoamExportIP6EnableDisable(ctx context.Context, in *Ioam if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/ioam_vxlan_gpe/ioam_vxlan_gpe.ba.go b/internal/testbinapi/binapi2001/ioam_vxlan_gpe/ioam_vxlan_gpe.ba.go index cac19f6..7ee44bc 100644 --- a/internal/testbinapi/binapi2001/ioam_vxlan_gpe/ioam_vxlan_gpe.ba.go +++ b/internal/testbinapi/binapi2001/ioam_vxlan_gpe/ioam_vxlan_gpe.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/ioam_vxlan_gpe.api.json @@ -17,11 +17,12 @@ package ioam_vxlan_gpe import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -247,12 +248,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -278,12 +282,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -312,12 +319,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -341,6 +351,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -353,8 +367,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -364,12 +379,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -412,18 +430,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -466,18 +488,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -528,6 +554,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -538,13 +565,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -562,8 +592,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/ioam_vxlan_gpe/ioam_vxlan_gpe_rpc.ba.go b/internal/testbinapi/binapi2001/ioam_vxlan_gpe/ioam_vxlan_gpe_rpc.ba.go index e06b33a..19bdbb2 100644 --- a/internal/testbinapi/binapi2001/ioam_vxlan_gpe/ioam_vxlan_gpe_rpc.ba.go +++ b/internal/testbinapi/binapi2001/ioam_vxlan_gpe/ioam_vxlan_gpe_rpc.ba.go @@ -4,10 +4,11 @@ package ioam_vxlan_gpe import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service ioam_vxlan_gpe. +// RPCService defines RPC service ioam_vxlan_gpe. type RPCService interface { VxlanGpeIoamDisable(ctx context.Context, in *VxlanGpeIoamDisable) (*VxlanGpeIoamDisableReply, error) VxlanGpeIoamEnable(ctx context.Context, in *VxlanGpeIoamEnable) (*VxlanGpeIoamEnableReply, error) @@ -31,7 +32,7 @@ func (c *serviceClient) VxlanGpeIoamDisable(ctx context.Context, in *VxlanGpeIoa if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanGpeIoamEnable(ctx context.Context, in *VxlanGpeIoamEnable) (*VxlanGpeIoamEnableReply, error) { @@ -40,7 +41,7 @@ func (c *serviceClient) VxlanGpeIoamEnable(ctx context.Context, in *VxlanGpeIoam if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanGpeIoamTransitDisable(ctx context.Context, in *VxlanGpeIoamTransitDisable) (*VxlanGpeIoamTransitDisableReply, error) { @@ -49,7 +50,7 @@ func (c *serviceClient) VxlanGpeIoamTransitDisable(ctx context.Context, in *Vxla if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanGpeIoamTransitEnable(ctx context.Context, in *VxlanGpeIoamTransitEnable) (*VxlanGpeIoamTransitEnableReply, error) { @@ -58,7 +59,7 @@ func (c *serviceClient) VxlanGpeIoamTransitEnable(ctx context.Context, in *Vxlan if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanGpeIoamVniDisable(ctx context.Context, in *VxlanGpeIoamVniDisable) (*VxlanGpeIoamVniDisableReply, error) { @@ -67,7 +68,7 @@ func (c *serviceClient) VxlanGpeIoamVniDisable(ctx context.Context, in *VxlanGpe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanGpeIoamVniEnable(ctx context.Context, in *VxlanGpeIoamVniEnable) (*VxlanGpeIoamVniEnableReply, error) { @@ -76,5 +77,5 @@ func (c *serviceClient) VxlanGpeIoamVniEnable(ctx context.Context, in *VxlanGpeI if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/ip/ip.ba.go b/internal/testbinapi/binapi2001/ip/ip.ba.go index 1b0b6b2..2480300 100644 --- a/internal/testbinapi/binapi2001/ip/ip.ba.go +++ b/internal/testbinapi/binapi2001/ip/ip.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/ip.api.json @@ -17,11 +17,12 @@ package ip import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -725,12 +726,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -759,12 +763,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -793,12 +800,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -823,15 +833,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { @@ -852,6 +866,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -864,8 +882,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -875,12 +894,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -954,18 +976,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -1008,18 +1034,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -1102,6 +1132,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -1112,13 +1143,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -1143,8 +1177,9 @@ type PuntRedirect struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/ip/ip_rpc.ba.go b/internal/testbinapi/binapi2001/ip/ip_rpc.ba.go index 88dbb6b..26f72c2 100644 --- a/internal/testbinapi/binapi2001/ip/ip_rpc.ba.go +++ b/internal/testbinapi/binapi2001/ip/ip_rpc.ba.go @@ -5,12 +5,13 @@ package ip import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service ip. +// RPCService defines RPC service ip. type RPCService interface { IoamDisable(ctx context.Context, in *IoamDisable) (*IoamDisableReply, error) IoamEnable(ctx context.Context, in *IoamEnable) (*IoamEnableReply, error) @@ -58,7 +59,7 @@ func (c *serviceClient) IoamDisable(ctx context.Context, in *IoamDisable) (*Ioam if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IoamEnable(ctx context.Context, in *IoamEnable) (*IoamEnableReply, error) { @@ -67,7 +68,7 @@ func (c *serviceClient) IoamEnable(ctx context.Context, in *IoamEnable) (*IoamEn if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPAddressDump(ctx context.Context, in *IPAddressDump) (RPCService_IPAddressDumpClient, error) { @@ -103,6 +104,10 @@ func (c *serviceClient_IPAddressDumpClient) Recv() (*IPAddressDetails, error) { case *IPAddressDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -115,7 +120,7 @@ func (c *serviceClient) IPContainerProxyAddDel(ctx context.Context, in *IPContai if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPContainerProxyDump(ctx context.Context, in *IPContainerProxyDump) (RPCService_IPContainerProxyDumpClient, error) { @@ -151,6 +156,10 @@ func (c *serviceClient_IPContainerProxyDumpClient) Recv() (*IPContainerProxyDeta case *IPContainerProxyDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -190,6 +199,10 @@ func (c *serviceClient_IPDumpClient) Recv() (*IPDetails, error) { case *IPDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -202,7 +215,7 @@ func (c *serviceClient) IPMrouteAddDel(ctx context.Context, in *IPMrouteAddDel) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPMrouteDump(ctx context.Context, in *IPMrouteDump) (RPCService_IPMrouteDumpClient, error) { @@ -238,6 +251,10 @@ func (c *serviceClient_IPMrouteDumpClient) Recv() (*IPMrouteDetails, error) { case *IPMrouteDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -277,6 +294,10 @@ func (c *serviceClient_IPMtableDumpClient) Recv() (*IPMtableDetails, error) { case *IPMtableDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -289,7 +310,7 @@ func (c *serviceClient) IPPuntPolice(ctx context.Context, in *IPPuntPolice) (*IP if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPPuntRedirect(ctx context.Context, in *IPPuntRedirect) (*IPPuntRedirectReply, error) { @@ -298,7 +319,7 @@ func (c *serviceClient) IPPuntRedirect(ctx context.Context, in *IPPuntRedirect) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPPuntRedirectDump(ctx context.Context, in *IPPuntRedirectDump) (RPCService_IPPuntRedirectDumpClient, error) { @@ -334,6 +355,10 @@ func (c *serviceClient_IPPuntRedirectDumpClient) Recv() (*IPPuntRedirectDetails, case *IPPuntRedirectDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -346,7 +371,7 @@ func (c *serviceClient) IPReassemblyEnableDisable(ctx context.Context, in *IPRea if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPReassemblyGet(ctx context.Context, in *IPReassemblyGet) (*IPReassemblyGetReply, error) { @@ -355,7 +380,7 @@ func (c *serviceClient) IPReassemblyGet(ctx context.Context, in *IPReassemblyGet if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPReassemblySet(ctx context.Context, in *IPReassemblySet) (*IPReassemblySetReply, error) { @@ -364,7 +389,7 @@ func (c *serviceClient) IPReassemblySet(ctx context.Context, in *IPReassemblySet if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPRouteAddDel(ctx context.Context, in *IPRouteAddDel) (*IPRouteAddDelReply, error) { @@ -373,7 +398,7 @@ func (c *serviceClient) IPRouteAddDel(ctx context.Context, in *IPRouteAddDel) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPRouteDump(ctx context.Context, in *IPRouteDump) (RPCService_IPRouteDumpClient, error) { @@ -409,6 +434,10 @@ func (c *serviceClient_IPRouteDumpClient) Recv() (*IPRouteDetails, error) { case *IPRouteDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -421,7 +450,7 @@ func (c *serviceClient) IPSourceAndPortRangeCheckAddDel(ctx context.Context, in if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckInterfaceAddDel) (*IPSourceAndPortRangeCheckInterfaceAddDelReply, error) { @@ -430,7 +459,7 @@ func (c *serviceClient) IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Con if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPSourceCheckInterfaceAddDel(ctx context.Context, in *IPSourceCheckInterfaceAddDel) (*IPSourceCheckInterfaceAddDelReply, error) { @@ -439,7 +468,7 @@ func (c *serviceClient) IPSourceCheckInterfaceAddDel(ctx context.Context, in *IP if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPTableAddDel(ctx context.Context, in *IPTableAddDel) (*IPTableAddDelReply, error) { @@ -448,7 +477,7 @@ func (c *serviceClient) IPTableAddDel(ctx context.Context, in *IPTableAddDel) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPTableDump(ctx context.Context, in *IPTableDump) (RPCService_IPTableDumpClient, error) { @@ -484,6 +513,10 @@ func (c *serviceClient_IPTableDumpClient) Recv() (*IPTableDetails, error) { case *IPTableDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -496,7 +529,7 @@ func (c *serviceClient) IPTableFlush(ctx context.Context, in *IPTableFlush) (*IP if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPTableReplaceBegin(ctx context.Context, in *IPTableReplaceBegin) (*IPTableReplaceBeginReply, error) { @@ -505,7 +538,7 @@ func (c *serviceClient) IPTableReplaceBegin(ctx context.Context, in *IPTableRepl if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPTableReplaceEnd(ctx context.Context, in *IPTableReplaceEnd) (*IPTableReplaceEndReply, error) { @@ -514,7 +547,7 @@ func (c *serviceClient) IPTableReplaceEnd(ctx context.Context, in *IPTableReplac if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPUnnumberedDump(ctx context.Context, in *IPUnnumberedDump) (RPCService_IPUnnumberedDumpClient, error) { @@ -550,6 +583,10 @@ func (c *serviceClient_IPUnnumberedDumpClient) Recv() (*IPUnnumberedDetails, err case *IPUnnumberedDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -589,6 +626,10 @@ func (c *serviceClient_MfibSignalDumpClient) Recv() (*MfibSignalDetails, error) case *MfibSignalDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -601,7 +642,7 @@ func (c *serviceClient) SetIPFlowHash(ctx context.Context, in *SetIPFlowHash) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceIP6EnableDisable(ctx context.Context, in *SwInterfaceIP6EnableDisable) (*SwInterfaceIP6EnableDisableReply, error) { @@ -610,7 +651,7 @@ func (c *serviceClient) SwInterfaceIP6EnableDisable(ctx context.Context, in *SwI if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceIP6SetLinkLocalAddress(ctx context.Context, in *SwInterfaceIP6SetLinkLocalAddress) (*SwInterfaceIP6SetLinkLocalAddressReply, error) { @@ -619,5 +660,5 @@ func (c *serviceClient) SwInterfaceIP6SetLinkLocalAddress(ctx context.Context, i if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/ip6_nd/ip6_nd.ba.go b/internal/testbinapi/binapi2001/ip6_nd/ip6_nd.ba.go index e21f2d3..bae32c7 100644 --- a/internal/testbinapi/binapi2001/ip6_nd/ip6_nd.ba.go +++ b/internal/testbinapi/binapi2001/ip6_nd/ip6_nd.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/ip6_nd.api.json @@ -17,11 +17,12 @@ package ip6_nd import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -595,6 +605,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -607,8 +621,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -618,12 +633,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -666,18 +684,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -720,18 +742,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -790,6 +816,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -800,13 +827,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -824,8 +854,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/ip6_nd/ip6_nd_rpc.ba.go b/internal/testbinapi/binapi2001/ip6_nd/ip6_nd_rpc.ba.go index e4840db..1d18c7d 100644 --- a/internal/testbinapi/binapi2001/ip6_nd/ip6_nd_rpc.ba.go +++ b/internal/testbinapi/binapi2001/ip6_nd/ip6_nd_rpc.ba.go @@ -5,12 +5,13 @@ package ip6_nd import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service ip6_nd. +// RPCService defines RPC service ip6_nd. type RPCService interface { IP6ndProxyAddDel(ctx context.Context, in *IP6ndProxyAddDel) (*IP6ndProxyAddDelReply, error) IP6ndProxyDump(ctx context.Context, in *IP6ndProxyDump) (RPCService_IP6ndProxyDumpClient, error) @@ -34,7 +35,7 @@ func (c *serviceClient) IP6ndProxyAddDel(ctx context.Context, in *IP6ndProxyAddD if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IP6ndProxyDump(ctx context.Context, in *IP6ndProxyDump) (RPCService_IP6ndProxyDumpClient, error) { @@ -70,6 +71,10 @@ func (c *serviceClient_IP6ndProxyDumpClient) Recv() (*IP6ndProxyDetails, error) case *IP6ndProxyDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -82,7 +87,7 @@ func (c *serviceClient) IP6ndSendRouterSolicitation(ctx context.Context, in *IP6 if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceIP6ndRaConfig(ctx context.Context, in *SwInterfaceIP6ndRaConfig) (*SwInterfaceIP6ndRaConfigReply, error) { @@ -91,7 +96,7 @@ func (c *serviceClient) SwInterfaceIP6ndRaConfig(ctx context.Context, in *SwInte if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceIP6ndRaPrefix(ctx context.Context, in *SwInterfaceIP6ndRaPrefix) (*SwInterfaceIP6ndRaPrefixReply, error) { @@ -100,7 +105,7 @@ func (c *serviceClient) SwInterfaceIP6ndRaPrefix(ctx context.Context, in *SwInte if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) WantIP6RaEvents(ctx context.Context, in *WantIP6RaEvents) (*WantIP6RaEventsReply, error) { @@ -109,5 +114,5 @@ func (c *serviceClient) WantIP6RaEvents(ctx context.Context, in *WantIP6RaEvents if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/ip_neighbor/ip_neighbor.ba.go b/internal/testbinapi/binapi2001/ip_neighbor/ip_neighbor.ba.go index 93def01..6e88503 100644 --- a/internal/testbinapi/binapi2001/ip_neighbor/ip_neighbor.ba.go +++ b/internal/testbinapi/binapi2001/ip_neighbor/ip_neighbor.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/ip_neighbor.api.json @@ -17,11 +17,12 @@ package ip_neighbor import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -547,12 +548,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -581,12 +585,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -615,12 +622,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -645,15 +655,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { @@ -674,6 +688,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -686,8 +704,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -697,12 +716,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -745,18 +767,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -799,18 +825,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -869,6 +899,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -879,13 +910,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -903,8 +937,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/ip_neighbor/ip_neighbor_rpc.ba.go b/internal/testbinapi/binapi2001/ip_neighbor/ip_neighbor_rpc.ba.go index 89a64d6..9cab182 100644 --- a/internal/testbinapi/binapi2001/ip_neighbor/ip_neighbor_rpc.ba.go +++ b/internal/testbinapi/binapi2001/ip_neighbor/ip_neighbor_rpc.ba.go @@ -5,12 +5,13 @@ package ip_neighbor import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service ip_neighbor. +// RPCService defines RPC service ip_neighbor. type RPCService interface { IPNeighborAddDel(ctx context.Context, in *IPNeighborAddDel) (*IPNeighborAddDelReply, error) IPNeighborConfig(ctx context.Context, in *IPNeighborConfig) (*IPNeighborConfigReply, error) @@ -32,7 +33,7 @@ func (c *serviceClient) IPNeighborAddDel(ctx context.Context, in *IPNeighborAddD if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPNeighborConfig(ctx context.Context, in *IPNeighborConfig) (*IPNeighborConfigReply, error) { @@ -41,7 +42,7 @@ func (c *serviceClient) IPNeighborConfig(ctx context.Context, in *IPNeighborConf if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IPNeighborDump(ctx context.Context, in *IPNeighborDump) (RPCService_IPNeighborDumpClient, error) { @@ -77,6 +78,10 @@ func (c *serviceClient_IPNeighborDumpClient) Recv() (*IPNeighborDetails, error) case *IPNeighborDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -89,5 +94,5 @@ func (c *serviceClient) WantIPNeighborEvents(ctx context.Context, in *WantIPNeig if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/ip_types/ip_types.ba.go b/internal/testbinapi/binapi2001/ip_types/ip_types.ba.go index 67d02c9..b302df0 100644 --- a/internal/testbinapi/binapi2001/ip_types/ip_types.ba.go +++ b/internal/testbinapi/binapi2001/ip_types/ip_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/ip_types.api.json @@ -16,11 +16,12 @@ package ip_types import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -29,6 +30,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "ip_types" + APIVersion = "3.0.0" + VersionCrc = 0x80424562 +) + // AddressFamily defines enum 'address_family'. type AddressFamily uint32 @@ -240,12 +247,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -271,12 +281,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -305,12 +318,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -334,6 +350,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -346,8 +366,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -357,12 +378,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -405,18 +429,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -459,18 +487,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -521,6 +553,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -531,13 +564,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -555,8 +591,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/ipfix_export/ipfix_export.ba.go b/internal/testbinapi/binapi2001/ipfix_export/ipfix_export.ba.go index 12b020b..ee75bbf 100644 --- a/internal/testbinapi/binapi2001/ipfix_export/ipfix_export.ba.go +++ b/internal/testbinapi/binapi2001/ipfix_export/ipfix_export.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/ipfix_export.api.json @@ -17,11 +17,12 @@ package ipfix_export import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -247,12 +248,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -278,12 +282,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -312,12 +319,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -341,6 +351,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -353,8 +367,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -364,12 +379,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -412,18 +430,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -466,18 +488,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -528,6 +554,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -538,13 +565,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -562,8 +592,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/ipfix_export/ipfix_export_rpc.ba.go b/internal/testbinapi/binapi2001/ipfix_export/ipfix_export_rpc.ba.go index 0189d4d..c0de49b 100644 --- a/internal/testbinapi/binapi2001/ipfix_export/ipfix_export_rpc.ba.go +++ b/internal/testbinapi/binapi2001/ipfix_export/ipfix_export_rpc.ba.go @@ -5,12 +5,13 @@ package ipfix_export import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service ipfix_export. +// RPCService defines RPC service ipfix_export. type RPCService interface { IpfixClassifyStreamDump(ctx context.Context, in *IpfixClassifyStreamDump) (RPCService_IpfixClassifyStreamDumpClient, error) IpfixClassifyTableAddDel(ctx context.Context, in *IpfixClassifyTableAddDel) (*IpfixClassifyTableAddDelReply, error) @@ -62,6 +63,10 @@ func (c *serviceClient_IpfixClassifyStreamDumpClient) Recv() (*IpfixClassifyStre case *IpfixClassifyStreamDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -74,7 +79,7 @@ func (c *serviceClient) IpfixClassifyTableAddDel(ctx context.Context, in *IpfixC if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpfixClassifyTableDump(ctx context.Context, in *IpfixClassifyTableDump) (RPCService_IpfixClassifyTableDumpClient, error) { @@ -110,6 +115,10 @@ func (c *serviceClient_IpfixClassifyTableDumpClient) Recv() (*IpfixClassifyTable case *IpfixClassifyTableDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -149,6 +158,10 @@ func (c *serviceClient_IpfixExporterDumpClient) Recv() (*IpfixExporterDetails, e case *IpfixExporterDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -161,7 +174,7 @@ func (c *serviceClient) IpfixFlush(ctx context.Context, in *IpfixFlush) (*IpfixF if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SetIpfixClassifyStream(ctx context.Context, in *SetIpfixClassifyStream) (*SetIpfixClassifyStreamReply, error) { @@ -170,7 +183,7 @@ func (c *serviceClient) SetIpfixClassifyStream(ctx context.Context, in *SetIpfix if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SetIpfixExporter(ctx context.Context, in *SetIpfixExporter) (*SetIpfixExporterReply, error) { @@ -179,5 +192,5 @@ func (c *serviceClient) SetIpfixExporter(ctx context.Context, in *SetIpfixExport if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/ipip/ipip.ba.go b/internal/testbinapi/binapi2001/ipip/ipip.ba.go index e345dc7..6118a82 100644 --- a/internal/testbinapi/binapi2001/ipip/ipip.ba.go +++ b/internal/testbinapi/binapi2001/ipip/ipip.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/ipip.api.json @@ -17,11 +17,12 @@ package ipip import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -556,12 +557,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -590,12 +594,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -624,12 +631,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -653,6 +663,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -665,8 +679,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -676,12 +691,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -724,18 +742,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -778,18 +800,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -851,6 +877,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -861,13 +888,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -885,8 +915,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/ipip/ipip_rpc.ba.go b/internal/testbinapi/binapi2001/ipip/ipip_rpc.ba.go index 66acb4e..27666ae 100644 --- a/internal/testbinapi/binapi2001/ipip/ipip_rpc.ba.go +++ b/internal/testbinapi/binapi2001/ipip/ipip_rpc.ba.go @@ -5,12 +5,13 @@ package ipip import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service ipip. +// RPCService defines RPC service ipip. type RPCService interface { Ipip6rdAddTunnel(ctx context.Context, in *Ipip6rdAddTunnel) (*Ipip6rdAddTunnelReply, error) Ipip6rdDelTunnel(ctx context.Context, in *Ipip6rdDelTunnel) (*Ipip6rdDelTunnelReply, error) @@ -33,7 +34,7 @@ func (c *serviceClient) Ipip6rdAddTunnel(ctx context.Context, in *Ipip6rdAddTunn if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ipip6rdDelTunnel(ctx context.Context, in *Ipip6rdDelTunnel) (*Ipip6rdDelTunnelReply, error) { @@ -42,7 +43,7 @@ func (c *serviceClient) Ipip6rdDelTunnel(ctx context.Context, in *Ipip6rdDelTunn if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpipAddTunnel(ctx context.Context, in *IpipAddTunnel) (*IpipAddTunnelReply, error) { @@ -51,7 +52,7 @@ func (c *serviceClient) IpipAddTunnel(ctx context.Context, in *IpipAddTunnel) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpipDelTunnel(ctx context.Context, in *IpipDelTunnel) (*IpipDelTunnelReply, error) { @@ -60,7 +61,7 @@ func (c *serviceClient) IpipDelTunnel(ctx context.Context, in *IpipDelTunnel) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpipTunnelDump(ctx context.Context, in *IpipTunnelDump) (RPCService_IpipTunnelDumpClient, error) { @@ -96,6 +97,10 @@ func (c *serviceClient_IpipTunnelDumpClient) Recv() (*IpipTunnelDetails, error) case *IpipTunnelDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/ipip_types/ipip_types.ba.go b/internal/testbinapi/binapi2001/ipip_types/ipip_types.ba.go index 62d42d7..a345908 100644 --- a/internal/testbinapi/binapi2001/ipip_types/ipip_types.ba.go +++ b/internal/testbinapi/binapi2001/ipip_types/ipip_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/ipip_types.api.json @@ -12,8 +12,9 @@ package ipip_types import ( - api "git.fd.io/govpp.git/api" "strconv" + + api "git.fd.io/govpp.git/api" ) // This is a compile-time assertion to ensure that this generated file @@ -22,6 +23,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "ipip_types" + APIVersion = "" + VersionCrc = 0xa2a8fa8d +) + // IpipTunnelFlags defines enum 'ipip_tunnel_flags'. type IpipTunnelFlags uint8 diff --git a/internal/testbinapi/binapi2001/ipsec/ipsec.ba.go b/internal/testbinapi/binapi2001/ipsec/ipsec.ba.go index b1c0079..68aab51 100644 --- a/internal/testbinapi/binapi2001/ipsec/ipsec.ba.go +++ b/internal/testbinapi/binapi2001/ipsec/ipsec.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/ipsec.api.json @@ -17,11 +17,12 @@ package ipsec import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -715,12 +716,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -749,12 +753,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -783,12 +790,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -812,6 +822,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -824,8 +838,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -835,12 +850,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -883,18 +901,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -937,18 +959,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -1047,6 +1073,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -1057,13 +1084,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -1081,8 +1111,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/ipsec/ipsec_rpc.ba.go b/internal/testbinapi/binapi2001/ipsec/ipsec_rpc.ba.go index c14df44..d2ccabb 100644 --- a/internal/testbinapi/binapi2001/ipsec/ipsec_rpc.ba.go +++ b/internal/testbinapi/binapi2001/ipsec/ipsec_rpc.ba.go @@ -5,12 +5,13 @@ package ipsec import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service ipsec. +// RPCService defines RPC service ipsec. type RPCService interface { IpsecBackendDump(ctx context.Context, in *IpsecBackendDump) (RPCService_IpsecBackendDumpClient, error) IpsecInterfaceAddDelSpd(ctx context.Context, in *IpsecInterfaceAddDelSpd) (*IpsecInterfaceAddDelSpdReply, error) @@ -70,6 +71,10 @@ func (c *serviceClient_IpsecBackendDumpClient) Recv() (*IpsecBackendDetails, err case *IpsecBackendDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -82,7 +87,7 @@ func (c *serviceClient) IpsecInterfaceAddDelSpd(ctx context.Context, in *IpsecIn if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpsecSaDump(ctx context.Context, in *IpsecSaDump) (RPCService_IpsecSaDumpClient, error) { @@ -118,6 +123,10 @@ func (c *serviceClient_IpsecSaDumpClient) Recv() (*IpsecSaDetails, error) { case *IpsecSaDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -130,7 +139,7 @@ func (c *serviceClient) IpsecSadEntryAddDel(ctx context.Context, in *IpsecSadEnt if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpsecSelectBackend(ctx context.Context, in *IpsecSelectBackend) (*IpsecSelectBackendReply, error) { @@ -139,7 +148,7 @@ func (c *serviceClient) IpsecSelectBackend(ctx context.Context, in *IpsecSelectB if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpsecSpdAddDel(ctx context.Context, in *IpsecSpdAddDel) (*IpsecSpdAddDelReply, error) { @@ -148,7 +157,7 @@ func (c *serviceClient) IpsecSpdAddDel(ctx context.Context, in *IpsecSpdAddDel) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpsecSpdDump(ctx context.Context, in *IpsecSpdDump) (RPCService_IpsecSpdDumpClient, error) { @@ -184,6 +193,10 @@ func (c *serviceClient_IpsecSpdDumpClient) Recv() (*IpsecSpdDetails, error) { case *IpsecSpdDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -196,7 +209,7 @@ func (c *serviceClient) IpsecSpdEntryAddDel(ctx context.Context, in *IpsecSpdEnt if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpsecSpdInterfaceDump(ctx context.Context, in *IpsecSpdInterfaceDump) (RPCService_IpsecSpdInterfaceDumpClient, error) { @@ -232,6 +245,10 @@ func (c *serviceClient_IpsecSpdInterfaceDumpClient) Recv() (*IpsecSpdInterfaceDe case *IpsecSpdInterfaceDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -271,6 +288,10 @@ func (c *serviceClient_IpsecSpdsDumpClient) Recv() (*IpsecSpdsDetails, error) { case *IpsecSpdsDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -283,7 +304,7 @@ func (c *serviceClient) IpsecTunnelIfAddDel(ctx context.Context, in *IpsecTunnel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpsecTunnelIfSetSa(ctx context.Context, in *IpsecTunnelIfSetSa) (*IpsecTunnelIfSetSaReply, error) { @@ -292,7 +313,7 @@ func (c *serviceClient) IpsecTunnelIfSetSa(ctx context.Context, in *IpsecTunnelI if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpsecTunnelProtectDel(ctx context.Context, in *IpsecTunnelProtectDel) (*IpsecTunnelProtectDelReply, error) { @@ -301,7 +322,7 @@ func (c *serviceClient) IpsecTunnelProtectDel(ctx context.Context, in *IpsecTunn if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) IpsecTunnelProtectDump(ctx context.Context, in *IpsecTunnelProtectDump) (RPCService_IpsecTunnelProtectDumpClient, error) { @@ -337,6 +358,10 @@ func (c *serviceClient_IpsecTunnelProtectDumpClient) Recv() (*IpsecTunnelProtect case *IpsecTunnelProtectDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -349,5 +374,5 @@ func (c *serviceClient) IpsecTunnelProtectUpdate(ctx context.Context, in *IpsecT if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/ipsec_types/ipsec_types.ba.go b/internal/testbinapi/binapi2001/ipsec_types/ipsec_types.ba.go index 9123fc4..a55ac08 100644 --- a/internal/testbinapi/binapi2001/ipsec_types/ipsec_types.ba.go +++ b/internal/testbinapi/binapi2001/ipsec_types/ipsec_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/ipsec_types.api.json @@ -16,11 +16,12 @@ package ipsec_types import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -29,6 +30,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "ipsec_types" + APIVersion = "3.0.0" + VersionCrc = 0x6e9f4c73 +) + // AddressFamily defines enum 'address_family'. type AddressFamily uint32 @@ -424,12 +431,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -455,12 +465,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -489,12 +502,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -518,6 +534,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -530,8 +550,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -541,12 +562,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -589,18 +613,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -643,18 +671,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -727,6 +759,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -737,13 +770,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -761,8 +797,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/l2/l2.ba.go b/internal/testbinapi/binapi2001/l2/l2.ba.go index d4af668..9eee598 100644 --- a/internal/testbinapi/binapi2001/l2/l2.ba.go +++ b/internal/testbinapi/binapi2001/l2/l2.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/l2.api.json @@ -17,11 +17,12 @@ package l2 import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -589,12 +590,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -623,12 +627,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -657,12 +664,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -687,15 +697,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { @@ -716,6 +730,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -728,8 +746,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -739,12 +758,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -801,18 +823,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -855,18 +881,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -925,6 +955,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -935,13 +966,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -959,8 +993,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/l2/l2_rpc.ba.go b/internal/testbinapi/binapi2001/l2/l2_rpc.ba.go index 7f8f246..106ca97 100644 --- a/internal/testbinapi/binapi2001/l2/l2_rpc.ba.go +++ b/internal/testbinapi/binapi2001/l2/l2_rpc.ba.go @@ -5,12 +5,13 @@ package l2 import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service l2. +// RPCService defines RPC service l2. type RPCService interface { BdIPMacAddDel(ctx context.Context, in *BdIPMacAddDel) (*BdIPMacAddDelReply, error) BdIPMacDump(ctx context.Context, in *BdIPMacDump) (RPCService_BdIPMacDumpClient, error) @@ -54,7 +55,7 @@ func (c *serviceClient) BdIPMacAddDel(ctx context.Context, in *BdIPMacAddDel) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BdIPMacDump(ctx context.Context, in *BdIPMacDump) (RPCService_BdIPMacDumpClient, error) { @@ -90,6 +91,10 @@ func (c *serviceClient_BdIPMacDumpClient) Recv() (*BdIPMacDetails, error) { case *BdIPMacDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -102,7 +107,7 @@ func (c *serviceClient) BdIPMacFlush(ctx context.Context, in *BdIPMacFlush) (*Bd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BridgeDomainAddDel(ctx context.Context, in *BridgeDomainAddDel) (*BridgeDomainAddDelReply, error) { @@ -111,7 +116,7 @@ func (c *serviceClient) BridgeDomainAddDel(ctx context.Context, in *BridgeDomain if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BridgeDomainDump(ctx context.Context, in *BridgeDomainDump) (RPCService_BridgeDomainDumpClient, error) { @@ -147,6 +152,10 @@ func (c *serviceClient_BridgeDomainDumpClient) Recv() (*BridgeDomainDetails, err case *BridgeDomainDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -159,7 +168,7 @@ func (c *serviceClient) BridgeDomainSetMacAge(ctx context.Context, in *BridgeDom if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BridgeFlags(ctx context.Context, in *BridgeFlags) (*BridgeFlagsReply, error) { @@ -168,7 +177,7 @@ func (c *serviceClient) BridgeFlags(ctx context.Context, in *BridgeFlags) (*Brid if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BviCreate(ctx context.Context, in *BviCreate) (*BviCreateReply, error) { @@ -177,7 +186,7 @@ func (c *serviceClient) BviCreate(ctx context.Context, in *BviCreate) (*BviCreat if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BviDelete(ctx context.Context, in *BviDelete) (*BviDeleteReply, error) { @@ -186,7 +195,7 @@ func (c *serviceClient) BviDelete(ctx context.Context, in *BviDelete) (*BviDelet if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2FibClearTable(ctx context.Context, in *L2FibClearTable) (*L2FibClearTableReply, error) { @@ -195,7 +204,7 @@ func (c *serviceClient) L2FibClearTable(ctx context.Context, in *L2FibClearTable if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2FibTableDump(ctx context.Context, in *L2FibTableDump) (RPCService_L2FibTableDumpClient, error) { @@ -231,6 +240,10 @@ func (c *serviceClient_L2FibTableDumpClient) Recv() (*L2FibTableDetails, error) case *L2FibTableDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -243,7 +256,7 @@ func (c *serviceClient) L2Flags(ctx context.Context, in *L2Flags) (*L2FlagsReply if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2InterfaceEfpFilter(ctx context.Context, in *L2InterfaceEfpFilter) (*L2InterfaceEfpFilterReply, error) { @@ -252,7 +265,7 @@ func (c *serviceClient) L2InterfaceEfpFilter(ctx context.Context, in *L2Interfac if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2InterfacePbbTagRewrite(ctx context.Context, in *L2InterfacePbbTagRewrite) (*L2InterfacePbbTagRewriteReply, error) { @@ -261,7 +274,7 @@ func (c *serviceClient) L2InterfacePbbTagRewrite(ctx context.Context, in *L2Inte if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2InterfaceVlanTagRewrite(ctx context.Context, in *L2InterfaceVlanTagRewrite) (*L2InterfaceVlanTagRewriteReply, error) { @@ -270,7 +283,7 @@ func (c *serviceClient) L2InterfaceVlanTagRewrite(ctx context.Context, in *L2Int if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2PatchAddDel(ctx context.Context, in *L2PatchAddDel) (*L2PatchAddDelReply, error) { @@ -279,7 +292,7 @@ func (c *serviceClient) L2PatchAddDel(ctx context.Context, in *L2PatchAddDel) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2XconnectDump(ctx context.Context, in *L2XconnectDump) (RPCService_L2XconnectDumpClient, error) { @@ -315,6 +328,10 @@ func (c *serviceClient_L2XconnectDumpClient) Recv() (*L2XconnectDetails, error) case *L2XconnectDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -327,7 +344,7 @@ func (c *serviceClient) L2fibAddDel(ctx context.Context, in *L2fibAddDel) (*L2fi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2fibFlushAll(ctx context.Context, in *L2fibFlushAll) (*L2fibFlushAllReply, error) { @@ -336,7 +353,7 @@ func (c *serviceClient) L2fibFlushAll(ctx context.Context, in *L2fibFlushAll) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2fibFlushBd(ctx context.Context, in *L2fibFlushBd) (*L2fibFlushBdReply, error) { @@ -345,7 +362,7 @@ func (c *serviceClient) L2fibFlushBd(ctx context.Context, in *L2fibFlushBd) (*L2 if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2fibFlushInt(ctx context.Context, in *L2fibFlushInt) (*L2fibFlushIntReply, error) { @@ -354,7 +371,7 @@ func (c *serviceClient) L2fibFlushInt(ctx context.Context, in *L2fibFlushInt) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSetL2Bridge(ctx context.Context, in *SwInterfaceSetL2Bridge) (*SwInterfaceSetL2BridgeReply, error) { @@ -363,7 +380,7 @@ func (c *serviceClient) SwInterfaceSetL2Bridge(ctx context.Context, in *SwInterf if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSetL2Xconnect(ctx context.Context, in *SwInterfaceSetL2Xconnect) (*SwInterfaceSetL2XconnectReply, error) { @@ -372,7 +389,7 @@ func (c *serviceClient) SwInterfaceSetL2Xconnect(ctx context.Context, in *SwInte if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSetVpath(ctx context.Context, in *SwInterfaceSetVpath) (*SwInterfaceSetVpathReply, error) { @@ -381,7 +398,7 @@ func (c *serviceClient) SwInterfaceSetVpath(ctx context.Context, in *SwInterface if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) WantL2ArpTermEvents(ctx context.Context, in *WantL2ArpTermEvents) (*WantL2ArpTermEventsReply, error) { @@ -390,7 +407,7 @@ func (c *serviceClient) WantL2ArpTermEvents(ctx context.Context, in *WantL2ArpTe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) WantL2MacsEvents(ctx context.Context, in *WantL2MacsEvents) (*WantL2MacsEventsReply, error) { @@ -399,5 +416,5 @@ func (c *serviceClient) WantL2MacsEvents(ctx context.Context, in *WantL2MacsEven if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/l2e/l2e.ba.go b/internal/testbinapi/binapi2001/l2e/l2e.ba.go index 02680bb..ef750b9 100644 --- a/internal/testbinapi/binapi2001/l2e/l2e.ba.go +++ b/internal/testbinapi/binapi2001/l2e/l2e.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/l2e.api.json @@ -14,9 +14,10 @@ package l2e import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/l2e/l2e_rpc.ba.go b/internal/testbinapi/binapi2001/l2e/l2e_rpc.ba.go index e589d28..277e04e 100644 --- a/internal/testbinapi/binapi2001/l2e/l2e_rpc.ba.go +++ b/internal/testbinapi/binapi2001/l2e/l2e_rpc.ba.go @@ -4,10 +4,11 @@ package l2e import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service l2e. +// RPCService defines RPC service l2e. type RPCService interface { L2Emulation(ctx context.Context, in *L2Emulation) (*L2EmulationReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) L2Emulation(ctx context.Context, in *L2Emulation) (*L2Em if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/l2tp/l2tp.ba.go b/internal/testbinapi/binapi2001/l2tp/l2tp.ba.go index 402bb21..3aea952 100644 --- a/internal/testbinapi/binapi2001/l2tp/l2tp.ba.go +++ b/internal/testbinapi/binapi2001/l2tp/l2tp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/l2tp.api.json @@ -17,11 +17,12 @@ package l2tp import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -528,12 +529,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -562,12 +566,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -596,12 +603,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -626,15 +636,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { @@ -655,6 +669,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -667,8 +685,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -678,12 +697,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -726,18 +748,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -780,18 +806,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -842,6 +872,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -852,13 +883,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -876,8 +910,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/l2tp/l2tp_rpc.ba.go b/internal/testbinapi/binapi2001/l2tp/l2tp_rpc.ba.go index 49db4ce..f0b1e59 100644 --- a/internal/testbinapi/binapi2001/l2tp/l2tp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/l2tp/l2tp_rpc.ba.go @@ -5,12 +5,13 @@ package l2tp import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service l2tp. +// RPCService defines RPC service l2tp. type RPCService interface { L2tpv3CreateTunnel(ctx context.Context, in *L2tpv3CreateTunnel) (*L2tpv3CreateTunnelReply, error) L2tpv3InterfaceEnableDisable(ctx context.Context, in *L2tpv3InterfaceEnableDisable) (*L2tpv3InterfaceEnableDisableReply, error) @@ -33,7 +34,7 @@ func (c *serviceClient) L2tpv3CreateTunnel(ctx context.Context, in *L2tpv3Create if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2tpv3InterfaceEnableDisable(ctx context.Context, in *L2tpv3InterfaceEnableDisable) (*L2tpv3InterfaceEnableDisableReply, error) { @@ -42,7 +43,7 @@ func (c *serviceClient) L2tpv3InterfaceEnableDisable(ctx context.Context, in *L2 if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2tpv3SetLookupKey(ctx context.Context, in *L2tpv3SetLookupKey) (*L2tpv3SetLookupKeyReply, error) { @@ -51,7 +52,7 @@ func (c *serviceClient) L2tpv3SetLookupKey(ctx context.Context, in *L2tpv3SetLoo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L2tpv3SetTunnelCookies(ctx context.Context, in *L2tpv3SetTunnelCookies) (*L2tpv3SetTunnelCookiesReply, error) { @@ -60,7 +61,7 @@ func (c *serviceClient) L2tpv3SetTunnelCookies(ctx context.Context, in *L2tpv3Se if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwIfL2tpv3TunnelDump(ctx context.Context, in *SwIfL2tpv3TunnelDump) (RPCService_SwIfL2tpv3TunnelDumpClient, error) { @@ -96,6 +97,10 @@ func (c *serviceClient_SwIfL2tpv3TunnelDumpClient) Recv() (*SwIfL2tpv3TunnelDeta case *SwIfL2tpv3TunnelDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/l3xc/l3xc.ba.go b/internal/testbinapi/binapi2001/l3xc/l3xc.ba.go index 82948f2..27aa4c6 100644 --- a/internal/testbinapi/binapi2001/l3xc/l3xc.ba.go +++ b/internal/testbinapi/binapi2001/l3xc/l3xc.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/l3xc.api.json @@ -17,11 +17,12 @@ package l3xc import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -640,12 +641,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -674,12 +678,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -708,12 +715,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -737,6 +747,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -749,8 +763,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -760,12 +775,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -839,18 +857,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -893,18 +915,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -963,6 +989,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -973,13 +1000,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -997,8 +1027,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/l3xc/l3xc_rpc.ba.go b/internal/testbinapi/binapi2001/l3xc/l3xc_rpc.ba.go index b25727e..9f4c8a7 100644 --- a/internal/testbinapi/binapi2001/l3xc/l3xc_rpc.ba.go +++ b/internal/testbinapi/binapi2001/l3xc/l3xc_rpc.ba.go @@ -5,12 +5,13 @@ package l3xc import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service l3xc. +// RPCService defines RPC service l3xc. type RPCService interface { L3xcDel(ctx context.Context, in *L3xcDel) (*L3xcDelReply, error) L3xcDump(ctx context.Context, in *L3xcDump) (RPCService_L3xcDumpClient, error) @@ -32,7 +33,7 @@ func (c *serviceClient) L3xcDel(ctx context.Context, in *L3xcDel) (*L3xcDelReply if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) L3xcDump(ctx context.Context, in *L3xcDump) (RPCService_L3xcDumpClient, error) { @@ -68,6 +69,10 @@ func (c *serviceClient_L3xcDumpClient) Recv() (*L3xcDetails, error) { case *L3xcDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -89,5 +94,5 @@ func (c *serviceClient) L3xcUpdate(ctx context.Context, in *L3xcUpdate) (*L3xcUp if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/lacp/lacp.ba.go b/internal/testbinapi/binapi2001/lacp/lacp.ba.go index a2b5a9e..848079b 100644 --- a/internal/testbinapi/binapi2001/lacp/lacp.ba.go +++ b/internal/testbinapi/binapi2001/lacp/lacp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/lacp.api.json @@ -14,10 +14,11 @@ package lacp import ( - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -298,15 +299,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { diff --git a/internal/testbinapi/binapi2001/lacp/lacp_rpc.ba.go b/internal/testbinapi/binapi2001/lacp/lacp_rpc.ba.go index f983ccb..a2176a9 100644 --- a/internal/testbinapi/binapi2001/lacp/lacp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/lacp/lacp_rpc.ba.go @@ -5,12 +5,13 @@ package lacp import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service lacp. +// RPCService defines RPC service lacp. type RPCService interface { SwInterfaceLacpDump(ctx context.Context, in *SwInterfaceLacpDump) (RPCService_SwInterfaceLacpDumpClient, error) } @@ -56,6 +57,10 @@ func (c *serviceClient_SwInterfaceLacpDumpClient) Recv() (*SwInterfaceLacpDetail case *SwInterfaceLacpDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/lb/lb.ba.go b/internal/testbinapi/binapi2001/lb/lb.ba.go index 348a150..12536bb 100644 --- a/internal/testbinapi/binapi2001/lb/lb.ba.go +++ b/internal/testbinapi/binapi2001/lb/lb.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/lb.api.json @@ -17,11 +17,12 @@ package lb import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -675,12 +676,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -709,12 +713,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -743,12 +750,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -772,6 +782,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -784,8 +798,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -795,12 +810,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -843,18 +861,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -897,18 +919,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -966,6 +992,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -976,13 +1003,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -1000,8 +1030,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/lb/lb_rpc.ba.go b/internal/testbinapi/binapi2001/lb/lb_rpc.ba.go index 3375e9c..43c0c4b 100644 --- a/internal/testbinapi/binapi2001/lb/lb_rpc.ba.go +++ b/internal/testbinapi/binapi2001/lb/lb_rpc.ba.go @@ -5,12 +5,13 @@ package lb import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service lb. +// RPCService defines RPC service lb. type RPCService interface { LbAddDelAs(ctx context.Context, in *LbAddDelAs) (*LbAddDelAsReply, error) LbAddDelIntfNat4(ctx context.Context, in *LbAddDelIntfNat4) (*LbAddDelIntfNat4Reply, error) @@ -36,7 +37,7 @@ func (c *serviceClient) LbAddDelAs(ctx context.Context, in *LbAddDelAs) (*LbAddD if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LbAddDelIntfNat4(ctx context.Context, in *LbAddDelIntfNat4) (*LbAddDelIntfNat4Reply, error) { @@ -45,7 +46,7 @@ func (c *serviceClient) LbAddDelIntfNat4(ctx context.Context, in *LbAddDelIntfNa if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LbAddDelIntfNat6(ctx context.Context, in *LbAddDelIntfNat6) (*LbAddDelIntfNat6Reply, error) { @@ -54,7 +55,7 @@ func (c *serviceClient) LbAddDelIntfNat6(ctx context.Context, in *LbAddDelIntfNa if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LbAddDelVip(ctx context.Context, in *LbAddDelVip) (*LbAddDelVipReply, error) { @@ -63,7 +64,7 @@ func (c *serviceClient) LbAddDelVip(ctx context.Context, in *LbAddDelVip) (*LbAd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LbAsDump(ctx context.Context, in *LbAsDump) (RPCService_LbAsDumpClient, error) { @@ -99,6 +100,10 @@ func (c *serviceClient_LbAsDumpClient) Recv() (*LbAsDetails, error) { case *LbAsDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -111,7 +116,7 @@ func (c *serviceClient) LbConf(ctx context.Context, in *LbConf) (*LbConfReply, e if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LbFlushVip(ctx context.Context, in *LbFlushVip) (*LbFlushVipReply, error) { @@ -120,7 +125,7 @@ func (c *serviceClient) LbFlushVip(ctx context.Context, in *LbFlushVip) (*LbFlus if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LbVipDump(ctx context.Context, in *LbVipDump) (RPCService_LbVipDumpClient, error) { @@ -156,6 +161,10 @@ func (c *serviceClient_LbVipDumpClient) Recv() (*LbVipDetails, error) { case *LbVipDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/lb_types/lb_types.ba.go b/internal/testbinapi/binapi2001/lb_types/lb_types.ba.go index 48aa105..a2ac411 100644 --- a/internal/testbinapi/binapi2001/lb_types/lb_types.ba.go +++ b/internal/testbinapi/binapi2001/lb_types/lb_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/lb_types.api.json @@ -16,11 +16,12 @@ package lb_types import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -29,6 +30,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "lb_types" + APIVersion = "" + VersionCrc = 0xd04207f3 +) + // AddressFamily defines enum 'address_family'. type AddressFamily uint32 @@ -417,12 +424,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -448,12 +458,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -482,12 +495,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -511,6 +527,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -523,8 +543,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -534,12 +555,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -582,18 +606,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -636,18 +664,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -705,6 +737,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -715,13 +748,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -739,8 +775,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/lisp/lisp.ba.go b/internal/testbinapi/binapi2001/lisp/lisp.ba.go index 20a7d42..dd605c7 100644 --- a/internal/testbinapi/binapi2001/lisp/lisp.ba.go +++ b/internal/testbinapi/binapi2001/lisp/lisp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/lisp.api.json diff --git a/internal/testbinapi/binapi2001/lisp/lisp_rpc.ba.go b/internal/testbinapi/binapi2001/lisp/lisp_rpc.ba.go index a8fbddd..5c9c632 100644 --- a/internal/testbinapi/binapi2001/lisp/lisp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/lisp/lisp_rpc.ba.go @@ -5,12 +5,13 @@ package lisp import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service lisp. +// RPCService defines RPC service lisp. type RPCService interface { LispAddDelAdjacency(ctx context.Context, in *LispAddDelAdjacency) (*LispAddDelAdjacencyReply, error) LispAddDelLocalEid(ctx context.Context, in *LispAddDelLocalEid) (*LispAddDelLocalEidReply, error) @@ -58,7 +59,7 @@ func (c *serviceClient) LispAddDelAdjacency(ctx context.Context, in *LispAddDelA if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispAddDelLocalEid(ctx context.Context, in *LispAddDelLocalEid) (*LispAddDelLocalEidReply, error) { @@ -67,7 +68,7 @@ func (c *serviceClient) LispAddDelLocalEid(ctx context.Context, in *LispAddDelLo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispAddDelLocator(ctx context.Context, in *LispAddDelLocator) (*LispAddDelLocatorReply, error) { @@ -76,7 +77,7 @@ func (c *serviceClient) LispAddDelLocator(ctx context.Context, in *LispAddDelLoc if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispAddDelLocatorSet(ctx context.Context, in *LispAddDelLocatorSet) (*LispAddDelLocatorSetReply, error) { @@ -85,7 +86,7 @@ func (c *serviceClient) LispAddDelLocatorSet(ctx context.Context, in *LispAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispAddDelMapRequestItrRlocs(ctx context.Context, in *LispAddDelMapRequestItrRlocs) (*LispAddDelMapRequestItrRlocsReply, error) { @@ -94,7 +95,7 @@ func (c *serviceClient) LispAddDelMapRequestItrRlocs(ctx context.Context, in *Li if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispAddDelMapResolver(ctx context.Context, in *LispAddDelMapResolver) (*LispAddDelMapResolverReply, error) { @@ -103,7 +104,7 @@ func (c *serviceClient) LispAddDelMapResolver(ctx context.Context, in *LispAddDe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispAddDelMapServer(ctx context.Context, in *LispAddDelMapServer) (*LispAddDelMapServerReply, error) { @@ -112,7 +113,7 @@ func (c *serviceClient) LispAddDelMapServer(ctx context.Context, in *LispAddDelM if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispAddDelRemoteMapping(ctx context.Context, in *LispAddDelRemoteMapping) (*LispAddDelRemoteMappingReply, error) { @@ -121,7 +122,7 @@ func (c *serviceClient) LispAddDelRemoteMapping(ctx context.Context, in *LispAdd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispAdjacenciesGet(ctx context.Context, in *LispAdjacenciesGet) (*LispAdjacenciesGetReply, error) { @@ -130,7 +131,7 @@ func (c *serviceClient) LispAdjacenciesGet(ctx context.Context, in *LispAdjacenc if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispEidTableAddDelMap(ctx context.Context, in *LispEidTableAddDelMap) (*LispEidTableAddDelMapReply, error) { @@ -139,7 +140,7 @@ func (c *serviceClient) LispEidTableAddDelMap(ctx context.Context, in *LispEidTa if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispEidTableDump(ctx context.Context, in *LispEidTableDump) (RPCService_LispEidTableDumpClient, error) { @@ -175,6 +176,10 @@ func (c *serviceClient_LispEidTableDumpClient) Recv() (*LispEidTableDetails, err case *LispEidTableDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -214,6 +219,10 @@ func (c *serviceClient_LispEidTableMapDumpClient) Recv() (*LispEidTableMapDetail case *LispEidTableMapDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -253,6 +262,10 @@ func (c *serviceClient_LispEidTableVniDumpClient) Recv() (*LispEidTableVniDetail case *LispEidTableVniDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -265,7 +278,7 @@ func (c *serviceClient) LispEnableDisable(ctx context.Context, in *LispEnableDis if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispGetMapRequestItrRlocs(ctx context.Context, in *LispGetMapRequestItrRlocs) (*LispGetMapRequestItrRlocsReply, error) { @@ -274,7 +287,7 @@ func (c *serviceClient) LispGetMapRequestItrRlocs(ctx context.Context, in *LispG if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispLocatorDump(ctx context.Context, in *LispLocatorDump) (RPCService_LispLocatorDumpClient, error) { @@ -310,6 +323,10 @@ func (c *serviceClient_LispLocatorDumpClient) Recv() (*LispLocatorDetails, error case *LispLocatorDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -349,6 +366,10 @@ func (c *serviceClient_LispLocatorSetDumpClient) Recv() (*LispLocatorSetDetails, case *LispLocatorSetDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -361,7 +382,7 @@ func (c *serviceClient) LispMapRegisterEnableDisable(ctx context.Context, in *Li if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispMapRequestMode(ctx context.Context, in *LispMapRequestMode) (*LispMapRequestModeReply, error) { @@ -370,7 +391,7 @@ func (c *serviceClient) LispMapRequestMode(ctx context.Context, in *LispMapReque if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispMapResolverDump(ctx context.Context, in *LispMapResolverDump) (RPCService_LispMapResolverDumpClient, error) { @@ -406,6 +427,10 @@ func (c *serviceClient_LispMapResolverDumpClient) Recv() (*LispMapResolverDetail case *LispMapResolverDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -445,6 +470,10 @@ func (c *serviceClient_LispMapServerDumpClient) Recv() (*LispMapServerDetails, e case *LispMapServerDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -457,7 +486,7 @@ func (c *serviceClient) LispPitrSetLocatorSet(ctx context.Context, in *LispPitrS if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispRlocProbeEnableDisable(ctx context.Context, in *LispRlocProbeEnableDisable) (*LispRlocProbeEnableDisableReply, error) { @@ -466,7 +495,7 @@ func (c *serviceClient) LispRlocProbeEnableDisable(ctx context.Context, in *Lisp if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LispUsePetr(ctx context.Context, in *LispUsePetr) (*LispUsePetrReply, error) { @@ -475,7 +504,7 @@ func (c *serviceClient) LispUsePetr(ctx context.Context, in *LispUsePetr) (*Lisp if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowLispMapRegisterState(ctx context.Context, in *ShowLispMapRegisterState) (*ShowLispMapRegisterStateReply, error) { @@ -484,7 +513,7 @@ func (c *serviceClient) ShowLispMapRegisterState(ctx context.Context, in *ShowLi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowLispMapRequestMode(ctx context.Context, in *ShowLispMapRequestMode) (*ShowLispMapRequestModeReply, error) { @@ -493,7 +522,7 @@ func (c *serviceClient) ShowLispMapRequestMode(ctx context.Context, in *ShowLisp if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowLispPitr(ctx context.Context, in *ShowLispPitr) (*ShowLispPitrReply, error) { @@ -502,7 +531,7 @@ func (c *serviceClient) ShowLispPitr(ctx context.Context, in *ShowLispPitr) (*Sh if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowLispRlocProbeState(ctx context.Context, in *ShowLispRlocProbeState) (*ShowLispRlocProbeStateReply, error) { @@ -511,7 +540,7 @@ func (c *serviceClient) ShowLispRlocProbeState(ctx context.Context, in *ShowLisp if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowLispStatus(ctx context.Context, in *ShowLispStatus) (*ShowLispStatusReply, error) { @@ -520,7 +549,7 @@ func (c *serviceClient) ShowLispStatus(ctx context.Context, in *ShowLispStatus) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowLispUsePetr(ctx context.Context, in *ShowLispUsePetr) (*ShowLispUsePetrReply, error) { @@ -529,5 +558,5 @@ func (c *serviceClient) ShowLispUsePetr(ctx context.Context, in *ShowLispUsePetr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/lisp_gpe/lisp_gpe.ba.go b/internal/testbinapi/binapi2001/lisp_gpe/lisp_gpe.ba.go index 3dd5ab6..f46aa92 100644 --- a/internal/testbinapi/binapi2001/lisp_gpe/lisp_gpe.ba.go +++ b/internal/testbinapi/binapi2001/lisp_gpe/lisp_gpe.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/lisp_gpe.api.json diff --git a/internal/testbinapi/binapi2001/lisp_gpe/lisp_gpe_rpc.ba.go b/internal/testbinapi/binapi2001/lisp_gpe/lisp_gpe_rpc.ba.go index e81bf7c..5fc0c95 100644 --- a/internal/testbinapi/binapi2001/lisp_gpe/lisp_gpe_rpc.ba.go +++ b/internal/testbinapi/binapi2001/lisp_gpe/lisp_gpe_rpc.ba.go @@ -5,12 +5,13 @@ package lisp_gpe import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service lisp_gpe. +// RPCService defines RPC service lisp_gpe. type RPCService interface { GpeAddDelFwdEntry(ctx context.Context, in *GpeAddDelFwdEntry) (*GpeAddDelFwdEntryReply, error) GpeAddDelIface(ctx context.Context, in *GpeAddDelIface) (*GpeAddDelIfaceReply, error) @@ -38,7 +39,7 @@ func (c *serviceClient) GpeAddDelFwdEntry(ctx context.Context, in *GpeAddDelFwdE if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GpeAddDelIface(ctx context.Context, in *GpeAddDelIface) (*GpeAddDelIfaceReply, error) { @@ -47,7 +48,7 @@ func (c *serviceClient) GpeAddDelIface(ctx context.Context, in *GpeAddDelIface) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GpeAddDelNativeFwdRpath(ctx context.Context, in *GpeAddDelNativeFwdRpath) (*GpeAddDelNativeFwdRpathReply, error) { @@ -56,7 +57,7 @@ func (c *serviceClient) GpeAddDelNativeFwdRpath(ctx context.Context, in *GpeAddD if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GpeEnableDisable(ctx context.Context, in *GpeEnableDisable) (*GpeEnableDisableReply, error) { @@ -65,7 +66,7 @@ func (c *serviceClient) GpeEnableDisable(ctx context.Context, in *GpeEnableDisab if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GpeFwdEntriesGet(ctx context.Context, in *GpeFwdEntriesGet) (*GpeFwdEntriesGetReply, error) { @@ -74,7 +75,7 @@ func (c *serviceClient) GpeFwdEntriesGet(ctx context.Context, in *GpeFwdEntriesG if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GpeFwdEntryPathDump(ctx context.Context, in *GpeFwdEntryPathDump) (RPCService_GpeFwdEntryPathDumpClient, error) { @@ -110,6 +111,10 @@ func (c *serviceClient_GpeFwdEntryPathDumpClient) Recv() (*GpeFwdEntryPathDetail case *GpeFwdEntryPathDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -122,7 +127,7 @@ func (c *serviceClient) GpeFwdEntryVnisGet(ctx context.Context, in *GpeFwdEntryV if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GpeGetEncapMode(ctx context.Context, in *GpeGetEncapMode) (*GpeGetEncapModeReply, error) { @@ -131,7 +136,7 @@ func (c *serviceClient) GpeGetEncapMode(ctx context.Context, in *GpeGetEncapMode if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GpeNativeFwdRpathsGet(ctx context.Context, in *GpeNativeFwdRpathsGet) (*GpeNativeFwdRpathsGetReply, error) { @@ -140,7 +145,7 @@ func (c *serviceClient) GpeNativeFwdRpathsGet(ctx context.Context, in *GpeNative if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GpeSetEncapMode(ctx context.Context, in *GpeSetEncapMode) (*GpeSetEncapModeReply, error) { @@ -149,5 +154,5 @@ func (c *serviceClient) GpeSetEncapMode(ctx context.Context, in *GpeSetEncapMode if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/lldp/lldp.ba.go b/internal/testbinapi/binapi2001/lldp/lldp.ba.go index 767087e..0bca38e 100644 --- a/internal/testbinapi/binapi2001/lldp/lldp.ba.go +++ b/internal/testbinapi/binapi2001/lldp/lldp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/lldp.api.json diff --git a/internal/testbinapi/binapi2001/lldp/lldp_rpc.ba.go b/internal/testbinapi/binapi2001/lldp/lldp_rpc.ba.go index 9d5eb85..d9fdbc5 100644 --- a/internal/testbinapi/binapi2001/lldp/lldp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/lldp/lldp_rpc.ba.go @@ -4,10 +4,11 @@ package lldp import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service lldp. +// RPCService defines RPC service lldp. type RPCService interface { LldpConfig(ctx context.Context, in *LldpConfig) (*LldpConfigReply, error) SwInterfaceSetLldp(ctx context.Context, in *SwInterfaceSetLldp) (*SwInterfaceSetLldpReply, error) @@ -27,7 +28,7 @@ func (c *serviceClient) LldpConfig(ctx context.Context, in *LldpConfig) (*LldpCo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceSetLldp(ctx context.Context, in *SwInterfaceSetLldp) (*SwInterfaceSetLldpReply, error) { @@ -36,5 +37,5 @@ func (c *serviceClient) SwInterfaceSetLldp(ctx context.Context, in *SwInterfaceS if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/mactime/mactime.ba.go b/internal/testbinapi/binapi2001/mactime/mactime.ba.go index 2824cf2..699d329 100644 --- a/internal/testbinapi/binapi2001/mactime/mactime.ba.go +++ b/internal/testbinapi/binapi2001/mactime/mactime.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/mactime.api.json @@ -15,10 +15,11 @@ package mactime import ( - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -299,15 +300,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { diff --git a/internal/testbinapi/binapi2001/mactime/mactime_rpc.ba.go b/internal/testbinapi/binapi2001/mactime/mactime_rpc.ba.go index 4e17e54..89630da 100644 --- a/internal/testbinapi/binapi2001/mactime/mactime_rpc.ba.go +++ b/internal/testbinapi/binapi2001/mactime/mactime_rpc.ba.go @@ -5,12 +5,13 @@ package mactime import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service mactime. +// RPCService defines RPC service mactime. type RPCService interface { MactimeAddDelRange(ctx context.Context, in *MactimeAddDelRange) (*MactimeAddDelRangeReply, error) MactimeDump(ctx context.Context, in *MactimeDump) (RPCService_MactimeDumpClient, error) @@ -31,7 +32,7 @@ func (c *serviceClient) MactimeAddDelRange(ctx context.Context, in *MactimeAddDe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MactimeDump(ctx context.Context, in *MactimeDump) (RPCService_MactimeDumpClient, error) { @@ -67,6 +68,10 @@ func (c *serviceClient_MactimeDumpClient) Recv() (*MactimeDetails, error) { case *MactimeDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -79,5 +84,5 @@ func (c *serviceClient) MactimeEnableDisable(ctx context.Context, in *MactimeEna if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/map/map.ba.go b/internal/testbinapi/binapi2001/map/map.ba.go index 3e132ad..b5dc558 100644 --- a/internal/testbinapi/binapi2001/map/map.ba.go +++ b/internal/testbinapi/binapi2001/map/map.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/map.api.json @@ -17,11 +17,12 @@ package maps import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -595,6 +605,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -607,8 +621,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -618,12 +633,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -666,18 +684,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -720,18 +742,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -782,6 +808,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -792,13 +819,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -816,8 +846,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/map/map_rpc.ba.go b/internal/testbinapi/binapi2001/map/map_rpc.ba.go index 2aa851c..bfc48e7 100644 --- a/internal/testbinapi/binapi2001/map/map_rpc.ba.go +++ b/internal/testbinapi/binapi2001/map/map_rpc.ba.go @@ -5,12 +5,13 @@ package maps import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service map. +// RPCService defines RPC service map. type RPCService interface { MapAddDelRule(ctx context.Context, in *MapAddDelRule) (*MapAddDelRuleReply, error) MapAddDomain(ctx context.Context, in *MapAddDomain) (*MapAddDomainReply, error) @@ -43,7 +44,7 @@ func (c *serviceClient) MapAddDelRule(ctx context.Context, in *MapAddDelRule) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapAddDomain(ctx context.Context, in *MapAddDomain) (*MapAddDomainReply, error) { @@ -52,7 +53,7 @@ func (c *serviceClient) MapAddDomain(ctx context.Context, in *MapAddDomain) (*Ma if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapDelDomain(ctx context.Context, in *MapDelDomain) (*MapDelDomainReply, error) { @@ -61,7 +62,7 @@ func (c *serviceClient) MapDelDomain(ctx context.Context, in *MapDelDomain) (*Ma if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapDomainDump(ctx context.Context, in *MapDomainDump) (RPCService_MapDomainDumpClient, error) { @@ -97,6 +98,10 @@ func (c *serviceClient_MapDomainDumpClient) Recv() (*MapDomainDetails, error) { case *MapDomainDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -109,7 +114,7 @@ func (c *serviceClient) MapIfEnableDisable(ctx context.Context, in *MapIfEnableD if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapParamAddDelPreResolve(ctx context.Context, in *MapParamAddDelPreResolve) (*MapParamAddDelPreResolveReply, error) { @@ -118,7 +123,7 @@ func (c *serviceClient) MapParamAddDelPreResolve(ctx context.Context, in *MapPar if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapParamGet(ctx context.Context, in *MapParamGet) (*MapParamGetReply, error) { @@ -127,7 +132,7 @@ func (c *serviceClient) MapParamGet(ctx context.Context, in *MapParamGet) (*MapP if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapParamSetFragmentation(ctx context.Context, in *MapParamSetFragmentation) (*MapParamSetFragmentationReply, error) { @@ -136,7 +141,7 @@ func (c *serviceClient) MapParamSetFragmentation(ctx context.Context, in *MapPar if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapParamSetICMP(ctx context.Context, in *MapParamSetICMP) (*MapParamSetICMPReply, error) { @@ -145,7 +150,7 @@ func (c *serviceClient) MapParamSetICMP(ctx context.Context, in *MapParamSetICMP if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapParamSetICMP6(ctx context.Context, in *MapParamSetICMP6) (*MapParamSetICMP6Reply, error) { @@ -154,7 +159,7 @@ func (c *serviceClient) MapParamSetICMP6(ctx context.Context, in *MapParamSetICM if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapParamSetSecurityCheck(ctx context.Context, in *MapParamSetSecurityCheck) (*MapParamSetSecurityCheckReply, error) { @@ -163,7 +168,7 @@ func (c *serviceClient) MapParamSetSecurityCheck(ctx context.Context, in *MapPar if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapParamSetTCP(ctx context.Context, in *MapParamSetTCP) (*MapParamSetTCPReply, error) { @@ -172,7 +177,7 @@ func (c *serviceClient) MapParamSetTCP(ctx context.Context, in *MapParamSetTCP) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapParamSetTrafficClass(ctx context.Context, in *MapParamSetTrafficClass) (*MapParamSetTrafficClassReply, error) { @@ -181,7 +186,7 @@ func (c *serviceClient) MapParamSetTrafficClass(ctx context.Context, in *MapPara if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapRuleDump(ctx context.Context, in *MapRuleDump) (RPCService_MapRuleDumpClient, error) { @@ -217,6 +222,10 @@ func (c *serviceClient_MapRuleDumpClient) Recv() (*MapRuleDetails, error) { case *MapRuleDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -229,5 +238,5 @@ func (c *serviceClient) MapSummaryStats(ctx context.Context, in *MapSummaryStats if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/mdata/mdata.ba.go b/internal/testbinapi/binapi2001/mdata/mdata.ba.go index 3a79b3e..d7e8ee2 100644 --- a/internal/testbinapi/binapi2001/mdata/mdata.ba.go +++ b/internal/testbinapi/binapi2001/mdata/mdata.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/mdata.api.json @@ -14,9 +14,10 @@ package mdata import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file @@ -286,6 +287,7 @@ func (x SubIfFlags) String() string { type InterfaceIndex uint32 // MdataEnableDisable defines message 'mdata_enable_disable'. +// InProgress: the message form may change in the future versions type MdataEnableDisable struct { EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` } @@ -319,6 +321,7 @@ func (m *MdataEnableDisable) Unmarshal(b []byte) error { } // MdataEnableDisableReply defines message 'mdata_enable_disable_reply'. +// InProgress: the message form may change in the future versions type MdataEnableDisableReply struct { Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } diff --git a/internal/testbinapi/binapi2001/mdata/mdata_rpc.ba.go b/internal/testbinapi/binapi2001/mdata/mdata_rpc.ba.go index 08e05d5..8ae8748 100644 --- a/internal/testbinapi/binapi2001/mdata/mdata_rpc.ba.go +++ b/internal/testbinapi/binapi2001/mdata/mdata_rpc.ba.go @@ -4,10 +4,11 @@ package mdata import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service mdata. +// RPCService defines RPC service mdata. type RPCService interface { MdataEnableDisable(ctx context.Context, in *MdataEnableDisable) (*MdataEnableDisableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) MdataEnableDisable(ctx context.Context, in *MdataEnableD if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/memclnt/memclnt.ba.go b/internal/testbinapi/binapi2001/memclnt/memclnt.ba.go index 4c6edf8..f2c8136 100644 --- a/internal/testbinapi/binapi2001/memclnt/memclnt.ba.go +++ b/internal/testbinapi/binapi2001/memclnt/memclnt.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/memclnt.api.json diff --git a/internal/testbinapi/binapi2001/memclnt/memclnt_rpc.ba.go b/internal/testbinapi/binapi2001/memclnt/memclnt_rpc.ba.go index ec60156..03d32ef 100644 --- a/internal/testbinapi/binapi2001/memclnt/memclnt_rpc.ba.go +++ b/internal/testbinapi/binapi2001/memclnt/memclnt_rpc.ba.go @@ -4,10 +4,11 @@ package memclnt import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service memclnt. +// RPCService defines RPC service memclnt. type RPCService interface { APIVersions(ctx context.Context, in *APIVersions) (*APIVersionsReply, error) GetFirstMsgID(ctx context.Context, in *GetFirstMsgID) (*GetFirstMsgIDReply, error) @@ -38,7 +39,7 @@ func (c *serviceClient) APIVersions(ctx context.Context, in *APIVersions) (*APIV if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GetFirstMsgID(ctx context.Context, in *GetFirstMsgID) (*GetFirstMsgIDReply, error) { @@ -47,7 +48,7 @@ func (c *serviceClient) GetFirstMsgID(ctx context.Context, in *GetFirstMsgID) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MemclntCreate(ctx context.Context, in *MemclntCreate) (*MemclntCreateReply, error) { @@ -74,7 +75,7 @@ func (c *serviceClient) MemclntKeepalive(ctx context.Context, in *MemclntKeepali if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MemclntReadTimeout(ctx context.Context, in *MemclntReadTimeout) error { @@ -86,6 +87,10 @@ func (c *serviceClient) MemclntReadTimeout(ctx context.Context, in *MemclntReadT if err != nil { return err } + err = stream.Close() + if err != nil { + return err + } return nil } @@ -98,6 +103,10 @@ func (c *serviceClient) MemclntRxThreadSuspend(ctx context.Context, in *MemclntR if err != nil { return err } + err = stream.Close() + if err != nil { + return err + } return nil } @@ -107,7 +116,7 @@ func (c *serviceClient) RPCCall(ctx context.Context, in *RPCCall) (*RPCCallReply if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) RxThreadExit(ctx context.Context, in *RxThreadExit) error { @@ -119,6 +128,10 @@ func (c *serviceClient) RxThreadExit(ctx context.Context, in *RxThreadExit) erro if err != nil { return err } + err = stream.Close() + if err != nil { + return err + } return nil } @@ -128,7 +141,7 @@ func (c *serviceClient) SockInitShm(ctx context.Context, in *SockInitShm) (*Sock if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SockclntCreate(ctx context.Context, in *SockclntCreate) (*SockclntCreateReply, error) { @@ -158,5 +171,9 @@ func (c *serviceClient) TracePluginMsgIds(ctx context.Context, in *TracePluginMs if err != nil { return err } + err = stream.Close() + if err != nil { + return err + } return nil } diff --git a/internal/testbinapi/binapi2001/memif/memif.ba.go b/internal/testbinapi/binapi2001/memif/memif.ba.go index d3a0963..e1e9178 100644 --- a/internal/testbinapi/binapi2001/memif/memif.ba.go +++ b/internal/testbinapi/binapi2001/memif/memif.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/memif.api.json @@ -14,10 +14,11 @@ package memif import ( - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -355,15 +356,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { diff --git a/internal/testbinapi/binapi2001/memif/memif_rpc.ba.go b/internal/testbinapi/binapi2001/memif/memif_rpc.ba.go index 8e6c7bc..e086d64 100644 --- a/internal/testbinapi/binapi2001/memif/memif_rpc.ba.go +++ b/internal/testbinapi/binapi2001/memif/memif_rpc.ba.go @@ -5,12 +5,13 @@ package memif import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service memif. +// RPCService defines RPC service memif. type RPCService interface { MemifCreate(ctx context.Context, in *MemifCreate) (*MemifCreateReply, error) MemifDelete(ctx context.Context, in *MemifDelete) (*MemifDeleteReply, error) @@ -33,7 +34,7 @@ func (c *serviceClient) MemifCreate(ctx context.Context, in *MemifCreate) (*Memi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MemifDelete(ctx context.Context, in *MemifDelete) (*MemifDeleteReply, error) { @@ -42,7 +43,7 @@ func (c *serviceClient) MemifDelete(ctx context.Context, in *MemifDelete) (*Memi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MemifDump(ctx context.Context, in *MemifDump) (RPCService_MemifDumpClient, error) { @@ -78,6 +79,10 @@ func (c *serviceClient_MemifDumpClient) Recv() (*MemifDetails, error) { case *MemifDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -90,7 +95,7 @@ func (c *serviceClient) MemifSocketFilenameAddDel(ctx context.Context, in *Memif if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MemifSocketFilenameDump(ctx context.Context, in *MemifSocketFilenameDump) (RPCService_MemifSocketFilenameDumpClient, error) { @@ -126,6 +131,10 @@ func (c *serviceClient_MemifSocketFilenameDumpClient) Recv() (*MemifSocketFilena case *MemifSocketFilenameDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/mfib_types/mfib_types.ba.go b/internal/testbinapi/binapi2001/mfib_types/mfib_types.ba.go index 2283f8b..cc79850 100644 --- a/internal/testbinapi/binapi2001/mfib_types/mfib_types.ba.go +++ b/internal/testbinapi/binapi2001/mfib_types/mfib_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/mfib_types.api.json @@ -16,11 +16,12 @@ package mfib_types import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -29,6 +30,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "mfib_types" + APIVersion = "" + VersionCrc = 0xba024d84 +) + // AddressFamily defines enum 'address_family'. type AddressFamily uint32 @@ -440,12 +447,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -471,12 +481,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -505,12 +518,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -534,6 +550,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -546,8 +566,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -557,12 +578,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -636,18 +660,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -690,18 +718,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -758,6 +790,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -768,13 +801,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -792,8 +828,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/mpls/mpls.ba.go b/internal/testbinapi/binapi2001/mpls/mpls.ba.go index 11ab34b..15c1f46 100644 --- a/internal/testbinapi/binapi2001/mpls/mpls.ba.go +++ b/internal/testbinapi/binapi2001/mpls/mpls.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/mpls.api.json @@ -17,11 +17,12 @@ package mpls import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -640,12 +641,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -674,12 +678,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -708,12 +715,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -737,6 +747,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -749,8 +763,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -760,12 +775,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -839,18 +857,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -893,18 +915,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -982,6 +1008,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -992,13 +1019,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -1016,8 +1046,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/mpls/mpls_rpc.ba.go b/internal/testbinapi/binapi2001/mpls/mpls_rpc.ba.go index 422e185..79cf550 100644 --- a/internal/testbinapi/binapi2001/mpls/mpls_rpc.ba.go +++ b/internal/testbinapi/binapi2001/mpls/mpls_rpc.ba.go @@ -5,12 +5,13 @@ package mpls import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service mpls. +// RPCService defines RPC service mpls. type RPCService interface { MplsIPBindUnbind(ctx context.Context, in *MplsIPBindUnbind) (*MplsIPBindUnbindReply, error) MplsRouteAddDel(ctx context.Context, in *MplsRouteAddDel) (*MplsRouteAddDelReply, error) @@ -36,7 +37,7 @@ func (c *serviceClient) MplsIPBindUnbind(ctx context.Context, in *MplsIPBindUnbi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MplsRouteAddDel(ctx context.Context, in *MplsRouteAddDel) (*MplsRouteAddDelReply, error) { @@ -45,7 +46,7 @@ func (c *serviceClient) MplsRouteAddDel(ctx context.Context, in *MplsRouteAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MplsRouteDump(ctx context.Context, in *MplsRouteDump) (RPCService_MplsRouteDumpClient, error) { @@ -81,6 +82,10 @@ func (c *serviceClient_MplsRouteDumpClient) Recv() (*MplsRouteDetails, error) { case *MplsRouteDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -93,7 +98,7 @@ func (c *serviceClient) MplsTableAddDel(ctx context.Context, in *MplsTableAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MplsTableDump(ctx context.Context, in *MplsTableDump) (RPCService_MplsTableDumpClient, error) { @@ -129,6 +134,10 @@ func (c *serviceClient_MplsTableDumpClient) Recv() (*MplsTableDetails, error) { case *MplsTableDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -141,7 +150,7 @@ func (c *serviceClient) MplsTunnelAddDel(ctx context.Context, in *MplsTunnelAddD if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MplsTunnelDump(ctx context.Context, in *MplsTunnelDump) (RPCService_MplsTunnelDumpClient, error) { @@ -177,6 +186,10 @@ func (c *serviceClient_MplsTunnelDumpClient) Recv() (*MplsTunnelDetails, error) case *MplsTunnelDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -189,5 +202,5 @@ func (c *serviceClient) SwInterfaceSetMplsEnable(ctx context.Context, in *SwInte if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/nat/nat.ba.go b/internal/testbinapi/binapi2001/nat/nat.ba.go index e6ef501..fd3bc20 100644 --- a/internal/testbinapi/binapi2001/nat/nat.ba.go +++ b/internal/testbinapi/binapi2001/nat/nat.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/nat.api.json @@ -17,11 +17,12 @@ package nat import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -604,12 +605,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -638,12 +642,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -672,12 +679,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -701,6 +711,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -713,8 +727,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -724,12 +739,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -772,18 +790,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -826,18 +848,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -896,6 +922,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -906,13 +933,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -930,8 +960,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/nat/nat_rpc.ba.go b/internal/testbinapi/binapi2001/nat/nat_rpc.ba.go index f6069ec..32d74c2 100644 --- a/internal/testbinapi/binapi2001/nat/nat_rpc.ba.go +++ b/internal/testbinapi/binapi2001/nat/nat_rpc.ba.go @@ -5,12 +5,13 @@ package nat import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service nat. +// RPCService defines RPC service nat. type RPCService interface { DsliteAddDelPoolAddrRange(ctx context.Context, in *DsliteAddDelPoolAddrRange) (*DsliteAddDelPoolAddrRangeReply, error) DsliteAddressDump(ctx context.Context, in *DsliteAddressDump) (RPCService_DsliteAddressDumpClient, error) @@ -93,7 +94,7 @@ func (c *serviceClient) DsliteAddDelPoolAddrRange(ctx context.Context, in *Dslit if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DsliteAddressDump(ctx context.Context, in *DsliteAddressDump) (RPCService_DsliteAddressDumpClient, error) { @@ -129,6 +130,10 @@ func (c *serviceClient_DsliteAddressDumpClient) Recv() (*DsliteAddressDetails, e case *DsliteAddressDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -141,7 +146,7 @@ func (c *serviceClient) DsliteGetAftrAddr(ctx context.Context, in *DsliteGetAftr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DsliteGetB4Addr(ctx context.Context, in *DsliteGetB4Addr) (*DsliteGetB4AddrReply, error) { @@ -150,7 +155,7 @@ func (c *serviceClient) DsliteGetB4Addr(ctx context.Context, in *DsliteGetB4Addr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DsliteSetAftrAddr(ctx context.Context, in *DsliteSetAftrAddr) (*DsliteSetAftrAddrReply, error) { @@ -159,7 +164,7 @@ func (c *serviceClient) DsliteSetAftrAddr(ctx context.Context, in *DsliteSetAftr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DsliteSetB4Addr(ctx context.Context, in *DsliteSetB4Addr) (*DsliteSetB4AddrReply, error) { @@ -168,7 +173,7 @@ func (c *serviceClient) DsliteSetB4Addr(ctx context.Context, in *DsliteSetB4Addr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat44AddDelAddressRange(ctx context.Context, in *Nat44AddDelAddressRange) (*Nat44AddDelAddressRangeReply, error) { @@ -177,7 +182,7 @@ func (c *serviceClient) Nat44AddDelAddressRange(ctx context.Context, in *Nat44Ad if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat44AddDelIdentityMapping(ctx context.Context, in *Nat44AddDelIdentityMapping) (*Nat44AddDelIdentityMappingReply, error) { @@ -186,7 +191,7 @@ func (c *serviceClient) Nat44AddDelIdentityMapping(ctx context.Context, in *Nat4 if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat44AddDelInterfaceAddr(ctx context.Context, in *Nat44AddDelInterfaceAddr) (*Nat44AddDelInterfaceAddrReply, error) { @@ -195,7 +200,7 @@ func (c *serviceClient) Nat44AddDelInterfaceAddr(ctx context.Context, in *Nat44A if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat44AddDelLbStaticMapping(ctx context.Context, in *Nat44AddDelLbStaticMapping) (*Nat44AddDelLbStaticMappingReply, error) { @@ -204,7 +209,7 @@ func (c *serviceClient) Nat44AddDelLbStaticMapping(ctx context.Context, in *Nat4 if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat44AddDelStaticMapping(ctx context.Context, in *Nat44AddDelStaticMapping) (*Nat44AddDelStaticMappingReply, error) { @@ -213,7 +218,7 @@ func (c *serviceClient) Nat44AddDelStaticMapping(ctx context.Context, in *Nat44A if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat44AddressDump(ctx context.Context, in *Nat44AddressDump) (RPCService_Nat44AddressDumpClient, error) { @@ -249,6 +254,10 @@ func (c *serviceClient_Nat44AddressDumpClient) Recv() (*Nat44AddressDetails, err case *Nat44AddressDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -261,7 +270,7 @@ func (c *serviceClient) Nat44DelSession(ctx context.Context, in *Nat44DelSession if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat44ForwardingEnableDisable(ctx context.Context, in *Nat44ForwardingEnableDisable) (*Nat44ForwardingEnableDisableReply, error) { @@ -270,7 +279,7 @@ func (c *serviceClient) Nat44ForwardingEnableDisable(ctx context.Context, in *Na if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat44ForwardingIsEnabled(ctx context.Context, in *Nat44ForwardingIsEnabled) (*Nat44ForwardingIsEnabledReply, error) { @@ -315,6 +324,10 @@ func (c *serviceClient_Nat44IdentityMappingDumpClient) Recv() (*Nat44IdentityMap case *Nat44IdentityMappingDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -327,7 +340,7 @@ func (c *serviceClient) Nat44InterfaceAddDelFeature(ctx context.Context, in *Nat if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat44InterfaceAddDelOutputFeature(ctx context.Context, in *Nat44InterfaceAddDelOutputFeature) (*Nat44InterfaceAddDelOutputFeatureReply, error) { @@ -336,7 +349,7 @@ func (c *serviceClient) Nat44InterfaceAddDelOutputFeature(ctx context.Context, i if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat44InterfaceAddrDump(ctx context.Context, in *Nat44InterfaceAddrDump) (RPCService_Nat44InterfaceAddrDumpClient, error) { @@ -372,6 +385,10 @@ func (c *serviceClient_Nat44InterfaceAddrDumpClient) Recv() (*Nat44InterfaceAddr case *Nat44InterfaceAddrDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -411,6 +428,10 @@ func (c *serviceClient_Nat44InterfaceDumpClient) Recv() (*Nat44InterfaceDetails, case *Nat44InterfaceDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -450,6 +471,10 @@ func (c *serviceClient_Nat44InterfaceOutputFeatureDumpClient) Recv() (*Nat44Inte case *Nat44InterfaceOutputFeatureDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -462,7 +487,7 @@ func (c *serviceClient) Nat44LbStaticMappingAddDelLocal(ctx context.Context, in if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat44LbStaticMappingDump(ctx context.Context, in *Nat44LbStaticMappingDump) (RPCService_Nat44LbStaticMappingDumpClient, error) { @@ -498,6 +523,10 @@ func (c *serviceClient_Nat44LbStaticMappingDumpClient) Recv() (*Nat44LbStaticMap case *Nat44LbStaticMappingDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -537,6 +566,10 @@ func (c *serviceClient_Nat44StaticMappingDumpClient) Recv() (*Nat44StaticMapping case *Nat44StaticMappingDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -576,6 +609,10 @@ func (c *serviceClient_Nat44UserDumpClient) Recv() (*Nat44UserDetails, error) { case *Nat44UserDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -615,6 +652,10 @@ func (c *serviceClient_Nat44UserSessionDumpClient) Recv() (*Nat44UserSessionDeta case *Nat44UserSessionDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -627,7 +668,7 @@ func (c *serviceClient) Nat64AddDelInterface(ctx context.Context, in *Nat64AddDe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat64AddDelInterfaceAddr(ctx context.Context, in *Nat64AddDelInterfaceAddr) (*Nat64AddDelInterfaceAddrReply, error) { @@ -636,7 +677,7 @@ func (c *serviceClient) Nat64AddDelInterfaceAddr(ctx context.Context, in *Nat64A if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat64AddDelPoolAddrRange(ctx context.Context, in *Nat64AddDelPoolAddrRange) (*Nat64AddDelPoolAddrRangeReply, error) { @@ -645,7 +686,7 @@ func (c *serviceClient) Nat64AddDelPoolAddrRange(ctx context.Context, in *Nat64A if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat64AddDelPrefix(ctx context.Context, in *Nat64AddDelPrefix) (*Nat64AddDelPrefixReply, error) { @@ -654,7 +695,7 @@ func (c *serviceClient) Nat64AddDelPrefix(ctx context.Context, in *Nat64AddDelPr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat64AddDelStaticBib(ctx context.Context, in *Nat64AddDelStaticBib) (*Nat64AddDelStaticBibReply, error) { @@ -663,7 +704,7 @@ func (c *serviceClient) Nat64AddDelStaticBib(ctx context.Context, in *Nat64AddDe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat64BibDump(ctx context.Context, in *Nat64BibDump) (RPCService_Nat64BibDumpClient, error) { @@ -699,6 +740,10 @@ func (c *serviceClient_Nat64BibDumpClient) Recv() (*Nat64BibDetails, error) { case *Nat64BibDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -738,6 +783,10 @@ func (c *serviceClient_Nat64InterfaceDumpClient) Recv() (*Nat64InterfaceDetails, case *Nat64InterfaceDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -777,6 +826,10 @@ func (c *serviceClient_Nat64PoolAddrDumpClient) Recv() (*Nat64PoolAddrDetails, e case *Nat64PoolAddrDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -816,6 +869,10 @@ func (c *serviceClient_Nat64PrefixDumpClient) Recv() (*Nat64PrefixDetails, error case *Nat64PrefixDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -855,6 +912,10 @@ func (c *serviceClient_Nat64StDumpClient) Recv() (*Nat64StDetails, error) { case *Nat64StDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -867,7 +928,7 @@ func (c *serviceClient) Nat66AddDelInterface(ctx context.Context, in *Nat66AddDe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat66AddDelStaticMapping(ctx context.Context, in *Nat66AddDelStaticMapping) (*Nat66AddDelStaticMappingReply, error) { @@ -876,7 +937,7 @@ func (c *serviceClient) Nat66AddDelStaticMapping(ctx context.Context, in *Nat66A if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Nat66InterfaceDump(ctx context.Context, in *Nat66InterfaceDump) (RPCService_Nat66InterfaceDumpClient, error) { @@ -912,6 +973,10 @@ func (c *serviceClient_Nat66InterfaceDumpClient) Recv() (*Nat66InterfaceDetails, case *Nat66InterfaceDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -951,6 +1016,10 @@ func (c *serviceClient_Nat66StaticMappingDumpClient) Recv() (*Nat66StaticMapping case *Nat66StaticMappingDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -963,7 +1032,7 @@ func (c *serviceClient) NatControlPing(ctx context.Context, in *NatControlPing) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatDetAddDelMap(ctx context.Context, in *NatDetAddDelMap) (*NatDetAddDelMapReply, error) { @@ -972,7 +1041,7 @@ func (c *serviceClient) NatDetAddDelMap(ctx context.Context, in *NatDetAddDelMap if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatDetCloseSessionIn(ctx context.Context, in *NatDetCloseSessionIn) (*NatDetCloseSessionInReply, error) { @@ -981,7 +1050,7 @@ func (c *serviceClient) NatDetCloseSessionIn(ctx context.Context, in *NatDetClos if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatDetCloseSessionOut(ctx context.Context, in *NatDetCloseSessionOut) (*NatDetCloseSessionOutReply, error) { @@ -990,7 +1059,7 @@ func (c *serviceClient) NatDetCloseSessionOut(ctx context.Context, in *NatDetClo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatDetForward(ctx context.Context, in *NatDetForward) (*NatDetForwardReply, error) { @@ -999,7 +1068,7 @@ func (c *serviceClient) NatDetForward(ctx context.Context, in *NatDetForward) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatDetMapDump(ctx context.Context, in *NatDetMapDump) (RPCService_NatDetMapDumpClient, error) { @@ -1035,6 +1104,10 @@ func (c *serviceClient_NatDetMapDumpClient) Recv() (*NatDetMapDetails, error) { case *NatDetMapDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -1047,7 +1120,7 @@ func (c *serviceClient) NatDetReverse(ctx context.Context, in *NatDetReverse) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatDetSessionDump(ctx context.Context, in *NatDetSessionDump) (RPCService_NatDetSessionDumpClient, error) { @@ -1083,6 +1156,10 @@ func (c *serviceClient_NatDetSessionDumpClient) Recv() (*NatDetSessionDetails, e case *NatDetSessionDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -1095,7 +1172,7 @@ func (c *serviceClient) NatGetAddrAndPortAllocAlg(ctx context.Context, in *NatGe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatGetMssClamping(ctx context.Context, in *NatGetMssClamping) (*NatGetMssClampingReply, error) { @@ -1104,7 +1181,7 @@ func (c *serviceClient) NatGetMssClamping(ctx context.Context, in *NatGetMssClam if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatGetTimeouts(ctx context.Context, in *NatGetTimeouts) (*NatGetTimeoutsReply, error) { @@ -1113,7 +1190,7 @@ func (c *serviceClient) NatGetTimeouts(ctx context.Context, in *NatGetTimeouts) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatHaFlush(ctx context.Context, in *NatHaFlush) (*NatHaFlushReply, error) { @@ -1122,7 +1199,7 @@ func (c *serviceClient) NatHaFlush(ctx context.Context, in *NatHaFlush) (*NatHaF if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatHaGetFailover(ctx context.Context, in *NatHaGetFailover) (*NatHaGetFailoverReply, error) { @@ -1131,7 +1208,7 @@ func (c *serviceClient) NatHaGetFailover(ctx context.Context, in *NatHaGetFailov if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatHaGetListener(ctx context.Context, in *NatHaGetListener) (*NatHaGetListenerReply, error) { @@ -1140,7 +1217,7 @@ func (c *serviceClient) NatHaGetListener(ctx context.Context, in *NatHaGetListen if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatHaResync(ctx context.Context, in *NatHaResync) (*NatHaResyncReply, error) { @@ -1149,7 +1226,7 @@ func (c *serviceClient) NatHaResync(ctx context.Context, in *NatHaResync) (*NatH if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatHaSetFailover(ctx context.Context, in *NatHaSetFailover) (*NatHaSetFailoverReply, error) { @@ -1158,7 +1235,7 @@ func (c *serviceClient) NatHaSetFailover(ctx context.Context, in *NatHaSetFailov if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatHaSetListener(ctx context.Context, in *NatHaSetListener) (*NatHaSetListenerReply, error) { @@ -1167,7 +1244,7 @@ func (c *serviceClient) NatHaSetListener(ctx context.Context, in *NatHaSetListen if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatIpfixEnableDisable(ctx context.Context, in *NatIpfixEnableDisable) (*NatIpfixEnableDisableReply, error) { @@ -1176,7 +1253,7 @@ func (c *serviceClient) NatIpfixEnableDisable(ctx context.Context, in *NatIpfixE if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatSetAddrAndPortAllocAlg(ctx context.Context, in *NatSetAddrAndPortAllocAlg) (*NatSetAddrAndPortAllocAlgReply, error) { @@ -1185,7 +1262,7 @@ func (c *serviceClient) NatSetAddrAndPortAllocAlg(ctx context.Context, in *NatSe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatSetLogLevel(ctx context.Context, in *NatSetLogLevel) (*NatSetLogLevelReply, error) { @@ -1194,7 +1271,7 @@ func (c *serviceClient) NatSetLogLevel(ctx context.Context, in *NatSetLogLevel) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatSetMssClamping(ctx context.Context, in *NatSetMssClamping) (*NatSetMssClampingReply, error) { @@ -1203,7 +1280,7 @@ func (c *serviceClient) NatSetMssClamping(ctx context.Context, in *NatSetMssClam if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatSetTimeouts(ctx context.Context, in *NatSetTimeouts) (*NatSetTimeoutsReply, error) { @@ -1212,7 +1289,7 @@ func (c *serviceClient) NatSetTimeouts(ctx context.Context, in *NatSetTimeouts) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatSetWorkers(ctx context.Context, in *NatSetWorkers) (*NatSetWorkersReply, error) { @@ -1221,7 +1298,7 @@ func (c *serviceClient) NatSetWorkers(ctx context.Context, in *NatSetWorkers) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatShowConfig(ctx context.Context, in *NatShowConfig) (*NatShowConfigReply, error) { @@ -1230,7 +1307,7 @@ func (c *serviceClient) NatShowConfig(ctx context.Context, in *NatShowConfig) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NatWorkerDump(ctx context.Context, in *NatWorkerDump) (RPCService_NatWorkerDumpClient, error) { @@ -1266,6 +1343,10 @@ func (c *serviceClient_NatWorkerDumpClient) Recv() (*NatWorkerDetails, error) { case *NatWorkerDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/netmap/netmap.ba.go b/internal/testbinapi/binapi2001/netmap/netmap.ba.go index 0934ce6..99a81dc 100644 --- a/internal/testbinapi/binapi2001/netmap/netmap.ba.go +++ b/internal/testbinapi/binapi2001/netmap/netmap.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/netmap.api.json diff --git a/internal/testbinapi/binapi2001/netmap/netmap_rpc.ba.go b/internal/testbinapi/binapi2001/netmap/netmap_rpc.ba.go index 366bed0..9746ff7 100644 --- a/internal/testbinapi/binapi2001/netmap/netmap_rpc.ba.go +++ b/internal/testbinapi/binapi2001/netmap/netmap_rpc.ba.go @@ -4,10 +4,11 @@ package netmap import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service netmap. +// RPCService defines RPC service netmap. type RPCService interface { NetmapCreate(ctx context.Context, in *NetmapCreate) (*NetmapCreateReply, error) NetmapDelete(ctx context.Context, in *NetmapDelete) (*NetmapDeleteReply, error) @@ -27,7 +28,7 @@ func (c *serviceClient) NetmapCreate(ctx context.Context, in *NetmapCreate) (*Ne if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NetmapDelete(ctx context.Context, in *NetmapDelete) (*NetmapDeleteReply, error) { @@ -36,5 +37,5 @@ func (c *serviceClient) NetmapDelete(ctx context.Context, in *NetmapDelete) (*Ne if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/nhrp/nhrp.ba.go b/internal/testbinapi/binapi2001/nhrp/nhrp.ba.go index 0dd5c4c..7d326b7 100644 --- a/internal/testbinapi/binapi2001/nhrp/nhrp.ba.go +++ b/internal/testbinapi/binapi2001/nhrp/nhrp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/nhrp.api.json @@ -17,11 +17,12 @@ package nhrp import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -595,6 +605,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -607,8 +621,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -618,12 +633,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -666,18 +684,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -720,18 +742,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -790,6 +816,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -800,13 +827,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -824,8 +854,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/nhrp/nhrp_rpc.ba.go b/internal/testbinapi/binapi2001/nhrp/nhrp_rpc.ba.go index 841bda4..8b7261c 100644 --- a/internal/testbinapi/binapi2001/nhrp/nhrp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/nhrp/nhrp_rpc.ba.go @@ -5,12 +5,13 @@ package nhrp import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service nhrp. +// RPCService defines RPC service nhrp. type RPCService interface { NhrpDump(ctx context.Context, in *NhrpDump) (RPCService_NhrpDumpClient, error) NhrpEntryAddDel(ctx context.Context, in *NhrpEntryAddDel) (*NhrpEntryAddDelReply, error) @@ -57,6 +58,10 @@ func (c *serviceClient_NhrpDumpClient) Recv() (*NhrpDetails, error) { case *NhrpDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -69,5 +74,5 @@ func (c *serviceClient) NhrpEntryAddDel(ctx context.Context, in *NhrpEntryAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/nsh/nsh.ba.go b/internal/testbinapi/binapi2001/nsh/nsh.ba.go index 75cb38a..c6d20be 100644 --- a/internal/testbinapi/binapi2001/nsh/nsh.ba.go +++ b/internal/testbinapi/binapi2001/nsh/nsh.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/nsh.api.json @@ -14,9 +14,10 @@ package nsh import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/nsh/nsh_rpc.ba.go b/internal/testbinapi/binapi2001/nsh/nsh_rpc.ba.go index 0c34e58..6399b32 100644 --- a/internal/testbinapi/binapi2001/nsh/nsh_rpc.ba.go +++ b/internal/testbinapi/binapi2001/nsh/nsh_rpc.ba.go @@ -5,12 +5,13 @@ package nsh import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service nsh. +// RPCService defines RPC service nsh. type RPCService interface { NshAddDelEntry(ctx context.Context, in *NshAddDelEntry) (*NshAddDelEntryReply, error) NshAddDelMap(ctx context.Context, in *NshAddDelMap) (*NshAddDelMapReply, error) @@ -32,7 +33,7 @@ func (c *serviceClient) NshAddDelEntry(ctx context.Context, in *NshAddDelEntry) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NshAddDelMap(ctx context.Context, in *NshAddDelMap) (*NshAddDelMapReply, error) { @@ -41,7 +42,7 @@ func (c *serviceClient) NshAddDelMap(ctx context.Context, in *NshAddDelMap) (*Ns if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NshEntryDump(ctx context.Context, in *NshEntryDump) (RPCService_NshEntryDumpClient, error) { @@ -77,6 +78,10 @@ func (c *serviceClient_NshEntryDumpClient) Recv() (*NshEntryDetails, error) { case *NshEntryDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -116,6 +121,10 @@ func (c *serviceClient_NshMapDumpClient) Recv() (*NshMapDetails, error) { case *NshMapDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/nsim/nsim.ba.go b/internal/testbinapi/binapi2001/nsim/nsim.ba.go index 4955164..009d4bd 100644 --- a/internal/testbinapi/binapi2001/nsim/nsim.ba.go +++ b/internal/testbinapi/binapi2001/nsim/nsim.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/nsim.api.json @@ -14,9 +14,10 @@ package nsim import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/nsim/nsim_rpc.ba.go b/internal/testbinapi/binapi2001/nsim/nsim_rpc.ba.go index f35e6b3..d46b1ef 100644 --- a/internal/testbinapi/binapi2001/nsim/nsim_rpc.ba.go +++ b/internal/testbinapi/binapi2001/nsim/nsim_rpc.ba.go @@ -4,10 +4,11 @@ package nsim import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service nsim. +// RPCService defines RPC service nsim. type RPCService interface { NsimConfigure(ctx context.Context, in *NsimConfigure) (*NsimConfigureReply, error) NsimCrossConnectEnableDisable(ctx context.Context, in *NsimCrossConnectEnableDisable) (*NsimCrossConnectEnableDisableReply, error) @@ -28,7 +29,7 @@ func (c *serviceClient) NsimConfigure(ctx context.Context, in *NsimConfigure) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NsimCrossConnectEnableDisable(ctx context.Context, in *NsimCrossConnectEnableDisable) (*NsimCrossConnectEnableDisableReply, error) { @@ -37,7 +38,7 @@ func (c *serviceClient) NsimCrossConnectEnableDisable(ctx context.Context, in *N if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) NsimOutputFeatureEnableDisable(ctx context.Context, in *NsimOutputFeatureEnableDisable) (*NsimOutputFeatureEnableDisableReply, error) { @@ -46,5 +47,5 @@ func (c *serviceClient) NsimOutputFeatureEnableDisable(ctx context.Context, in * if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/oddbuf/oddbuf.ba.go b/internal/testbinapi/binapi2001/oddbuf/oddbuf.ba.go index c2b3e5e..281960f 100644 --- a/internal/testbinapi/binapi2001/oddbuf/oddbuf.ba.go +++ b/internal/testbinapi/binapi2001/oddbuf/oddbuf.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/oddbuf.api.json @@ -14,9 +14,10 @@ package oddbuf import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file @@ -286,6 +287,7 @@ func (x SubIfFlags) String() string { type InterfaceIndex uint32 // OddbufEnableDisable defines message 'oddbuf_enable_disable'. +// InProgress: the message form may change in the future versions type OddbufEnableDisable struct { EnableDisable bool `binapi:"bool,name=enable_disable" json:"enable_disable,omitempty"` SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` @@ -323,6 +325,7 @@ func (m *OddbufEnableDisable) Unmarshal(b []byte) error { } // OddbufEnableDisableReply defines message 'oddbuf_enable_disable_reply'. +// InProgress: the message form may change in the future versions type OddbufEnableDisableReply struct { Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` } diff --git a/internal/testbinapi/binapi2001/oddbuf/oddbuf_rpc.ba.go b/internal/testbinapi/binapi2001/oddbuf/oddbuf_rpc.ba.go index a8c245e..f7c0164 100644 --- a/internal/testbinapi/binapi2001/oddbuf/oddbuf_rpc.ba.go +++ b/internal/testbinapi/binapi2001/oddbuf/oddbuf_rpc.ba.go @@ -4,10 +4,11 @@ package oddbuf import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service oddbuf. +// RPCService defines RPC service oddbuf. type RPCService interface { OddbufEnableDisable(ctx context.Context, in *OddbufEnableDisable) (*OddbufEnableDisableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) OddbufEnableDisable(ctx context.Context, in *OddbufEnabl if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/one/one.ba.go b/internal/testbinapi/binapi2001/one/one.ba.go index a121d94..83a4d17 100644 --- a/internal/testbinapi/binapi2001/one/one.ba.go +++ b/internal/testbinapi/binapi2001/one/one.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/one.api.json diff --git a/internal/testbinapi/binapi2001/one/one_rpc.ba.go b/internal/testbinapi/binapi2001/one/one_rpc.ba.go index 1b18bdf..9d01e5f 100644 --- a/internal/testbinapi/binapi2001/one/one_rpc.ba.go +++ b/internal/testbinapi/binapi2001/one/one_rpc.ba.go @@ -5,12 +5,13 @@ package one import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service one. +// RPCService defines RPC service one. type RPCService interface { OneAddDelAdjacency(ctx context.Context, in *OneAddDelAdjacency) (*OneAddDelAdjacencyReply, error) OneAddDelL2ArpEntry(ctx context.Context, in *OneAddDelL2ArpEntry) (*OneAddDelL2ArpEntryReply, error) @@ -82,7 +83,7 @@ func (c *serviceClient) OneAddDelAdjacency(ctx context.Context, in *OneAddDelAdj if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneAddDelL2ArpEntry(ctx context.Context, in *OneAddDelL2ArpEntry) (*OneAddDelL2ArpEntryReply, error) { @@ -91,7 +92,7 @@ func (c *serviceClient) OneAddDelL2ArpEntry(ctx context.Context, in *OneAddDelL2 if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneAddDelLocalEid(ctx context.Context, in *OneAddDelLocalEid) (*OneAddDelLocalEidReply, error) { @@ -100,7 +101,7 @@ func (c *serviceClient) OneAddDelLocalEid(ctx context.Context, in *OneAddDelLoca if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneAddDelLocator(ctx context.Context, in *OneAddDelLocator) (*OneAddDelLocatorReply, error) { @@ -109,7 +110,7 @@ func (c *serviceClient) OneAddDelLocator(ctx context.Context, in *OneAddDelLocat if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneAddDelLocatorSet(ctx context.Context, in *OneAddDelLocatorSet) (*OneAddDelLocatorSetReply, error) { @@ -118,7 +119,7 @@ func (c *serviceClient) OneAddDelLocatorSet(ctx context.Context, in *OneAddDelLo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneAddDelMapRequestItrRlocs(ctx context.Context, in *OneAddDelMapRequestItrRlocs) (*OneAddDelMapRequestItrRlocsReply, error) { @@ -127,7 +128,7 @@ func (c *serviceClient) OneAddDelMapRequestItrRlocs(ctx context.Context, in *One if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneAddDelMapResolver(ctx context.Context, in *OneAddDelMapResolver) (*OneAddDelMapResolverReply, error) { @@ -136,7 +137,7 @@ func (c *serviceClient) OneAddDelMapResolver(ctx context.Context, in *OneAddDelM if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneAddDelMapServer(ctx context.Context, in *OneAddDelMapServer) (*OneAddDelMapServerReply, error) { @@ -145,7 +146,7 @@ func (c *serviceClient) OneAddDelMapServer(ctx context.Context, in *OneAddDelMap if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneAddDelNdpEntry(ctx context.Context, in *OneAddDelNdpEntry) (*OneAddDelNdpEntryReply, error) { @@ -154,7 +155,7 @@ func (c *serviceClient) OneAddDelNdpEntry(ctx context.Context, in *OneAddDelNdpE if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneAddDelRemoteMapping(ctx context.Context, in *OneAddDelRemoteMapping) (*OneAddDelRemoteMappingReply, error) { @@ -163,7 +164,7 @@ func (c *serviceClient) OneAddDelRemoteMapping(ctx context.Context, in *OneAddDe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneAdjacenciesGet(ctx context.Context, in *OneAdjacenciesGet) (*OneAdjacenciesGetReply, error) { @@ -172,7 +173,7 @@ func (c *serviceClient) OneAdjacenciesGet(ctx context.Context, in *OneAdjacencie if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneEidTableAddDelMap(ctx context.Context, in *OneEidTableAddDelMap) (*OneEidTableAddDelMapReply, error) { @@ -181,7 +182,7 @@ func (c *serviceClient) OneEidTableAddDelMap(ctx context.Context, in *OneEidTabl if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneEidTableDump(ctx context.Context, in *OneEidTableDump) (RPCService_OneEidTableDumpClient, error) { @@ -217,6 +218,10 @@ func (c *serviceClient_OneEidTableDumpClient) Recv() (*OneEidTableDetails, error case *OneEidTableDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -256,6 +261,10 @@ func (c *serviceClient_OneEidTableMapDumpClient) Recv() (*OneEidTableMapDetails, case *OneEidTableMapDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -295,6 +304,10 @@ func (c *serviceClient_OneEidTableVniDumpClient) Recv() (*OneEidTableVniDetails, case *OneEidTableVniDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -307,7 +320,7 @@ func (c *serviceClient) OneEnableDisable(ctx context.Context, in *OneEnableDisab if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneEnableDisablePetrMode(ctx context.Context, in *OneEnableDisablePetrMode) (*OneEnableDisablePetrModeReply, error) { @@ -316,7 +329,7 @@ func (c *serviceClient) OneEnableDisablePetrMode(ctx context.Context, in *OneEna if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneEnableDisablePitrMode(ctx context.Context, in *OneEnableDisablePitrMode) (*OneEnableDisablePitrModeReply, error) { @@ -325,7 +338,7 @@ func (c *serviceClient) OneEnableDisablePitrMode(ctx context.Context, in *OneEna if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneEnableDisableXtrMode(ctx context.Context, in *OneEnableDisableXtrMode) (*OneEnableDisableXtrModeReply, error) { @@ -334,7 +347,7 @@ func (c *serviceClient) OneEnableDisableXtrMode(ctx context.Context, in *OneEnab if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneGetMapRequestItrRlocs(ctx context.Context, in *OneGetMapRequestItrRlocs) (*OneGetMapRequestItrRlocsReply, error) { @@ -343,7 +356,7 @@ func (c *serviceClient) OneGetMapRequestItrRlocs(ctx context.Context, in *OneGet if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneGetTransportProtocol(ctx context.Context, in *OneGetTransportProtocol) (*OneGetTransportProtocolReply, error) { @@ -352,7 +365,7 @@ func (c *serviceClient) OneGetTransportProtocol(ctx context.Context, in *OneGetT if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneL2ArpBdGet(ctx context.Context, in *OneL2ArpBdGet) (*OneL2ArpBdGetReply, error) { @@ -361,7 +374,7 @@ func (c *serviceClient) OneL2ArpBdGet(ctx context.Context, in *OneL2ArpBdGet) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneL2ArpEntriesGet(ctx context.Context, in *OneL2ArpEntriesGet) (*OneL2ArpEntriesGetReply, error) { @@ -370,7 +383,7 @@ func (c *serviceClient) OneL2ArpEntriesGet(ctx context.Context, in *OneL2ArpEntr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneLocatorDump(ctx context.Context, in *OneLocatorDump) (RPCService_OneLocatorDumpClient, error) { @@ -406,6 +419,10 @@ func (c *serviceClient_OneLocatorDumpClient) Recv() (*OneLocatorDetails, error) case *OneLocatorDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -445,6 +462,10 @@ func (c *serviceClient_OneLocatorSetDumpClient) Recv() (*OneLocatorSetDetails, e case *OneLocatorSetDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -457,7 +478,7 @@ func (c *serviceClient) OneMapRegisterEnableDisable(ctx context.Context, in *One if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneMapRegisterFallbackThreshold(ctx context.Context, in *OneMapRegisterFallbackThreshold) (*OneMapRegisterFallbackThresholdReply, error) { @@ -466,7 +487,7 @@ func (c *serviceClient) OneMapRegisterFallbackThreshold(ctx context.Context, in if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneMapRegisterSetTTL(ctx context.Context, in *OneMapRegisterSetTTL) (*OneMapRegisterSetTTLReply, error) { @@ -475,7 +496,7 @@ func (c *serviceClient) OneMapRegisterSetTTL(ctx context.Context, in *OneMapRegi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneMapRequestMode(ctx context.Context, in *OneMapRequestMode) (*OneMapRequestModeReply, error) { @@ -484,7 +505,7 @@ func (c *serviceClient) OneMapRequestMode(ctx context.Context, in *OneMapRequest if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneMapResolverDump(ctx context.Context, in *OneMapResolverDump) (RPCService_OneMapResolverDumpClient, error) { @@ -520,6 +541,10 @@ func (c *serviceClient_OneMapResolverDumpClient) Recv() (*OneMapResolverDetails, case *OneMapResolverDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -559,6 +584,10 @@ func (c *serviceClient_OneMapServerDumpClient) Recv() (*OneMapServerDetails, err case *OneMapServerDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -571,7 +600,7 @@ func (c *serviceClient) OneNdpBdGet(ctx context.Context, in *OneNdpBdGet) (*OneN if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneNdpEntriesGet(ctx context.Context, in *OneNdpEntriesGet) (*OneNdpEntriesGetReply, error) { @@ -580,7 +609,7 @@ func (c *serviceClient) OneNdpEntriesGet(ctx context.Context, in *OneNdpEntriesG if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneNshSetLocatorSet(ctx context.Context, in *OneNshSetLocatorSet) (*OneNshSetLocatorSetReply, error) { @@ -589,7 +618,7 @@ func (c *serviceClient) OneNshSetLocatorSet(ctx context.Context, in *OneNshSetLo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OnePitrSetLocatorSet(ctx context.Context, in *OnePitrSetLocatorSet) (*OnePitrSetLocatorSetReply, error) { @@ -598,7 +627,7 @@ func (c *serviceClient) OnePitrSetLocatorSet(ctx context.Context, in *OnePitrSet if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneRlocProbeEnableDisable(ctx context.Context, in *OneRlocProbeEnableDisable) (*OneRlocProbeEnableDisableReply, error) { @@ -607,7 +636,7 @@ func (c *serviceClient) OneRlocProbeEnableDisable(ctx context.Context, in *OneRl if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneSetTransportProtocol(ctx context.Context, in *OneSetTransportProtocol) (*OneSetTransportProtocolReply, error) { @@ -616,7 +645,7 @@ func (c *serviceClient) OneSetTransportProtocol(ctx context.Context, in *OneSetT if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneShowPetrMode(ctx context.Context, in *OneShowPetrMode) (*OneShowPetrModeReply, error) { @@ -625,7 +654,7 @@ func (c *serviceClient) OneShowPetrMode(ctx context.Context, in *OneShowPetrMode if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneShowPitrMode(ctx context.Context, in *OneShowPitrMode) (*OneShowPitrModeReply, error) { @@ -634,7 +663,7 @@ func (c *serviceClient) OneShowPitrMode(ctx context.Context, in *OneShowPitrMode if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneShowXtrMode(ctx context.Context, in *OneShowXtrMode) (*OneShowXtrModeReply, error) { @@ -643,7 +672,7 @@ func (c *serviceClient) OneShowXtrMode(ctx context.Context, in *OneShowXtrMode) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneStatsDump(ctx context.Context, in *OneStatsDump) (RPCService_OneStatsDumpClient, error) { @@ -679,6 +708,10 @@ func (c *serviceClient_OneStatsDumpClient) Recv() (*OneStatsDetails, error) { case *OneStatsDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -691,7 +724,7 @@ func (c *serviceClient) OneStatsEnableDisable(ctx context.Context, in *OneStatsE if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneStatsFlush(ctx context.Context, in *OneStatsFlush) (*OneStatsFlushReply, error) { @@ -700,7 +733,7 @@ func (c *serviceClient) OneStatsFlush(ctx context.Context, in *OneStatsFlush) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OneUsePetr(ctx context.Context, in *OneUsePetr) (*OneUsePetrReply, error) { @@ -709,7 +742,7 @@ func (c *serviceClient) OneUsePetr(ctx context.Context, in *OneUsePetr) (*OneUse if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowOneMapRegisterFallbackThreshold(ctx context.Context, in *ShowOneMapRegisterFallbackThreshold) (*ShowOneMapRegisterFallbackThresholdReply, error) { @@ -718,7 +751,7 @@ func (c *serviceClient) ShowOneMapRegisterFallbackThreshold(ctx context.Context, if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowOneMapRegisterState(ctx context.Context, in *ShowOneMapRegisterState) (*ShowOneMapRegisterStateReply, error) { @@ -727,7 +760,7 @@ func (c *serviceClient) ShowOneMapRegisterState(ctx context.Context, in *ShowOne if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowOneMapRegisterTTL(ctx context.Context, in *ShowOneMapRegisterTTL) (*ShowOneMapRegisterTTLReply, error) { @@ -736,7 +769,7 @@ func (c *serviceClient) ShowOneMapRegisterTTL(ctx context.Context, in *ShowOneMa if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowOneMapRequestMode(ctx context.Context, in *ShowOneMapRequestMode) (*ShowOneMapRequestModeReply, error) { @@ -745,7 +778,7 @@ func (c *serviceClient) ShowOneMapRequestMode(ctx context.Context, in *ShowOneMa if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowOneNshMapping(ctx context.Context, in *ShowOneNshMapping) (*ShowOneNshMappingReply, error) { @@ -754,7 +787,7 @@ func (c *serviceClient) ShowOneNshMapping(ctx context.Context, in *ShowOneNshMap if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowOnePitr(ctx context.Context, in *ShowOnePitr) (*ShowOnePitrReply, error) { @@ -763,7 +796,7 @@ func (c *serviceClient) ShowOnePitr(ctx context.Context, in *ShowOnePitr) (*Show if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowOneRlocProbeState(ctx context.Context, in *ShowOneRlocProbeState) (*ShowOneRlocProbeStateReply, error) { @@ -772,7 +805,7 @@ func (c *serviceClient) ShowOneRlocProbeState(ctx context.Context, in *ShowOneRl if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowOneStatsEnableDisable(ctx context.Context, in *ShowOneStatsEnableDisable) (*ShowOneStatsEnableDisableReply, error) { @@ -781,7 +814,7 @@ func (c *serviceClient) ShowOneStatsEnableDisable(ctx context.Context, in *ShowO if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowOneStatus(ctx context.Context, in *ShowOneStatus) (*ShowOneStatusReply, error) { @@ -790,7 +823,7 @@ func (c *serviceClient) ShowOneStatus(ctx context.Context, in *ShowOneStatus) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowOneUsePetr(ctx context.Context, in *ShowOneUsePetr) (*ShowOneUsePetrReply, error) { @@ -799,5 +832,5 @@ func (c *serviceClient) ShowOneUsePetr(ctx context.Context, in *ShowOneUsePetr) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/p2p_ethernet/p2p_ethernet.ba.go b/internal/testbinapi/binapi2001/p2p_ethernet/p2p_ethernet.ba.go index bf0096b..fdf488c 100644 --- a/internal/testbinapi/binapi2001/p2p_ethernet/p2p_ethernet.ba.go +++ b/internal/testbinapi/binapi2001/p2p_ethernet/p2p_ethernet.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/p2p_ethernet.api.json @@ -14,10 +14,11 @@ package p2p_ethernet import ( - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -298,15 +299,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { diff --git a/internal/testbinapi/binapi2001/p2p_ethernet/p2p_ethernet_rpc.ba.go b/internal/testbinapi/binapi2001/p2p_ethernet/p2p_ethernet_rpc.ba.go index ed1e012..c96d6a5 100644 --- a/internal/testbinapi/binapi2001/p2p_ethernet/p2p_ethernet_rpc.ba.go +++ b/internal/testbinapi/binapi2001/p2p_ethernet/p2p_ethernet_rpc.ba.go @@ -4,10 +4,11 @@ package p2p_ethernet import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service p2p_ethernet. +// RPCService defines RPC service p2p_ethernet. type RPCService interface { P2pEthernetAdd(ctx context.Context, in *P2pEthernetAdd) (*P2pEthernetAddReply, error) P2pEthernetDel(ctx context.Context, in *P2pEthernetDel) (*P2pEthernetDelReply, error) @@ -27,7 +28,7 @@ func (c *serviceClient) P2pEthernetAdd(ctx context.Context, in *P2pEthernetAdd) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) P2pEthernetDel(ctx context.Context, in *P2pEthernetDel) (*P2pEthernetDelReply, error) { @@ -36,5 +37,5 @@ func (c *serviceClient) P2pEthernetDel(ctx context.Context, in *P2pEthernetDel) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/pci_types/pci_types.ba.go b/internal/testbinapi/binapi2001/pci_types/pci_types.ba.go index c529a67..d4ea7b2 100644 --- a/internal/testbinapi/binapi2001/pci_types/pci_types.ba.go +++ b/internal/testbinapi/binapi2001/pci_types/pci_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/pci_types.api.json @@ -21,6 +21,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "pci_types" + APIVersion = "1.0.0" + VersionCrc = 0x5d418665 +) + // PciAddress defines type 'pci_address'. type PciAddress struct { Domain uint16 `binapi:"u16,name=domain" json:"domain,omitempty"` diff --git a/internal/testbinapi/binapi2001/pg/pg.ba.go b/internal/testbinapi/binapi2001/pg/pg.ba.go index 283ed12..1e304c4 100644 --- a/internal/testbinapi/binapi2001/pg/pg.ba.go +++ b/internal/testbinapi/binapi2001/pg/pg.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/pg.api.json diff --git a/internal/testbinapi/binapi2001/pg/pg_rpc.ba.go b/internal/testbinapi/binapi2001/pg/pg_rpc.ba.go index 1d905d0..697f684 100644 --- a/internal/testbinapi/binapi2001/pg/pg_rpc.ba.go +++ b/internal/testbinapi/binapi2001/pg/pg_rpc.ba.go @@ -4,10 +4,11 @@ package pg import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service pg. +// RPCService defines RPC service pg. type RPCService interface { PgCapture(ctx context.Context, in *PgCapture) (*PgCaptureReply, error) PgCreateInterface(ctx context.Context, in *PgCreateInterface) (*PgCreateInterfaceReply, error) @@ -28,7 +29,7 @@ func (c *serviceClient) PgCapture(ctx context.Context, in *PgCapture) (*PgCaptur if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PgCreateInterface(ctx context.Context, in *PgCreateInterface) (*PgCreateInterfaceReply, error) { @@ -37,7 +38,7 @@ func (c *serviceClient) PgCreateInterface(ctx context.Context, in *PgCreateInter if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PgEnableDisable(ctx context.Context, in *PgEnableDisable) (*PgEnableDisableReply, error) { @@ -46,5 +47,5 @@ func (c *serviceClient) PgEnableDisable(ctx context.Context, in *PgEnableDisable if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/pipe/pipe.ba.go b/internal/testbinapi/binapi2001/pipe/pipe.ba.go index 66f044c..da324cb 100644 --- a/internal/testbinapi/binapi2001/pipe/pipe.ba.go +++ b/internal/testbinapi/binapi2001/pipe/pipe.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/pipe.api.json @@ -14,9 +14,10 @@ package pipe import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/pipe/pipe_rpc.ba.go b/internal/testbinapi/binapi2001/pipe/pipe_rpc.ba.go index ce2037d..3f2dbc9 100644 --- a/internal/testbinapi/binapi2001/pipe/pipe_rpc.ba.go +++ b/internal/testbinapi/binapi2001/pipe/pipe_rpc.ba.go @@ -5,12 +5,13 @@ package pipe import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service pipe. +// RPCService defines RPC service pipe. type RPCService interface { PipeCreate(ctx context.Context, in *PipeCreate) (*PipeCreateReply, error) PipeDelete(ctx context.Context, in *PipeDelete) (*PipeDeleteReply, error) @@ -31,7 +32,7 @@ func (c *serviceClient) PipeCreate(ctx context.Context, in *PipeCreate) (*PipeCr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PipeDelete(ctx context.Context, in *PipeDelete) (*PipeDeleteReply, error) { @@ -40,7 +41,7 @@ func (c *serviceClient) PipeDelete(ctx context.Context, in *PipeDelete) (*PipeDe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PipeDump(ctx context.Context, in *PipeDump) (RPCService_PipeDumpClient, error) { @@ -76,6 +77,10 @@ func (c *serviceClient_PipeDumpClient) Recv() (*PipeDetails, error) { case *PipeDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/policer/policer.ba.go b/internal/testbinapi/binapi2001/policer/policer.ba.go index d5bf1d4..3c8577b 100644 --- a/internal/testbinapi/binapi2001/policer/policer.ba.go +++ b/internal/testbinapi/binapi2001/policer/policer.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/policer.api.json diff --git a/internal/testbinapi/binapi2001/policer/policer_rpc.ba.go b/internal/testbinapi/binapi2001/policer/policer_rpc.ba.go index 3a2008e..64422fb 100644 --- a/internal/testbinapi/binapi2001/policer/policer_rpc.ba.go +++ b/internal/testbinapi/binapi2001/policer/policer_rpc.ba.go @@ -5,12 +5,13 @@ package policer import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service policer. +// RPCService defines RPC service policer. type RPCService interface { PolicerAddDel(ctx context.Context, in *PolicerAddDel) (*PolicerAddDelReply, error) PolicerDump(ctx context.Context, in *PolicerDump) (RPCService_PolicerDumpClient, error) @@ -30,7 +31,7 @@ func (c *serviceClient) PolicerAddDel(ctx context.Context, in *PolicerAddDel) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PolicerDump(ctx context.Context, in *PolicerDump) (RPCService_PolicerDumpClient, error) { @@ -66,6 +67,10 @@ func (c *serviceClient_PolicerDumpClient) Recv() (*PolicerDetails, error) { case *PolicerDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/pot/pot.ba.go b/internal/testbinapi/binapi2001/pot/pot.ba.go index 17f1c4d..d7fdfa9 100644 --- a/internal/testbinapi/binapi2001/pot/pot.ba.go +++ b/internal/testbinapi/binapi2001/pot/pot.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/pot.api.json diff --git a/internal/testbinapi/binapi2001/pot/pot_rpc.ba.go b/internal/testbinapi/binapi2001/pot/pot_rpc.ba.go index 7194482..83adca6 100644 --- a/internal/testbinapi/binapi2001/pot/pot_rpc.ba.go +++ b/internal/testbinapi/binapi2001/pot/pot_rpc.ba.go @@ -5,12 +5,13 @@ package pot import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service pot. +// RPCService defines RPC service pot. type RPCService interface { PotProfileActivate(ctx context.Context, in *PotProfileActivate) (*PotProfileActivateReply, error) PotProfileAdd(ctx context.Context, in *PotProfileAdd) (*PotProfileAddReply, error) @@ -32,7 +33,7 @@ func (c *serviceClient) PotProfileActivate(ctx context.Context, in *PotProfileAc if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PotProfileAdd(ctx context.Context, in *PotProfileAdd) (*PotProfileAddReply, error) { @@ -41,7 +42,7 @@ func (c *serviceClient) PotProfileAdd(ctx context.Context, in *PotProfileAdd) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PotProfileDel(ctx context.Context, in *PotProfileDel) (*PotProfileDelReply, error) { @@ -50,7 +51,7 @@ func (c *serviceClient) PotProfileDel(ctx context.Context, in *PotProfileDel) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PotProfileShowConfigDump(ctx context.Context, in *PotProfileShowConfigDump) (RPCService_PotProfileShowConfigDumpClient, error) { @@ -86,6 +87,10 @@ func (c *serviceClient_PotProfileShowConfigDumpClient) Recv() (*PotProfileShowCo case *PotProfileShowConfigDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/pppoe/pppoe.ba.go b/internal/testbinapi/binapi2001/pppoe/pppoe.ba.go index 281bbe0..3c8d027 100644 --- a/internal/testbinapi/binapi2001/pppoe/pppoe.ba.go +++ b/internal/testbinapi/binapi2001/pppoe/pppoe.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/pppoe.api.json @@ -17,11 +17,12 @@ package pppoe import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -596,15 +606,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { @@ -625,6 +639,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -637,8 +655,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -648,12 +667,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -696,18 +718,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -750,18 +776,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -812,6 +842,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -822,13 +853,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -846,8 +880,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/pppoe/pppoe_rpc.ba.go b/internal/testbinapi/binapi2001/pppoe/pppoe_rpc.ba.go index 7feaf6f..09d7112 100644 --- a/internal/testbinapi/binapi2001/pppoe/pppoe_rpc.ba.go +++ b/internal/testbinapi/binapi2001/pppoe/pppoe_rpc.ba.go @@ -5,12 +5,13 @@ package pppoe import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service pppoe. +// RPCService defines RPC service pppoe. type RPCService interface { PppoeAddDelSession(ctx context.Context, in *PppoeAddDelSession) (*PppoeAddDelSessionReply, error) PppoeSessionDump(ctx context.Context, in *PppoeSessionDump) (RPCService_PppoeSessionDumpClient, error) @@ -30,7 +31,7 @@ func (c *serviceClient) PppoeAddDelSession(ctx context.Context, in *PppoeAddDelS if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PppoeSessionDump(ctx context.Context, in *PppoeSessionDump) (RPCService_PppoeSessionDumpClient, error) { @@ -66,6 +67,10 @@ func (c *serviceClient_PppoeSessionDumpClient) Recv() (*PppoeSessionDetails, err case *PppoeSessionDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/punt/punt.ba.go b/internal/testbinapi/binapi2001/punt/punt.ba.go index 285aaf1..e10832f 100644 --- a/internal/testbinapi/binapi2001/punt/punt.ba.go +++ b/internal/testbinapi/binapi2001/punt/punt.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/punt.api.json @@ -17,11 +17,12 @@ package punt import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -277,12 +278,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -308,12 +312,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -342,12 +349,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -371,6 +381,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -383,8 +397,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -394,12 +409,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -442,18 +460,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -496,18 +518,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -558,6 +584,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -568,13 +595,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -622,8 +652,9 @@ type PuntReason struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } @@ -657,9 +688,10 @@ func (u *AddressUnion) GetIP6() (a IP6Address) { // PuntUnion defines union 'punt_union'. type PuntUnion struct { - // Exception *PuntException - // L4 *PuntL4 - // IPProto *PuntIPProto + // PuntUnion can be one of: + // - Exception *PuntException + // - L4 *PuntL4 + // - IPProto *PuntIPProto XXX_UnionData [10]byte } diff --git a/internal/testbinapi/binapi2001/punt/punt_rpc.ba.go b/internal/testbinapi/binapi2001/punt/punt_rpc.ba.go index c55a0af..337eeb7 100644 --- a/internal/testbinapi/binapi2001/punt/punt_rpc.ba.go +++ b/internal/testbinapi/binapi2001/punt/punt_rpc.ba.go @@ -5,12 +5,13 @@ package punt import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service punt. +// RPCService defines RPC service punt. type RPCService interface { PuntReasonDump(ctx context.Context, in *PuntReasonDump) (RPCService_PuntReasonDumpClient, error) PuntSocketDeregister(ctx context.Context, in *PuntSocketDeregister) (*PuntSocketDeregisterReply, error) @@ -60,6 +61,10 @@ func (c *serviceClient_PuntReasonDumpClient) Recv() (*PuntReasonDetails, error) case *PuntReasonDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -72,7 +77,7 @@ func (c *serviceClient) PuntSocketDeregister(ctx context.Context, in *PuntSocket if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PuntSocketDump(ctx context.Context, in *PuntSocketDump) (RPCService_PuntSocketDumpClient, error) { @@ -108,6 +113,10 @@ func (c *serviceClient_PuntSocketDumpClient) Recv() (*PuntSocketDetails, error) case *PuntSocketDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -120,7 +129,7 @@ func (c *serviceClient) PuntSocketRegister(ctx context.Context, in *PuntSocketRe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SetPunt(ctx context.Context, in *SetPunt) (*SetPuntReply, error) { @@ -129,5 +138,5 @@ func (c *serviceClient) SetPunt(ctx context.Context, in *SetPunt) (*SetPuntReply if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/qos/qos.ba.go b/internal/testbinapi/binapi2001/qos/qos.ba.go index 5414145..d91fccb 100644 --- a/internal/testbinapi/binapi2001/qos/qos.ba.go +++ b/internal/testbinapi/binapi2001/qos/qos.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/qos.api.json @@ -17,11 +17,12 @@ package qos import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -531,12 +532,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -565,12 +569,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -599,12 +606,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -628,6 +638,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -640,8 +654,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -651,12 +666,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -699,18 +717,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -753,18 +775,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -815,6 +841,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -825,13 +852,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -880,8 +910,9 @@ type QosStore struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/qos/qos_rpc.ba.go b/internal/testbinapi/binapi2001/qos/qos_rpc.ba.go index ed5909c..2334c62 100644 --- a/internal/testbinapi/binapi2001/qos/qos_rpc.ba.go +++ b/internal/testbinapi/binapi2001/qos/qos_rpc.ba.go @@ -5,12 +5,13 @@ package qos import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service qos. +// RPCService defines RPC service qos. type RPCService interface { QosEgressMapDelete(ctx context.Context, in *QosEgressMapDelete) (*QosEgressMapDeleteReply, error) QosEgressMapDump(ctx context.Context, in *QosEgressMapDump) (RPCService_QosEgressMapDumpClient, error) @@ -37,7 +38,7 @@ func (c *serviceClient) QosEgressMapDelete(ctx context.Context, in *QosEgressMap if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) QosEgressMapDump(ctx context.Context, in *QosEgressMapDump) (RPCService_QosEgressMapDumpClient, error) { @@ -73,6 +74,10 @@ func (c *serviceClient_QosEgressMapDumpClient) Recv() (*QosEgressMapDetails, err case *QosEgressMapDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -85,7 +90,7 @@ func (c *serviceClient) QosEgressMapUpdate(ctx context.Context, in *QosEgressMap if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) QosMarkDump(ctx context.Context, in *QosMarkDump) (RPCService_QosMarkDumpClient, error) { @@ -121,6 +126,10 @@ func (c *serviceClient_QosMarkDumpClient) Recv() (*QosMarkDetails, error) { case *QosMarkDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -133,7 +142,7 @@ func (c *serviceClient) QosMarkEnableDisable(ctx context.Context, in *QosMarkEna if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) QosRecordDump(ctx context.Context, in *QosRecordDump) (RPCService_QosRecordDumpClient, error) { @@ -169,6 +178,10 @@ func (c *serviceClient_QosRecordDumpClient) Recv() (*QosRecordDetails, error) { case *QosRecordDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -181,7 +194,7 @@ func (c *serviceClient) QosRecordEnableDisable(ctx context.Context, in *QosRecor if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) QosStoreDump(ctx context.Context, in *QosStoreDump) (RPCService_QosStoreDumpClient, error) { @@ -217,6 +230,10 @@ func (c *serviceClient_QosStoreDumpClient) Recv() (*QosStoreDetails, error) { case *QosStoreDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -229,5 +246,5 @@ func (c *serviceClient) QosStoreEnableDisable(ctx context.Context, in *QosStoreE if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/rd_cp/rd_cp.ba.go b/internal/testbinapi/binapi2001/rd_cp/rd_cp.ba.go index db3579d..92fa94c 100644 --- a/internal/testbinapi/binapi2001/rd_cp/rd_cp.ba.go +++ b/internal/testbinapi/binapi2001/rd_cp/rd_cp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/rd_cp.api.json @@ -14,9 +14,10 @@ package rd_cp import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/rd_cp/rd_cp_rpc.ba.go b/internal/testbinapi/binapi2001/rd_cp/rd_cp_rpc.ba.go index af7ba12..56b2c18 100644 --- a/internal/testbinapi/binapi2001/rd_cp/rd_cp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/rd_cp/rd_cp_rpc.ba.go @@ -4,10 +4,11 @@ package rd_cp import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service rd_cp. +// RPCService defines RPC service rd_cp. type RPCService interface { IP6NdAddressAutoconfig(ctx context.Context, in *IP6NdAddressAutoconfig) (*IP6NdAddressAutoconfigReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) IP6NdAddressAutoconfig(ctx context.Context, in *IP6NdAdd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/rdma/rdma.ba.go b/internal/testbinapi/binapi2001/rdma/rdma.ba.go index fcbf2c2..79c738a 100644 --- a/internal/testbinapi/binapi2001/rdma/rdma.ba.go +++ b/internal/testbinapi/binapi2001/rdma/rdma.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/rdma.api.json @@ -14,9 +14,10 @@ package rdma import ( + "strconv" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file diff --git a/internal/testbinapi/binapi2001/rdma/rdma_rpc.ba.go b/internal/testbinapi/binapi2001/rdma/rdma_rpc.ba.go index 850f04a..489297d 100644 --- a/internal/testbinapi/binapi2001/rdma/rdma_rpc.ba.go +++ b/internal/testbinapi/binapi2001/rdma/rdma_rpc.ba.go @@ -4,10 +4,11 @@ package rdma import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service rdma. +// RPCService defines RPC service rdma. type RPCService interface { RdmaCreate(ctx context.Context, in *RdmaCreate) (*RdmaCreateReply, error) RdmaDelete(ctx context.Context, in *RdmaDelete) (*RdmaDeleteReply, error) @@ -27,7 +28,7 @@ func (c *serviceClient) RdmaCreate(ctx context.Context, in *RdmaCreate) (*RdmaCr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) RdmaDelete(ctx context.Context, in *RdmaDelete) (*RdmaDeleteReply, error) { @@ -36,5 +37,5 @@ func (c *serviceClient) RdmaDelete(ctx context.Context, in *RdmaDelete) (*RdmaDe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/sctp/sctp.ba.go b/internal/testbinapi/binapi2001/sctp/sctp.ba.go index 61aeab6..c06e76e 100644 --- a/internal/testbinapi/binapi2001/sctp/sctp.ba.go +++ b/internal/testbinapi/binapi2001/sctp/sctp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/sctp.api.json diff --git a/internal/testbinapi/binapi2001/sctp/sctp_rpc.ba.go b/internal/testbinapi/binapi2001/sctp/sctp_rpc.ba.go index d5aa970..7e75326 100644 --- a/internal/testbinapi/binapi2001/sctp/sctp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/sctp/sctp_rpc.ba.go @@ -4,10 +4,11 @@ package sctp import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service sctp. +// RPCService defines RPC service sctp. type RPCService interface { SctpAddSrcDstConnection(ctx context.Context, in *SctpAddSrcDstConnection) (*SctpAddSrcDstConnectionReply, error) SctpConfig(ctx context.Context, in *SctpConfig) (*SctpConfigReply, error) @@ -28,7 +29,7 @@ func (c *serviceClient) SctpAddSrcDstConnection(ctx context.Context, in *SctpAdd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SctpConfig(ctx context.Context, in *SctpConfig) (*SctpConfigReply, error) { @@ -37,7 +38,7 @@ func (c *serviceClient) SctpConfig(ctx context.Context, in *SctpConfig) (*SctpCo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SctpDelSrcDstConnection(ctx context.Context, in *SctpDelSrcDstConnection) (*SctpDelSrcDstConnectionReply, error) { @@ -46,5 +47,5 @@ func (c *serviceClient) SctpDelSrcDstConnection(ctx context.Context, in *SctpDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/session/session.ba.go b/internal/testbinapi/binapi2001/session/session.ba.go index 7f5af5c..b6d5706 100644 --- a/internal/testbinapi/binapi2001/session/session.ba.go +++ b/internal/testbinapi/binapi2001/session/session.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/session.api.json diff --git a/internal/testbinapi/binapi2001/session/session_rpc.ba.go b/internal/testbinapi/binapi2001/session/session_rpc.ba.go index 519aa06..9910c24 100644 --- a/internal/testbinapi/binapi2001/session/session_rpc.ba.go +++ b/internal/testbinapi/binapi2001/session/session_rpc.ba.go @@ -5,12 +5,13 @@ package session import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service session. +// RPCService defines RPC service session. type RPCService interface { AppAddCertKeyPair(ctx context.Context, in *AppAddCertKeyPair) (*AppAddCertKeyPairReply, error) AppAttach(ctx context.Context, in *AppAttach) (*AppAttachReply, error) @@ -50,7 +51,7 @@ func (c *serviceClient) AppAddCertKeyPair(ctx context.Context, in *AppAddCertKey if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) AppAttach(ctx context.Context, in *AppAttach) (*AppAttachReply, error) { @@ -59,7 +60,7 @@ func (c *serviceClient) AppAttach(ctx context.Context, in *AppAttach) (*AppAttac if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) AppCutThroughRegistrationAdd(ctx context.Context, in *AppCutThroughRegistrationAdd) (*AppCutThroughRegistrationAddReply, error) { @@ -68,7 +69,7 @@ func (c *serviceClient) AppCutThroughRegistrationAdd(ctx context.Context, in *Ap if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) AppDelCertKeyPair(ctx context.Context, in *AppDelCertKeyPair) (*AppDelCertKeyPairReply, error) { @@ -77,7 +78,7 @@ func (c *serviceClient) AppDelCertKeyPair(ctx context.Context, in *AppDelCertKey if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) AppNamespaceAddDel(ctx context.Context, in *AppNamespaceAddDel) (*AppNamespaceAddDelReply, error) { @@ -86,7 +87,7 @@ func (c *serviceClient) AppNamespaceAddDel(ctx context.Context, in *AppNamespace if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) AppWorkerAddDel(ctx context.Context, in *AppWorkerAddDel) (*AppWorkerAddDelReply, error) { @@ -95,7 +96,7 @@ func (c *serviceClient) AppWorkerAddDel(ctx context.Context, in *AppWorkerAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ApplicationAttach(ctx context.Context, in *ApplicationAttach) (*ApplicationAttachReply, error) { @@ -104,7 +105,7 @@ func (c *serviceClient) ApplicationAttach(ctx context.Context, in *ApplicationAt if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ApplicationDetach(ctx context.Context, in *ApplicationDetach) (*ApplicationDetachReply, error) { @@ -113,7 +114,7 @@ func (c *serviceClient) ApplicationDetach(ctx context.Context, in *ApplicationDe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ApplicationTLSCertAdd(ctx context.Context, in *ApplicationTLSCertAdd) (*ApplicationTLSCertAddReply, error) { @@ -122,7 +123,7 @@ func (c *serviceClient) ApplicationTLSCertAdd(ctx context.Context, in *Applicati if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ApplicationTLSKeyAdd(ctx context.Context, in *ApplicationTLSKeyAdd) (*ApplicationTLSKeyAddReply, error) { @@ -131,7 +132,7 @@ func (c *serviceClient) ApplicationTLSKeyAdd(ctx context.Context, in *Applicatio if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BindSock(ctx context.Context, in *BindSock) (*BindSockReply, error) { @@ -140,7 +141,7 @@ func (c *serviceClient) BindSock(ctx context.Context, in *BindSock) (*BindSockRe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) BindURI(ctx context.Context, in *BindURI) (*BindURIReply, error) { @@ -149,7 +150,7 @@ func (c *serviceClient) BindURI(ctx context.Context, in *BindURI) (*BindURIReply if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ConnectSock(ctx context.Context, in *ConnectSock) (*ConnectSockReply, error) { @@ -158,7 +159,7 @@ func (c *serviceClient) ConnectSock(ctx context.Context, in *ConnectSock) (*Conn if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ConnectURI(ctx context.Context, in *ConnectURI) (*ConnectURIReply, error) { @@ -167,7 +168,7 @@ func (c *serviceClient) ConnectURI(ctx context.Context, in *ConnectURI) (*Connec if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DisconnectSession(ctx context.Context, in *DisconnectSession) (*DisconnectSessionReply, error) { @@ -176,7 +177,7 @@ func (c *serviceClient) DisconnectSession(ctx context.Context, in *DisconnectSes if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) MapAnotherSegment(ctx context.Context, in *MapAnotherSegment) (*MapAnotherSegmentReply, error) { @@ -185,7 +186,7 @@ func (c *serviceClient) MapAnotherSegment(ctx context.Context, in *MapAnotherSeg if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SessionEnableDisable(ctx context.Context, in *SessionEnableDisable) (*SessionEnableDisableReply, error) { @@ -194,7 +195,7 @@ func (c *serviceClient) SessionEnableDisable(ctx context.Context, in *SessionEna if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SessionRuleAddDel(ctx context.Context, in *SessionRuleAddDel) (*SessionRuleAddDelReply, error) { @@ -203,7 +204,7 @@ func (c *serviceClient) SessionRuleAddDel(ctx context.Context, in *SessionRuleAd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SessionRulesDump(ctx context.Context, in *SessionRulesDump) (RPCService_SessionRulesDumpClient, error) { @@ -239,6 +240,10 @@ func (c *serviceClient_SessionRulesDumpClient) Recv() (*SessionRulesDetails, err case *SessionRulesDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -251,7 +256,7 @@ func (c *serviceClient) UnbindSock(ctx context.Context, in *UnbindSock) (*Unbind if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) UnbindURI(ctx context.Context, in *UnbindURI) (*UnbindURIReply, error) { @@ -260,7 +265,7 @@ func (c *serviceClient) UnbindURI(ctx context.Context, in *UnbindURI) (*UnbindUR if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) UnmapSegment(ctx context.Context, in *UnmapSegment) (*UnmapSegmentReply, error) { @@ -269,5 +274,5 @@ func (c *serviceClient) UnmapSegment(ctx context.Context, in *UnmapSegment) (*Un if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/span/span.ba.go b/internal/testbinapi/binapi2001/span/span.ba.go index 31e9044..f7ef2a3 100644 --- a/internal/testbinapi/binapi2001/span/span.ba.go +++ b/internal/testbinapi/binapi2001/span/span.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/span.api.json diff --git a/internal/testbinapi/binapi2001/span/span_rpc.ba.go b/internal/testbinapi/binapi2001/span/span_rpc.ba.go index 44f5c73..bea9950 100644 --- a/internal/testbinapi/binapi2001/span/span_rpc.ba.go +++ b/internal/testbinapi/binapi2001/span/span_rpc.ba.go @@ -5,12 +5,13 @@ package span import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service span. +// RPCService defines RPC service span. type RPCService interface { SwInterfaceSpanDump(ctx context.Context, in *SwInterfaceSpanDump) (RPCService_SwInterfaceSpanDumpClient, error) SwInterfaceSpanEnableDisable(ctx context.Context, in *SwInterfaceSpanEnableDisable) (*SwInterfaceSpanEnableDisableReply, error) @@ -57,6 +58,10 @@ func (c *serviceClient_SwInterfaceSpanDumpClient) Recv() (*SwInterfaceSpanDetail case *SwInterfaceSpanDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -69,5 +74,5 @@ func (c *serviceClient) SwInterfaceSpanEnableDisable(ctx context.Context, in *Sw if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/sr/sr.ba.go b/internal/testbinapi/binapi2001/sr/sr.ba.go index 1a13b5a..a8d63b9 100644 --- a/internal/testbinapi/binapi2001/sr/sr.ba.go +++ b/internal/testbinapi/binapi2001/sr/sr.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/sr.api.json diff --git a/internal/testbinapi/binapi2001/sr/sr_rpc.ba.go b/internal/testbinapi/binapi2001/sr/sr_rpc.ba.go index 51adb98..843a400 100644 --- a/internal/testbinapi/binapi2001/sr/sr_rpc.ba.go +++ b/internal/testbinapi/binapi2001/sr/sr_rpc.ba.go @@ -5,12 +5,13 @@ package sr import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service sr. +// RPCService defines RPC service sr. type RPCService interface { SrLocalsidAddDel(ctx context.Context, in *SrLocalsidAddDel) (*SrLocalsidAddDelReply, error) SrLocalsidsDump(ctx context.Context, in *SrLocalsidsDump) (RPCService_SrLocalsidsDumpClient, error) @@ -38,7 +39,7 @@ func (c *serviceClient) SrLocalsidAddDel(ctx context.Context, in *SrLocalsidAddD if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SrLocalsidsDump(ctx context.Context, in *SrLocalsidsDump) (RPCService_SrLocalsidsDumpClient, error) { @@ -74,6 +75,10 @@ func (c *serviceClient_SrLocalsidsDumpClient) Recv() (*SrLocalsidsDetails, error case *SrLocalsidsDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -113,6 +118,10 @@ func (c *serviceClient_SrPoliciesDumpClient) Recv() (*SrPoliciesDetails, error) case *SrPoliciesDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -125,7 +134,7 @@ func (c *serviceClient) SrPolicyAdd(ctx context.Context, in *SrPolicyAdd) (*SrPo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SrPolicyDel(ctx context.Context, in *SrPolicyDel) (*SrPolicyDelReply, error) { @@ -134,7 +143,7 @@ func (c *serviceClient) SrPolicyDel(ctx context.Context, in *SrPolicyDel) (*SrPo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SrPolicyMod(ctx context.Context, in *SrPolicyMod) (*SrPolicyModReply, error) { @@ -143,7 +152,7 @@ func (c *serviceClient) SrPolicyMod(ctx context.Context, in *SrPolicyMod) (*SrPo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SrSetEncapHopLimit(ctx context.Context, in *SrSetEncapHopLimit) (*SrSetEncapHopLimitReply, error) { @@ -152,7 +161,7 @@ func (c *serviceClient) SrSetEncapHopLimit(ctx context.Context, in *SrSetEncapHo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SrSetEncapSource(ctx context.Context, in *SrSetEncapSource) (*SrSetEncapSourceReply, error) { @@ -161,7 +170,7 @@ func (c *serviceClient) SrSetEncapSource(ctx context.Context, in *SrSetEncapSour if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SrSteeringAddDel(ctx context.Context, in *SrSteeringAddDel) (*SrSteeringAddDelReply, error) { @@ -170,7 +179,7 @@ func (c *serviceClient) SrSteeringAddDel(ctx context.Context, in *SrSteeringAddD if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SrSteeringPolDump(ctx context.Context, in *SrSteeringPolDump) (RPCService_SrSteeringPolDumpClient, error) { @@ -206,6 +215,10 @@ func (c *serviceClient_SrSteeringPolDumpClient) Recv() (*SrSteeringPolDetails, e case *SrSteeringPolDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/sr_mpls/sr_mpls.ba.go b/internal/testbinapi/binapi2001/sr_mpls/sr_mpls.ba.go index 2c8f388..f2e73a2 100644 --- a/internal/testbinapi/binapi2001/sr_mpls/sr_mpls.ba.go +++ b/internal/testbinapi/binapi2001/sr_mpls/sr_mpls.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/sr_mpls.api.json diff --git a/internal/testbinapi/binapi2001/sr_mpls/sr_mpls_rpc.ba.go b/internal/testbinapi/binapi2001/sr_mpls/sr_mpls_rpc.ba.go index 8669e70..556d32e 100644 --- a/internal/testbinapi/binapi2001/sr_mpls/sr_mpls_rpc.ba.go +++ b/internal/testbinapi/binapi2001/sr_mpls/sr_mpls_rpc.ba.go @@ -4,10 +4,11 @@ package sr_mpls import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service sr_mpls. +// RPCService defines RPC service sr_mpls. type RPCService interface { SrMplsPolicyAdd(ctx context.Context, in *SrMplsPolicyAdd) (*SrMplsPolicyAddReply, error) SrMplsPolicyAssignEndpointColor(ctx context.Context, in *SrMplsPolicyAssignEndpointColor) (*SrMplsPolicyAssignEndpointColorReply, error) @@ -30,7 +31,7 @@ func (c *serviceClient) SrMplsPolicyAdd(ctx context.Context, in *SrMplsPolicyAdd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SrMplsPolicyAssignEndpointColor(ctx context.Context, in *SrMplsPolicyAssignEndpointColor) (*SrMplsPolicyAssignEndpointColorReply, error) { @@ -39,7 +40,7 @@ func (c *serviceClient) SrMplsPolicyAssignEndpointColor(ctx context.Context, in if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SrMplsPolicyDel(ctx context.Context, in *SrMplsPolicyDel) (*SrMplsPolicyDelReply, error) { @@ -48,7 +49,7 @@ func (c *serviceClient) SrMplsPolicyDel(ctx context.Context, in *SrMplsPolicyDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SrMplsPolicyMod(ctx context.Context, in *SrMplsPolicyMod) (*SrMplsPolicyModReply, error) { @@ -57,7 +58,7 @@ func (c *serviceClient) SrMplsPolicyMod(ctx context.Context, in *SrMplsPolicyMod if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SrMplsSteeringAddDel(ctx context.Context, in *SrMplsSteeringAddDel) (*SrMplsSteeringAddDelReply, error) { @@ -66,5 +67,5 @@ func (c *serviceClient) SrMplsSteeringAddDel(ctx context.Context, in *SrMplsStee if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/stn/stn.ba.go b/internal/testbinapi/binapi2001/stn/stn.ba.go index 25b7dcd..8e9d7dc 100644 --- a/internal/testbinapi/binapi2001/stn/stn.ba.go +++ b/internal/testbinapi/binapi2001/stn/stn.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/stn.api.json @@ -17,11 +17,12 @@ package stn import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -595,6 +605,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -607,8 +621,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -618,12 +633,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -666,18 +684,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -720,18 +742,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -782,6 +808,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -792,13 +819,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -816,8 +846,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/stn/stn_rpc.ba.go b/internal/testbinapi/binapi2001/stn/stn_rpc.ba.go index b638e8e..80639a7 100644 --- a/internal/testbinapi/binapi2001/stn/stn_rpc.ba.go +++ b/internal/testbinapi/binapi2001/stn/stn_rpc.ba.go @@ -5,12 +5,13 @@ package stn import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service stn. +// RPCService defines RPC service stn. type RPCService interface { StnAddDelRule(ctx context.Context, in *StnAddDelRule) (*StnAddDelRuleReply, error) StnRulesDump(ctx context.Context, in *StnRulesDump) (RPCService_StnRulesDumpClient, error) @@ -30,7 +31,7 @@ func (c *serviceClient) StnAddDelRule(ctx context.Context, in *StnAddDelRule) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) StnRulesDump(ctx context.Context, in *StnRulesDump) (RPCService_StnRulesDumpClient, error) { @@ -66,6 +67,10 @@ func (c *serviceClient_StnRulesDumpClient) Recv() (*StnRulesDetails, error) { case *StnRulesDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/svs/svs.ba.go b/internal/testbinapi/binapi2001/svs/svs.ba.go index 7c3d7c6..9e5db42 100644 --- a/internal/testbinapi/binapi2001/svs/svs.ba.go +++ b/internal/testbinapi/binapi2001/svs/svs.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/svs.api.json @@ -17,11 +17,12 @@ package svs import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -498,12 +499,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -532,12 +536,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -566,12 +573,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -595,6 +605,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -607,8 +621,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -618,12 +633,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -666,18 +684,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -720,18 +742,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -782,6 +808,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -792,13 +819,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -816,8 +846,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/svs/svs_rpc.ba.go b/internal/testbinapi/binapi2001/svs/svs_rpc.ba.go index 7b4b13a..c69c02b 100644 --- a/internal/testbinapi/binapi2001/svs/svs_rpc.ba.go +++ b/internal/testbinapi/binapi2001/svs/svs_rpc.ba.go @@ -5,12 +5,13 @@ package svs import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service svs. +// RPCService defines RPC service svs. type RPCService interface { SvsDump(ctx context.Context, in *SvsDump) (RPCService_SvsDumpClient, error) SvsEnableDisable(ctx context.Context, in *SvsEnableDisable) (*SvsEnableDisableReply, error) @@ -60,6 +61,10 @@ func (c *serviceClient_SvsDumpClient) Recv() (*SvsDetails, error) { case *SvsDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -72,7 +77,7 @@ func (c *serviceClient) SvsEnableDisable(ctx context.Context, in *SvsEnableDisab if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SvsPluginGetVersion(ctx context.Context, in *SvsPluginGetVersion) (*SvsPluginGetVersionReply, error) { @@ -90,7 +95,7 @@ func (c *serviceClient) SvsRouteAddDel(ctx context.Context, in *SvsRouteAddDel) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SvsTableAddDel(ctx context.Context, in *SvsTableAddDel) (*SvsTableAddDelReply, error) { @@ -99,5 +104,5 @@ func (c *serviceClient) SvsTableAddDel(ctx context.Context, in *SvsTableAddDel) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/syslog/syslog.ba.go b/internal/testbinapi/binapi2001/syslog/syslog.ba.go index c9fd0f7..0136824 100644 --- a/internal/testbinapi/binapi2001/syslog/syslog.ba.go +++ b/internal/testbinapi/binapi2001/syslog/syslog.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/syslog.api.json @@ -17,11 +17,12 @@ package syslog import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -292,12 +293,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -323,12 +327,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -357,12 +364,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -386,6 +396,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -398,8 +412,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -409,12 +424,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -457,18 +475,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -511,18 +533,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -573,6 +599,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -583,13 +610,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -607,8 +637,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/syslog/syslog_rpc.ba.go b/internal/testbinapi/binapi2001/syslog/syslog_rpc.ba.go index a1f4a27..da005b3 100644 --- a/internal/testbinapi/binapi2001/syslog/syslog_rpc.ba.go +++ b/internal/testbinapi/binapi2001/syslog/syslog_rpc.ba.go @@ -4,10 +4,11 @@ package syslog import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service syslog. +// RPCService defines RPC service syslog. type RPCService interface { SyslogGetFilter(ctx context.Context, in *SyslogGetFilter) (*SyslogGetFilterReply, error) SyslogGetSender(ctx context.Context, in *SyslogGetSender) (*SyslogGetSenderReply, error) @@ -29,7 +30,7 @@ func (c *serviceClient) SyslogGetFilter(ctx context.Context, in *SyslogGetFilter if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SyslogGetSender(ctx context.Context, in *SyslogGetSender) (*SyslogGetSenderReply, error) { @@ -38,7 +39,7 @@ func (c *serviceClient) SyslogGetSender(ctx context.Context, in *SyslogGetSender if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SyslogSetFilter(ctx context.Context, in *SyslogSetFilter) (*SyslogSetFilterReply, error) { @@ -47,7 +48,7 @@ func (c *serviceClient) SyslogSetFilter(ctx context.Context, in *SyslogSetFilter if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SyslogSetSender(ctx context.Context, in *SyslogSetSender) (*SyslogSetSenderReply, error) { @@ -56,5 +57,5 @@ func (c *serviceClient) SyslogSetSender(ctx context.Context, in *SyslogSetSender if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/tapv2/tapv2.ba.go b/internal/testbinapi/binapi2001/tapv2/tapv2.ba.go index 36898ea..d81c09f 100644 --- a/internal/testbinapi/binapi2001/tapv2/tapv2.ba.go +++ b/internal/testbinapi/binapi2001/tapv2/tapv2.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/tapv2.api.json @@ -17,11 +17,12 @@ package tapv2 import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -544,12 +545,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -578,12 +582,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -612,12 +619,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -642,15 +652,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { @@ -671,6 +685,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -683,8 +701,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -694,12 +713,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -742,18 +764,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -796,18 +822,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -858,6 +888,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -868,13 +899,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -892,8 +926,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/tapv2/tapv2_rpc.ba.go b/internal/testbinapi/binapi2001/tapv2/tapv2_rpc.ba.go index b6c5349..785ef24 100644 --- a/internal/testbinapi/binapi2001/tapv2/tapv2_rpc.ba.go +++ b/internal/testbinapi/binapi2001/tapv2/tapv2_rpc.ba.go @@ -5,12 +5,13 @@ package tapv2 import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service tapv2. +// RPCService defines RPC service tapv2. type RPCService interface { SwInterfaceTapV2Dump(ctx context.Context, in *SwInterfaceTapV2Dump) (RPCService_SwInterfaceTapV2DumpClient, error) TapCreateV2(ctx context.Context, in *TapCreateV2) (*TapCreateV2Reply, error) @@ -58,6 +59,10 @@ func (c *serviceClient_SwInterfaceTapV2DumpClient) Recv() (*SwInterfaceTapV2Deta case *SwInterfaceTapV2Details: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -70,7 +75,7 @@ func (c *serviceClient) TapCreateV2(ctx context.Context, in *TapCreateV2) (*TapC if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) TapDeleteV2(ctx context.Context, in *TapDeleteV2) (*TapDeleteV2Reply, error) { @@ -79,5 +84,5 @@ func (c *serviceClient) TapDeleteV2(ctx context.Context, in *TapDeleteV2) (*TapD if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/tcp/tcp.ba.go b/internal/testbinapi/binapi2001/tcp/tcp.ba.go index 05fcf37..48fe539 100644 --- a/internal/testbinapi/binapi2001/tcp/tcp.ba.go +++ b/internal/testbinapi/binapi2001/tcp/tcp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/tcp.api.json @@ -17,11 +17,12 @@ package tcp import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -247,12 +248,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -278,12 +282,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -312,12 +319,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -341,6 +351,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -353,8 +367,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -364,12 +379,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -412,18 +430,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -466,18 +488,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -528,6 +554,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -538,13 +565,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -562,8 +592,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/tcp/tcp_rpc.ba.go b/internal/testbinapi/binapi2001/tcp/tcp_rpc.ba.go index 8be3619..2d045f7 100644 --- a/internal/testbinapi/binapi2001/tcp/tcp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/tcp/tcp_rpc.ba.go @@ -4,10 +4,11 @@ package tcp import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service tcp. +// RPCService defines RPC service tcp. type RPCService interface { TCPConfigureSrcAddresses(ctx context.Context, in *TCPConfigureSrcAddresses) (*TCPConfigureSrcAddressesReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) TCPConfigureSrcAddresses(ctx context.Context, in *TCPCon if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/tls_openssl/tls_openssl.ba.go b/internal/testbinapi/binapi2001/tls_openssl/tls_openssl.ba.go index 96a66c0..743521c 100644 --- a/internal/testbinapi/binapi2001/tls_openssl/tls_openssl.ba.go +++ b/internal/testbinapi/binapi2001/tls_openssl/tls_openssl.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/tls_openssl.api.json diff --git a/internal/testbinapi/binapi2001/tls_openssl/tls_openssl_rpc.ba.go b/internal/testbinapi/binapi2001/tls_openssl/tls_openssl_rpc.ba.go index 2575bf2..57ef26d 100644 --- a/internal/testbinapi/binapi2001/tls_openssl/tls_openssl_rpc.ba.go +++ b/internal/testbinapi/binapi2001/tls_openssl/tls_openssl_rpc.ba.go @@ -4,10 +4,11 @@ package tls_openssl import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service tls_openssl. +// RPCService defines RPC service tls_openssl. type RPCService interface { TLSOpensslSetEngine(ctx context.Context, in *TLSOpensslSetEngine) (*TLSOpensslSetEngineReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) TLSOpensslSetEngine(ctx context.Context, in *TLSOpensslS if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/trace/trace.ba.go b/internal/testbinapi/binapi2001/trace/trace.ba.go index 210021d..1902e78 100644 --- a/internal/testbinapi/binapi2001/trace/trace.ba.go +++ b/internal/testbinapi/binapi2001/trace/trace.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/trace.api.json diff --git a/internal/testbinapi/binapi2001/trace/trace_rpc.ba.go b/internal/testbinapi/binapi2001/trace/trace_rpc.ba.go index f0f2ca7..e3f1eca 100644 --- a/internal/testbinapi/binapi2001/trace/trace_rpc.ba.go +++ b/internal/testbinapi/binapi2001/trace/trace_rpc.ba.go @@ -4,10 +4,11 @@ package trace import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service trace. +// RPCService defines RPC service trace. type RPCService interface { TraceProfileAdd(ctx context.Context, in *TraceProfileAdd) (*TraceProfileAddReply, error) TraceProfileDel(ctx context.Context, in *TraceProfileDel) (*TraceProfileDelReply, error) @@ -28,7 +29,7 @@ func (c *serviceClient) TraceProfileAdd(ctx context.Context, in *TraceProfileAdd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) TraceProfileDel(ctx context.Context, in *TraceProfileDel) (*TraceProfileDelReply, error) { @@ -37,7 +38,7 @@ func (c *serviceClient) TraceProfileDel(ctx context.Context, in *TraceProfileDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) TraceProfileShowConfig(ctx context.Context, in *TraceProfileShowConfig) (*TraceProfileShowConfigReply, error) { @@ -46,5 +47,5 @@ func (c *serviceClient) TraceProfileShowConfig(ctx context.Context, in *TracePro if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/udp/udp.ba.go b/internal/testbinapi/binapi2001/udp/udp.ba.go index 31cb6ed..6c4dabe 100644 --- a/internal/testbinapi/binapi2001/udp/udp.ba.go +++ b/internal/testbinapi/binapi2001/udp/udp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/udp.api.json @@ -17,11 +17,12 @@ package udp import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -247,12 +248,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -278,12 +282,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -312,12 +319,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -341,6 +351,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -353,8 +367,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -364,12 +379,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -412,18 +430,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -466,18 +488,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -528,6 +554,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -538,13 +565,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -572,8 +602,9 @@ type UDPEncap struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/udp/udp_rpc.ba.go b/internal/testbinapi/binapi2001/udp/udp_rpc.ba.go index 4057867..8c138fb 100644 --- a/internal/testbinapi/binapi2001/udp/udp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/udp/udp_rpc.ba.go @@ -5,12 +5,13 @@ package udp import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service udp. +// RPCService defines RPC service udp. type RPCService interface { UDPEncapAdd(ctx context.Context, in *UDPEncapAdd) (*UDPEncapAddReply, error) UDPEncapDel(ctx context.Context, in *UDPEncapDel) (*UDPEncapDelReply, error) @@ -31,7 +32,7 @@ func (c *serviceClient) UDPEncapAdd(ctx context.Context, in *UDPEncapAdd) (*UDPE if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) UDPEncapDel(ctx context.Context, in *UDPEncapDel) (*UDPEncapDelReply, error) { @@ -40,7 +41,7 @@ func (c *serviceClient) UDPEncapDel(ctx context.Context, in *UDPEncapDel) (*UDPE if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) UDPEncapDump(ctx context.Context, in *UDPEncapDump) (RPCService_UDPEncapDumpClient, error) { @@ -76,6 +77,10 @@ func (c *serviceClient_UDPEncapDumpClient) Recv() (*UDPEncapDetails, error) { case *UDPEncapDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/udp_ping/udp_ping.ba.go b/internal/testbinapi/binapi2001/udp_ping/udp_ping.ba.go index 2b8ccad..6187a67 100644 --- a/internal/testbinapi/binapi2001/udp_ping/udp_ping.ba.go +++ b/internal/testbinapi/binapi2001/udp_ping/udp_ping.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/udp_ping.api.json @@ -17,11 +17,12 @@ package udp_ping import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -247,12 +248,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -278,12 +282,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -312,12 +319,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -341,6 +351,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -353,8 +367,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -364,12 +379,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -412,18 +430,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -466,18 +488,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -528,6 +554,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -538,13 +565,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -562,8 +592,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/udp_ping/udp_ping_rpc.ba.go b/internal/testbinapi/binapi2001/udp_ping/udp_ping_rpc.ba.go index eae0ab4..3b01ff7 100644 --- a/internal/testbinapi/binapi2001/udp_ping/udp_ping_rpc.ba.go +++ b/internal/testbinapi/binapi2001/udp_ping/udp_ping_rpc.ba.go @@ -4,10 +4,11 @@ package udp_ping import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service udp_ping. +// RPCService defines RPC service udp_ping. type RPCService interface { UDPPingAddDel(ctx context.Context, in *UDPPingAddDel) (*UDPPingAddDelReply, error) UDPPingExport(ctx context.Context, in *UDPPingExport) (*UDPPingExportReply, error) @@ -27,7 +28,7 @@ func (c *serviceClient) UDPPingAddDel(ctx context.Context, in *UDPPingAddDel) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) UDPPingExport(ctx context.Context, in *UDPPingExport) (*UDPPingExportReply, error) { @@ -36,5 +37,5 @@ func (c *serviceClient) UDPPingExport(ctx context.Context, in *UDPPingExport) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/vhost_user/vhost_user.ba.go b/internal/testbinapi/binapi2001/vhost_user/vhost_user.ba.go index cd5a64a..a3aa648 100644 --- a/internal/testbinapi/binapi2001/vhost_user/vhost_user.ba.go +++ b/internal/testbinapi/binapi2001/vhost_user/vhost_user.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/vhost_user.api.json @@ -14,10 +14,11 @@ package vhost_user import ( - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -391,15 +392,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { diff --git a/internal/testbinapi/binapi2001/vhost_user/vhost_user_rpc.ba.go b/internal/testbinapi/binapi2001/vhost_user/vhost_user_rpc.ba.go index 91132eb..dcb13ff 100644 --- a/internal/testbinapi/binapi2001/vhost_user/vhost_user_rpc.ba.go +++ b/internal/testbinapi/binapi2001/vhost_user/vhost_user_rpc.ba.go @@ -5,12 +5,13 @@ package vhost_user import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service vhost_user. +// RPCService defines RPC service vhost_user. type RPCService interface { CreateVhostUserIf(ctx context.Context, in *CreateVhostUserIf) (*CreateVhostUserIfReply, error) DeleteVhostUserIf(ctx context.Context, in *DeleteVhostUserIf) (*DeleteVhostUserIfReply, error) @@ -32,7 +33,7 @@ func (c *serviceClient) CreateVhostUserIf(ctx context.Context, in *CreateVhostUs if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) DeleteVhostUserIf(ctx context.Context, in *DeleteVhostUserIf) (*DeleteVhostUserIfReply, error) { @@ -41,7 +42,7 @@ func (c *serviceClient) DeleteVhostUserIf(ctx context.Context, in *DeleteVhostUs if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ModifyVhostUserIf(ctx context.Context, in *ModifyVhostUserIf) (*ModifyVhostUserIfReply, error) { @@ -50,7 +51,7 @@ func (c *serviceClient) ModifyVhostUserIf(ctx context.Context, in *ModifyVhostUs if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) SwInterfaceVhostUserDump(ctx context.Context, in *SwInterfaceVhostUserDump) (RPCService_SwInterfaceVhostUserDumpClient, error) { @@ -86,6 +87,10 @@ func (c *serviceClient_SwInterfaceVhostUserDumpClient) Recv() (*SwInterfaceVhost case *SwInterfaceVhostUserDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/virtio/virtio.ba.go b/internal/testbinapi/binapi2001/virtio/virtio.ba.go index e4b9c08..ad56fd4 100644 --- a/internal/testbinapi/binapi2001/virtio/virtio.ba.go +++ b/internal/testbinapi/binapi2001/virtio/virtio.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/virtio.api.json @@ -15,10 +15,11 @@ package virtio import ( - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -299,15 +300,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { diff --git a/internal/testbinapi/binapi2001/virtio/virtio_rpc.ba.go b/internal/testbinapi/binapi2001/virtio/virtio_rpc.ba.go index 86f86fe..bcb5e21 100644 --- a/internal/testbinapi/binapi2001/virtio/virtio_rpc.ba.go +++ b/internal/testbinapi/binapi2001/virtio/virtio_rpc.ba.go @@ -5,12 +5,13 @@ package virtio import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service virtio. +// RPCService defines RPC service virtio. type RPCService interface { SwInterfaceVirtioPciDump(ctx context.Context, in *SwInterfaceVirtioPciDump) (RPCService_SwInterfaceVirtioPciDumpClient, error) VirtioPciCreate(ctx context.Context, in *VirtioPciCreate) (*VirtioPciCreateReply, error) @@ -58,6 +59,10 @@ func (c *serviceClient_SwInterfaceVirtioPciDumpClient) Recv() (*SwInterfaceVirti case *SwInterfaceVirtioPciDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -70,7 +75,7 @@ func (c *serviceClient) VirtioPciCreate(ctx context.Context, in *VirtioPciCreate if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VirtioPciDelete(ctx context.Context, in *VirtioPciDelete) (*VirtioPciDeleteReply, error) { @@ -79,5 +84,5 @@ func (c *serviceClient) VirtioPciDelete(ctx context.Context, in *VirtioPciDelete if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/virtio_types/virtio_types.ba.go b/internal/testbinapi/binapi2001/virtio_types/virtio_types.ba.go index 3715966..753ee5e 100644 --- a/internal/testbinapi/binapi2001/virtio_types/virtio_types.ba.go +++ b/internal/testbinapi/binapi2001/virtio_types/virtio_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/virtio_types.api.json @@ -12,8 +12,9 @@ package virtio_types import ( - api "git.fd.io/govpp.git/api" "strconv" + + api "git.fd.io/govpp.git/api" ) // This is a compile-time assertion to ensure that this generated file @@ -22,6 +23,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "virtio_types" + APIVersion = "1.0.0" + VersionCrc = 0x7a70a44e +) + // VirtioNetFeaturesFirst32 defines enum 'virtio_net_features_first_32'. type VirtioNetFeaturesFirst32 uint32 diff --git a/internal/testbinapi/binapi2001/vmxnet3/vmxnet3.ba.go b/internal/testbinapi/binapi2001/vmxnet3/vmxnet3.ba.go index 7986818..d048166 100644 --- a/internal/testbinapi/binapi2001/vmxnet3/vmxnet3.ba.go +++ b/internal/testbinapi/binapi2001/vmxnet3/vmxnet3.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/vmxnet3.api.json @@ -15,10 +15,11 @@ package vmxnet3 import ( - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -299,15 +300,19 @@ func ParseMacAddress(s string) (MacAddress, error) { copy(macaddr[:], mac[:]) return macaddr, nil } + func (x MacAddress) ToMAC() net.HardwareAddr { return net.HardwareAddr(x[:]) } + func (x MacAddress) String() string { return x.ToMAC().String() } + func (x *MacAddress) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *MacAddress) UnmarshalText(text []byte) error { mac, err := ParseMacAddress(string(text)) if err != nil { diff --git a/internal/testbinapi/binapi2001/vmxnet3/vmxnet3_rpc.ba.go b/internal/testbinapi/binapi2001/vmxnet3/vmxnet3_rpc.ba.go index 4d072ce..7a85512 100644 --- a/internal/testbinapi/binapi2001/vmxnet3/vmxnet3_rpc.ba.go +++ b/internal/testbinapi/binapi2001/vmxnet3/vmxnet3_rpc.ba.go @@ -5,12 +5,13 @@ package vmxnet3 import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service vmxnet3. +// RPCService defines RPC service vmxnet3. type RPCService interface { Vmxnet3Create(ctx context.Context, in *Vmxnet3Create) (*Vmxnet3CreateReply, error) Vmxnet3Delete(ctx context.Context, in *Vmxnet3Delete) (*Vmxnet3DeleteReply, error) @@ -31,7 +32,7 @@ func (c *serviceClient) Vmxnet3Create(ctx context.Context, in *Vmxnet3Create) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Vmxnet3Delete(ctx context.Context, in *Vmxnet3Delete) (*Vmxnet3DeleteReply, error) { @@ -40,7 +41,7 @@ func (c *serviceClient) Vmxnet3Delete(ctx context.Context, in *Vmxnet3Delete) (* if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Vmxnet3Dump(ctx context.Context, in *Vmxnet3Dump) (RPCService_Vmxnet3DumpClient, error) { @@ -76,6 +77,10 @@ func (c *serviceClient_Vmxnet3DumpClient) Recv() (*Vmxnet3Details, error) { case *Vmxnet3Details: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/vpe/vpe.ba.go b/internal/testbinapi/binapi2001/vpe/vpe.ba.go index f970104..34842fb 100644 --- a/internal/testbinapi/binapi2001/vpe/vpe.ba.go +++ b/internal/testbinapi/binapi2001/vpe/vpe.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/vpe.api.json @@ -15,9 +15,11 @@ package vpe import ( + "strconv" + "time" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file @@ -86,6 +88,37 @@ type Timedelta float64 // Timestamp defines alias 'timestamp'. type Timestamp float64 +func NewTimestamp(t time.Time) Timestamp { + sec := int64(t.Unix()) + nsec := int32(t.Nanosecond()) + ns := float64(sec) + float64(nsec/1e9) + return Timestamp(ns) +} + +func (x Timestamp) ToTime() time.Time { + ns := int64(x * 1e9) + sec := ns / 1e9 + nsec := ns % 1e9 + return time.Unix(sec, nsec) +} + +func (x Timestamp) String() string { + return x.ToTime().String() +} + +func (x *Timestamp) MarshalText() ([]byte, error) { + return []byte(x.ToTime().Format(time.RFC3339Nano)), nil +} + +func (x *Timestamp) UnmarshalText(text []byte) error { + t, err := time.Parse(time.RFC3339Nano, string(text)) + if err != nil { + return err + } + *x = NewTimestamp(t) + return nil +} + // ThreadData defines type 'thread_data'. type ThreadData struct { ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` diff --git a/internal/testbinapi/binapi2001/vpe/vpe_rpc.ba.go b/internal/testbinapi/binapi2001/vpe/vpe_rpc.ba.go index dfa669f..557a397 100644 --- a/internal/testbinapi/binapi2001/vpe/vpe_rpc.ba.go +++ b/internal/testbinapi/binapi2001/vpe/vpe_rpc.ba.go @@ -5,11 +5,12 @@ package vpe import ( "context" "fmt" - api "git.fd.io/govpp.git/api" "io" + + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service vpe. +// RPCService defines RPC service vpe. type RPCService interface { AddNodeNext(ctx context.Context, in *AddNodeNext) (*AddNodeNextReply, error) Cli(ctx context.Context, in *Cli) (*CliReply, error) @@ -40,7 +41,7 @@ func (c *serviceClient) AddNodeNext(ctx context.Context, in *AddNodeNext) (*AddN if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Cli(ctx context.Context, in *Cli) (*CliReply, error) { @@ -49,7 +50,7 @@ func (c *serviceClient) Cli(ctx context.Context, in *Cli) (*CliReply, error) { if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) CliInband(ctx context.Context, in *CliInband) (*CliInbandReply, error) { @@ -58,7 +59,7 @@ func (c *serviceClient) CliInband(ctx context.Context, in *CliInband) (*CliInban if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ControlPing(ctx context.Context, in *ControlPing) (*ControlPingReply, error) { @@ -67,7 +68,7 @@ func (c *serviceClient) ControlPing(ctx context.Context, in *ControlPing) (*Cont if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GetF64EndianValue(ctx context.Context, in *GetF64EndianValue) (*GetF64EndianValueReply, error) { @@ -76,7 +77,7 @@ func (c *serviceClient) GetF64EndianValue(ctx context.Context, in *GetF64EndianV if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(int32(out.Retval)) } func (c *serviceClient) GetF64IncrementByOne(ctx context.Context, in *GetF64IncrementByOne) (*GetF64IncrementByOneReply, error) { @@ -85,7 +86,7 @@ func (c *serviceClient) GetF64IncrementByOne(ctx context.Context, in *GetF64Incr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(int32(out.Retval)) } func (c *serviceClient) GetNextIndex(ctx context.Context, in *GetNextIndex) (*GetNextIndexReply, error) { @@ -94,7 +95,7 @@ func (c *serviceClient) GetNextIndex(ctx context.Context, in *GetNextIndex) (*Ge if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GetNodeGraph(ctx context.Context, in *GetNodeGraph) (*GetNodeGraphReply, error) { @@ -103,7 +104,7 @@ func (c *serviceClient) GetNodeGraph(ctx context.Context, in *GetNodeGraph) (*Ge if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GetNodeIndex(ctx context.Context, in *GetNodeIndex) (*GetNodeIndexReply, error) { @@ -112,7 +113,7 @@ func (c *serviceClient) GetNodeIndex(ctx context.Context, in *GetNodeIndex) (*Ge if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) LogDump(ctx context.Context, in *LogDump) (RPCService_LogDumpClient, error) { @@ -148,6 +149,10 @@ func (c *serviceClient_LogDumpClient) Recv() (*LogDetails, error) { case *LogDetails: return m, nil case *ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) @@ -160,7 +165,7 @@ func (c *serviceClient) ShowThreads(ctx context.Context, in *ShowThreads) (*Show if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowVersion(ctx context.Context, in *ShowVersion) (*ShowVersionReply, error) { @@ -169,7 +174,7 @@ func (c *serviceClient) ShowVersion(ctx context.Context, in *ShowVersion) (*Show if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ShowVpeSystemTime(ctx context.Context, in *ShowVpeSystemTime) (*ShowVpeSystemTimeReply, error) { @@ -178,5 +183,5 @@ func (c *serviceClient) ShowVpeSystemTime(ctx context.Context, in *ShowVpeSystem if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } diff --git a/internal/testbinapi/binapi2001/vpe_types/vpe_types.ba.go b/internal/testbinapi/binapi2001/vpe_types/vpe_types.ba.go index 280005e..140995d 100644 --- a/internal/testbinapi/binapi2001/vpe_types/vpe_types.ba.go +++ b/internal/testbinapi/binapi2001/vpe_types/vpe_types.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/vpe_types.api.json @@ -14,8 +14,10 @@ package vpe_types import ( - api "git.fd.io/govpp.git/api" "strconv" + "time" + + api "git.fd.io/govpp.git/api" ) // This is a compile-time assertion to ensure that this generated file @@ -24,6 +26,12 @@ import ( // GoVPP api package needs to be updated. const _ = api.GoVppAPIPackageIsVersion2 +const ( + APIFile = "vpe_types" + APIVersion = "" + VersionCrc = 0x3369988d +) + // LogLevel defines enum 'log_level'. type LogLevel uint32 @@ -78,6 +86,37 @@ type Timedelta float64 // Timestamp defines alias 'timestamp'. type Timestamp float64 +func NewTimestamp(t time.Time) Timestamp { + sec := int64(t.Unix()) + nsec := int32(t.Nanosecond()) + ns := float64(sec) + float64(nsec/1e9) + return Timestamp(ns) +} + +func (x Timestamp) ToTime() time.Time { + ns := int64(x * 1e9) + sec := ns / 1e9 + nsec := ns % 1e9 + return time.Unix(sec, nsec) +} + +func (x Timestamp) String() string { + return x.ToTime().String() +} + +func (x *Timestamp) MarshalText() ([]byte, error) { + return []byte(x.ToTime().Format(time.RFC3339Nano)), nil +} + +func (x *Timestamp) UnmarshalText(text []byte) error { + t, err := time.Parse(time.RFC3339Nano, string(text)) + if err != nil { + return err + } + *x = NewTimestamp(t) + return nil +} + // Version defines type 'version'. type Version struct { Major uint32 `binapi:"u32,name=major" json:"major,omitempty"` diff --git a/internal/testbinapi/binapi2001/vxlan/vxlan.ba.go b/internal/testbinapi/binapi2001/vxlan/vxlan.ba.go index 04a9541..b3582c9 100644 --- a/internal/testbinapi/binapi2001/vxlan/vxlan.ba.go +++ b/internal/testbinapi/binapi2001/vxlan/vxlan.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/vxlan.api.json diff --git a/internal/testbinapi/binapi2001/vxlan/vxlan_rpc.ba.go b/internal/testbinapi/binapi2001/vxlan/vxlan_rpc.ba.go index 0d56593..a80b8b6 100644 --- a/internal/testbinapi/binapi2001/vxlan/vxlan_rpc.ba.go +++ b/internal/testbinapi/binapi2001/vxlan/vxlan_rpc.ba.go @@ -5,12 +5,13 @@ package vxlan import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service vxlan. +// RPCService defines RPC service vxlan. type RPCService interface { SwInterfaceSetVxlanBypass(ctx context.Context, in *SwInterfaceSetVxlanBypass) (*SwInterfaceSetVxlanBypassReply, error) VxlanAddDelTunnel(ctx context.Context, in *VxlanAddDelTunnel) (*VxlanAddDelTunnelReply, error) @@ -32,7 +33,7 @@ func (c *serviceClient) SwInterfaceSetVxlanBypass(ctx context.Context, in *SwInt if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanAddDelTunnel(ctx context.Context, in *VxlanAddDelTunnel) (*VxlanAddDelTunnelReply, error) { @@ -41,7 +42,7 @@ func (c *serviceClient) VxlanAddDelTunnel(ctx context.Context, in *VxlanAddDelTu if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanOffloadRx(ctx context.Context, in *VxlanOffloadRx) (*VxlanOffloadRxReply, error) { @@ -50,7 +51,7 @@ func (c *serviceClient) VxlanOffloadRx(ctx context.Context, in *VxlanOffloadRx) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanTunnelDump(ctx context.Context, in *VxlanTunnelDump) (RPCService_VxlanTunnelDumpClient, error) { @@ -86,6 +87,10 @@ func (c *serviceClient_VxlanTunnelDumpClient) Recv() (*VxlanTunnelDetails, error case *VxlanTunnelDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/vxlan_gbp/vxlan_gbp.ba.go b/internal/testbinapi/binapi2001/vxlan_gbp/vxlan_gbp.ba.go index 85fc2c8..a28a882 100644 --- a/internal/testbinapi/binapi2001/vxlan_gbp/vxlan_gbp.ba.go +++ b/internal/testbinapi/binapi2001/vxlan_gbp/vxlan_gbp.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/vxlan_gbp.api.json @@ -17,11 +17,12 @@ package vxlan_gbp import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -525,12 +526,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -559,12 +563,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -593,12 +600,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -622,6 +632,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -634,8 +648,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -645,12 +660,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -693,18 +711,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -747,18 +769,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -809,6 +835,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -819,13 +846,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -855,8 +885,9 @@ type VxlanGbpTunnel struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/vxlan_gbp/vxlan_gbp_rpc.ba.go b/internal/testbinapi/binapi2001/vxlan_gbp/vxlan_gbp_rpc.ba.go index e2ec338..c975099 100644 --- a/internal/testbinapi/binapi2001/vxlan_gbp/vxlan_gbp_rpc.ba.go +++ b/internal/testbinapi/binapi2001/vxlan_gbp/vxlan_gbp_rpc.ba.go @@ -5,12 +5,13 @@ package vxlan_gbp import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service vxlan_gbp. +// RPCService defines RPC service vxlan_gbp. type RPCService interface { SwInterfaceSetVxlanGbpBypass(ctx context.Context, in *SwInterfaceSetVxlanGbpBypass) (*SwInterfaceSetVxlanGbpBypassReply, error) VxlanGbpTunnelAddDel(ctx context.Context, in *VxlanGbpTunnelAddDel) (*VxlanGbpTunnelAddDelReply, error) @@ -31,7 +32,7 @@ func (c *serviceClient) SwInterfaceSetVxlanGbpBypass(ctx context.Context, in *Sw if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanGbpTunnelAddDel(ctx context.Context, in *VxlanGbpTunnelAddDel) (*VxlanGbpTunnelAddDelReply, error) { @@ -40,7 +41,7 @@ func (c *serviceClient) VxlanGbpTunnelAddDel(ctx context.Context, in *VxlanGbpTu if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanGbpTunnelDump(ctx context.Context, in *VxlanGbpTunnelDump) (RPCService_VxlanGbpTunnelDumpClient, error) { @@ -76,6 +77,10 @@ func (c *serviceClient_VxlanGbpTunnelDumpClient) Recv() (*VxlanGbpTunnelDetails, case *VxlanGbpTunnelDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/vxlan_gpe/vxlan_gpe.ba.go b/internal/testbinapi/binapi2001/vxlan_gpe/vxlan_gpe.ba.go index 105fa77..f9c4d11 100644 --- a/internal/testbinapi/binapi2001/vxlan_gpe/vxlan_gpe.ba.go +++ b/internal/testbinapi/binapi2001/vxlan_gpe/vxlan_gpe.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/vxlan_gpe.api.json diff --git a/internal/testbinapi/binapi2001/vxlan_gpe/vxlan_gpe_rpc.ba.go b/internal/testbinapi/binapi2001/vxlan_gpe/vxlan_gpe_rpc.ba.go index 3cb05d5..8c3f496 100644 --- a/internal/testbinapi/binapi2001/vxlan_gpe/vxlan_gpe_rpc.ba.go +++ b/internal/testbinapi/binapi2001/vxlan_gpe/vxlan_gpe_rpc.ba.go @@ -5,12 +5,13 @@ package vxlan_gpe import ( "context" "fmt" + "io" + api "git.fd.io/govpp.git/api" vpe "git.fd.io/govpp.git/internal/testbinapi/binapi2001/vpe" - "io" ) -// RPCService defines RPC service vxlan_gpe. +// RPCService defines RPC service vxlan_gpe. type RPCService interface { SwInterfaceSetVxlanGpeBypass(ctx context.Context, in *SwInterfaceSetVxlanGpeBypass) (*SwInterfaceSetVxlanGpeBypassReply, error) VxlanGpeAddDelTunnel(ctx context.Context, in *VxlanGpeAddDelTunnel) (*VxlanGpeAddDelTunnelReply, error) @@ -31,7 +32,7 @@ func (c *serviceClient) SwInterfaceSetVxlanGpeBypass(ctx context.Context, in *Sw if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanGpeAddDelTunnel(ctx context.Context, in *VxlanGpeAddDelTunnel) (*VxlanGpeAddDelTunnelReply, error) { @@ -40,7 +41,7 @@ func (c *serviceClient) VxlanGpeAddDelTunnel(ctx context.Context, in *VxlanGpeAd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) VxlanGpeTunnelDump(ctx context.Context, in *VxlanGpeTunnelDump) (RPCService_VxlanGpeTunnelDumpClient, error) { @@ -76,6 +77,10 @@ func (c *serviceClient_VxlanGpeTunnelDumpClient) Recv() (*VxlanGpeTunnelDetails, case *VxlanGpeTunnelDetails: return m, nil case *vpe.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } return nil, io.EOF default: return nil, fmt.Errorf("unexpected message: %T %v", m, m) diff --git a/internal/testbinapi/binapi2001/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export.ba.go b/internal/testbinapi/binapi2001/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export.ba.go index a70fdd1..e9c81c1 100644 --- a/internal/testbinapi/binapi2001/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export.ba.go +++ b/internal/testbinapi/binapi2001/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/plugins/vxlan_gpe_ioam_export.api.json @@ -17,11 +17,12 @@ package vxlan_gpe_ioam_export import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -247,12 +248,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } 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 { @@ -278,12 +282,15 @@ func ParseIP4Address(s string) (IP4Address, error) { 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 { @@ -312,12 +319,15 @@ func ParseIP6Address(s string) (IP6Address, error) { 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 { @@ -341,6 +351,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -353,8 +367,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -364,12 +379,15 @@ func (x Address) ToIP() net.IP { 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 { @@ -412,18 +430,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } 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 { @@ -466,18 +488,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } 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 { @@ -528,6 +554,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -538,13 +565,16 @@ func (x Prefix) ToIPNet() *net.IPNet { 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 { @@ -562,8 +592,9 @@ type PrefixMatcher struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } diff --git a/internal/testbinapi/binapi2001/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export_rpc.ba.go b/internal/testbinapi/binapi2001/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export_rpc.ba.go index ce35b62..f688803 100644 --- a/internal/testbinapi/binapi2001/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export_rpc.ba.go +++ b/internal/testbinapi/binapi2001/vxlan_gpe_ioam_export/vxlan_gpe_ioam_export_rpc.ba.go @@ -4,10 +4,11 @@ package vxlan_gpe_ioam_export import ( "context" + api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service vxlan_gpe_ioam_export. +// RPCService defines RPC service vxlan_gpe_ioam_export. type RPCService interface { VxlanGpeIoamExportEnableDisable(ctx context.Context, in *VxlanGpeIoamExportEnableDisable) (*VxlanGpeIoamExportEnableDisableReply, error) } @@ -26,5 +27,5 @@ func (c *serviceClient) VxlanGpeIoamExportEnableDisable(ctx context.Context, in if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } |