• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2023 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_base/netmanager_base_config.gni")
16
17config("netsys_native_manager_config") {
18  include_dirs = [
19    "$C_UTILS_ROOT/base/include",
20    "$DHCP_MANAGER_ROOT/interfaces/inner_api/include",
21    "$DHCP_MANAGER_ROOT/interfaces/inner_api/interfaces",
22    "$INNERKITS_ROOT/include",
23    "$NETMANAGER_BASE_ROOT/services/common/include",
24    "$NETMANAGER_BASE_ROOT/utils/common_utils/include",
25    "$INNERKITS_ROOT/netmanagernative/include",
26    "include",
27    "include/manager",
28    "include/netsys",
29    "include/netsys/wrapper",
30    "$C_UTILS_ROOT/base/include",
31    "$DHCP_MANAGER_ROOT/interfaces/inner_api/include",
32    "$DHCP_MANAGER_ROOT/interfaces/inner_api/interfaces",
33    "$SAMGR_MANAGER_ROOT/interfaces/innerkits/samgr_proxy/include",
34    "$FWMARK_CLIENT_DIR/include",
35    "$NETMANAGER_BASE_ROOT/services/netmanagernative/bpf/include",
36    "$NETCONNMANAGER_SOURCE_DIR/include",
37    "$NETCONNMANAGER_SOURCE_DIR/include/stub",
38    "$INNERKITS_ROOT/netconnclient/include/proxy",
39    "$THIRD_PARTY_ROOT/curl/include",
40    "$NETSYSCONTROLLER_ROOT_DIR/include",
41  ]
42
43  if (build_selinux) {
44    include_dirs += [ "$THIRD_PARTY_ROOT/selinux/libselinux/include/selinux" ]
45  }
46}
47
48netsys_native_manager_sources = [
49  "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/dhcp_result_parcel.cpp",
50  "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/netsys_native_service_proxy.cpp",
51  "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/netsys_net_diag_data.cpp",
52  "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/notify_callback_proxy.cpp",
53  "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/uid_range.cpp",
54  "src/dhcp_controller.cpp",
55  "src/manager/bandwidth_manager.cpp",
56  "src/manager/conn_manager.cpp",
57  "src/manager/dns_manager.cpp",
58  "src/manager/firewall_manager.cpp",
59  "src/manager/interface_manager.cpp",
60  "src/manager/route_manager.cpp",
61  "src/manager/sharing_manager.cpp",
62  "src/manager/traffic_manager.cpp",
63  "src/manager/vpn_manager.cpp",
64  "src/net_diag_callback_proxy.cpp",
65  "src/netsys/dnsresolv/dns_getaddrinfo.cpp",
66  "src/netsys/dnsresolv/dns_lookup_name.cpp",
67  "src/netsys/dnsresolv/dns_lookup_parse.cpp",
68  "src/netsys/dnsresolv/dns_param_cache.cpp",
69  "src/netsys/dnsresolv/dns_proxy_listen.cpp",
70  "src/netsys/dnsresolv/dns_quality_diag.cpp",
71  "src/netsys/dnsresolv/dns_quality_event_handler.cpp",
72  "src/netsys/dnsresolv/dns_resolv_config.cpp",
73  "src/netsys/dnsresolv/dns_resolv_listen.cpp",
74  "src/netsys/dnsresolv/net_dns_health_callback_proxy.cpp",
75  "src/netsys/dnsresolv/net_dns_health_callback_stub.cpp",
76  "src/netsys/dnsresolv/net_dns_result_callback_proxy.cpp",
77  "src/netsys/dnsresolv/net_dns_result_callback_stub.cpp",
78  "src/netsys/dnsresolv/netsys_net_dns_health_data.cpp",
79  "src/netsys/dnsresolv/netsys_net_dns_result_data.cpp",
80  "src/netsys/fwmark_network.cpp",
81  "src/netsys/iptables_wrapper.cpp",
82  "src/netsys/local_network.cpp",
83  "src/netsys/net_diag_wrapper.cpp",
84  "src/netsys/net_manager_native.cpp",
85  "src/netsys/netlink_msg.cpp",
86  "src/netsys/netlink_socket.cpp",
87  "src/netsys/netlink_socket_diag.cpp",
88  "src/netsys/netsys_network.cpp",
89  "src/netsys/netsys_udp_transfer.cpp",
90  "src/netsys/physical_network.cpp",
91  "src/netsys/virtual_network.cpp",
92  "src/netsys/wrapper/data_receiver.cpp",
93  "src/netsys/wrapper/netlink_manager.cpp",
94  "src/netsys/wrapper/netsys_event_message.cpp",
95  "src/netsys/wrapper/wrapper_decoder.cpp",
96  "src/netsys/wrapper/wrapper_distributor.cpp",
97  "src/netsys/wrapper/wrapper_listener.cpp",
98  "src/netsys_native_service.cpp",
99  "src/netsys_native_service_stub.cpp",
100  "src/notify_callback_stub.cpp",
101]
102
103netsys_native_manager_deps = [
104  "$FWMARK_CLIENT_DIR:fwmark_client",
105  "$INNERKITS_ROOT/netconnclient:net_conn_manager_if",
106  "$NETMANAGERNATIVE_ROOT/netsys_client",
107  "$NETMANAGER_BASE_ROOT/utils:net_manager_common",
108  "$THIRD_PARTY_ROOT/iptables:iptables",
109  "$THIRD_PARTY_ROOT/iptables:iptables-restore",
110  "$THIRD_PARTY_ROOT/iptables:iptables-save",
111  "bpf:netsys",
112  "bpf:netsys_bpf_utils",
113]
114
115ohos_shared_library("netsys_native_manager") {
116  sanitize = {
117    cfi = true
118    cfi_cross_dso = true
119    debug = false
120  }
121  configs = [ ":netsys_native_manager_config" ]
122
123  cflags = [
124    "-fvisibility=hidden",
125    "-fdata-sections",
126    "-ffunction-sections",
127    "-Os",
128    "-fstack-protector-strong",
129    "-D_FORTIFY_SOURCE=2",
130    "-O2",
131  ]
132
133  cflags_cc = [
134    "-fvisibility-inlines-hidden",
135    "-Os",
136    "-fstack-protector-strong",
137    "-D_FORTIFY_SOURCE=2",
138    "-O2",
139  ]
140
141  ldflags = [
142    "-Wl,--exclude-libs=ALL",
143    "-Wl,--gc-sections",
144  ]
145
146  sources = netsys_native_manager_sources
147
148  deps = netsys_native_manager_deps
149
150  defines = [
151    "NETMGRNATIVE_LOG_TAG = \"NetsysNativeService\"",
152    "LOG_DOMAIN = 0xD0015B0",
153    "NETSYS_CONFIG_DEBUG=0",
154    "DNS_CONFIG_DEBUG=0",
155    "NETSYS_DNS_MONITOR=0",
156  ]
157
158  if (build_selinux) {
159    deps += [ "$THIRD_PARTY_ROOT/selinux:libselinux" ]
160    defines += [ "USE_SELINUX" ]
161  }
162
163  external_deps = [
164    "c_utils:utils",
165    "dhcp:dhcp_sdk",
166    "eventhandler:libeventhandler",
167    "init:libbegetutil",
168    "ipc:ipc_core",
169    "safwk:system_ability_fwk",
170  ]
171
172  public_configs = [ "$NETMANAGER_BASE_ROOT/utils:netmgr_common_config" ]
173
174  if (enable_sys_func) {
175    defines += [ "SYS_FUNC" ]
176  }
177
178  if (enable_server_support_ipv6) {
179    defines += [ "SERVER_SUPPORT_IPV6" ]
180  }
181
182  external_deps += [ "hilog:libhilog" ]
183
184  part_name = "netmanager_base"
185  innerapi_tags = [ "platformsdk_indirect" ]
186  subsystem_name = "communication"
187}
188
189ohos_static_library("netsys_native_manager_static") {
190  testonly = true
191  sources = netsys_native_manager_sources
192
193  configs = [ ":netsys_native_manager_config" ]
194
195  deps = netsys_native_manager_deps
196
197  external_deps = [
198    "dhcp:dhcp_sdk",
199    "eventhandler:libeventhandler",
200    "init:libbegetutil",
201    "ipc:ipc_core",
202    "safwk:system_ability_fwk",
203  ]
204
205  defines = [
206    "NETMGRNATIVE_LOG_TAG = \"NetsysNativeService\"",
207    "LOG_DOMAIN = 0xD0015B0",
208    "NETSYS_CONFIG_DEBUG=0",
209    "DNS_CONFIG_DEBUG=0",
210  ]
211
212  if (build_selinux) {
213    deps += [ "$THIRD_PARTY_ROOT/selinux:libselinux" ]
214    defines += [ "USE_SELINUX" ]
215  }
216
217  public_configs = [ "$NETMANAGER_BASE_ROOT/utils:netmgr_common_config" ]
218
219  if (enable_sys_func) {
220    defines += [ "SYS_FUNC" ]
221  }
222
223  if (enable_server_support_ipv6) {
224    defines += [ "SERVER_SUPPORT_IPV6" ]
225  }
226
227  external_deps += [ "hilog:libhilog" ]
228
229  part_name = "netmanager_base"
230  subsystem_name = "communication"
231}
232