• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #pragma once
17 
18 #include <aidl/android/system/net/netd/BnNetd.h>
19 
20 namespace android {
21 namespace net {
22 namespace aidl {
23 using NetdHw = ::aidl::android::system::net::netd::BnNetd;
24 using OemNetwork = ::aidl::android::system::net::netd::INetd::OemNetwork;
25 using ScopedAStatus = ::ndk::ScopedAStatus;
26 
27 class NetdHwAidlService : public NetdHw {
28   public:
29     // Start and run the AIDL service.
30     // This blocks when joining the threadpool so start this in a separate thread.
31     static void run();
32     ScopedAStatus createOemNetwork(OemNetwork* network) override;
33     ScopedAStatus destroyOemNetwork(int64_t netHandle) override;
34     ScopedAStatus addRouteToOemNetwork(int64_t networkHandle, const std::string& ifname,
35                                        const std::string& destination,
36                                        const std::string& nexthop) override;
37     ScopedAStatus removeRouteFromOemNetwork(int64_t networkHandle, const std::string& ifname,
38                                             const std::string& destination,
39                                             const std::string& nexthop) override;
40     ScopedAStatus addInterfaceToOemNetwork(int64_t networkHandle,
41                                            const std::string& ifname) override;
42     ScopedAStatus removeInterfaceFromOemNetwork(int64_t networkHandle,
43                                                 const std::string& ifname) override;
44     ScopedAStatus setIpForwardEnable(bool enable) override;
45     ScopedAStatus setForwardingBetweenInterfaces(const std::string& inputIfName,
46                                                  const std::string& outputIfName,
47                                                  bool enable) override;
48 };
49 
50 }  // namespace aidl
51 }  // namespace net
52 }  // namespace android
53