9fb250a145c011cc11382e38a76ff2ca29afc5bf
[govpp.git] / binapi / l2tp / l2tp_rpc.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package l2tp
4
5 import (
6         "context"
7         "fmt"
8         api "git.fd.io/govpp.git/api"
9         vpe "git.fd.io/govpp.git/binapi/vpe"
10         "io"
11 )
12
13 // RPCService defines RPC service  l2tp.
14 type RPCService interface {
15         L2tpv3CreateTunnel(ctx context.Context, in *L2tpv3CreateTunnel) (*L2tpv3CreateTunnelReply, error)
16         L2tpv3InterfaceEnableDisable(ctx context.Context, in *L2tpv3InterfaceEnableDisable) (*L2tpv3InterfaceEnableDisableReply, error)
17         L2tpv3SetLookupKey(ctx context.Context, in *L2tpv3SetLookupKey) (*L2tpv3SetLookupKeyReply, error)
18         L2tpv3SetTunnelCookies(ctx context.Context, in *L2tpv3SetTunnelCookies) (*L2tpv3SetTunnelCookiesReply, error)
19         SwIfL2tpv3TunnelDump(ctx context.Context, in *SwIfL2tpv3TunnelDump) (RPCService_SwIfL2tpv3TunnelDumpClient, error)
20 }
21
22 type serviceClient struct {
23         conn api.Connection
24 }
25
26 func NewServiceClient(conn api.Connection) RPCService {
27         return &serviceClient{conn}
28 }
29
30 func (c *serviceClient) L2tpv3CreateTunnel(ctx context.Context, in *L2tpv3CreateTunnel) (*L2tpv3CreateTunnelReply, error) {
31         out := new(L2tpv3CreateTunnelReply)
32         err := c.conn.Invoke(ctx, in, out)
33         if err != nil {
34                 return nil, err
35         }
36         return out, nil
37 }
38
39 func (c *serviceClient) L2tpv3InterfaceEnableDisable(ctx context.Context, in *L2tpv3InterfaceEnableDisable) (*L2tpv3InterfaceEnableDisableReply, error) {
40         out := new(L2tpv3InterfaceEnableDisableReply)
41         err := c.conn.Invoke(ctx, in, out)
42         if err != nil {
43                 return nil, err
44         }
45         return out, nil
46 }
47
48 func (c *serviceClient) L2tpv3SetLookupKey(ctx context.Context, in *L2tpv3SetLookupKey) (*L2tpv3SetLookupKeyReply, error) {
49         out := new(L2tpv3SetLookupKeyReply)
50         err := c.conn.Invoke(ctx, in, out)
51         if err != nil {
52                 return nil, err
53         }
54         return out, nil
55 }
56
57 func (c *serviceClient) L2tpv3SetTunnelCookies(ctx context.Context, in *L2tpv3SetTunnelCookies) (*L2tpv3SetTunnelCookiesReply, error) {
58         out := new(L2tpv3SetTunnelCookiesReply)
59         err := c.conn.Invoke(ctx, in, out)
60         if err != nil {
61                 return nil, err
62         }
63         return out, nil
64 }
65
66 func (c *serviceClient) SwIfL2tpv3TunnelDump(ctx context.Context, in *SwIfL2tpv3TunnelDump) (RPCService_SwIfL2tpv3TunnelDumpClient, error) {
67         stream, err := c.conn.NewStream(ctx)
68         if err != nil {
69                 return nil, err
70         }
71         x := &serviceClient_SwIfL2tpv3TunnelDumpClient{stream}
72         if err := x.Stream.SendMsg(in); err != nil {
73                 return nil, err
74         }
75         if err = x.Stream.SendMsg(&vpe.ControlPing{}); err != nil {
76                 return nil, err
77         }
78         return x, nil
79 }
80
81 type RPCService_SwIfL2tpv3TunnelDumpClient interface {
82         Recv() (*SwIfL2tpv3TunnelDetails, error)
83         api.Stream
84 }
85
86 type serviceClient_SwIfL2tpv3TunnelDumpClient struct {
87         api.Stream
88 }
89
90 func (c *serviceClient_SwIfL2tpv3TunnelDumpClient) Recv() (*SwIfL2tpv3TunnelDetails, error) {
91         msg, err := c.Stream.RecvMsg()
92         if err != nil {
93                 return nil, err
94         }
95         switch m := msg.(type) {
96         case *SwIfL2tpv3TunnelDetails:
97                 return m, nil
98         case *vpe.ControlPingReply:
99                 return nil, io.EOF
100         default:
101                 return nil, fmt.Errorf("unexpected message: %T %v", m, m)
102         }
103 }