1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef COMMON_LIBS_NET_NETLINK_CLIENT_H_
17 #define COMMON_LIBS_NET_NETLINK_CLIENT_H_
18 
19 #include <memory>
20 
21 #include "common/libs/net/netlink_request.h"
22 
23 namespace cuttlefish {
24 
25 // Abstraction of Netlink client class.
26 class NetlinkClient {
27  public:
NetlinkClient()28   NetlinkClient() {}
~NetlinkClient()29   virtual ~NetlinkClient() {}
30 
31   // Send netlink message to kernel.
32   virtual bool Send(const NetlinkRequest& message) = 0;
33 
34  private:
35   NetlinkClient(const NetlinkClient&);
36   NetlinkClient& operator= (const NetlinkClient&);
37 };
38 
39 class NetlinkClientFactory {
40  public:
41   // Create new NetlinkClient instance of a specified type.
42   // type can be any of the NETLINK_* types (eg. NETLINK_ROUTE).
43   virtual std::unique_ptr<NetlinkClient> New(int type) = 0;
44 
45   static NetlinkClientFactory* Default();
46 
47  protected:
48   NetlinkClientFactory() = default;
49   virtual ~NetlinkClientFactory() = default;
50 };
51 
52 }  // namespace cuttlefish
53 
54 #endif  // COMMON_LIBS_NET_NETLINK_CLIENT_H_
55