1 /* 2 * Copyright (c) 2024 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_VPN_DATA_BEAN_H 17 #define NET_VPN_DATA_BEAN_H 18 19 #include <string> 20 #include <vector> 21 22 #include "inet_addr.h" 23 #include "ipsecvpn_config.h" 24 #include "l2tpvpn_config.h" 25 #include "openvpn_config.h" 26 #include "refbase.h" 27 #include "vpn_config.h" 28 29 namespace OHOS { 30 namespace NetManagerStandard { 31 struct VpnDataBean : public virtual RefBase { 32 //common 33 std::string vpnId_; 34 std::string vpnName_; 35 int32_t vpnType_ = -1; 36 std::string vpnAddress_; 37 std::string userName_; 38 std::string password_; 39 int32_t userId_ = 0; 40 int32_t isLegacy_ = 1; 41 int32_t saveLogin_ = 0; 42 std::string forwardingRoutes_; 43 std::string dnsAddresses_; 44 std::string searchDomains_; 45 46 //openvpn 47 std::string ovpnPort_; 48 int32_t ovpnProtocol_; 49 std::string ovpnConfig_; 50 int32_t ovpnAuthType_; 51 std::string askpass_; 52 std::string ovpnConfigFilePath_; 53 std::string ovpnCaCertFilePath_; 54 std::string ovpnUserCertFilePath_; 55 std::string ovpnPrivateKeyFilePath_; 56 57 //ipsec 58 std::string ipsecPreSharedKey_; 59 std::string ipsecIdentifier_; 60 std::string swanctlConf_; 61 std::string strongswanConf_; 62 std::string ipsecCaCertConf_; 63 std::string ipsecPrivateUserCertConf_; 64 std::string ipsecPublicUserCertConf_; 65 std::string ipsecPrivateServerCertConf_; 66 std::string ipsecPublicServerCertConf_; 67 std::string ipsecCaCertFilePath_; 68 std::string ipsecPrivateUserCertFilePath_; 69 std::string ipsecPublicUserCertFilePath_; 70 std::string ipsecPrivateServerCertFilePath_; 71 std::string ipsecPublicServerCertFilePath_; 72 73 //l2tp 74 std::string ipsecConf_; 75 std::string ipsecSecrets_; 76 std::string optionsL2tpdClient_; 77 std::string xl2tpdConf_; 78 std::string l2tpSharedKey_; 79 80 static sptr<SysVpnConfig> ConvertVpnBeanToSysVpnConfig(sptr<VpnDataBean> &vpnBean); 81 static sptr<OpenvpnConfig> ConvertVpnBeanToOpenvpnConfig(sptr<VpnDataBean> vpnBean); 82 static sptr<IpsecVpnConfig> ConvertVpnBeanToIpsecVpnConfig(sptr<VpnDataBean> &vpnBean); 83 static sptr<L2tpVpnConfig> ConvertVpnBeanToL2tpVpnConfig(sptr<VpnDataBean> &vpnBean); 84 static sptr<VpnDataBean> ConvertSysVpnConfigToVpnBean(sptr<SysVpnConfig> &sysVpnConfig); 85 static void ConvertCommonVpnConfigToVpnBean(sptr<SysVpnConfig> &sysVpnConfig, sptr<VpnDataBean> &vpnBean); 86 static void ConvertOpenvpnConfigToVpnBean(sptr<SysVpnConfig> sysVpnConfig, sptr<VpnDataBean> &vpnBean); 87 static void ConvertIpsecVpnConfigToVpnBean(sptr<SysVpnConfig> sysVpnConfig, sptr<VpnDataBean> &vpnBean); 88 static void ConvertL2tpVpnConfigToVpnBean(sptr<SysVpnConfig> sysVpnConfig, sptr<VpnDataBean> &vpnBean); 89 }; 90 } // namespace NetManagerStandard 91 } // namespace OHOS 92 #endif // NET_VPN_DATA_BEAN_H