• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    "$EXT_INNERKITS_ROOT/include",
20    "$EXT_INNERKITS_ROOT/netvpnclient/include",
21    "$EXT_INNERKITS_ROOT/netvpnclient/include/ipc",
22    "$NETCONNMANAGER_COMMON_DIR/include",
23    "$NETMANAGER_EXT_ROOT/utils/log/include",
24    "$VPNMANAGER_SOURCE_DIR/include",
25    "$VPNMANAGER_SOURCE_DIR/include/ipc",
26    "$NETWORKSHAREMANAGER_UTILS_DIR/event_report/include",
27    "$NETMANAGERNATIVE_ROOT/include/netsys",
28    "$NETSYSCONTROLLER_ROOT_DIR/include",
29    "$NETMANAGER_EXT_ROOT/frameworks/js/napi/vpnext/include",
30  ]
31
32  defines = [
33    "NETMGR_LOG_TAG = \"NetworkVpnManager\"",
34    "LOG_DOMAIN = 0xD0015B0",
35  ]
36
37  if (enable_netmgr_ext_debug) {
38    defines += [ "NETMGR_DEBUG" ]
39  }
40}
41
42net_vpn_manager_sources = [
43  "$VPNMANAGER_SOURCE_DIR/src/extended_vpn_ctl.cpp",
44  "$VPNMANAGER_SOURCE_DIR/src/ipc/networkvpn_service_stub.cpp",
45  "$VPNMANAGER_SOURCE_DIR/src/ipc/vpn_event_callback_proxy.cpp",
46  "$VPNMANAGER_SOURCE_DIR/src/net_vpn_impl.cpp",
47  "$VPNMANAGER_SOURCE_DIR/src/networkvpn_hisysevent.cpp",
48  "$VPNMANAGER_SOURCE_DIR/src/networkvpn_service.cpp",
49  "$VPN_INNERKITS_SOURCE_DIR/src/vpn_config.cpp",
50]
51
52if (netmanager_ext_feature_sysvpn) {
53  net_vpn_manager_sources += [
54    "$VPNMANAGER_SOURCE_DIR/src/vpn_database_helper.cpp",
55    "$VPNMANAGER_SOURCE_DIR/src/vpn_encryption_util.cpp",
56    "$VPN_INNERKITS_SOURCE_DIR/src/ipsecvpn_config.cpp",
57    "$VPN_INNERKITS_SOURCE_DIR/src/l2tpvpn_config.cpp",
58    "$VPN_INNERKITS_SOURCE_DIR/src/openvpn_config.cpp",
59    "$VPN_INNERKITS_SOURCE_DIR/src/sysvpn_config.cpp",
60    "$VPN_INNERKITS_SOURCE_DIR/src/vpn_data_bean.cpp",
61  ]
62}
63
64net_vpn_manager_deps = [ "$NETMANAGER_EXT_ROOT/utils:net_event_report" ]
65
66net_vpn_manager_external_deps = [
67  "ability_base:want",
68  "ability_base:zuri",
69  "ability_runtime:ability_manager",
70  "ability_runtime:app_manager",
71  "bundle_framework:appexecfwk_base",
72  "bundle_framework:appexecfwk_core",
73  "cJSON:cjson",
74  "c_utils:utils",
75  "common_event_service:cesfwk_innerkits",
76  "eventhandler:libeventhandler",
77  "ffrt:libffrt",
78  "hilog:libhilog",
79  "hisysevent:libhisysevent",
80  "huks:libhukssdk",
81  "ipc:ipc_core",
82  "netmanager_base:net_conn_manager_if",
83  "netmanager_base:net_data_share",
84  "netmanager_base:net_manager_common",
85  "netmanager_base:net_native_manager_if",
86  "netmanager_base:netsys_controller",
87  "os_account:os_account_innerkits",
88  "relational_store:native_rdb",
89  "safwk:system_ability_fwk",
90  "samgr:samgr_proxy",
91]
92
93ohos_shared_library("net_vpn_manager") {
94  sanitize = {
95    cfi = true
96    cfi_cross_dso = true
97    blocklist = "./cfi_blocklist.txt"
98    debug = false
99  }
100
101  branch_protector_ret = "pac_ret"
102
103  configs = [ ":net_vpn_manager_config" ]
104
105  defines = []
106  if (netmanager_ext_feature_vpn_for_user0) {
107    defines += [ "ENABLE_VPN_FOR_USER0" ]
108  }
109
110  sources = net_vpn_manager_sources
111  deps = net_vpn_manager_deps
112  external_deps = net_vpn_manager_external_deps
113
114  cflags = memory_optimization_cflags
115  cflags += [
116    "-fstack-protector-strong",
117    "-D_FORTIFY_SOURCE=2",
118    "-O2",
119  ]
120  defines = []
121  if (netmanager_ext_feature_vpn_for_user0) {
122    defines += [ "ENABLE_VPN_FOR_USER0" ]
123  }
124  cflags_cc = memory_optimization_cflags_cc
125  cflags_cc += [
126    "-fstack-protector-strong",
127    "-D_FORTIFY_SOURCE=2",
128    "-O2",
129  ]
130
131  if (netmanager_ext_feature_sysvpn) {
132    cflags += sysvpn_flags
133    cflags_cc += sysvpn_flags
134    sources += [
135      "$VPNMANAGER_SOURCE_DIR/src/ipsec_vpn_ctl.cpp",
136      "$VPNMANAGER_SOURCE_DIR/src/l2tp_vpn_ctl.cpp",
137      "$VPNMANAGER_SOURCE_DIR/src/open_vpn_ctl.cpp",
138    ]
139  }
140
141  ldflags = memory_optimization_ldflags
142
143  part_name = "netmanager_ext"
144  subsystem_name = "communication"
145}
146
147ohos_static_library("net_vpn_manager_static") {
148  sanitize = {
149    cfi = true
150    cfi_cross_dso = true
151    blocklist = "./cfi_blocklist.txt"
152    debug = false
153  }
154
155  branch_protector_ret = "pac_ret"
156
157  configs = [ ":net_vpn_manager_config" ]
158
159  sources = net_vpn_manager_sources
160
161  if (netmanager_ext_feature_sysvpn) {
162    cflags = sysvpn_flags
163    cflags_cc = sysvpn_flags
164    sources += [
165      "$VPNMANAGER_SOURCE_DIR/src/ipsec_vpn_ctl.cpp",
166      "$VPNMANAGER_SOURCE_DIR/src/l2tp_vpn_ctl.cpp",
167      "$VPNMANAGER_SOURCE_DIR/src/open_vpn_ctl.cpp",
168    ]
169  }
170
171  deps = net_vpn_manager_deps
172  external_deps = net_vpn_manager_external_deps
173
174  part_name = "netmanager_ext"
175  subsystem_name = "communication"
176}
177