• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022-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
17ohos_bpf("netsys") {
18  sources = [ "src/netsys.c" ]
19
20  include_dirs = [ "include" ]
21
22  if (netmanager_base_enable_feature_net_firewall) {
23    defines = [
24      "FEATURE_NET_FIREWALL_ENABLE",
25      "NET_FIREWALL_DEBUG=0",
26      "NET_FIREWALL_DEBUG_TUPLE=0",
27    ]
28  }
29
30  if (netmanager_base_support_ebpf_memory_miniaturization) {
31    defines = [ "SUPPORT_EBPF_MEM_MIN" ]
32  }
33
34  subsystem_name = "communication"
35  part_name = "netmanager_base"
36}
37
38ohos_shared_library("netsys_bpf_utils") {
39  sanitize = {
40    cfi = true
41    cfi_cross_dso = true
42    boundary_sanitize = true
43    ubsan = true
44    debug = false
45  }
46
47  branch_protector_ret = "pac_ret"
48
49  sources = [
50    "$NETSTATSMANAGER_INNERKITS_SOURCE_DIR/src/net_stats_info.cpp",
51    "src/bpf_loader.cpp",
52    "src/bpf_ring_buffer.cpp",
53    "src/bpf_stats.cpp",
54  ]
55
56  include_dirs = [
57    "include",
58    "$NETMANAGER_BASE_ROOT/interfaces/innerkits/include",
59    "$NETMANAGER_BASE_ROOT/interfaces/innerkits/netmanagernative/include",
60    "$NETMANAGER_BASE_ROOT/interfaces/innerkits/netstatsclient/include",
61    "$NETMANAGER_BASE_ROOT/utils/common_utils/include",
62    "$NETMANAGER_BASE_ROOT/utils/log/include",
63    "$NETPOLICYMANAGER_SOURCE_DIR/include",
64    "$NETMANAGER_BASE_ROOT/services/netmanagernative/include",
65  ]
66
67  cflags = [
68    "-fstack-protector-strong",
69    "-D_FORTIFY_SOURCE=2",
70    "-O2",
71  ]
72
73  cflags_cc = [
74    "-fstack-protector-strong",
75    "-D_FORTIFY_SOURCE=2",
76    "-O2",
77  ]
78
79  defines = [
80    "NETMGRNATIVE_LOG_TAG = \"NetSysBpf\"",
81    "LOG_DOMAIN = 0xD0015B0",
82  ]
83
84  external_deps = [
85    "c_utils:utils",
86    "elfio:elfio",
87    "ffrt:libffrt",
88    "hilog:libhilog",
89    "ipc:ipc_core",
90    "libbpf:libbpf",
91  ]
92  use_exceptions = true
93  deps = [ "$INNERKITS_ROOT/netpolicyclient:net_policy_manager_if" ]
94
95  if (netmanager_base_enable_feature_net_firewall) {
96    public_configs = [ "$NETMANAGER_BASE_ROOT/resource:coverage_flags" ]
97    sources += [
98      "src/bitmap_manager.cpp",
99      "src/bpf_netfirewall.cpp",
100    ]
101
102    defines += [ "FEATURE_NET_FIREWALL_ENABLE" ]
103
104    deps += [ "$INNERKITS_ROOT/netmanagernative:net_native_parcel" ]
105
106    external_deps += [
107      "ipc:ipc_core",
108      "safwk:system_ability_fwk",
109      "samgr:samgr_proxy",
110    ]
111  }
112
113  innerapi_tags = [ "platformsdk_indirect" ]
114  part_name = "netmanager_base"
115  subsystem_name = "communication"
116}
117