• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef NET_CONN_SERVICE_PROXY_H
17 #define NET_CONN_SERVICE_PROXY_H
18 
19 #include "iremote_proxy.h"
20 
21 #include "i_net_conn_service.h"
22 
23 namespace OHOS {
24 namespace NetManagerStandard {
25 class NetConnServiceProxy : public IRemoteProxy<INetConnService> {
26 public:
27     explicit NetConnServiceProxy(const sptr<IRemoteObject> &impl);
28     virtual ~NetConnServiceProxy();
29     int32_t SystemReady() override;
30     int32_t SetInternetPermission(uint32_t uid, uint8_t allow) override;
31     int32_t EnableVnicNetwork(const sptr<NetLinkInfo> &netLinkInfo, const std::set<int32_t> &uids) override;
32     int32_t DisableVnicNetwork() override;
33     int32_t EnableDistributedClientNet(const std::string &virnicAddr, const std::string &iif) override;
34     int32_t EnableDistributedServerNet(const std::string &iif, const std::string &devIface,
35                                        const std::string &dstAddr) override;
36     int32_t DisableDistributedNet(bool isServer) override;
37     int32_t RegisterNetSupplier(NetBearType bearerType, const std::string &ident, const std::set<NetCap> &netCaps,
38                                 uint32_t &supplierId) override;
39     int32_t UnregisterNetSupplier(uint32_t supplierId) override;
40     int32_t RegisterNetSupplierCallback(uint32_t supplierId, const sptr<INetSupplierCallback> &callback) override;
41     int32_t RegisterNetConnCallback(const sptr<INetConnCallback> callback) override;
42     int32_t RegisterNetConnCallback(const sptr<NetSpecifier> &netSpecifier, const sptr<INetConnCallback> callback,
43                                     const uint32_t &timeoutMS) override;
44     int32_t RequestNetConnection(const sptr<NetSpecifier> netSpecifier, const sptr<INetConnCallback> callback,
45                                     const uint32_t timeoutMS) override;
46     int32_t UnregisterNetConnCallback(const sptr<INetConnCallback> &callback) override;
47     int32_t UpdateNetCaps(const std::set<NetCap> &netCaps, const uint32_t supplierId) override;
48     int32_t UpdateNetStateForTest(const sptr<NetSpecifier> &netSpecifier, int32_t netState) override;
49     int32_t UpdateNetSupplierInfo(uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo) override;
50     int32_t UpdateNetLinkInfo(uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo) override;
51     int32_t GetDefaultNet(int32_t &netId) override;
52     int32_t HasDefaultNet(bool &flag) override;
53     int32_t GetIfaceNames(NetBearType bearerType, std::list<std::string> &ifaceNames) override;
54     int32_t GetIfaceNameByType(NetBearType bearerType, const std::string &ident, std::string &ifaceName) override;
55     int32_t GetIfaceNameIdentMaps(NetBearType bearerType,
56                                   SafeMap<std::string, std::string> &ifaceNameIdentMaps) override;
57     int32_t RegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) override;
58     int32_t UnRegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) override;
59     int32_t NetDetection(int32_t netId) override;
60     int32_t GetAddressesByName(const std::string &host, int32_t netId, std::vector<INetAddr> &addrList) override;
61     int32_t GetAddressByName(const std::string &host, int32_t netId, INetAddr &addr) override;
62     int32_t GetSpecificNet(NetBearType bearerType, std::list<int32_t> &netIdList) override;
63     int32_t GetSpecificNetByIdent(NetBearType bearerType, const std::string &ident,
64                                   std::list<int32_t> &netIdList) override;
65     int32_t GetAllNets(std::list<int32_t> &netIdList) override;
66     int32_t GetSpecificUidNet(int32_t uid, int32_t &netId) override;
67     int32_t GetConnectionProperties(int32_t netId, NetLinkInfo &info) override;
68     int32_t GetNetCapabilities(int32_t netId, NetAllCapabilities &netAllCap) override;
69     int32_t BindSocket(int32_t socketFd, int32_t netId) override;
70     int32_t SetAirplaneMode(bool state) override;
71     int32_t IsDefaultNetMetered(bool &isMetered) override;
72     int32_t SetGlobalHttpProxy(const HttpProxy &httpProxy) override;
73     int32_t GetGlobalHttpProxy(HttpProxy &httpProxy) override;
74     int32_t GetDefaultHttpProxy(int32_t bindNetId, HttpProxy &httpProxy) override;
75     int32_t GetNetIdByIdentifier(const std::string &ident, std::list<int32_t> &netIdList) override;
76     int32_t SetAppNet(int32_t netId) override;
77     int32_t RegisterNetInterfaceCallback(const sptr<INetInterfaceStateCallback> &callback) override;
78     int32_t UnregisterNetInterfaceCallback(const sptr<INetInterfaceStateCallback> &callback) override;
79     int32_t GetNetInterfaceConfiguration(const std::string &iface, NetInterfaceConfiguration &config) override;
80     int32_t SetNetInterfaceIpAddress(const std::string &iface, const std::string &ipAddress) override;
81     int32_t SetInterfaceUp(const std::string &iface) override;
82     int32_t SetInterfaceDown(const std::string &iface) override;
83     int32_t AddNetworkRoute(int32_t netId, const std::string &ifName, const std::string &destination,
84                             const std::string &nextHop) override;
85     int32_t RemoveNetworkRoute(int32_t netId, const std::string &ifName, const std::string &destination,
86                                const std::string &nextHop) override;
87     int32_t AddInterfaceAddress(const std::string &ifName, const std::string &ipAddr,
88                                 int32_t prefixLength) override;
89     int32_t DelInterfaceAddress(const std::string &ifName, const std::string &ipAddr,
90                                 int32_t prefixLength) override;
91     int32_t AddStaticArp(const std::string &ipAddr, const std::string &macAddr, const std::string &ifName) override;
92     int32_t DelStaticArp(const std::string &ipAddr, const std::string &macAddr, const std::string &ifName) override;
93     int32_t RegisterSlotType(uint32_t supplierId, int32_t type) override;
94     int32_t GetSlotType(std::string &type) override;
95     int32_t FactoryResetNetwork() override;
96     int32_t RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> &callback) override;
97     int32_t IsPreferCellularUrl(const std::string& url, bool& preferCellular) override;
98     int32_t RegisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback) override;
99     int32_t UnregisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback) override;
100     int32_t GetDefaultSupplierId(NetBearType bearerType, const std::string &ident,
101         uint32_t& supplierId) override;
102     int32_t UpdateSupplierScore(uint32_t supplierId, uint32_t detectionStatus) override;
103     int32_t CloseSocketsUid(int32_t netId, uint32_t uid) override;
104     int32_t SetPacUrl(const std::string &pacUrl) override;
105     int32_t GetPacUrl(std::string &pacUrl) override;
106     int32_t SetPacFileUrl(const std::string &pacUrl) override;
107     int32_t SetProxyMode(const OHOS::NetManagerStandard::ProxyModeType mode) override;
108     int32_t GetProxyMode(OHOS::NetManagerStandard::ProxyModeType &mode) override;
109     int32_t GetPacFileUrl(std::string &pacUrl) override;
110     int32_t FindProxyForURL(const std::string &url, const std::string &host, std::string &proxy) override;
111     int32_t QueryTraceRoute(const std::string &destination, int32_t maxJumpNumber, int32_t packetsType,
112         std::string &traceRouteInfo) override;
113     virtual int32_t SetAppIsFrozened(uint32_t uid, bool isFrozened) override;
114     virtual int32_t EnableAppFrozenedCallbackLimitation(bool flag) override;
115     int32_t SetReuseSupplierId(uint32_t supplierId, uint32_t reuseSupplierId, bool isReused) override;
116     int32_t GetNetExtAttribute(int32_t netId, std::string &netExtAttribute) override;
117     int32_t SetNetExtAttribute(int32_t netId, const std::string &netExtAttribute) override;
118     int32_t AddStaticIpv6Addr(const std::string &ipv6Addr, const std::string &macAddr,
119         const std::string &ifName) override;
120     int32_t DelStaticIpv6Addr(const std::string &ipv6Addr, const std::string &macAddr,
121         const std::string &ifName) override;
122 private:
123     bool WriteInterfaceToken(MessageParcel &data);
124     int32_t GetNetCapData(MessageParcel &reply, NetAllCapabilities &netAllCap);
125     int32_t RemoteSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply);
126 
127 private:
128     static inline BrokerDelegator<NetConnServiceProxy> delegator_;
129 };
130 } // namespace NetManagerStandard
131 } // namespace OHOS
132 #endif // NET_CONN_SERVICE_PROXY_H
133