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