1 /* 2 * Copyright (c) 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_NETWORK_VPN_SERVICE_H 17 #define I_NETWORK_VPN_SERVICE_H 18 19 #include <string> 20 #include <vector> 21 22 #include "iremote_broker.h" 23 #include "iremote_object.h" 24 25 #include "i_vpn_event_callback.h" 26 #include "net_manager_ext_constants.h" 27 #include "vpn_config.h" 28 #ifdef SUPPORT_SYSVPN 29 #include "sysvpn_config.h" 30 #endif // SUPPORT_SYSVPN 31 32 namespace OHOS { 33 namespace NetManagerStandard { 34 class INetworkVpnService : public IRemoteBroker { 35 public: 36 enum class MessageCode { 37 CMD_START_INTERNAL_VPN, // for start internal vpn 38 CMD_PREPARE, 39 CMD_START_VPN, // for start extended vpn 40 CMD_PROTECT, 41 CMD_STOP_VPN, 42 CMD_REGISTER_EVENT_CALLBACK, 43 CMD_UNREGISTER_EVENT_CALLBACK, 44 CMD_CREATE_VPN_CONNECTION, 45 CMD_FACTORYRESET_VPN, 46 #ifdef SUPPORT_SYSVPN 47 CMD_ADD_SYS_VPN_CONFIG, 48 CMD_DELETE_SYS_VPN_CONFIG, 49 CMD_GET_SYS_VPN_CONFIG_LIST, 50 CMD_GET_SYS_VPN_CONFIG, 51 CMD_GET_CONNECTED_SYS_VPN_CONFIG, 52 #endif // SUPPORT_SYSVPN 53 CMD_START_VPN_EXT, // for start extension extended vpn 54 CMD_PROTECT_EXT, 55 CMD_STOP_VPN_EXT, 56 CMD_CREATE_VPN_CONNECTION_EXT, 57 CMD_REGISTER_BUNDLENAME, 58 CMD_GET_SELF_APP_NAME, 59 }; 60 61 public: 62 virtual int32_t Prepare(bool &isExistVpn, bool &isRun, std::string &pkg) = 0; 63 virtual int32_t SetUpVpn(const sptr<VpnConfig> &config, bool isVpnExtCall = false) = 0; 64 virtual int32_t Protect(bool isVpnExtCall = false) = 0; 65 virtual int32_t DestroyVpn(bool isVpnExtCall = false) = 0; 66 virtual int32_t RegisterVpnEvent(const sptr<IVpnEventCallback> callback) = 0; 67 virtual int32_t UnregisterVpnEvent(const sptr<IVpnEventCallback> callback) = 0; 68 virtual int32_t CreateVpnConnection(bool isVpnExtCall = false) = 0; 69 virtual int32_t FactoryResetVpn() = 0; 70 virtual int32_t RegisterBundleName(const std::string &bundleName) = 0; 71 #ifdef SUPPORT_SYSVPN 72 virtual int32_t AddSysVpnConfig(sptr<SysVpnConfig> &config) = 0; 73 virtual int32_t DeleteSysVpnConfig(std::string &vpnId) = 0; 74 virtual int32_t GetSysVpnConfigList(std::vector<SysVpnConfig> &vpnList) = 0; 75 virtual int32_t GetSysVpnConfig(sptr<SysVpnConfig> &config, std::string &vpnId) = 0; 76 virtual int32_t GetConnectedSysVpnConfig(sptr<SysVpnConfig> &config) = 0; 77 #endif // SUPPORT_SYSVPN 78 virtual int32_t GetSelfAppName(std::string &selfAppName) = 0; 79 80 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.NetManagerStandard.INetworkVpnService"); 81 }; 82 } // namespace NetManagerStandard 83 } // namespace OHOS 84 #endif // I_NETWORK_VPN_SERVICE_H 85