blob: ad469f8165ece1f49178f4189cf4c31e8d02c09f [file] [log] [blame]
markchien38c32482021-09-29 12:19:44 +08001/**
2 * Copyright (c) 2016, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.net;
18
19import android.net.INetdUnsolicitedEventListener;
20import android.net.InterfaceConfigurationParcel;
21import android.net.MarkMaskParcel;
22import android.net.NativeNetworkConfig;
23import android.net.RouteInfoParcel;
24import android.net.TetherConfigParcel;
25import android.net.TetherOffloadRuleParcel;
26import android.net.TetherStatsParcel;
27import android.net.UidRangeParcel;
28import android.net.netd.aidl.NativeUidRangeConfig;
29
30/** {@hide} */
31interface INetd {
32 /**
33 * Returns true if the service is responding.
34 */
35 boolean isAlive();
36
37 /**
38 * Replaces the contents of the specified UID-based firewall chain.
39 *
40 * The chain may be an allowlist chain or a denylist chain. A denylist chain contains DROP
41 * rules for the specified UIDs and a RETURN rule at the end. An allowlist chain contains RETURN
42 * rules for the system UID range (0 to {@code UID_APP} - 1), RETURN rules for for the specified
43 * UIDs, and a DROP rule at the end. The chain will be created if it does not exist.
44 *
45 * @param chainName The name of the chain to replace.
46 * @param isAllowlist Whether this is an allowlist or denylist chain.
47 * @param uids The list of UIDs to allow/deny.
48 * @return true if the chain was successfully replaced, false otherwise.
49 */
50 boolean firewallReplaceUidChain(in @utf8InCpp String chainName,
51 boolean isAllowlist,
52 in int[] uids);
53
54 /**
55 * Enables or disables data saver mode on costly network interfaces.
56 *
57 * - When disabled, all packets to/from apps in the penalty box chain are rejected on costly
58 * interfaces. Traffic to/from other apps or on other network interfaces is allowed.
59 * - When enabled, only apps that are in the happy box chain and not in the penalty box chain
60 * are allowed network connectivity on costly interfaces. All other packets on these
61 * interfaces are rejected. The happy box chain always contains all system UIDs; to disallow
62 * traffic from system UIDs, place them in the penalty box chain.
63 *
64 * By default, data saver mode is disabled. This command has no effect but might still return an
65 * error) if {@code enable} is the same as the current value.
66 *
67 * @param enable whether to enable or disable data saver mode.
68 * @return true if the if the operation was successful, false otherwise.
69 */
70 boolean bandwidthEnableDataSaver(boolean enable);
71
72 /**
73 * Creates a physical network (i.e., one containing physical interfaces.
74 * @deprecated use networkCreate() instead.
75 *
76 * @param netId the networkId to create.
77 * @param permission the permission necessary to use the network. Must be one of
78 * PERMISSION_NONE/PERMISSION_NETWORK/PERMISSION_SYSTEM.
79 *
80 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
81 * unix errno.
82 */
83 void networkCreatePhysical(int netId, int permission);
84
85 /**
86 * Creates a VPN network.
87 * @deprecated use networkCreate() instead.
88 *
89 * @param netId the network to create.
90 * @param secure whether unprivileged apps are allowed to bypass the VPN.
91 *
92 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
93 * unix errno.
94 */
95 void networkCreateVpn(int netId, boolean secure);
96
97 /**
98 * Destroys a network. Any interfaces added to the network are removed, and the network ceases
99 * to be the default network.
100 *
101 * @param netId the network to destroy.
102 *
103 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
104 * unix errno.
105 */
106 void networkDestroy(int netId);
107
108 /**
109 * Adds an interface to a network. The interface must not be assigned to any network, including
110 * the specified network.
111 *
112 * @param netId the network to add the interface to.
113 * @param interface the name of the interface to add.
114 *
115 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
116 * unix errno.
117 */
118 void networkAddInterface(int netId, in @utf8InCpp String iface);
119
120 /**
121 * Adds an interface to a network. The interface must be assigned to the specified network.
122 *
123 * @param netId the network to remove the interface from.
124 * @param interface the name of the interface to remove.
125 *
126 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
127 * unix errno.
128 */
129 void networkRemoveInterface(int netId, in @utf8InCpp String iface);
130
131 /**
132 * Adds the specified UID ranges to the specified network. The network can be physical or
133 * virtual. Traffic from the UID ranges will be routed to the network by default.
134 *
135 * @param netId the network ID of the network to add the ranges to.
136 * @param uidRanges a set of non-overlapping ranges of UIDs to add. These exact ranges
137 * must not overlap with existing ranges assigned to this network.
138 *
139 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
140 * unix errno.
141 */
142 void networkAddUidRanges(int netId, in UidRangeParcel[] uidRanges);
143
144 /**
145 * Remove the specified UID ranges from the specified network. The network can be physical or
146 * virtual. Traffic from the UID ranges will no longer be routed to the network by default.
147 *
148 * @param netId the network ID of the network to remove the ranges from.
149 * @param uidRanges a set of non-overlapping ranges of UIDs to remove. These exact ranges
150 * must already be assigned to this network.
151 *
152 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
153 * unix errno.
154 */
155 void networkRemoveUidRanges(int netId, in UidRangeParcel[] uidRanges);
156
157 /**
158 * Adds or removes one rule for each supplied UID range to prohibit all network activity outside
159 * of secure VPN.
160 *
161 * When a UID is covered by one of these rules, traffic sent through any socket that is not
162 * protected or explicitly overriden by the system will be rejected. The kernel will respond
163 * with an ICMP prohibit message.
164 *
165 * Initially, there are no such rules. Any rules that are added will only last until the next
166 * restart of netd or the device.
167 *
168 * @param add {@code true} if the specified UID ranges should be denied access to any network
169 * which is not secure VPN by adding rules, {@code false} to remove existing rules.
170 * @param uidRanges a set of non-overlapping, contiguous ranges of UIDs to which to apply or
171 * remove this restriction.
172 * <p> Added rules should not overlap with existing rules. Likewise, removed rules should
173 * each correspond to an existing rule.
174 *
175 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
176 * unix errno.
177 */
178 void networkRejectNonSecureVpn(boolean add, in UidRangeParcel[] uidRanges);
179
180 /**
181 * Administratively closes sockets belonging to the specified UIDs.
182 */
183 void socketDestroy(in UidRangeParcel[] uidRanges, in int[] exemptUids);
184
185 /**
186 * Instruct the tethering DNS server to reevaluated serving interfaces.
187 * This is needed to for the DNS server to observe changes in the set
188 * of potential listening IP addresses. (Listening on wildcard addresses
189 * can turn the device into an open resolver; b/7530468)
190 *
191 * TODO: Return something richer than just a boolean.
192 */
193 boolean tetherApplyDnsInterfaces();
194
195 /**
196 * Return tethering statistics.
197 *
198 * @return an array of TetherStatsParcel, where each entry contains the upstream interface
199 * name and its tethering statistics since netd startup.
200 * There will only ever be one entry for a given interface.
201 * @throws ServiceSpecificException in case of failure, with an error code indicating the
202 * cause of the failure.
203 */
204 TetherStatsParcel[] tetherGetStats();
205
206 /**
207 * Add/Remove and IP address from an interface.
208 *
209 * @param ifName the interface name
210 * @param addrString the IP address to add/remove as a string literal
211 * @param prefixLength the prefix length associated with this IP address
212 *
213 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
214 * unix errno.
215 */
216 void interfaceAddAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString,
217 int prefixLength);
218 void interfaceDelAddress(in @utf8InCpp String ifName, in @utf8InCpp String addrString,
219 int prefixLength);
220
221 /**
222 * Set and get /proc/sys/net interface configuration parameters.
223 *
224 * @param ipversion One of IPV4/IPV6 integers, indicating the desired IP version directory.
225 * @param which One of CONF/NEIGH integers, indicating the desired parameter category directory.
226 * @param ifname The interface name portion of the path; may also be "all" or "default".
227 * @param parameter The parameter name portion of the path.
228 * @param value The value string to be written into the assembled path.
229 *
230 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
231 * unix errno.
232 */
233
234 const int IPV4 = 4;
235 const int IPV6 = 6;
236 const int CONF = 1;
237 const int NEIGH = 2;
238 @utf8InCpp String getProcSysNet(int ipversion, int which, in @utf8InCpp String ifname,
239 in @utf8InCpp String parameter);
240 void setProcSysNet(int ipversion, int which, in @utf8InCpp String ifname,
241 in @utf8InCpp String parameter, in @utf8InCpp String value);
242
243 /**
244 * Sets owner of socket ParcelFileDescriptor to the new UID, checking to ensure that the caller's
245 * uid is that of the old owner's, and that this is a UDP-encap socket
246 *
247 * @param ParcelFileDescriptor socket Socket file descriptor
248 * @param int newUid UID of the new socket fd owner
249 */
250 void ipSecSetEncapSocketOwner(in ParcelFileDescriptor socket, int newUid);
251
252 /**
253 * Reserve an SPI from the kernel
254 *
255 * @param transformId a unique identifier for allocated resources
256 * @param sourceAddress InetAddress as string for the sending endpoint
257 * @param destinationAddress InetAddress as string for the receiving endpoint
258 * @param spi a requested 32-bit unique ID or 0 to request random allocation
259 * @return the SPI that was allocated or 0 if failed
260 */
261 int ipSecAllocateSpi(
262 int transformId,
263 in @utf8InCpp String sourceAddress,
264 in @utf8InCpp String destinationAddress,
265 int spi);
266
267 /**
268 * Create an IpSec Security Association describing how ip(v6) traffic will be encrypted
269 * or decrypted.
270 *
271 * @param transformId a unique identifier for allocated resources
272 * @param mode either Transport or Tunnel mode
273 * @param sourceAddress InetAddress as string for the sending endpoint
274 * @param destinationAddress InetAddress as string for the receiving endpoint
275 * @param underlyingNetId the netId of the network to which the SA is applied. Only accepted for
276 * tunnel mode SAs.
277 * @param spi a 32-bit unique ID allocated to the user
278 * @param markValue a 32-bit unique ID chosen by the user
279 * @param markMask a 32-bit mask chosen by the user
280 * @param authAlgo a string identifying the authentication algorithm to be used
281 * @param authKey a byte array containing the authentication key
282 * @param authTruncBits the truncation length of the MAC produced by the authentication algorithm
283 * @param cryptAlgo a string identifying the encryption algorithm to be used
284 * @param cryptKey a byte arrray containing the encryption key
285 * @param cryptTruncBits unused parameter
286 * @param aeadAlgo a string identifying the authenticated encryption algorithm to be used
287 * @param aeadKey a byte arrray containing the key to be used in authenticated encryption
288 * @param aeadIcvBits the truncation length of the ICV produced by the authentication algorithm
289 * (similar to authTruncBits in function)
290 * @param encapType encapsulation type used (if any) for the udp encap socket
291 * @param encapLocalPort the port number on the host to be used in encap packets
292 * @param encapRemotePort the port number of the remote to be used for encap packets
293 * @param interfaceId the identifier for the IPsec tunnel interface.
294 * Only accepted for tunnel mode SAs.
295 */
296 void ipSecAddSecurityAssociation(
297 int transformId,
298 int mode,
299 in @utf8InCpp String sourceAddress,
300 in @utf8InCpp String destinationAddress,
301 int underlyingNetId,
302 int spi,
303 int markValue,
304 int markMask,
305 in @utf8InCpp String authAlgo, in byte[] authKey, in int authTruncBits,
306 in @utf8InCpp String cryptAlgo, in byte[] cryptKey, in int cryptTruncBits,
307 in @utf8InCpp String aeadAlgo, in byte[] aeadKey, in int aeadIcvBits,
308 int encapType,
309 int encapLocalPort,
310 int encapRemotePort,
311 int interfaceId);
312
313 /**
314 * Delete a previously created security association identified by the provided parameters
315 *
316 * @param transformId a unique identifier for allocated resources
317 * @param sourceAddress InetAddress as string for the sending endpoint
318 * @param destinationAddress InetAddress as string for the receiving endpoint
319 * @param spi a requested 32-bit unique ID allocated to the user
320 * @param markValue a 32-bit unique ID chosen by the user
321 * @param markMask a 32-bit mask chosen by the user
322 * @param interfaceId the identifier for the IPsec tunnel interface.
323 */
324 void ipSecDeleteSecurityAssociation(
325 int transformId,
326 in @utf8InCpp String sourceAddress,
327 in @utf8InCpp String destinationAddress,
328 int spi,
329 int markValue,
330 int markMask,
331 int interfaceId);
332
333 /**
334 * Apply a previously created SA to a specified socket, starting IPsec on that socket
335 *
336 * @param socket a user-provided socket that will have IPsec applied
337 * @param transformId a unique identifier for allocated resources
338 * @param direction DIRECTION_IN or DIRECTION_OUT
339 * @param sourceAddress InetAddress as string for the sending endpoint
340 * @param destinationAddress InetAddress as string for the receiving endpoint
341 * @param spi a 32-bit unique ID allocated to the user (socket owner)
342 */
343 void ipSecApplyTransportModeTransform(
344 in ParcelFileDescriptor socket,
345 int transformId,
346 int direction,
347 in @utf8InCpp String sourceAddress,
348 in @utf8InCpp String destinationAddress,
349 int spi);
350
351 /**
352 * Remove an IPsec SA from a given socket. This will allow unencrypted traffic to flow
353 * on that socket if a transform had been previously applied.
354 *
355 * @param socket a user-provided socket from which to remove any IPsec configuration
356 */
357 void ipSecRemoveTransportModeTransform(
358 in ParcelFileDescriptor socket);
359
360 /**
361 * Adds an IPsec global policy.
362 *
363 * @param transformId a unique identifier for allocated resources
364 * @param selAddrFamily the address family identifier for the selector
365 * @param direction DIRECTION_IN or DIRECTION_OUT
366 * @param tmplSrcAddress InetAddress as string for the sending endpoint
367 * @param tmplDstAddress InetAddress as string for the receiving endpoint
368 * @param spi a 32-bit unique ID allocated to the user
369 * @param markValue a 32-bit unique ID chosen by the user
370 * @param markMask a 32-bit mask chosen by the user
371 * @param interfaceId the identifier for the IPsec tunnel interface.
372 */
373 void ipSecAddSecurityPolicy(
374 int transformId,
375 int selAddrFamily,
376 int direction,
377 in @utf8InCpp String tmplSrcAddress,
378 in @utf8InCpp String tmplDstAddress,
379 int spi,
380 int markValue,
381 int markMask,
382 int interfaceId);
383
384 /**
385 * Updates an IPsec global policy.
386 *
387 * @param transformId a unique identifier for allocated resources
388 * @param selAddrFamily the address family identifier for the selector
389 * @param direction DIRECTION_IN or DIRECTION_OUT
390 * @param tmplSrcAddress InetAddress as string for the sending endpoint
391 * @param tmplDstAddress InetAddress as string for the receiving endpoint
392 * @param spi a 32-bit unique ID allocated to the user
393 * @param markValue a 32-bit unique ID chosen by the user
394 * @param markMask a 32-bit mask chosen by the user
395 * @param interfaceId the identifier for the IPsec tunnel interface.
396 */
397 void ipSecUpdateSecurityPolicy(
398 int transformId,
399 int selAddrFamily,
400 int direction,
401 in @utf8InCpp String tmplSrcAddress,
402 in @utf8InCpp String tmplDstAddress,
403 int spi,
404 int markValue,
405 int markMask,
406 int interfaceId);
407
408 /**
409 * Deletes an IPsec global policy.
410 *
411 * Deletion of global policies does not do any matching based on the templates, thus
412 * template source/destination addresses are not needed (as opposed to add/update).
413 *
414 * @param transformId a unique identifier for allocated resources
415 * @param selAddrFamily the address family identifier for the selector
416 * @param direction DIRECTION_IN or DIRECTION_OUT
417 * @param markValue a 32-bit unique ID chosen by the user
418 * @param markMask a 32-bit mask chosen by the user
419 * @param interfaceId the identifier for the IPsec tunnel interface.
420 */
421 void ipSecDeleteSecurityPolicy(
422 int transformId,
423 int selAddrFamily,
424 int direction,
425 int markValue,
426 int markMask,
427 int interfaceId);
428
429 // This could not be declared as @uft8InCpp; thus, when used in native code it must be
430 // converted from a UTF-16 string to an ASCII string.
431 const String IPSEC_INTERFACE_PREFIX = "ipsec";
432
433 /**
434 * Add a IPsec Tunnel Interface.
435 *
436 * @param devName a unique identifier that represents the name of the device
437 * @param localAddress InetAddress as string for the local endpoint
438 * @param remoteAddress InetAddress as string for the remote endpoint
439 * @param iKey, to match Policies and SAs for input packets.
440 * @param oKey, to match Policies and SAs for output packets.
441 * @param interfaceId the identifier for the IPsec tunnel interface.
442 */
443 void ipSecAddTunnelInterface(
444 in @utf8InCpp String deviceName,
445 in @utf8InCpp String localAddress,
446 in @utf8InCpp String remoteAddress,
447 int iKey,
448 int oKey,
449 int interfaceId);
450
451 /**
452 * Update a IPsec Tunnel Interface.
453 *
454 * @param devName a unique identifier that represents the name of the device
455 * @param localAddress InetAddress as string for the local endpoint
456 * @param remoteAddress InetAddress as string for the remote endpoint
457 * @param iKey, to match Policies and SAs for input packets.
458 * @param oKey, to match Policies and SAs for output packets.
459 * @param interfaceId the identifier for the IPsec tunnel interface.
460 */
461 void ipSecUpdateTunnelInterface(
462 in @utf8InCpp String deviceName,
463 in @utf8InCpp String localAddress,
464 in @utf8InCpp String remoteAddress,
465 int iKey,
466 int oKey,
467 int interfaceId);
468
469 /**
470 * Removes a IPsec Tunnel Interface.
471 *
472 * @param devName a unique identifier that represents the name of the device
473 */
474 void ipSecRemoveTunnelInterface(in @utf8InCpp String deviceName);
475
476 /**
477 * Request notification of wakeup packets arriving on an interface. Notifications will be
478 * delivered to INetdEventListener.onWakeupEvent().
479 *
480 * @param ifName the interface
481 * @param prefix arbitrary string used to identify wakeup sources in onWakeupEvent
482 */
483 void wakeupAddInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
484
485 /**
486 * Stop notification of wakeup packets arriving on an interface.
487 *
488 * @param ifName the interface
489 * @param prefix arbitrary string used to identify wakeup sources in onWakeupEvent
490 */
491 void wakeupDelInterface(in @utf8InCpp String ifName, in @utf8InCpp String prefix, int mark, int mask);
492
493 const int IPV6_ADDR_GEN_MODE_EUI64 = 0;
494 const int IPV6_ADDR_GEN_MODE_NONE = 1;
495 const int IPV6_ADDR_GEN_MODE_STABLE_PRIVACY = 2;
496 const int IPV6_ADDR_GEN_MODE_RANDOM = 3;
497
498 const int IPV6_ADDR_GEN_MODE_DEFAULT = 0;
499 /**
500 * Set IPv6 address generation mode. IPv6 should be disabled before changing mode.
501 *
502 * @param mode SLAAC address generation mechanism to use
503 */
504 void setIPv6AddrGenMode(in @utf8InCpp String ifName, int mode);
505
506 /**
507 * Add idletimer for specific interface
508 *
509 * @param ifName Name of target interface
510 * @param timeout The time in seconds that will trigger idletimer
511 * @param classLabel The unique identifier for this idletimer
512 * @throws ServiceSpecificException in case of failure, with an error code indicating the
513 * cause of the failure.
514 */
515 void idletimerAddInterface(
516 in @utf8InCpp String ifName,
517 int timeout,
518 in @utf8InCpp String classLabel);
519
520 /**
521 * Remove idletimer for specific interface
522 *
523 * @param ifName Name of target interface
524 * @param timeout The time in seconds that will trigger idletimer
525 * @param classLabel The unique identifier for this idletimer
526 * @throws ServiceSpecificException in case of failure, with an error code indicating the
527 * cause of the failure.
528 */
529 void idletimerRemoveInterface(
530 in @utf8InCpp String ifName,
531 int timeout,
532 in @utf8InCpp String classLabel);
533
534 const int PENALTY_POLICY_ACCEPT = 1;
535 const int PENALTY_POLICY_LOG = 2;
536 const int PENALTY_POLICY_REJECT = 3;
537
538 /**
539 * Offers to detect sockets sending data not wrapped inside a layer of SSL/TLS encryption.
540 *
541 * @param uid Uid of the app
542 * @param policyPenalty The penalty policy of the app
543 * @throws ServiceSpecificException in case of failure, with an error code indicating the
544 * cause of the failure.
545 */
546 void strictUidCleartextPenalty(int uid, int policyPenalty);
547
548 /**
549 * Start clatd
550 *
Hungming Chened129262022-04-26 19:10:45 +0800551 * @deprecated This method has no effect and throws UnsupportedOperationException. The clatd
552 * control plane moved to the mainline module starting in T. See ClatCoordinator.
markchien38c32482021-09-29 12:19:44 +0800553 * @param ifName interface name to start clatd
554 * @param nat64Prefix the NAT64 prefix, e.g., "2001:db8:64::/96".
555 * @return a string, the IPv6 address that will be used for 464xlat.
556 * @throws ServiceSpecificException in case of failure, with an error code indicating the
557 * cause of the failure.
558 */
559 @utf8InCpp String clatdStart(in @utf8InCpp String ifName, in @utf8InCpp String nat64Prefix);
560
561 /**
562 * Stop clatd
563 *
Hungming Chened129262022-04-26 19:10:45 +0800564 * @deprecated This method has no effect and throws UnsupportedOperationException. The clatd
565 * control plane moved to the mainline module starting in T. See ClatCoordinator.
markchien38c32482021-09-29 12:19:44 +0800566 * @param ifName interface name to stop clatd
567 * @throws ServiceSpecificException in case of failure, with an error code indicating the
568 * cause of the failure.
569 */
570 void clatdStop(in @utf8InCpp String ifName);
571
572 /**
573 * Get status of IP forwarding
574 *
575 * @return true if IP forwarding is enabled, false otherwise.
576 */
577 boolean ipfwdEnabled();
578
579 /**
580 * Get requester list of IP forwarding
581 *
582 * @return An array of strings containing requester list of IP forwarding
583 */
584 @utf8InCpp String[] ipfwdGetRequesterList();
585
586 /**
587 * Enable IP forwarding for specific requester
588 *
589 * @param requester requester name to enable IP forwarding. It is a unique name which will be
590 * stored in Netd to make sure if any requester needs IP forwarding.
591 * @throws ServiceSpecificException in case of failure, with an error code indicating the
592 * cause of the failure.
593 */
594 void ipfwdEnableForwarding(in @utf8InCpp String requester);
595
596 /**
597 * Disable IP forwarding for specific requester
598 *
599 * @param requester requester name to disable IP forwarding. This name should match the
600 * names which are set by ipfwdEnableForwarding.
601 * IP forwarding would be disabled if it is the last requester.
602 * @throws ServiceSpecificException in case of failure, with an error code indicating the
603 * cause of the failure.
604 */
605 void ipfwdDisableForwarding(in @utf8InCpp String requester);
606
607 /**
608 * Add forwarding ip rule
609 *
610 * @param fromIface interface name to add forwarding ip rule
611 * @param toIface interface name to add forwarding ip rule
612 * @throws ServiceSpecificException in case of failure, with an error code indicating the
613 * cause of the failure.
614 */
615 void ipfwdAddInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
616
617 /**
618 * Remove forwarding ip rule
619 *
620 * @param fromIface interface name to remove forwarding ip rule
621 * @param toIface interface name to remove forwarding ip rule
622 * @throws ServiceSpecificException in case of failure, with an error code indicating the
623 * cause of the failure.
624 */
625 void ipfwdRemoveInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
626
627 /**
628 * Set quota for interface
629 *
630 * @param ifName Name of target interface
631 * @param bytes Quota value in bytes
632 * @throws ServiceSpecificException in case of failure, with an error code indicating the
633 * cause of the failure.
634 */
635 void bandwidthSetInterfaceQuota(in @utf8InCpp String ifName, long bytes);
636
637 /**
638 * Remove quota for interface
639 *
640 * @param ifName Name of target interface
641 * @throws ServiceSpecificException in case of failure, with an error code indicating the
642 * cause of the failure.
643 */
644 void bandwidthRemoveInterfaceQuota(in @utf8InCpp String ifName);
645
646 /**
647 * Set alert for interface
648 *
649 * @param ifName Name of target interface
650 * @param bytes Alert value in bytes
651 * @throws ServiceSpecificException in case of failure, with an error code indicating the
652 * cause of the failure.
653 */
654 void bandwidthSetInterfaceAlert(in @utf8InCpp String ifName, long bytes);
655
656 /**
657 * Remove alert for interface
658 *
659 * @param ifName Name of target interface
660 * @throws ServiceSpecificException in case of failure, with an error code indicating the
661 * cause of the failure.
662 */
663 void bandwidthRemoveInterfaceAlert(in @utf8InCpp String ifName);
664
665 /**
666 * Set global alert
667 *
668 * @param bytes Alert value in bytes
669 * @throws ServiceSpecificException in case of failure, with an error code indicating the
670 * cause of the failure.
671 */
672 void bandwidthSetGlobalAlert(long bytes);
673
674 /**
675 * Add naughty app bandwidth rule for specific app
676 *
677 * @param uid uid of target app
678 * @throws ServiceSpecificException in case of failure, with an error code indicating the
679 * cause of the failure.
680 */
681 void bandwidthAddNaughtyApp(int uid);
682
683 /**
684 * Remove naughty app bandwidth rule for specific app
685 *
686 * @param uid uid of target app
687 * @throws ServiceSpecificException in case of failure, with an error code indicating the
688 * cause of the failure.
689 */
690 void bandwidthRemoveNaughtyApp(int uid);
691
692 /**
693 * Add nice app bandwidth rule for specific app
694 *
695 * @param uid uid of target app
696 * @throws ServiceSpecificException in case of failure, with an error code indicating the
697 * cause of the failure.
698 */
699 void bandwidthAddNiceApp(int uid);
700
701 /**
702 * Remove nice app bandwidth rule for specific app
703 *
704 * @param uid uid of target app
705 * @throws ServiceSpecificException in case of failure, with an error code indicating the
706 * cause of the failure.
707 */
708 void bandwidthRemoveNiceApp(int uid);
709
710 /**
711 * Start tethering
712 *
713 * @param dhcpRanges dhcp ranges to set.
714 * dhcpRanges might contain many addresss {addr1, addr2, aadr3, addr4...}
715 * Netd splits them into ranges: addr1-addr2, addr3-addr4, etc.
716 * An odd number of addrs will fail.
717 * @throws ServiceSpecificException in case of failure, with an error code indicating the
718 * cause of the failure.
719 */
720 void tetherStart(in @utf8InCpp String[] dhcpRanges);
721
722 /**
723 * Stop tethering
724 *
725 * @throws ServiceSpecificException in case of failure, with an error code indicating the
726 * cause of the failure.
727 */
728 void tetherStop();
729
730 /**
731 * Get status of tethering
732 *
733 * @return true if tethering is enabled, false otherwise.
734 */
735 boolean tetherIsEnabled();
736
737 /**
738 * Setup interface for tethering
739 *
740 * @param ifName interface name to add
741 * @throws ServiceSpecificException in case of failure, with an error code indicating the
742 * cause of the failure.
743 */
744 void tetherInterfaceAdd(in @utf8InCpp String ifName);
745
746 /**
747 * Reset interface for tethering
748 *
749 * @param ifName interface name to remove
750 * @throws ServiceSpecificException in case of failure, with an error code indicating the
751 * cause of the failure.
752 */
753 void tetherInterfaceRemove(in @utf8InCpp String ifName);
754
755 /**
756 * Get the interface list which is stored in netd
757 * The list contains the interfaces managed by tetherInterfaceAdd/tetherInterfaceRemove
758 *
759 * @return An array of strings containing interface list result
760 */
761 @utf8InCpp String[] tetherInterfaceList();
762
763 /**
764 * Set DNS forwarder server
765 *
766 * @param netId the upstream network to forward DNS queries to
767 * @param dnsAddrs DNS server address to set
768 * @throws ServiceSpecificException in case of failure, with an error code indicating the
769 * cause of the failure.
770 */
771 void tetherDnsSet(int netId, in @utf8InCpp String[] dnsAddrs);
772
773 /**
774 * Return the DNS list set by tetherDnsSet
775 *
776 * @return An array of strings containing the list of DNS servers
777 */
778 @utf8InCpp String[] tetherDnsList();
779
780 const int LOCAL_NET_ID = 99;
781
782 /**
783 * Constant net ID for the "dummy" network.
784 *
785 * The dummy network is used to blackhole or reject traffic. Any attempt to use it will
786 * either drop the packets or fail with ENETUNREACH.
787 */
788 const int DUMMY_NET_ID = 51;
789
790 /**
791 * Constant net ID for the "unreachable" network.
792 *
793 * The unreachable network is used to reject traffic. Any attempt to use it will fail
794 * with ENETUNREACH.
795 */
796 const int UNREACHABLE_NET_ID = 52;
797
798 // Route does not specify a next hop
799 const String NEXTHOP_NONE = "";
800 // Route next hop is unreachable
801 const String NEXTHOP_UNREACHABLE = "unreachable";
802 // Route next hop is throw
803 const String NEXTHOP_THROW = "throw";
804
805 /**
806 * Add a route for specific network
807 *
808 * @param netId the network to add the route to
809 * @param ifName the name of interface of the route.
810 * This interface should be assigned to the netID.
811 * @param destination the destination of the route
812 * @param nextHop The route's next hop address,
813 * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
814 * @throws ServiceSpecificException in case of failure, with an error code indicating the
815 * cause of the failure.
816 */
817 void networkAddRoute(
818 int netId,
819 in @utf8InCpp String ifName,
820 in @utf8InCpp String destination,
821 in @utf8InCpp String nextHop);
822
823 /**
824 * Remove a route for specific network
825 *
826 * @param netId the network to remove the route from
827 * @param ifName the name of interface of the route.
828 * This interface should be assigned to the netID.
829 * @param destination the destination of the route
830 * @param nextHop The route's next hop address,
831 * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
832 * @throws ServiceSpecificException in case of failure, with an error code indicating the
833 * cause of the failure.
834 */
835 void networkRemoveRoute(
836 int netId,
837 in @utf8InCpp String ifName,
838 in @utf8InCpp String destination,
839 in @utf8InCpp String nextHop);
840
841 /**
842 * Add a route to legacy routing table for specific network
843 *
844 * @param netId the network to add the route to
845 * @param ifName the name of interface of the route.
846 * This interface should be assigned to the netID.
847 * @param destination the destination of the route
848 * @param nextHop The route's next hop address,
849 * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
850 * @param uid uid of the user
851 * @throws ServiceSpecificException in case of failure, with an error code indicating the
852 * cause of the failure.
853 */
854 void networkAddLegacyRoute(
855 int netId,
856 in @utf8InCpp String ifName,
857 in @utf8InCpp String destination,
858 in @utf8InCpp String nextHop,
859 int uid);
860
861 /**
862 * Remove a route from legacy routing table for specific network
863 *
864 * @param netId the network to remove the route from
865 * @param ifName the name of interface of the route.
866 * This interface should be assigned to the netID.
867 * @param destination the destination of the route
868 * @param nextHop The route's next hop address,
869 * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
870 * @param uid uid of the user
871 * @throws ServiceSpecificException in case of failure, with an error code indicating the
872 * cause of the failure.
873 */
874 void networkRemoveLegacyRoute(
875 int netId,
876 in @utf8InCpp String ifName,
877 in @utf8InCpp String destination,
878 in @utf8InCpp String nextHop,
879 int uid);
880
881 /**
882 * Get default network
883 *
884 * @return netId of default network
885 */
886 int networkGetDefault();
887
888 /**
889 * Set network as default network
890 *
891 * @param netId the network to set as the default
892 * @throws ServiceSpecificException in case of failure, with an error code indicating the
893 * cause of the failure.
894 */
895 void networkSetDefault(int netId);
896
897 /**
898 * Clear default network
899 *
900 * @throws ServiceSpecificException in case of failure, with an error code indicating the
901 * cause of the failure.
902 */
903 void networkClearDefault();
904
905 /**
906 * PERMISSION_NONE is used for regular networks and apps. TODO: use PERMISSION_INTERNET
907 * for this instead, and use PERMISSION_NONE to indicate no network permissions at all.
908 */
909 const int PERMISSION_NONE = 0;
910
911 /**
912 * PERMISSION_NETWORK represents the CHANGE_NETWORK_STATE permission.
913 */
914 const int PERMISSION_NETWORK = 1;
915
916 /**
917 * PERMISSION_SYSTEM represents the ability to use restricted networks. This is mostly
918 * equivalent to the CONNECTIVITY_USE_RESTRICTED_NETWORKS permission.
919 */
920 const int PERMISSION_SYSTEM = 2;
921
922 /**
923 * NO_PERMISSIONS indicates that this app is installed and doesn't have either
924 * PERMISSION_INTERNET or PERMISSION_UPDATE_DEVICE_STATS.
925 * TODO: use PERMISSION_NONE to represent this case
926 */
927 const int NO_PERMISSIONS = 0;
928
929 /**
930 * PERMISSION_INTERNET indicates that the app can create AF_INET and AF_INET6 sockets
931 */
932 const int PERMISSION_INTERNET = 4;
933
934 /**
935 * PERMISSION_UPDATE_DEVICE_STATS is used for system UIDs and privileged apps
936 * that have the UPDATE_DEVICE_STATS permission
937 */
938 const int PERMISSION_UPDATE_DEVICE_STATS = 8;
939
940 /**
941 * PERMISSION_UNINSTALLED is used when an app is uninstalled from the device. All internet
942 * related permissions need to be cleaned
943 */
944 const int PERMISSION_UNINSTALLED = -1;
945
946
947 /**
948 * Sets the permission required to access a specific network.
949 *
950 * @param netId the network to set
951 * @param permission network permission to use
952 * @throws ServiceSpecificException in case of failure, with an error code indicating the
953 * cause of the failure.
954 */
955 void networkSetPermissionForNetwork(int netId, int permission);
956
957 /**
958 * Assigns network access permissions to the specified users.
959 *
960 * @param permission network permission to use
961 * @param uids uid of users to set permission
962 */
963 void networkSetPermissionForUser(int permission, in int[] uids);
964
965 /**
966 * Clears network access permissions for the specified users.
967 *
968 * @param uids uid of users to clear permission
969 */
970 void networkClearPermissionForUser(in int[] uids);
971
972 /**
973 * Assigns android.permission.INTERNET and/or android.permission.UPDATE_DEVICE_STATS to the uids
974 * specified. Or remove all permissions from the uids.
975 *
976 * @param permission The permission to grant, it could be either PERMISSION_INTERNET and/or
977 * PERMISSION_UPDATE_DEVICE_STATS. If the permission is NO_PERMISSIONS, then
978 * revoke all permissions for the uids.
979 * @param uids uid of users to grant permission
980 */
981 void trafficSetNetPermForUids(int permission, in int[] uids);
982
983 /**
984 * Gives the specified user permission to protect sockets from VPNs.
985 * Typically used by VPN apps themselves, to ensure that the sockets
986 * they use to communicate with the VPN server aren't routed through
987 * the VPN network.
988 *
989 * @param uid uid of user to set
990 */
991 void networkSetProtectAllow(int uid);
992
993 /**
994 * Removes the permission to protect sockets from VPN.
995 *
996 * @param uid uid of user to set
997 */
998 void networkSetProtectDeny(int uid);
999
1000 /**
1001 * Get the status of network protect for user
1002 *
1003 * @param uids uid of user
1004 * @return true if the user can protect sockets from VPN, false otherwise.
1005 */
1006 boolean networkCanProtect(int uid);
1007
1008 /** Only allows packets from specific UID/Interface.
1009 @deprecated use FIREWALL_ALLOWLIST. */
1010 const int FIREWALL_WHITELIST = 0;
1011
1012 /** Only allows packets from specific UID/Interface. */
1013 const int FIREWALL_ALLOWLIST = 0;
1014
1015 /** Blocks packets from specific UID/Interface.
1016 @deprecated use FIREWALL_DENYLIST. */
1017 const int FIREWALL_BLACKLIST = 1;
1018
1019 /** Blocks packets from specific UID/Interface. */
1020 const int FIREWALL_DENYLIST = 1;
1021
1022 /**
1023 * Set type of firewall
1024 * Type allowlist only allows packets from specific UID/Interface
1025 * Type denylist blocks packets from specific UID/Interface
1026 *
1027 * @param firewalltype type of firewall, either FIREWALL_ALLOWLIST or FIREWALL_DENYLIST
1028 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1029 * cause of the failure.
1030 */
1031 void firewallSetFirewallType(int firewalltype);
1032
1033 // Specify allow Rule which allows packets
1034 const int FIREWALL_RULE_ALLOW = 1;
1035 // Specify deny Rule which drops packets
1036 const int FIREWALL_RULE_DENY = 2;
1037
1038 // No specific chain is chosen, use general firewall chain(fw_input, fw_output)
1039 const int FIREWALL_CHAIN_NONE = 0;
1040 // Specify DOZABLE chain(fw_dozable) which is used in dozable mode
1041 const int FIREWALL_CHAIN_DOZABLE = 1;
1042 // Specify STANDBY chain(fw_standby) which is used in standby mode
1043 const int FIREWALL_CHAIN_STANDBY = 2;
1044 // Specify POWERSAVE chain(fw_powersave) which is used in power save mode
1045 const int FIREWALL_CHAIN_POWERSAVE = 3;
1046 // Specify RESTRICTED chain(fw_restricted) which is used in restricted
1047 // networking mode
1048 const int FIREWALL_CHAIN_RESTRICTED = 4;
1049
1050 /**
1051 * Set firewall rule for interface
1052 *
1053 * @param ifName the interface to allow/deny
1054 * @param firewallRule either FIREWALL_RULE_ALLOW or FIREWALL_RULE_DENY
1055 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1056 * cause of the failure.
1057 */
1058 void firewallSetInterfaceRule(in @utf8InCpp String ifName, int firewallRule);
1059
1060 /**
1061 * Set firewall rule for uid
1062 *
1063 * @param childChain target chain
1064 * @param uid uid to allow/deny
1065 * @param firewallRule either FIREWALL_RULE_ALLOW or FIREWALL_RULE_DENY
1066 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1067 * cause of the failure.
1068 */
1069 void firewallSetUidRule(int childChain, int uid, int firewallRule);
1070
1071 /**
1072 * Enable/Disable target firewall child chain
1073 *
1074 * @param childChain target chain to enable
1075 * @param enable whether to enable or disable child chain.
1076 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1077 * cause of the failure.
1078 */
1079 void firewallEnableChildChain(int childChain, boolean enable);
1080
1081 /**
1082 * Get interface list
1083 *
1084 * @return An array of strings containing all the interfaces on the system.
1085 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1086 * unix errno.
1087 */
1088 @utf8InCpp String[] interfaceGetList();
1089
1090 // Must be kept in sync with constant in InterfaceConfiguration.java
1091 const String IF_STATE_UP = "up";
1092 const String IF_STATE_DOWN = "down";
1093
1094 const String IF_FLAG_BROADCAST = "broadcast";
1095 const String IF_FLAG_LOOPBACK = "loopback";
1096 const String IF_FLAG_POINTOPOINT = "point-to-point";
1097 const String IF_FLAG_RUNNING = "running";
1098 const String IF_FLAG_MULTICAST = "multicast";
1099
1100 /**
1101 * Get interface configuration
1102 *
1103 * @param ifName interface name
1104 * @return An InterfaceConfigurationParcel for the specified interface.
1105 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1106 * unix errno.
1107 */
1108 InterfaceConfigurationParcel interfaceGetCfg(in @utf8InCpp String ifName);
1109
1110 /**
1111 * Set interface configuration
1112 *
1113 * @param cfg Interface configuration to set
1114 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1115 * unix errno.
1116 */
1117 void interfaceSetCfg(in InterfaceConfigurationParcel cfg);
1118
1119 /**
1120 * Set interface IPv6 privacy extensions
1121 *
1122 * @param ifName interface name
1123 * @param enable whether to enable or disable this setting.
1124 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1125 * cause of the failure.
1126 */
1127 void interfaceSetIPv6PrivacyExtensions(in @utf8InCpp String ifName, boolean enable);
1128
1129 /**
1130 * Clear all IP addresses on the given interface
1131 *
1132 * @param ifName interface name
1133 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1134 * POSIX errno.
1135 */
1136 void interfaceClearAddrs(in @utf8InCpp String ifName);
1137
1138 /**
1139 * Enable or disable IPv6 on the given interface
1140 *
1141 * @param ifName interface name
1142 * @param enable whether to enable or disable this setting.
1143 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1144 * cause of the failure.
1145 */
1146 void interfaceSetEnableIPv6(in @utf8InCpp String ifName, boolean enable);
1147
1148 /**
1149 * Set interface MTU
1150 *
1151 * @param ifName interface name
1152 * @param mtu MTU value
1153 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1154 * cause of the failure.
1155 */
1156 void interfaceSetMtu(in @utf8InCpp String ifName, int mtu);
1157
1158 /**
1159 * Add forwarding rule/stats on given interface.
1160 *
1161 * @param intIface downstream interface
1162 * @param extIface upstream interface
1163 */
1164 void tetherAddForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
1165
1166 /**
1167 * Remove forwarding rule/stats on given interface.
1168 *
1169 * @param intIface downstream interface
1170 * @param extIface upstream interface
1171 */
1172 void tetherRemoveForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
1173
1174 /**
1175 * Set the values of tcp_{rmem,wmem}.
1176 *
1177 * @param rmemValues the target values of tcp_rmem, each value is separated by spaces
1178 * @param wmemValues the target values of tcp_wmem, each value is separated by spaces
1179 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1180 * cause of the failure.
1181 */
1182 void setTcpRWmemorySize(in @utf8InCpp String rmemValues, in @utf8InCpp String wmemValues);
1183
1184 /**
1185 * Register unsolicited event listener
1186 * Netd supports multiple unsolicited event listeners.
1187 *
1188 * @param listener unsolicited event listener to register
1189 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1190 * cause of the failure.
1191 */
1192 void registerUnsolicitedEventListener(INetdUnsolicitedEventListener listener);
1193
1194 /**
1195 * Add ingress interface filtering rules to a list of UIDs
1196 *
1197 * For a given uid, once a filtering rule is added, the kernel will only allow packets from the
1198 * allowed interface and loopback to be sent to the list of UIDs.
1199 *
1200 * Calling this method on one or more UIDs with an existing filtering rule but a different
1201 * interface name will result in the filtering rule being updated to allow the new interface
1202 * instead. Otherwise calling this method will not affect existing rules set on other UIDs.
1203 *
1204 * @param ifName the name of the interface on which the filtering rules will allow packets to
1205 be received.
1206 * @param uids an array of UIDs which the filtering rules will be set
1207 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1208 * cause of the failure.
1209 */
1210 void firewallAddUidInterfaceRules(in @utf8InCpp String ifName, in int[] uids);
1211
1212 /**
1213 * Remove ingress interface filtering rules from a list of UIDs
1214 *
1215 * Clear the ingress interface filtering rules from the list of UIDs which were previously set
1216 * by firewallAddUidInterfaceRules(). Ignore any uid which does not have filtering rule.
1217 *
1218 * @param uids an array of UIDs from which the filtering rules will be removed
1219 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1220 * cause of the failure.
1221 */
1222 void firewallRemoveUidInterfaceRules(in int[] uids);
1223
1224 /**
1225 * Request netd to change the current active network stats map.
1226 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1227 * cause of the failure.
1228 */
1229 void trafficSwapActiveStatsMap();
1230
1231 /**
1232 * Retrieves OEM netd listener interface
1233 *
1234 * @return a IBinder object, it could be casted to oem specific interface.
1235 */
1236 IBinder getOemNetd();
1237
1238 /**
1239 * Start tethering with given configuration
1240 *
1241 * @param config config to start tethering.
1242 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1243 * cause of the failure.
1244 */
1245 void tetherStartWithConfiguration(in TetherConfigParcel config);
1246
1247
1248 /**
1249 * Get the fwmark and its net id mask for the given network id.
1250 *
1251 * @param netId the network to get the fwmark and mask for.
1252 * @return A MarkMaskParcel of the given network id.
1253 */
1254 MarkMaskParcel getFwmarkForNetwork(int netId);
1255
1256 /**
1257 * Add a route for specific network
1258 *
1259 * @param netId the network to add the route to
1260 * @param routeInfo parcelable with route information
1261 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1262 * cause of the failure.
1263 */
1264 void networkAddRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
1265
1266 /**
1267 * Update a route for specific network
1268 *
1269 * @param routeInfo parcelable with route information
1270 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1271 * cause of the failure.
1272 */
1273 void networkUpdateRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
1274
1275 /**
1276 * Remove a route for specific network
1277 *
1278 * @param routeInfo parcelable with route information
1279 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1280 * cause of the failure.
1281 */
1282 void networkRemoveRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
1283
1284 /**
1285 * Adds a tethering offload rule, or updates it if it already exists.
1286 *
1287 * Currently, only downstream /128 IPv6 entries are supported. An existing rule will be updated
1288 * if the input interface and destination prefix match. Otherwise, a new rule will be created.
1289 *
Hungming Chened129262022-04-26 19:10:45 +08001290 * @deprecated This method has no effect and throws UnsupportedOperationException. The mainline
1291 * module accesses the BPF map directly starting in S. See BpfCoordinator.
markchien38c32482021-09-29 12:19:44 +08001292 * @param rule The rule to add or update.
1293 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1294 * cause of the failure.
1295 */
1296 void tetherOffloadRuleAdd(in TetherOffloadRuleParcel rule);
1297
1298 /**
1299 * Deletes a tethering offload rule.
1300 *
1301 * Currently, only downstream /128 IPv6 entries are supported. An existing rule will be deleted
1302 * if the destination IP address and the source interface match. It is not an error if there is
1303 * no matching rule to delete.
1304 *
Hungming Chened129262022-04-26 19:10:45 +08001305 * @deprecated This method has no effect and throws UnsupportedOperationException. The mainline
1306 * module accesses the BPF map directly starting in S. See BpfCoordinator.
markchien38c32482021-09-29 12:19:44 +08001307 * @param rule The rule to delete.
1308 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1309 * cause of the failure.
1310 */
1311 void tetherOffloadRuleRemove(in TetherOffloadRuleParcel rule);
1312
1313 /**
1314 * Return BPF tethering offload statistics.
1315 *
Hungming Chened129262022-04-26 19:10:45 +08001316 * @deprecated This method has no effect and throws UnsupportedOperationException. The mainline
1317 * module accesses the BPF map directly starting in S. See BpfCoordinator.
markchien38c32482021-09-29 12:19:44 +08001318 * @return an array of TetherStatsParcel's, where each entry contains the upstream interface
1319 * index and its tethering statistics since tethering was first started.
1320 * There will only ever be one entry for a given interface index.
1321 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1322 * cause of the failure.
1323 */
1324 TetherStatsParcel[] tetherOffloadGetStats();
1325
1326 /**
1327 * Set a per-interface quota for tethering offload.
1328 *
Hungming Chened129262022-04-26 19:10:45 +08001329 * @deprecated This method has no effect and throws UnsupportedOperationException. The mainline
1330 * module accesses the BPF map directly starting in S. See BpfCoordinator.
markchien38c32482021-09-29 12:19:44 +08001331 * @param ifIndex Index of upstream interface
1332 * @param quotaBytes The quota defined as the number of bytes, starting from zero and counting
Hungming Chened129262022-04-26 19:10:45 +08001333 * from *now*. A value of QUOTA_UNLIMITED (-1) indicates there is no limit.
markchien38c32482021-09-29 12:19:44 +08001334 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1335 * cause of the failure.
1336 */
1337 void tetherOffloadSetInterfaceQuota(int ifIndex, long quotaBytes);
1338
1339 /**
1340 * Return BPF tethering offload statistics and clear the stats for a given upstream.
1341 *
1342 * Must only be called once all offload rules have already been deleted for the given upstream
1343 * interface. The existing stats will be fetched and returned. The stats and the limit for the
1344 * given upstream interface will be deleted as well.
1345 *
1346 * The stats and limit for a given upstream interface must be initialized (using
1347 * tetherOffloadSetInterfaceQuota) before any offload will occur on that interface.
1348 *
Hungming Chened129262022-04-26 19:10:45 +08001349 * @deprecated This method has no effect and throws UnsupportedOperationException. The mainline
1350 * module accesses the BPF map directly starting in S. See BpfCoordinator.
markchien38c32482021-09-29 12:19:44 +08001351 * @param ifIndex Index of upstream interface.
1352 * @return TetherStatsParcel, which contains the given upstream interface index and its
1353 * tethering statistics since tethering was first started on that upstream interface.
1354 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1355 * cause of the failure.
1356 */
1357 TetherStatsParcel tetherOffloadGetAndClearStats(int ifIndex);
1358
1359 /**
1360 * Creates a network.
1361 *
1362 * @param config the configuration of network.
1363 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1364 * unix errno.
1365 */
1366 void networkCreate(in NativeNetworkConfig config);
1367
1368 /**
1369 * Adds the specified UID ranges to the specified network. The network can be physical or
1370 * virtual. Traffic from the UID ranges will be routed to the network by default. The possible
1371 * value of subsidiary priority for physical and unreachable networks is 0-999. 0 is the highest
1372 * priority. 0 is also the default value. Virtual network supports only the default value.
1373 *
1374 * @param NativeUidRangeConfig a parcel contains netId, UID ranges, subsidiary priority, etc.
1375 *
1376 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1377 * unix errno.
1378 */
1379 void networkAddUidRangesParcel(in NativeUidRangeConfig uidRangesConfig);
1380
1381 /**
1382 * Removes the specified UID ranges from the specified network. The network can be physical or
1383 * virtual. Traffic from the UID ranges will no longer be routed to the network by default. The
1384 * possible value of subsidiary priority for physical and unreachable networks is 0-999. 0 is
1385 * the highest priority. 0 is also the default value. Virtual network supports only the default
1386 * value.
1387 *
1388 * @param NativeUidRangeConfig a parcel contains netId, UID ranges, subsidiary priority, etc.
1389 *
1390 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1391 * unix errno.
1392 */
1393 void networkRemoveUidRangesParcel(in NativeUidRangeConfig uidRangesConfig);
1394}