1 /* 2 * Copyright (c) 2025 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_TEMPLATE_PROCESSOR_H 17 #define NET_VPN_TEMPLATE_PROCESSOR_H 18 19 #include <unordered_map> 20 #include "ipsecvpn_config.h" 21 #include "l2tpvpn_config.h" 22 #include "net_vpn_impl.h" 23 24 namespace OHOS { 25 namespace NetManagerStandard { 26 class VpnTemplateProcessor { 27 public: 28 int32_t BuildConfig(std::shared_ptr<NetVpnImpl> &vpnObj, 29 std::map<std::string, std::shared_ptr<NetVpnImpl>> &vpnObjMap); 30 31 private: 32 void GenSwanctlOrIpsecConf(sptr<IpsecVpnConfig> &ipsecConfig, sptr<L2tpVpnConfig> &l2tpConfig, 33 int32_t ifNameId, std::map<std::string, std::shared_ptr<NetVpnImpl>> &vpnObjMap); 34 void GenXl2tpdConf(sptr<L2tpVpnConfig> &config, int32_t ifNameId, 35 std::map<std::string, std::shared_ptr<NetVpnImpl>> &vpnObjMap); 36 void GenOptionsL2tpdClient(sptr<L2tpVpnConfig> &config); 37 void GenIpsecSecrets(sptr<L2tpVpnConfig> &config); 38 void GetSecret(sptr<IpsecVpnConfig> &ipsecConfig, int32_t ifNameId, std::string &outSecret); 39 void GetConnect(sptr<IpsecVpnConfig> &ipsecConfig, int32_t ifNameId, std::string &outConnect); 40 void CreateConnectAndSecret(sptr<IpsecVpnConfig> &ipsecConfig, sptr<L2tpVpnConfig> &l2tpConfig, 41 int32_t ifNameId, std::string &outConnect, std::string &outSecret); 42 void CreateXl2tpdConf(sptr<L2tpVpnConfig> &config, int32_t ifNameId, std::string &outConf); 43 }; 44 } // namespace NetManagerStandard 45 } // namespace OHOS 46 #endif // NET_VPN_TEMPLATE_PROCESSOR_H 47