• 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  ]
37
38  if (build_selinux) {
39    include_dirs += [ "$THIRD_PARTY_ROOT/selinux/libselinux/include/selinux" ]
40  }
41}
42
43netsys_native_manager_sources = [
44  "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/dhcp_result_parcel.cpp",
45  "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/netsys_addr_info_parcel.cpp",
46  "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/netsys_native_service_proxy.cpp",
47  "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/notify_callback_proxy.cpp",
48  "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/uid_range.cpp",
49  "src/dhcp_controller.cpp",
50  "src/manager/bandwidth_manager.cpp",
51  "src/manager/conn_manager.cpp",
52  "src/manager/dns_manager.cpp",
53  "src/manager/firewall_manager.cpp",
54  "src/manager/interface_manager.cpp",
55  "src/manager/route_manager.cpp",
56  "src/manager/sharing_manager.cpp",
57  "src/manager/traffic_manager.cpp",
58  "src/manager/vpn_manager.cpp",
59  "src/netsys/dnsresolv/dns_getaddrinfo.cpp",
60  "src/netsys/dnsresolv/dns_lookup_name.cpp",
61  "src/netsys/dnsresolv/dns_lookup_parse.cpp",
62  "src/netsys/dnsresolv/dns_param_cache.cpp",
63  "src/netsys/dnsresolv/dns_proxy_listen.cpp",
64  "src/netsys/dnsresolv/dns_resolv_config.cpp",
65  "src/netsys/dnsresolv/dns_resolv_listen.cpp",
66  "src/netsys/fwmark_network.cpp",
67  "src/netsys/iptables_wrapper.cpp",
68  "src/netsys/local_network.cpp",
69  "src/netsys/net_manager_native.cpp",
70  "src/netsys/netlink_msg.cpp",
71  "src/netsys/netlink_socket.cpp",
72  "src/netsys/netlink_socket_diag.cpp",
73  "src/netsys/netsys_network.cpp",
74  "src/netsys/netsys_udp_transfer.cpp",
75  "src/netsys/physical_network.cpp",
76  "src/netsys/virtual_network.cpp",
77  "src/netsys/wrapper/data_receiver.cpp",
78  "src/netsys/wrapper/netlink_manager.cpp",
79  "src/netsys/wrapper/netsys_event_message.cpp",
80  "src/netsys/wrapper/wrapper_decoder.cpp",
81  "src/netsys/wrapper/wrapper_distributor.cpp",
82  "src/netsys/wrapper/wrapper_listener.cpp",
83  "src/netsys_native_service.cpp",
84  "src/netsys_native_service_stub.cpp",
85  "src/notify_callback_stub.cpp",
86]
87
88netsys_native_manager_deps = [
89  "$FWMARK_CLIENT_DIR:fwmark_client",
90  "$NETMANAGERNATIVE_ROOT/netsys_client",
91  "$NETMANAGER_BASE_ROOT/utils:net_manager_common",
92  "$THIRD_PARTY_ROOT/iptables:iptables",
93  "$THIRD_PARTY_ROOT/iptables:iptables-restore",
94  "$THIRD_PARTY_ROOT/iptables:iptables-save",
95  "bpf:netsys",
96  "bpf:netsys_bpf_utils",
97]
98
99ohos_shared_library("netsys_native_manager") {
100  sanitize = {
101    cfi = true
102    cfi_cross_dso = true
103    debug = false
104  }
105  configs = [ ":netsys_native_manager_config" ]
106
107  cflags = [
108    "-fvisibility=hidden",
109    "-fdata-sections",
110    "-ffunction-sections",
111    "-Os",
112  ]
113
114  cflags_cc = [
115    "-fvisibility-inlines-hidden",
116    "-Os",
117  ]
118
119  ldflags = [
120    "-Wl,--exclude-libs=ALL",
121    "-Wl,--gc-sections",
122  ]
123
124  sources = netsys_native_manager_sources
125
126  deps = netsys_native_manager_deps
127
128  defines = [
129    "NETMGRNATIVE_LOG_TAG = \"NetsysNativeService\"",
130    "LOG_DOMAIN = 0xD0015B0",
131    "NETSYS_CONFIG_DEBUG=0",
132    "DNS_CONFIG_DEBUG=0",
133  ]
134
135  if (build_selinux) {
136    deps += [ "$THIRD_PARTY_ROOT/selinux:libselinux" ]
137    defines += [ "USE_SELINUX" ]
138  }
139
140  external_deps = [
141    "c_utils:utils",
142    "dhcp:dhcp_manager_service",
143    "eventhandler:libeventhandler",
144    "init:libbegetutil",
145    "ipc:ipc_core",
146    "safwk:system_ability_fwk",
147  ]
148
149  public_configs = [ "$NETMANAGER_BASE_ROOT/utils:netmgr_common_config" ]
150
151  if (enable_sys_func) {
152    defines += [ "SYS_FUNC" ]
153  }
154
155  if (enable_server_support_ipv6) {
156    defines += [ "SERVER_SUPPORT_IPV6" ]
157  }
158
159  external_deps += [ "hilog:libhilog" ]
160
161  part_name = "netmanager_base"
162  innerapi_tags = [ "platformsdk_indirect" ]
163  subsystem_name = "communication"
164}
165
166ohos_static_library("netsys_native_manager_static") {
167  testonly = true
168  sources = netsys_native_manager_sources
169
170  configs = [ ":netsys_native_manager_config" ]
171
172  deps = netsys_native_manager_deps
173
174  external_deps = [
175    "eventhandler:libeventhandler",
176    "init:libbegetutil",
177    "ipc:ipc_core",
178    "safwk:system_ability_fwk",
179  ]
180
181  defines = [
182    "NETMGRNATIVE_LOG_TAG = \"NetsysNativeService\"",
183    "LOG_DOMAIN = 0xD0015B0",
184    "NETSYS_CONFIG_DEBUG=0",
185    "DNS_CONFIG_DEBUG=0",
186  ]
187
188  if (build_selinux) {
189    deps += [ "$THIRD_PARTY_ROOT/selinux:libselinux" ]
190    defines += [ "USE_SELINUX" ]
191  }
192
193  public_configs = [ "$NETMANAGER_BASE_ROOT/utils:netmgr_common_config" ]
194
195  if (enable_sys_func) {
196    defines += [ "SYS_FUNC" ]
197  }
198
199  if (enable_server_support_ipv6) {
200    defines += [ "SERVER_SUPPORT_IPV6" ]
201  }
202
203  external_deps += [ "hilog:libhilog" ]
204
205  part_name = "netmanager_base"
206  subsystem_name = "communication"
207}
208