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 I_NET_CONN_SERVICE_H 17 #define I_NET_CONN_SERVICE_H 18 19 #include <string> 20 21 #include "iremote_broker.h" 22 23 #include "http_proxy.h" 24 #include "i_net_conn_callback.h" 25 #include "i_net_detection_callback.h" 26 #include "i_net_interface_callback.h" 27 #include "i_net_supplier_callback.h" 28 #include "i_net_factoryreset_callback.h" 29 30 #include "net_conn_constants.h" 31 #include "net_interface_config.h" 32 #include "net_link_info.h" 33 #include "net_specifier.h" 34 #include "net_supplier_info.h" 35 #include "conn_ipc_interface_code.h" 36 #include "safe_map.h" 37 38 namespace OHOS { 39 namespace NetManagerStandard { 40 class INetConnService : public IRemoteBroker { 41 public: 42 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.NetManagerStandard.INetConnService"); 43 44 public: 45 virtual int32_t SystemReady() = 0; 46 virtual int32_t SetInternetPermission(uint32_t uid, uint8_t allow) = 0; 47 virtual int32_t RegisterNetSupplier(NetBearType bearerType, const std::string &ident, 48 const std::set<NetCap> &netCaps, uint32_t &supplierId) = 0; 49 virtual int32_t UnregisterNetSupplier(uint32_t supplierId) = 0; 50 virtual int32_t RegisterNetSupplierCallback(uint32_t supplierId, const sptr<INetSupplierCallback> &callback) = 0; 51 virtual int32_t RegisterNetConnCallback(const sptr<INetConnCallback> callback) = 0; 52 virtual int32_t RegisterNetConnCallback(const sptr<NetSpecifier> &netSpecifier, 53 const sptr<INetConnCallback> callback, const uint32_t &timeoutMS) = 0; 54 virtual int32_t RequestNetConnection(const sptr<NetSpecifier> netSpecifier, 55 const sptr<INetConnCallback> callback, const uint32_t timeoutMS) = 0; 56 virtual int32_t UnregisterNetConnCallback(const sptr<INetConnCallback> &callback) = 0; 57 virtual int32_t UpdateNetStateForTest(const sptr<NetSpecifier> &netSpecifier, int32_t netState) = 0; 58 virtual int32_t UpdateNetSupplierInfo(uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo) = 0; 59 virtual int32_t UpdateNetLinkInfo(uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo) = 0; 60 virtual int32_t GetIfaceNames(NetBearType bearerType, std::list<std::string> &ifaceNames) = 0; 61 virtual int32_t GetIfaceNameByType(NetBearType bearerType, const std::string &ident, std::string &ifaceName) = 0; 62 virtual int32_t GetIfaceNameIdentMaps(NetBearType bearerType, 63 SafeMap<std::string, std::string> &ifaceNameIdentMaps) = 0; 64 virtual int32_t RegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) = 0; 65 virtual int32_t UnRegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) = 0; 66 virtual int32_t NetDetection(int32_t netId) = 0; 67 virtual int32_t GetDefaultNet(int32_t &netId) = 0; 68 virtual int32_t HasDefaultNet(bool &flag) = 0; 69 virtual int32_t GetAddressesByName(const std::string &host, int32_t netId, std::vector<INetAddr> &addrList) = 0; 70 virtual int32_t GetAddressByName(const std::string &host, int32_t netId, INetAddr &addr) = 0; 71 virtual int32_t GetSpecificNet(NetBearType bearerType, std::list<int32_t> &netIdList) = 0; 72 virtual int32_t GetAllNets(std::list<int32_t> &netIdList) = 0; 73 virtual int32_t GetSpecificUidNet(int32_t uid, int32_t &netId) = 0; 74 virtual int32_t GetConnectionProperties(int32_t netId, NetLinkInfo &info) = 0; 75 virtual int32_t GetNetCapabilities(int32_t netId, NetAllCapabilities &netAllCap) = 0; 76 virtual int32_t BindSocket(int32_t socketFd, int32_t netId) = 0; 77 virtual int32_t SetAirplaneMode(bool state) = 0; 78 virtual int32_t IsDefaultNetMetered(bool &isMetered) = 0; 79 virtual int32_t SetGlobalHttpProxy(const HttpProxy &httpProxy) = 0; 80 virtual int32_t GetGlobalHttpProxy(HttpProxy &httpProxy) = 0; 81 virtual int32_t GetDefaultHttpProxy(int32_t bindNetId, HttpProxy &httpProxy) = 0; 82 virtual int32_t GetNetIdByIdentifier(const std::string &ident, std::list<int32_t> &netIdList) = 0; 83 virtual int32_t SetAppNet(int32_t netId) = 0; 84 virtual int32_t RegisterNetInterfaceCallback(const sptr<INetInterfaceStateCallback> &callback) = 0; 85 virtual int32_t GetNetInterfaceConfiguration(const std::string &iface, NetInterfaceConfiguration &config) = 0; 86 virtual int32_t AddNetworkRoute(int32_t netId, const std::string &ifName, 87 const std::string &destination, const std::string &nextHop) = 0; 88 virtual int32_t RemoveNetworkRoute(int32_t netId, const std::string &ifName, 89 const std::string &destination, const std::string &nextHop) = 0; 90 virtual int32_t AddInterfaceAddress(const std::string &ifName, const std::string &ipAddr, 91 int32_t prefixLength) = 0; 92 virtual int32_t DelInterfaceAddress(const std::string &ifName, const std::string &ipAddr, 93 int32_t prefixLength) = 0; 94 virtual int32_t AddStaticArp(const std::string &ipAddr, const std::string &macAddr, 95 const std::string &ifName) = 0; 96 virtual int32_t DelStaticArp(const std::string &ipAddr, const std::string &macAddr, 97 const std::string &ifName) = 0; 98 virtual int32_t RegisterSlotType(uint32_t supplierId, int32_t type) = 0; 99 virtual int32_t GetSlotType(std::string &type) = 0; 100 101 virtual int32_t FactoryResetNetwork() = 0; 102 virtual int32_t RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> &callback) = 0; 103 virtual int32_t IsPreferCellularUrl(const std::string& url, bool& preferCellular) = 0; 104 virtual int32_t RegisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback) = 0; 105 virtual int32_t UnregisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback) = 0; 106 virtual int32_t UpdateSupplierScore(NetBearType bearerType, uint32_t detectionStatus, uint32_t& supplierId) = 0; 107 virtual int32_t EnableVnicNetwork(const sptr<NetLinkInfo> &netLinkInfo, const std::set<int32_t> &uids) = 0; 108 virtual int32_t DisableVnicNetwork() = 0; 109 }; 110 } // namespace NetManagerStandard 111 } // namespace OHOS 112 #endif // I_NET_CONN_SERVICE_H 113