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