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_base/netmanager_base_config.gni")
16
17config("net_native_manager_if_config") {
18  # header file path
19  include_dirs = [
20    "$INNERKITS_ROOT/include",
21    "$INNERKITS_ROOT/netstatsclient/include/proxy",
22    "$INNERKITS_ROOT/netstatsclient/include",
23    "$INNERKITS_ROOT/netmanagernative/include",
24    "$INNERKITS_ROOT/netconnclient/include",
25    "$NETSYSNATIVE_SOURCE_DIR/include/netsys",
26  ]
27
28  cflags = []
29  if (is_double_framework) {
30    cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ]
31  }
32  if (target_cpu == "arm") {
33    cflags += [ "-DBINDER_IPC_32BIT" ]
34  }
35  if (is_standard_system) {
36    cflags += [ "-DCONFIG_STANDARD_SYSTEM" ]
37  }
38  if (defined(build_public_version) && build_public_version) {
39    cflags += [ "-DBUILD_PUBLIC_VERSION" ]
40  }
41  if (netmanager_base_enable_feature_net_firewall) {
42    defines = [ "FEATURE_NET_FIREWALL_ENABLE" ]
43  }
44}
45
46ohos_source_set("net_native_parcel") {
47  sanitize = {
48    cfi = true
49    cfi_cross_dso = true
50    debug = false
51  }
52
53  branch_protector_ret = "pac_ret"
54
55  sources = [
56    "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/dhcp_result_parcel.cpp",
57    "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/uid_range.cpp",
58  ]
59
60  if (netmanager_base_enable_feature_net_firewall) {
61    sources += [ "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/netfirewall_parcel.cpp" ]
62  }
63
64  include_dirs = [ "$INNERKITS_ROOT/netmanagernative/include" ]
65
66  deps = [ "$NETMANAGER_BASE_ROOT/utils:net_manager_common" ]
67  external_deps = [ "c_utils:utils" ]
68  external_deps += [ "hilog:libhilog" ]
69
70  part_name = "netmanager_base"
71  subsystem_name = "communication"
72}
73
74ohos_shared_library("net_native_manager_if") {
75  sanitize = {
76    cfi = true
77    cfi_cross_dso = true
78    debug = false
79  }
80
81  branch_protector_ret = "pac_ret"
82
83  cflags = [
84    "-fstack-protector-strong",
85    "-D_FORTIFY_SOURCE=2",
86    "-O2",
87  ]
88
89  cflags_cc = [
90    "-fstack-protector-strong",
91    "-D_FORTIFY_SOURCE=2",
92    "-O2",
93  ]
94  sources = [
95    "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/net_diag_callback_stub.cpp",
96    "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/netsys_native_service_proxy.cpp",
97    "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/netsys_net_diag_data.cpp",
98    "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/notify_callback_proxy.cpp",
99  ]
100
101  include_dirs = [
102    "$NETMANAGER_BASE_ROOT/utils/log/include",
103    "$NETSYSCONTROLLER_ROOT_DIR/include/",
104  ]
105
106  public_configs = [ ":net_native_manager_if_config" ]
107
108  if (netmanager_base_enable_feature_net_firewall) {
109    sources += [
110      "$NETSYSNATIVE_INNERKITS_SOURCE_DIR/netfirewall_callback_proxy.cpp",
111      "$NETSYSNATIVE_SOURCE_DIR/src/netfirewall_callback_stub.cpp",
112    ]
113
114    public_configs += [ "$NETMANAGER_BASE_ROOT/resource:coverage_flags" ]
115  }
116
117  deps = [
118    ":net_native_parcel",
119    "$INNERKITS_ROOT/netstatsclient:net_stats_manager_if",
120    "$NETSYSCONTROLLER_ROOT_DIR:netsys_controller",
121  ]
122
123  external_deps = [
124    "bounds_checking_function:libsec_shared",
125    "c_utils:utils",
126    "ipc:ipc_single",
127    "samgr:samgr_proxy",
128  ]
129
130  defines = [
131    "NETMGR_LOG_TAG = \"NetNativeMnager\"",
132    "LOG_DOMAIN = 0xD0015B0",
133  ]
134
135  if (enable_netmgr_debug) {
136    defines += [ "NETMGR_DEBUG" ]
137  }
138
139  external_deps += [ "hilog:libhilog" ]
140
141  innerapi_tags = [ "platformsdk" ]
142  part_name = "netmanager_base"
143  subsystem_name = "communication"
144}
145