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