1 /* 2 * Copyright (c) 2021 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 "i_net_conn_callback.h" 24 #include "i_net_supplier_callback.h" 25 #include "i_net_detection_callback.h" 26 #include "net_conn_constants.h" 27 #include "net_link_info.h" 28 #include "net_supplier_info.h" 29 #include "net_specifier.h" 30 #include "http_proxy.h" 31 32 namespace OHOS { 33 namespace NetManagerStandard { 34 class INetConnService : public IRemoteBroker { 35 public: 36 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.NetManagerStandard.INetConnService"); 37 enum { 38 CMD_NM_START, 39 CMD_NM_REGISTER_NET_SUPPLIER, 40 CMD_NM_SYSTEM_READY, 41 CMD_NM_REGISTER_NET_CONN_CALLBACK, 42 CMD_NM_REGISTER_NET_CONN_CALLBACK_BY_SPECIFIER, 43 CMD_NM_UNREGISTER_NET_CONN_CALLBACK, 44 CMD_NM_REG_NET_SUPPLIER, 45 CMD_NM_UNREG_NETWORK, 46 CMD_NM_SET_NET_SUPPLIER_INFO, 47 CMD_NM_SET_NET_LINK_INFO, 48 CMD_NM_GETDEFAULTNETWORK, 49 CMD_NM_HASDEFAULTNET, 50 CMD_NM_NET_DETECTION, 51 CMD_NM_GET_IFACE_NAMES, 52 CMD_NM_GET_IFACENAME_BY_TYPE, 53 CMD_NM_GET_ADDRESSES_BY_NAME, 54 CMD_NM_GET_ADDRESS_BY_NAME, 55 CMD_NM_GET_SPECIFIC_NET, 56 CMD_NM_GET_ALL_NETS, 57 CMD_NM_GET_SPECIFIC_UID_NET, 58 CMD_NM_GET_CONNECTION_PROPERTIES, 59 CMD_NM_GET_NET_CAPABILITIES, 60 CMD_NM_BIND_SOCKET, 61 CMD_NM_REGISTER_NET_DETECTION_RET_CALLBACK, 62 CMD_NM_UNREGISTER_NET_DETECTION_RET_CALLBACK, 63 CMD_NM_UPDATE_NET_STATE_FOR_TEST, 64 CMD_NM_REGISTER_NET_SUPPLIER_CALLBACK, 65 CMD_NM_SET_AIRPLANE_MODE, 66 CMD_NM_IS_DEFAULT_NET_METERED, 67 CMD_NM_SET_HTTP_PROXY, 68 CMD_NM_GET_HTTP_PROXY, 69 CMD_NM_GET_NET_ID_BY_IDENTIFIER, 70 CMD_NM_SET_APP_NET, 71 CMD_NM_END, 72 }; 73 74 public: 75 virtual int32_t SystemReady() = 0; 76 virtual int32_t RegisterNetSupplier(NetBearType bearerType, const std::string &ident, 77 const std::set<NetCap> &netCaps, uint32_t &supplierId) = 0; 78 virtual int32_t UnregisterNetSupplier(uint32_t supplierId) = 0; 79 virtual int32_t RegisterNetSupplierCallback(uint32_t supplierId, const sptr<INetSupplierCallback> &callback) = 0; 80 virtual int32_t RegisterNetConnCallback(const sptr<INetConnCallback> &callback) = 0; 81 virtual int32_t RegisterNetConnCallback(const sptr<NetSpecifier> &netSpecifier, 82 const sptr<INetConnCallback> &callback, const uint32_t &timeoutMS) = 0; 83 virtual int32_t UnregisterNetConnCallback(const sptr<INetConnCallback> &callback) = 0; 84 virtual int32_t UpdateNetStateForTest(const sptr<NetSpecifier> &netSpecifier, int32_t netState) = 0; 85 virtual int32_t UpdateNetSupplierInfo(uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo) = 0; 86 virtual int32_t UpdateNetLinkInfo(uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo) = 0; 87 virtual int32_t GetIfaceNames(NetBearType bearerType, std::list<std::string> &ifaceNames) = 0; 88 virtual int32_t GetIfaceNameByType(NetBearType bearerType, const std::string &ident, std::string &ifaceName) = 0; 89 virtual int32_t RegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) = 0; 90 virtual int32_t UnRegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) = 0; 91 virtual int32_t NetDetection(int32_t netId) = 0; 92 virtual int32_t GetDefaultNet(int32_t &netId) = 0; 93 virtual int32_t HasDefaultNet(bool &flag) = 0; 94 virtual int32_t GetAddressesByName(const std::string &host, int32_t netId, std::vector<INetAddr> &addrList) = 0; 95 virtual int32_t GetAddressByName(const std::string &host, int32_t netId, INetAddr &addr) = 0; 96 virtual int32_t GetSpecificNet(NetBearType bearerType, std::list<int32_t> &netIdList) = 0; 97 virtual int32_t GetAllNets(std::list<int32_t> &netIdList) = 0; 98 virtual int32_t GetSpecificUidNet(int32_t uid, int32_t &netId) = 0; 99 virtual int32_t GetConnectionProperties(int32_t netId, NetLinkInfo &info) = 0; 100 virtual int32_t GetNetCapabilities(int32_t netId, NetAllCapabilities &netAllCap) = 0; 101 virtual int32_t BindSocket(int32_t socket_fd, int32_t netId) = 0; 102 virtual int32_t SetAirplaneMode(bool state) = 0; 103 virtual int32_t IsDefaultNetMetered(bool &isMetered) = 0; 104 virtual int32_t SetGlobalHttpProxy(const HttpProxy &httpProxy) = 0; 105 virtual int32_t GetGlobalHttpProxy(HttpProxy &httpProxy) = 0; 106 virtual int32_t GetNetIdByIdentifier(const std::string &ident, int32_t &netId) = 0; 107 virtual int32_t SetAppNet(int32_t netId) = 0; 108 }; 109 } // namespace NetManagerStandard 110 } // namespace OHOS 111 #endif // I_NET_CONN_SERVICE_H 112