blob: 2d14ce61c364ff207df093ef2d325b000dbba32d [file] [log] [blame]
Luke Huangcaebcbb2018-09-27 20:37:14 +08001aidl_interface {
2 name: "netd_aidl_interface",
3 local_include_dir: "binder",
4 srcs: [
Luke Huang03074eb2018-11-23 17:03:03 +08005 "binder/android/net/INetd.aidl",
Luke Huang528af602018-08-29 19:06:05 +08006 // AIDL interface that callers can implement to receive networking events from netd.
7 "binder/android/net/INetdUnsolicitedEventListener.aidl",
Luke Huang03074eb2018-11-23 17:03:03 +08008 "binder/android/net/InterfaceConfigurationParcel.aidl",
Chiachang Wang00fc62f2019-12-04 20:38:26 +08009 "binder/android/net/MarkMaskParcel.aidl",
Tyler Wearfa94a272019-12-05 15:01:48 -080010 "binder/android/net/RouteInfoParcel.aidl",
Chiachang Wang08cb2112019-12-10 09:53:24 +080011 "binder/android/net/TetherConfigParcel.aidl",
Lorenzo Colittif0e051c2020-04-06 09:19:57 +000012 "binder/android/net/TetherOffloadRuleParcel.aidl",
Luke Huangcaebcbb2018-09-27 20:37:14 +080013 "binder/android/net/TetherStatsParcel.aidl",
Luke Huang94658ac2018-10-18 19:35:12 +090014 "binder/android/net/UidRangeParcel.aidl",
Luke Huangcaebcbb2018-09-27 20:37:14 +080015 ],
Luke Huangf7782042018-08-08 13:13:04 +080016 backend: {
Xiao Ma33d562a2018-12-16 16:27:38 +090017 cpp: {
18 gen_log: true,
19 },
Luke Huang67649312020-04-01 01:17:42 +080020 java: {
Lorenzo Colittie90d5c42020-04-30 08:33:38 +000021 // TODO: Remove apex_available and restrict visibility to only mainline modules that are
22 // either outside the system server or use jarjar to rename the generated AIDL classes.
Luke Huang67649312020-04-01 01:17:42 +080023 apex_available: [
Jiyong Park90813ad2020-04-08 14:12:27 +090024 "//apex_available:platform", // used from services.net
Luke Huang67649312020-04-01 01:17:42 +080025 "com.android.bluetooth.updatable",
Hungming Chenc6ec17f2020-05-29 19:54:57 +080026 "com.android.tethering",
Luke Huang67649312020-04-01 01:17:42 +080027 "com.android.wifi",
28 ],
29 },
Luke Huangf7782042018-08-08 13:13:04 +080030 },
Luke Huang00681282019-04-26 12:09:05 +080031 versions: [
32 "1",
33 "2",
Luke Huang29e5fdf2020-04-07 16:15:23 +000034 "3",
Lorenzo Colittic44d4662020-06-09 12:47:27 +090035 "4",
Uldiniadb198ec92018-03-01 08:54:00 -050036 "5",
Luke Huang00681282019-04-26 12:09:05 +080037 ],
Luke Huangcaebcbb2018-09-27 20:37:14 +080038}
39
Luke Huang0e5e69d2019-03-06 15:42:38 +080040aidl_interface {
Lorenzo Colittie90d5c42020-04-30 08:33:38 +000041 name: "netd_event_listener_interface",
42 local_include_dir: "binder",
43 srcs: [
44 "binder/android/net/metrics/INetdEventListener.aidl",
45 ],
46 versions: ["1"],
47 backend: {
48 ndk: {
49 apex_available: [
50 "//apex_available:platform",
51 "com.android.resolv",
52 ],
Jooyung Han46969792020-04-16 18:48:35 +090053 min_sdk_version: "29",
Lorenzo Colittie90d5c42020-04-30 08:33:38 +000054 },
55 },
56}
57
58aidl_interface {
Luke Huang2ff8b342019-04-30 15:33:33 +080059 // This interface is for OEM calls to netd and vice versa that do not exist in AOSP.
60 // Those calls cannot be part of INetd.aidl and INetdUnsolicitedEventListener.aidl
61 // because those interfaces are versioned.
62 // These interfaces must never be versioned or OEMs will not be able to change them.
Luke Huang0e5e69d2019-03-06 15:42:38 +080063 name: "oemnetd_aidl_interface",
Jiyong Park63917972020-04-13 15:09:35 +090064 unstable: true,
Luke Huang0e5e69d2019-03-06 15:42:38 +080065 local_include_dir: "binder",
66 srcs: [
67 "binder/com/android/internal/net/IOemNetd.aidl",
Luke Huang2ff8b342019-04-30 15:33:33 +080068 "binder/com/android/internal/net/IOemNetdUnsolicitedEventListener.aidl",
Luke Huang0e5e69d2019-03-06 15:42:38 +080069 ],
70}
71
Lorenzo Colittie90d5c42020-04-30 08:33:38 +000072// Convenience build target for the version of the netd stable AIDL interface used by the platform.
73// This exists to ensure that all non-updatable code in the system server uses the same version.
74// Mixing different versions of generated classes results in code non-deterministically(?) using one
75// of the compiled-in versions, and potentially crashing when code compiled against a newer version
76// ends up using a generated class from an older version and calls methods that don't exist.
77// This must be a frozen version on REL builds and can be -unstable on development builds.
78// See http://b/143560726 for an example.
79java_library {
80 name: "netd_aidl_interfaces-platform-java",
81 static_libs: [
82 "netd_aidl_interface-java",
83 "netd_event_listener_interface-java",
84 ],
85 // TODO: remove bluetooth, which doesn't actually use netd at all.
86 apex_available: [
Jiyong Park2c6d7942020-05-04 20:20:54 +090087 "//apex_available:platform", // due to the dependency from services.net
Lorenzo Colittie90d5c42020-04-30 08:33:38 +000088 "com.android.bluetooth.updatable",
89 ],
90 sdk_version: "system_current",
91}
92
93// These are used in netd_integration_test
94// TODO: fold these into a cc_library_static after converting netd/server to Android.bp
95filegroup {
96 name: "netd_integration_test_shared",
97 srcs: [
98 "NetdConstants.cpp",
99 "InterfaceController.cpp",
100 "NetlinkCommands.cpp",
101 "NetlinkListener.cpp",
Treehugger Robotfe5f4bd2020-06-01 15:18:04 +0000102 "OffloadUtils.cpp",
Lorenzo Colittie90d5c42020-04-30 08:33:38 +0000103 "SockDiag.cpp",
104 "XfrmController.cpp",
105 "TrafficController.cpp",
106 ],
107}
108
Bernie Innocenti98951792018-06-26 17:13:44 +0900109// Modules common to both netd and netd_unit_test
110cc_library_static {
111 name: "libnetd_server",
Lukas06100a2d4322018-09-01 12:16:45 +0200112 defaults: [
113 "netd_defaults",
114 "needs_netd_direct_connect_rule_defaults",
115 ],
Bernie Innocenti98951792018-06-26 17:13:44 +0900116 include_dirs: [
Bernie Innocenti98951792018-06-26 17:13:44 +0900117 "system/netd/include",
118 "system/netd/server/binder",
119 ],
120 srcs: [
121 "BandwidthController.cpp",
Lorenzo Colitti7ef8c0f2019-01-11 22:34:58 +0900122 "ClatdController.cpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900123 "Controllers.cpp",
124 "NetdConstants.cpp",
125 "FirewallController.cpp",
126 "IdletimerController.cpp",
127 "InterfaceController.cpp",
128 "IptablesRestoreController.cpp",
129 "NFLogListener.cpp",
130 "NetlinkCommands.cpp",
131 "NetlinkListener.cpp",
132 "NetlinkManager.cpp",
Treehugger Robotfe5f4bd2020-06-01 15:18:04 +0000133 "OffloadUtils.cpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900134 "RouteController.cpp",
135 "SockDiag.cpp",
136 "StrictController.cpp",
137 "TcpSocketMonitor.cpp",
138 "TetherController.cpp",
139 "TrafficController.cpp",
140 "UidRanges.cpp",
141 "WakeupController.cpp",
142 "XfrmController.cpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900143 ],
144 shared_libs: [
Chenbo Fenga54aaf52018-11-07 17:51:51 -0800145 "libbpf_android",
Bernie Innocenti98951792018-06-26 17:13:44 +0900146 "libbase",
147 "libbinder",
Chenbo Fengd6104d12018-10-16 20:29:29 -0700148 "libnetdbpf",
Bernie Innocenti98951792018-06-26 17:13:44 +0900149 "libnetutils",
150 "libnetdutils",
151 "libpcap",
152 "libqtaguid",
153 "libssl",
Luke Huang8b4ee582020-04-14 17:42:46 +0000154 "netd_aidl_interface-cpp",
Jeongik Chab54ecec2019-10-15 17:06:59 +0900155 "netd_event_listener_interface-cpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900156 ],
157 aidl: {
158 export_aidl_headers: true,
159 local_include_dirs: ["binder"],
160 },
161}
162
163cc_binary {
164 name: "netd",
165 defaults: ["netd_defaults"],
166 include_dirs: [
Bernie Innocenti98951792018-06-26 17:13:44 +0900167 "external/mdnsresponder/mDNSShared",
168 "system/netd/include",
169 ],
170 init_rc: ["netd.rc"],
Maciej Żenczykowskif428d6e2020-02-19 10:26:35 -0800171 required: [
172 "bpfloader",
173 "clatd.o",
174 "netd.o",
175 "offload.o",
176 ],
Bernie Innocenti98951792018-06-26 17:13:44 +0900177 shared_libs: [
178 "android.system.net.netd@1.0",
179 "android.system.net.netd@1.1",
Bernie Innocentif89b3512018-08-30 07:34:37 +0900180 "libbase",
Bernie Innocenti98951792018-06-26 17:13:44 +0900181 "libbinder",
Chenbo Fenga54aaf52018-11-07 17:51:51 -0800182 "libbpf_android",
Bernie Innocenti98951792018-06-26 17:13:44 +0900183 "libcutils",
184 "libdl",
185 "libhidlbase",
Jeongik Cha0f750c22019-02-22 18:43:44 +0900186 "libjsoncpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900187 "liblog",
Bernie Innocenti98951792018-06-26 17:13:44 +0900188 "libmdnssd",
Jooyung Han3e64aa12019-11-27 15:36:29 +0900189 "libnetd_resolv",
Chenbo Fengd6104d12018-10-16 20:29:29 -0700190 "libnetdbpf",
Bernie Innocenti98951792018-06-26 17:13:44 +0900191 "libnetdutils",
Bernie Innocentif89b3512018-08-30 07:34:37 +0900192 "libnetutils",
Bernie Innocenti98951792018-06-26 17:13:44 +0900193 "libpcap",
Suren Baghdasaryane072a3c2019-01-16 14:36:07 -0800194 "libprocessgroup",
Bernie Innocenti98951792018-06-26 17:13:44 +0900195 "libqtaguid",
196 "libselinux",
Bernie Innocenti98951792018-06-26 17:13:44 +0900197 "libsysutils",
Bernie Innocenti98951792018-06-26 17:13:44 +0900198 "libutils",
Luke Huang29e5fdf2020-04-07 16:15:23 +0000199 "netd_aidl_interface-cpp",
Jeongik Chab54ecec2019-10-15 17:06:59 +0900200 "netd_event_listener_interface-cpp",
Luke Huang0e5e69d2019-03-06 15:42:38 +0800201 "oemnetd_aidl_interface-cpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900202 ],
203 static_libs: [
204 "libnetd_server",
Bernie Innocenti98951792018-06-26 17:13:44 +0900205 ],
206 srcs: [
Bernie Innocenti98951792018-06-26 17:13:44 +0900207 "DummyNetwork.cpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900208 "EventReporter.cpp",
209 "FwmarkServer.cpp",
210 "LocalNetwork.cpp",
211 "MDnsSdListener.cpp",
212 "NetdCommand.cpp",
213 "NetdHwService.cpp",
214 "NetdNativeService.cpp",
215 "NetlinkHandler.cpp",
216 "Network.cpp",
217 "NetworkController.cpp",
Luke Huang0e5e69d2019-03-06 15:42:38 +0800218 "OemNetdListener.cpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900219 "PhysicalNetwork.cpp",
220 "PppController.cpp",
221 "Process.cpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900222 "VirtualNetwork.cpp",
223 "main.cpp",
224 "oem_iptables_hook.cpp",
225 ],
Ken Chen2e413c32020-01-13 11:59:53 +0800226 sanitize: {
227 cfi: true,
Ken Chen2e413c32020-01-13 11:59:53 +0800228 },
Bernie Innocenti98951792018-06-26 17:13:44 +0900229}
230
231cc_binary {
232 name: "ndc",
233 defaults: ["netd_defaults"],
Luke Huangcfd04b22019-03-18 15:53:21 +0800234 include_dirs: [
235 "system/netd/include",
236 ],
237 header_libs: [
238 "libnetd_client_headers",
239 ],
240 shared_libs: [
241 "libbase",
242 "libnetdutils",
243 "libnetutils",
244 "libcutils",
245 "liblog",
246 "libutils",
247 "libbinder",
Jeongik Chab54ecec2019-10-15 17:06:59 +0900248 "dnsresolver_aidl_interface-cpp",
249 "netd_aidl_interface-cpp",
Luke Huangcfd04b22019-03-18 15:53:21 +0800250 ],
251 srcs: [
252 "ndc.cpp",
253 "UidRanges.cpp",
254 "NdcDispatcher.cpp",
255 ],
Ken Chen2e413c32020-01-13 11:59:53 +0800256 sanitize: {
257 cfi: true,
Ken Chen2e413c32020-01-13 11:59:53 +0800258 },
Bernie Innocenti98951792018-06-26 17:13:44 +0900259}
260
261cc_test {
262 name: "netd_unit_test",
263 defaults: ["netd_defaults"],
264 test_suites: ["device-tests"],
Bernie Innocenti83a67ca2019-06-19 16:28:05 +0900265 require_root: true,
Bernie Innocenti98951792018-06-26 17:13:44 +0900266 include_dirs: [
267 "system/netd/include",
268 "system/netd/server/binder",
269 "system/netd/tests",
Bernie Innocenti98951792018-06-26 17:13:44 +0900270 ],
271 srcs: [
272 "BandwidthControllerTest.cpp",
Lorenzo Colitti7ef8c0f2019-01-11 22:34:58 +0900273 "ClatdControllerTest.cpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900274 "ControllersTest.cpp",
275 "FirewallControllerTest.cpp",
276 "IdletimerControllerTest.cpp",
277 "InterfaceControllerTest.cpp",
278 "IptablesBaseTest.cpp",
279 "IptablesRestoreControllerTest.cpp",
280 "NFLogListenerTest.cpp",
Maciej Żenczykowskieec72082020-02-04 23:29:41 -0800281 "OffloadUtilsTest.cpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900282 "RouteControllerTest.cpp",
283 "SockDiagTest.cpp",
284 "StrictControllerTest.cpp",
285 "TetherControllerTest.cpp",
286 "TrafficControllerTest.cpp",
287 "XfrmControllerTest.cpp",
288 "WakeupControllerTest.cpp",
289 ],
290 static_libs: [
291 "libgmock",
292 "libnetd_server",
293 "libnetd_test_tun_interface",
Lorenzo Colitti3f52fae2019-06-27 18:46:22 +0900294 "libqtaguid",
Lorenzo Colittif0e051c2020-04-06 09:19:57 +0000295 "netd_aidl_interface-unstable-cpp",
Jeongik Chab54ecec2019-10-15 17:06:59 +0900296 "netd_event_listener_interface-cpp",
Bernie Innocenti98951792018-06-26 17:13:44 +0900297 ],
298 shared_libs: [
299 "libbase",
300 "libbinder",
Chenbo Fenga54aaf52018-11-07 17:51:51 -0800301 "libbpf_android",
Bernie Innocenti98951792018-06-26 17:13:44 +0900302 "libcrypto",
303 "libcutils",
304 "liblog",
Chenbo Fengd6104d12018-10-16 20:29:29 -0700305 "libnetdbpf",
Bernie Innocenti98951792018-06-26 17:13:44 +0900306 "libnetdutils",
307 "libnetutils",
Bernie Innocenti98951792018-06-26 17:13:44 +0900308 "libsysutils",
309 "libutils",
310 ],
Lorenzo Colitti0766f2f2020-09-18 02:46:53 +0000311 // tidy: false, // cuts test build time by almost 1 minute
Bernie Innocenti98951792018-06-26 17:13:44 +0900312}