blob: 8bf8e5b9d692b87ee044a0bc32b525093cea2ccf [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
Lorenzo Colitti747ba672022-06-15 23:39:12 +0900572 /**
573 * Packet mark that identifies non-offloaded ingress clat packets.
574 */
575 const int CLAT_MARK = 0xdeadc1a7;
576
markchien38c32482021-09-29 12:19:44 +0800577 /**
578 * Get status of IP forwarding
579 *
580 * @return true if IP forwarding is enabled, false otherwise.
581 */
582 boolean ipfwdEnabled();
583
584 /**
585 * Get requester list of IP forwarding
586 *
587 * @return An array of strings containing requester list of IP forwarding
588 */
589 @utf8InCpp String[] ipfwdGetRequesterList();
590
591 /**
592 * Enable IP forwarding for specific requester
593 *
594 * @param requester requester name to enable IP forwarding. It is a unique name which will be
595 * stored in Netd to make sure if any requester needs IP forwarding.
596 * @throws ServiceSpecificException in case of failure, with an error code indicating the
597 * cause of the failure.
598 */
599 void ipfwdEnableForwarding(in @utf8InCpp String requester);
600
601 /**
602 * Disable IP forwarding for specific requester
603 *
604 * @param requester requester name to disable IP forwarding. This name should match the
605 * names which are set by ipfwdEnableForwarding.
606 * IP forwarding would be disabled if it is the last requester.
607 * @throws ServiceSpecificException in case of failure, with an error code indicating the
608 * cause of the failure.
609 */
610 void ipfwdDisableForwarding(in @utf8InCpp String requester);
611
612 /**
613 * Add forwarding ip rule
614 *
615 * @param fromIface interface name to add forwarding ip rule
616 * @param toIface interface name to add forwarding ip rule
617 * @throws ServiceSpecificException in case of failure, with an error code indicating the
618 * cause of the failure.
619 */
620 void ipfwdAddInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
621
622 /**
623 * Remove forwarding ip rule
624 *
625 * @param fromIface interface name to remove forwarding ip rule
626 * @param toIface interface name to remove forwarding ip rule
627 * @throws ServiceSpecificException in case of failure, with an error code indicating the
628 * cause of the failure.
629 */
630 void ipfwdRemoveInterfaceForward(in @utf8InCpp String fromIface, in @utf8InCpp String toIface);
631
632 /**
633 * Set quota for interface
634 *
635 * @param ifName Name of target interface
636 * @param bytes Quota value in bytes
637 * @throws ServiceSpecificException in case of failure, with an error code indicating the
638 * cause of the failure.
639 */
640 void bandwidthSetInterfaceQuota(in @utf8InCpp String ifName, long bytes);
641
642 /**
643 * Remove quota for interface
644 *
645 * @param ifName Name of target interface
646 * @throws ServiceSpecificException in case of failure, with an error code indicating the
647 * cause of the failure.
648 */
649 void bandwidthRemoveInterfaceQuota(in @utf8InCpp String ifName);
650
651 /**
652 * Set alert for interface
653 *
654 * @param ifName Name of target interface
655 * @param bytes Alert value in bytes
656 * @throws ServiceSpecificException in case of failure, with an error code indicating the
657 * cause of the failure.
658 */
659 void bandwidthSetInterfaceAlert(in @utf8InCpp String ifName, long bytes);
660
661 /**
662 * Remove alert for interface
663 *
664 * @param ifName Name of target interface
665 * @throws ServiceSpecificException in case of failure, with an error code indicating the
666 * cause of the failure.
667 */
668 void bandwidthRemoveInterfaceAlert(in @utf8InCpp String ifName);
669
670 /**
671 * Set global alert
672 *
673 * @param bytes Alert value in bytes
674 * @throws ServiceSpecificException in case of failure, with an error code indicating the
675 * cause of the failure.
676 */
677 void bandwidthSetGlobalAlert(long bytes);
678
679 /**
680 * Add naughty app bandwidth rule for specific app
681 *
682 * @param uid uid of target app
683 * @throws ServiceSpecificException in case of failure, with an error code indicating the
684 * cause of the failure.
685 */
686 void bandwidthAddNaughtyApp(int uid);
687
688 /**
689 * Remove naughty app bandwidth rule for specific app
690 *
691 * @param uid uid of target app
692 * @throws ServiceSpecificException in case of failure, with an error code indicating the
693 * cause of the failure.
694 */
695 void bandwidthRemoveNaughtyApp(int uid);
696
697 /**
698 * Add nice app bandwidth rule for specific app
699 *
700 * @param uid uid of target app
701 * @throws ServiceSpecificException in case of failure, with an error code indicating the
702 * cause of the failure.
703 */
704 void bandwidthAddNiceApp(int uid);
705
706 /**
707 * Remove nice app bandwidth rule for specific app
708 *
709 * @param uid uid of target app
710 * @throws ServiceSpecificException in case of failure, with an error code indicating the
711 * cause of the failure.
712 */
713 void bandwidthRemoveNiceApp(int uid);
714
715 /**
716 * Start tethering
717 *
718 * @param dhcpRanges dhcp ranges to set.
719 * dhcpRanges might contain many addresss {addr1, addr2, aadr3, addr4...}
720 * Netd splits them into ranges: addr1-addr2, addr3-addr4, etc.
721 * An odd number of addrs will fail.
722 * @throws ServiceSpecificException in case of failure, with an error code indicating the
723 * cause of the failure.
724 */
725 void tetherStart(in @utf8InCpp String[] dhcpRanges);
726
727 /**
728 * Stop tethering
729 *
730 * @throws ServiceSpecificException in case of failure, with an error code indicating the
731 * cause of the failure.
732 */
733 void tetherStop();
734
735 /**
736 * Get status of tethering
737 *
738 * @return true if tethering is enabled, false otherwise.
739 */
740 boolean tetherIsEnabled();
741
742 /**
743 * Setup interface for tethering
744 *
745 * @param ifName interface name to add
746 * @throws ServiceSpecificException in case of failure, with an error code indicating the
747 * cause of the failure.
748 */
749 void tetherInterfaceAdd(in @utf8InCpp String ifName);
750
751 /**
752 * Reset interface for tethering
753 *
754 * @param ifName interface name to remove
755 * @throws ServiceSpecificException in case of failure, with an error code indicating the
756 * cause of the failure.
757 */
758 void tetherInterfaceRemove(in @utf8InCpp String ifName);
759
760 /**
761 * Get the interface list which is stored in netd
762 * The list contains the interfaces managed by tetherInterfaceAdd/tetherInterfaceRemove
763 *
764 * @return An array of strings containing interface list result
765 */
766 @utf8InCpp String[] tetherInterfaceList();
767
768 /**
769 * Set DNS forwarder server
770 *
771 * @param netId the upstream network to forward DNS queries to
772 * @param dnsAddrs DNS server address to set
773 * @throws ServiceSpecificException in case of failure, with an error code indicating the
774 * cause of the failure.
775 */
776 void tetherDnsSet(int netId, in @utf8InCpp String[] dnsAddrs);
777
778 /**
779 * Return the DNS list set by tetherDnsSet
780 *
781 * @return An array of strings containing the list of DNS servers
782 */
783 @utf8InCpp String[] tetherDnsList();
784
785 const int LOCAL_NET_ID = 99;
786
787 /**
788 * Constant net ID for the "dummy" network.
789 *
790 * The dummy network is used to blackhole or reject traffic. Any attempt to use it will
791 * either drop the packets or fail with ENETUNREACH.
792 */
793 const int DUMMY_NET_ID = 51;
794
795 /**
796 * Constant net ID for the "unreachable" network.
797 *
798 * The unreachable network is used to reject traffic. Any attempt to use it will fail
799 * with ENETUNREACH.
800 */
801 const int UNREACHABLE_NET_ID = 52;
802
803 // Route does not specify a next hop
804 const String NEXTHOP_NONE = "";
805 // Route next hop is unreachable
806 const String NEXTHOP_UNREACHABLE = "unreachable";
807 // Route next hop is throw
808 const String NEXTHOP_THROW = "throw";
809
810 /**
811 * Add a route for specific network
812 *
813 * @param netId the network to add the route to
814 * @param ifName the name of interface of the route.
815 * This interface should be assigned to the netID.
816 * @param destination the destination of the route
817 * @param nextHop The route's next hop address,
818 * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
819 * @throws ServiceSpecificException in case of failure, with an error code indicating the
820 * cause of the failure.
821 */
822 void networkAddRoute(
823 int netId,
824 in @utf8InCpp String ifName,
825 in @utf8InCpp String destination,
826 in @utf8InCpp String nextHop);
827
828 /**
829 * Remove a route for specific network
830 *
831 * @param netId the network to remove the route from
832 * @param ifName the name of interface of the route.
833 * This interface should be assigned to the netID.
834 * @param destination the destination of the route
835 * @param nextHop The route's next hop address,
836 * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
837 * @throws ServiceSpecificException in case of failure, with an error code indicating the
838 * cause of the failure.
839 */
840 void networkRemoveRoute(
841 int netId,
842 in @utf8InCpp String ifName,
843 in @utf8InCpp String destination,
844 in @utf8InCpp String nextHop);
845
846 /**
847 * Add a route to legacy routing table for specific network
848 *
849 * @param netId the network to add the route to
850 * @param ifName the name of interface of the route.
851 * This interface should be assigned to the netID.
852 * @param destination the destination of the route
853 * @param nextHop The route's next hop address,
854 * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
855 * @param uid uid of the user
856 * @throws ServiceSpecificException in case of failure, with an error code indicating the
857 * cause of the failure.
858 */
859 void networkAddLegacyRoute(
860 int netId,
861 in @utf8InCpp String ifName,
862 in @utf8InCpp String destination,
863 in @utf8InCpp String nextHop,
864 int uid);
865
866 /**
867 * Remove a route from legacy routing table for specific network
868 *
869 * @param netId the network to remove the route from
870 * @param ifName the name of interface of the route.
871 * This interface should be assigned to the netID.
872 * @param destination the destination of the route
873 * @param nextHop The route's next hop address,
874 * or it could be either NEXTHOP_NONE, NEXTHOP_UNREACHABLE, NEXTHOP_THROW.
875 * @param uid uid of the user
876 * @throws ServiceSpecificException in case of failure, with an error code indicating the
877 * cause of the failure.
878 */
879 void networkRemoveLegacyRoute(
880 int netId,
881 in @utf8InCpp String ifName,
882 in @utf8InCpp String destination,
883 in @utf8InCpp String nextHop,
884 int uid);
885
886 /**
887 * Get default network
888 *
889 * @return netId of default network
890 */
891 int networkGetDefault();
892
893 /**
894 * Set network as default network
895 *
896 * @param netId the network to set as the default
897 * @throws ServiceSpecificException in case of failure, with an error code indicating the
898 * cause of the failure.
899 */
900 void networkSetDefault(int netId);
901
902 /**
903 * Clear default network
904 *
905 * @throws ServiceSpecificException in case of failure, with an error code indicating the
906 * cause of the failure.
907 */
908 void networkClearDefault();
909
910 /**
911 * PERMISSION_NONE is used for regular networks and apps. TODO: use PERMISSION_INTERNET
912 * for this instead, and use PERMISSION_NONE to indicate no network permissions at all.
913 */
914 const int PERMISSION_NONE = 0;
915
916 /**
917 * PERMISSION_NETWORK represents the CHANGE_NETWORK_STATE permission.
918 */
919 const int PERMISSION_NETWORK = 1;
920
921 /**
922 * PERMISSION_SYSTEM represents the ability to use restricted networks. This is mostly
923 * equivalent to the CONNECTIVITY_USE_RESTRICTED_NETWORKS permission.
924 */
925 const int PERMISSION_SYSTEM = 2;
926
927 /**
928 * NO_PERMISSIONS indicates that this app is installed and doesn't have either
929 * PERMISSION_INTERNET or PERMISSION_UPDATE_DEVICE_STATS.
930 * TODO: use PERMISSION_NONE to represent this case
931 */
932 const int NO_PERMISSIONS = 0;
933
934 /**
935 * PERMISSION_INTERNET indicates that the app can create AF_INET and AF_INET6 sockets
936 */
937 const int PERMISSION_INTERNET = 4;
938
939 /**
940 * PERMISSION_UPDATE_DEVICE_STATS is used for system UIDs and privileged apps
941 * that have the UPDATE_DEVICE_STATS permission
942 */
943 const int PERMISSION_UPDATE_DEVICE_STATS = 8;
944
945 /**
946 * PERMISSION_UNINSTALLED is used when an app is uninstalled from the device. All internet
947 * related permissions need to be cleaned
948 */
949 const int PERMISSION_UNINSTALLED = -1;
950
951
952 /**
953 * Sets the permission required to access a specific network.
954 *
955 * @param netId the network to set
956 * @param permission network permission to use
957 * @throws ServiceSpecificException in case of failure, with an error code indicating the
958 * cause of the failure.
959 */
960 void networkSetPermissionForNetwork(int netId, int permission);
961
962 /**
963 * Assigns network access permissions to the specified users.
964 *
965 * @param permission network permission to use
966 * @param uids uid of users to set permission
967 */
968 void networkSetPermissionForUser(int permission, in int[] uids);
969
970 /**
971 * Clears network access permissions for the specified users.
972 *
973 * @param uids uid of users to clear permission
974 */
975 void networkClearPermissionForUser(in int[] uids);
976
977 /**
978 * Assigns android.permission.INTERNET and/or android.permission.UPDATE_DEVICE_STATS to the uids
979 * specified. Or remove all permissions from the uids.
980 *
981 * @param permission The permission to grant, it could be either PERMISSION_INTERNET and/or
982 * PERMISSION_UPDATE_DEVICE_STATS. If the permission is NO_PERMISSIONS, then
983 * revoke all permissions for the uids.
984 * @param uids uid of users to grant permission
985 */
986 void trafficSetNetPermForUids(int permission, in int[] uids);
987
988 /**
989 * Gives the specified user permission to protect sockets from VPNs.
990 * Typically used by VPN apps themselves, to ensure that the sockets
991 * they use to communicate with the VPN server aren't routed through
992 * the VPN network.
993 *
994 * @param uid uid of user to set
995 */
996 void networkSetProtectAllow(int uid);
997
998 /**
999 * Removes the permission to protect sockets from VPN.
1000 *
1001 * @param uid uid of user to set
1002 */
1003 void networkSetProtectDeny(int uid);
1004
1005 /**
1006 * Get the status of network protect for user
1007 *
1008 * @param uids uid of user
1009 * @return true if the user can protect sockets from VPN, false otherwise.
1010 */
1011 boolean networkCanProtect(int uid);
1012
1013 /** Only allows packets from specific UID/Interface.
1014 @deprecated use FIREWALL_ALLOWLIST. */
1015 const int FIREWALL_WHITELIST = 0;
1016
1017 /** Only allows packets from specific UID/Interface. */
1018 const int FIREWALL_ALLOWLIST = 0;
1019
1020 /** Blocks packets from specific UID/Interface.
1021 @deprecated use FIREWALL_DENYLIST. */
1022 const int FIREWALL_BLACKLIST = 1;
1023
1024 /** Blocks packets from specific UID/Interface. */
1025 const int FIREWALL_DENYLIST = 1;
1026
1027 /**
1028 * Set type of firewall
1029 * Type allowlist only allows packets from specific UID/Interface
1030 * Type denylist blocks packets from specific UID/Interface
1031 *
1032 * @param firewalltype type of firewall, either FIREWALL_ALLOWLIST or FIREWALL_DENYLIST
1033 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1034 * cause of the failure.
1035 */
1036 void firewallSetFirewallType(int firewalltype);
1037
1038 // Specify allow Rule which allows packets
1039 const int FIREWALL_RULE_ALLOW = 1;
1040 // Specify deny Rule which drops packets
1041 const int FIREWALL_RULE_DENY = 2;
1042
1043 // No specific chain is chosen, use general firewall chain(fw_input, fw_output)
1044 const int FIREWALL_CHAIN_NONE = 0;
1045 // Specify DOZABLE chain(fw_dozable) which is used in dozable mode
1046 const int FIREWALL_CHAIN_DOZABLE = 1;
1047 // Specify STANDBY chain(fw_standby) which is used in standby mode
1048 const int FIREWALL_CHAIN_STANDBY = 2;
1049 // Specify POWERSAVE chain(fw_powersave) which is used in power save mode
1050 const int FIREWALL_CHAIN_POWERSAVE = 3;
1051 // Specify RESTRICTED chain(fw_restricted) which is used in restricted
1052 // networking mode
1053 const int FIREWALL_CHAIN_RESTRICTED = 4;
1054
1055 /**
1056 * Set firewall rule for interface
1057 *
1058 * @param ifName the interface to allow/deny
1059 * @param firewallRule either FIREWALL_RULE_ALLOW or FIREWALL_RULE_DENY
1060 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1061 * cause of the failure.
1062 */
1063 void firewallSetInterfaceRule(in @utf8InCpp String ifName, int firewallRule);
1064
1065 /**
1066 * Set firewall rule for uid
1067 *
1068 * @param childChain target chain
1069 * @param uid uid to allow/deny
1070 * @param firewallRule either FIREWALL_RULE_ALLOW or FIREWALL_RULE_DENY
1071 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1072 * cause of the failure.
1073 */
1074 void firewallSetUidRule(int childChain, int uid, int firewallRule);
1075
1076 /**
1077 * Enable/Disable target firewall child chain
1078 *
1079 * @param childChain target chain to enable
1080 * @param enable whether to enable or disable child chain.
1081 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1082 * cause of the failure.
1083 */
1084 void firewallEnableChildChain(int childChain, boolean enable);
1085
1086 /**
1087 * Get interface list
1088 *
1089 * @return An array of strings containing all the interfaces on the system.
1090 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1091 * unix errno.
1092 */
1093 @utf8InCpp String[] interfaceGetList();
1094
1095 // Must be kept in sync with constant in InterfaceConfiguration.java
1096 const String IF_STATE_UP = "up";
1097 const String IF_STATE_DOWN = "down";
1098
1099 const String IF_FLAG_BROADCAST = "broadcast";
1100 const String IF_FLAG_LOOPBACK = "loopback";
1101 const String IF_FLAG_POINTOPOINT = "point-to-point";
1102 const String IF_FLAG_RUNNING = "running";
1103 const String IF_FLAG_MULTICAST = "multicast";
1104
1105 /**
1106 * Get interface configuration
1107 *
1108 * @param ifName interface name
1109 * @return An InterfaceConfigurationParcel for the specified interface.
1110 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1111 * unix errno.
1112 */
1113 InterfaceConfigurationParcel interfaceGetCfg(in @utf8InCpp String ifName);
1114
1115 /**
1116 * Set interface configuration
1117 *
1118 * @param cfg Interface configuration to set
1119 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1120 * unix errno.
1121 */
1122 void interfaceSetCfg(in InterfaceConfigurationParcel cfg);
1123
1124 /**
1125 * Set interface IPv6 privacy extensions
1126 *
1127 * @param ifName interface name
1128 * @param enable whether to enable or disable this setting.
1129 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1130 * cause of the failure.
1131 */
1132 void interfaceSetIPv6PrivacyExtensions(in @utf8InCpp String ifName, boolean enable);
1133
1134 /**
1135 * Clear all IP addresses on the given interface
1136 *
1137 * @param ifName interface name
1138 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1139 * POSIX errno.
1140 */
1141 void interfaceClearAddrs(in @utf8InCpp String ifName);
1142
1143 /**
1144 * Enable or disable IPv6 on the given interface
1145 *
1146 * @param ifName interface name
1147 * @param enable whether to enable or disable this setting.
1148 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1149 * cause of the failure.
1150 */
1151 void interfaceSetEnableIPv6(in @utf8InCpp String ifName, boolean enable);
1152
1153 /**
1154 * Set interface MTU
1155 *
1156 * @param ifName interface name
1157 * @param mtu MTU value
1158 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1159 * cause of the failure.
1160 */
1161 void interfaceSetMtu(in @utf8InCpp String ifName, int mtu);
1162
1163 /**
1164 * Add forwarding rule/stats on given interface.
1165 *
1166 * @param intIface downstream interface
1167 * @param extIface upstream interface
1168 */
1169 void tetherAddForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
1170
1171 /**
1172 * Remove forwarding rule/stats on given interface.
1173 *
1174 * @param intIface downstream interface
1175 * @param extIface upstream interface
1176 */
1177 void tetherRemoveForward(in @utf8InCpp String intIface, in @utf8InCpp String extIface);
1178
1179 /**
1180 * Set the values of tcp_{rmem,wmem}.
1181 *
1182 * @param rmemValues the target values of tcp_rmem, each value is separated by spaces
1183 * @param wmemValues the target values of tcp_wmem, each value is separated by spaces
1184 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1185 * cause of the failure.
1186 */
1187 void setTcpRWmemorySize(in @utf8InCpp String rmemValues, in @utf8InCpp String wmemValues);
1188
1189 /**
1190 * Register unsolicited event listener
1191 * Netd supports multiple unsolicited event listeners.
1192 *
1193 * @param listener unsolicited event listener to register
1194 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1195 * cause of the failure.
1196 */
1197 void registerUnsolicitedEventListener(INetdUnsolicitedEventListener listener);
1198
1199 /**
1200 * Add ingress interface filtering rules to a list of UIDs
1201 *
1202 * For a given uid, once a filtering rule is added, the kernel will only allow packets from the
1203 * allowed interface and loopback to be sent to the list of UIDs.
1204 *
1205 * Calling this method on one or more UIDs with an existing filtering rule but a different
1206 * interface name will result in the filtering rule being updated to allow the new interface
1207 * instead. Otherwise calling this method will not affect existing rules set on other UIDs.
1208 *
1209 * @param ifName the name of the interface on which the filtering rules will allow packets to
1210 be received.
1211 * @param uids an array of UIDs which the filtering rules will be set
1212 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1213 * cause of the failure.
1214 */
1215 void firewallAddUidInterfaceRules(in @utf8InCpp String ifName, in int[] uids);
1216
1217 /**
1218 * Remove ingress interface filtering rules from a list of UIDs
1219 *
1220 * Clear the ingress interface filtering rules from the list of UIDs which were previously set
1221 * by firewallAddUidInterfaceRules(). Ignore any uid which does not have filtering rule.
1222 *
1223 * @param uids an array of UIDs from which the filtering rules will be removed
1224 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1225 * cause of the failure.
1226 */
1227 void firewallRemoveUidInterfaceRules(in int[] uids);
1228
1229 /**
1230 * Request netd to change the current active network stats map.
1231 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1232 * cause of the failure.
1233 */
1234 void trafficSwapActiveStatsMap();
1235
1236 /**
1237 * Retrieves OEM netd listener interface
1238 *
1239 * @return a IBinder object, it could be casted to oem specific interface.
1240 */
1241 IBinder getOemNetd();
1242
1243 /**
1244 * Start tethering with given configuration
1245 *
1246 * @param config config to start tethering.
1247 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1248 * cause of the failure.
1249 */
1250 void tetherStartWithConfiguration(in TetherConfigParcel config);
1251
1252
1253 /**
1254 * Get the fwmark and its net id mask for the given network id.
1255 *
1256 * @param netId the network to get the fwmark and mask for.
1257 * @return A MarkMaskParcel of the given network id.
1258 */
1259 MarkMaskParcel getFwmarkForNetwork(int netId);
1260
1261 /**
1262 * Add a route for specific network
1263 *
1264 * @param netId the network to add the route to
1265 * @param routeInfo parcelable with route information
1266 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1267 * cause of the failure.
1268 */
1269 void networkAddRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
1270
1271 /**
1272 * Update a route for specific network
1273 *
1274 * @param routeInfo parcelable with route information
1275 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1276 * cause of the failure.
1277 */
1278 void networkUpdateRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
1279
1280 /**
1281 * Remove a route for specific network
1282 *
1283 * @param routeInfo parcelable with route information
1284 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1285 * cause of the failure.
1286 */
1287 void networkRemoveRouteParcel(int netId, in android.net.RouteInfoParcel routeInfo);
1288
1289 /**
1290 * Adds a tethering offload rule, or updates it if it already exists.
1291 *
1292 * Currently, only downstream /128 IPv6 entries are supported. An existing rule will be updated
1293 * if the input interface and destination prefix match. Otherwise, a new rule will be created.
1294 *
Hungming Chened129262022-04-26 19:10:45 +08001295 * @deprecated This method has no effect and throws UnsupportedOperationException. The mainline
1296 * module accesses the BPF map directly starting in S. See BpfCoordinator.
markchien38c32482021-09-29 12:19:44 +08001297 * @param rule The rule to add or update.
1298 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1299 * cause of the failure.
1300 */
1301 void tetherOffloadRuleAdd(in TetherOffloadRuleParcel rule);
1302
1303 /**
1304 * Deletes a tethering offload rule.
1305 *
1306 * Currently, only downstream /128 IPv6 entries are supported. An existing rule will be deleted
1307 * if the destination IP address and the source interface match. It is not an error if there is
1308 * no matching rule to delete.
1309 *
Hungming Chened129262022-04-26 19:10:45 +08001310 * @deprecated This method has no effect and throws UnsupportedOperationException. The mainline
1311 * module accesses the BPF map directly starting in S. See BpfCoordinator.
markchien38c32482021-09-29 12:19:44 +08001312 * @param rule The rule to delete.
1313 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1314 * cause of the failure.
1315 */
1316 void tetherOffloadRuleRemove(in TetherOffloadRuleParcel rule);
1317
1318 /**
1319 * Return BPF tethering offload statistics.
1320 *
Hungming Chened129262022-04-26 19:10:45 +08001321 * @deprecated This method has no effect and throws UnsupportedOperationException. The mainline
1322 * module accesses the BPF map directly starting in S. See BpfCoordinator.
markchien38c32482021-09-29 12:19:44 +08001323 * @return an array of TetherStatsParcel's, where each entry contains the upstream interface
1324 * index and its tethering statistics since tethering was first started.
1325 * There will only ever be one entry for a given interface index.
1326 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1327 * cause of the failure.
1328 */
1329 TetherStatsParcel[] tetherOffloadGetStats();
1330
1331 /**
1332 * Set a per-interface quota for tethering offload.
1333 *
Hungming Chened129262022-04-26 19:10:45 +08001334 * @deprecated This method has no effect and throws UnsupportedOperationException. The mainline
1335 * module accesses the BPF map directly starting in S. See BpfCoordinator.
markchien38c32482021-09-29 12:19:44 +08001336 * @param ifIndex Index of upstream interface
1337 * @param quotaBytes The quota defined as the number of bytes, starting from zero and counting
Hungming Chened129262022-04-26 19:10:45 +08001338 * from *now*. A value of QUOTA_UNLIMITED (-1) indicates there is no limit.
markchien38c32482021-09-29 12:19:44 +08001339 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1340 * cause of the failure.
1341 */
1342 void tetherOffloadSetInterfaceQuota(int ifIndex, long quotaBytes);
1343
1344 /**
1345 * Return BPF tethering offload statistics and clear the stats for a given upstream.
1346 *
1347 * Must only be called once all offload rules have already been deleted for the given upstream
1348 * interface. The existing stats will be fetched and returned. The stats and the limit for the
1349 * given upstream interface will be deleted as well.
1350 *
1351 * The stats and limit for a given upstream interface must be initialized (using
1352 * tetherOffloadSetInterfaceQuota) before any offload will occur on that interface.
1353 *
Hungming Chened129262022-04-26 19:10:45 +08001354 * @deprecated This method has no effect and throws UnsupportedOperationException. The mainline
1355 * module accesses the BPF map directly starting in S. See BpfCoordinator.
markchien38c32482021-09-29 12:19:44 +08001356 * @param ifIndex Index of upstream interface.
1357 * @return TetherStatsParcel, which contains the given upstream interface index and its
1358 * tethering statistics since tethering was first started on that upstream interface.
1359 * @throws ServiceSpecificException in case of failure, with an error code indicating the
1360 * cause of the failure.
1361 */
1362 TetherStatsParcel tetherOffloadGetAndClearStats(int ifIndex);
1363
1364 /**
1365 * Creates a network.
1366 *
1367 * @param config the configuration of network.
1368 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1369 * unix errno.
1370 */
1371 void networkCreate(in NativeNetworkConfig config);
1372
1373 /**
1374 * Adds the specified UID ranges to the specified network. The network can be physical or
1375 * virtual. Traffic from the UID ranges will be routed to the network by default. The possible
1376 * value of subsidiary priority for physical and unreachable networks is 0-999. 0 is the highest
1377 * priority. 0 is also the default value. Virtual network supports only the default value.
1378 *
1379 * @param NativeUidRangeConfig a parcel contains netId, UID ranges, subsidiary priority, etc.
1380 *
1381 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1382 * unix errno.
1383 */
1384 void networkAddUidRangesParcel(in NativeUidRangeConfig uidRangesConfig);
1385
1386 /**
1387 * Removes the specified UID ranges from the specified network. The network can be physical or
1388 * virtual. Traffic from the UID ranges will no longer be routed to the network by default. The
1389 * possible value of subsidiary priority for physical and unreachable networks is 0-999. 0 is
1390 * the highest priority. 0 is also the default value. Virtual network supports only the default
1391 * value.
1392 *
1393 * @param NativeUidRangeConfig a parcel contains netId, UID ranges, subsidiary priority, etc.
1394 *
1395 * @throws ServiceSpecificException in case of failure, with an error code corresponding to the
1396 * unix errno.
1397 */
1398 void networkRemoveUidRangesParcel(in NativeUidRangeConfig uidRangesConfig);
1399}