1# Copyright (c) 2023-2024 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/ohos.gni") 15import("//foundation/communication/netmanager_ext/netmanager_ext_config.gni") 16 17config("net_vpn_manager_config") { 18 include_dirs = [ 19 "$UTILS_ROOT/native/base/include", 20 "$UTILS_ROOT/system/safwk/native/include", 21 "$EXT_INNERKITS_ROOT/include", 22 "$EXT_INNERKITS_ROOT/netvpnclient/include", 23 "$EXT_INNERKITS_ROOT/netvpnclient/include/ipc", 24 "$NETCONNMANAGER_COMMON_DIR/include", 25 "$NETMANAGER_EXT_ROOT/utils/log/include", 26 "$VPNMANAGER_SOURCE_DIR/include", 27 "$VPNMANAGER_SOURCE_DIR/include/ipc", 28 "$NETWORKSHAREMANAGER_UTILS_DIR/event_report/include", 29 "$BASE_INNERKITS_ROOT/include", 30 "$BASE_INNERKITS_ROOT/netconnclient/include", 31 "$BASE_INNERKITS_ROOT/netsyscontroller/include", 32 "$BASE_INNERKITS_ROOT/netmanagernative/include", 33 "$NETMANAGERNATIVE_ROOT/include/netsys", 34 "$NETSYSCONTROLLER_ROOT_DIR/include", 35 "$NETMANAGER_BASE_ROOT/utils/common_utils/include", 36 "$SAMGR_MANAGER_ROOT/interfaces/innerkits/samgr_proxy/include", 37 "$NETMANAGER_EXT_ROOT/frameworks/js/napi/vpnext/include", 38 ] 39 40 defines = [ 41 "NETMGR_LOG_TAG = \"NetworkVpnManager\"", 42 "LOG_DOMAIN = 0xD0015B0", 43 ] 44 45 if (enable_netmgr_ext_debug) { 46 defines += [ "NETMGR_DEBUG" ] 47 } 48} 49 50net_vpn_manager_sources = [ 51 "$VPNMANAGER_SOURCE_DIR/src/extended_vpn_ctl.cpp", 52 "$VPNMANAGER_SOURCE_DIR/src/ipc/networkvpn_service_stub.cpp", 53 "$VPNMANAGER_SOURCE_DIR/src/ipc/vpn_event_callback_proxy.cpp", 54 "$VPNMANAGER_SOURCE_DIR/src/net_vpn_impl.cpp", 55 "$VPNMANAGER_SOURCE_DIR/src/networkvpn_hisysevent.cpp", 56 "$VPNMANAGER_SOURCE_DIR/src/networkvpn_service.cpp", 57 "$VPN_INNERKITS_SOURCE_DIR/src/vpn_config.cpp", 58] 59 60if (netmanager_ext_feature_sysvpn) { 61 net_vpn_manager_sources += [ 62 "$VPNMANAGER_SOURCE_DIR/src/vpn_database_helper.cpp", 63 "$VPN_INNERKITS_SOURCE_DIR/src/ipsecvpn_config.cpp", 64 "$VPN_INNERKITS_SOURCE_DIR/src/l2tpvpn_config.cpp", 65 "$VPN_INNERKITS_SOURCE_DIR/src/openvpn_config.cpp", 66 "$VPN_INNERKITS_SOURCE_DIR/src/sysvpn_config.cpp", 67 "$VPN_INNERKITS_SOURCE_DIR/src/vpn_data_bean.cpp", 68 ] 69} 70 71net_vpn_manager_deps = [ "$NETMANAGER_EXT_ROOT/utils:net_event_report" ] 72 73net_vpn_manager_external_deps = [ 74 "ability_base:want", 75 "ability_base:zuri", 76 "ability_runtime:ability_manager", 77 "ability_runtime:app_manager", 78 "bundle_framework:appexecfwk_base", 79 "bundle_framework:appexecfwk_core", 80 "cJSON:cjson", 81 "c_utils:utils", 82 "common_event_service:cesfwk_innerkits", 83 "eventhandler:libeventhandler", 84 "ffrt:libffrt", 85 "hilog:libhilog", 86 "hisysevent:libhisysevent", 87 "ipc:ipc_core", 88 "netmanager_base:net_conn_manager_if", 89 "netmanager_base:net_data_share", 90 "netmanager_base:net_manager_common", 91 "netmanager_base:netsys_controller", 92 "os_account:os_account_innerkits", 93 "relational_store:native_rdb", 94 "safwk:system_ability_fwk", 95 "samgr:samgr_proxy", 96] 97 98ohos_shared_library("net_vpn_manager") { 99 sanitize = { 100 cfi = true 101 cfi_cross_dso = true 102 blocklist = "./cfi_blocklist.txt" 103 debug = false 104 } 105 106 branch_protector_ret = "pac_ret" 107 108 configs = [ ":net_vpn_manager_config" ] 109 110 defines = [] 111 if (netmanager_ext_feature_vpn_for_user0) { 112 defines += [ "ENABLE_VPN_FOR_USER0" ] 113 } 114 115 sources = net_vpn_manager_sources 116 deps = net_vpn_manager_deps 117 external_deps = net_vpn_manager_external_deps 118 119 cflags = memory_optimization_cflags 120 cflags += [ 121 "-fstack-protector-strong", 122 "-D_FORTIFY_SOURCE=2", 123 "-O2", 124 ] 125 defines = [] 126 if (netmanager_ext_feature_vpn_for_user0) { 127 defines += [ "ENABLE_VPN_FOR_USER0" ] 128 } 129 cflags_cc = memory_optimization_cflags_cc 130 cflags_cc += [ 131 "-fstack-protector-strong", 132 "-D_FORTIFY_SOURCE=2", 133 "-O2", 134 ] 135 136 if (netmanager_ext_feature_sysvpn) { 137 cflags += sysvpn_flags 138 cflags_cc += sysvpn_flags 139 sources += [ 140 "$VPNMANAGER_SOURCE_DIR/src/ipsec_vpn_ctl.cpp", 141 "$VPNMANAGER_SOURCE_DIR/src/l2tp_vpn_ctl.cpp", 142 "$VPNMANAGER_SOURCE_DIR/src/open_vpn_ctl.cpp", 143 ] 144 } 145 146 ldflags = memory_optimization_ldflags 147 148 part_name = "netmanager_ext" 149 subsystem_name = "communication" 150} 151 152ohos_static_library("net_vpn_manager_static") { 153 sanitize = { 154 cfi = true 155 cfi_cross_dso = true 156 blocklist = "./cfi_blocklist.txt" 157 debug = false 158 } 159 160 branch_protector_ret = "pac_ret" 161 162 configs = [ ":net_vpn_manager_config" ] 163 164 sources = net_vpn_manager_sources 165 166 if (netmanager_ext_feature_sysvpn) { 167 cflags = sysvpn_flags 168 cflags_cc = sysvpn_flags 169 sources += [ 170 "$VPNMANAGER_SOURCE_DIR/src/ipsec_vpn_ctl.cpp", 171 "$VPNMANAGER_SOURCE_DIR/src/l2tp_vpn_ctl.cpp", 172 "$VPNMANAGER_SOURCE_DIR/src/open_vpn_ctl.cpp", 173 ] 174 } 175 176 deps = net_vpn_manager_deps 177 external_deps = net_vpn_manager_external_deps 178 179 part_name = "netmanager_ext" 180 subsystem_name = "communication" 181} 182