• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* //device/java/android/android/os/INetworkManagementService.aidl
2 **
3 ** Copyright 2007, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 **     http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17 
18 package android.os;
19 
20 import android.net.InterfaceConfiguration;
21 import android.net.INetd;
22 import android.net.INetworkManagementEventObserver;
23 import android.net.Network;
24 import android.net.NetworkStats;
25 import android.net.RouteInfo;
26 import android.net.UidRange;
27 import android.net.wifi.WifiConfiguration;
28 import android.os.INetworkActivityListener;
29 
30 /**
31  * @hide
32  */
33 interface INetworkManagementService
34 {
35     /**
36      ** GENERAL
37      **/
38 
39     /**
40      * Register an observer to receive events.
41      */
registerObserver(INetworkManagementEventObserver obs)42     void registerObserver(INetworkManagementEventObserver obs);
43 
44     /**
45      * Unregister an observer from receiving events.
46      */
unregisterObserver(INetworkManagementEventObserver obs)47     void unregisterObserver(INetworkManagementEventObserver obs);
48 
49     /**
50      * Retrieve an INetd to talk to netd.
51      */
getNetdService()52     INetd getNetdService();
53 
54     /**
55      * Returns a list of currently known network interfaces
56      */
listInterfaces()57     String[] listInterfaces();
58 
59     /**
60      * Retrieves the specified interface config
61      *
62      */
getInterfaceConfig(String iface)63     InterfaceConfiguration getInterfaceConfig(String iface);
64 
65     /**
66      * Sets the configuration of the specified interface
67      */
setInterfaceConfig(String iface, in InterfaceConfiguration cfg)68     void setInterfaceConfig(String iface, in InterfaceConfiguration cfg);
69 
70     /**
71      * Clear all IP addresses on the specified interface
72      */
clearInterfaceAddresses(String iface)73     void clearInterfaceAddresses(String iface);
74 
75     /**
76      * Set interface down
77      */
setInterfaceDown(String iface)78     void setInterfaceDown(String iface);
79 
80     /**
81      * Set interface up
82      */
setInterfaceUp(String iface)83     void setInterfaceUp(String iface);
84 
85     /**
86      * Set interface IPv6 privacy extensions
87      */
setInterfaceIpv6PrivacyExtensions(String iface, boolean enable)88     void setInterfaceIpv6PrivacyExtensions(String iface, boolean enable);
89 
90     /**
91      * Disable IPv6 on an interface
92      */
disableIpv6(String iface)93     void disableIpv6(String iface);
94 
95     /**
96      * Enable IPv6 on an interface
97      */
enableIpv6(String iface)98     void enableIpv6(String iface);
99 
100     /**
101      * Enables or enables IPv6 ND offload.
102      */
setInterfaceIpv6NdOffload(String iface, boolean enable)103     void setInterfaceIpv6NdOffload(String iface, boolean enable);
104 
105     /**
106      * Add the specified route to the interface.
107      */
addRoute(int netId, in RouteInfo route)108     void addRoute(int netId, in RouteInfo route);
109 
110     /**
111      * Remove the specified route from the interface.
112      */
removeRoute(int netId, in RouteInfo route)113     void removeRoute(int netId, in RouteInfo route);
114 
115     /**
116      * Set the specified MTU size
117      */
setMtu(String iface, int mtu)118     void setMtu(String iface, int mtu);
119 
120     /**
121      * Shuts down the service
122      */
shutdown()123     void shutdown();
124 
125     /**
126      ** TETHERING RELATED
127      **/
128 
129     /**
130      * Returns true if IP forwarding is enabled
131      */
getIpForwardingEnabled()132     boolean getIpForwardingEnabled();
133 
134     /**
135      * Enables/Disables IP Forwarding
136      */
setIpForwardingEnabled(boolean enabled)137     void setIpForwardingEnabled(boolean enabled);
138 
139     /**
140      * Start tethering services with the specified dhcp server range
141      * arg is a set of start end pairs defining the ranges.
142      */
startTethering(in String[] dhcpRanges)143     void startTethering(in String[] dhcpRanges);
144 
145     /**
146      * Stop currently running tethering services
147      */
stopTethering()148     void stopTethering();
149 
150     /**
151      * Returns true if tethering services are started
152      */
isTetheringStarted()153     boolean isTetheringStarted();
154 
155     /**
156      * Tethers the specified interface
157      */
tetherInterface(String iface)158     void tetherInterface(String iface);
159 
160     /**
161      * Untethers the specified interface
162      */
untetherInterface(String iface)163     void untetherInterface(String iface);
164 
165     /**
166      * Returns a list of currently tethered interfaces
167      */
listTetheredInterfaces()168     String[] listTetheredInterfaces();
169 
170     /**
171      * Sets the list of DNS forwarders (in order of priority)
172      */
setDnsForwarders(in Network network, in String[] dns)173     void setDnsForwarders(in Network network, in String[] dns);
174 
175     /**
176      * Returns the list of DNS forwarders (in order of priority)
177      */
getDnsForwarders()178     String[] getDnsForwarders();
179 
180     /**
181      * Enables unidirectional packet forwarding from {@code fromIface} to
182      * {@code toIface}.
183      */
startInterfaceForwarding(String fromIface, String toIface)184     void startInterfaceForwarding(String fromIface, String toIface);
185 
186     /**
187      * Disables unidirectional packet forwarding from {@code fromIface} to
188      * {@code toIface}.
189      */
stopInterfaceForwarding(String fromIface, String toIface)190     void stopInterfaceForwarding(String fromIface, String toIface);
191 
192     /**
193      *  Enables Network Address Translation between two interfaces.
194      *  The address and netmask of the external interface is used for
195      *  the NAT'ed network.
196      */
enableNat(String internalInterface, String externalInterface)197     void enableNat(String internalInterface, String externalInterface);
198 
199     /**
200      *  Disables Network Address Translation between two interfaces.
201      */
disableNat(String internalInterface, String externalInterface)202     void disableNat(String internalInterface, String externalInterface);
203 
204     /**
205      ** PPPD
206      **/
207 
208     /**
209      * Returns the list of currently known TTY devices on the system
210      */
listTtys()211     String[] listTtys();
212 
213     /**
214      * Attaches a PPP server daemon to the specified TTY with the specified
215      * local/remote addresses.
216      */
attachPppd(String tty, String localAddr, String remoteAddr, String dns1Addr, String dns2Addr)217     void attachPppd(String tty, String localAddr, String remoteAddr, String dns1Addr,
218             String dns2Addr);
219 
220     /**
221      * Detaches a PPP server daemon from the specified TTY.
222      */
detachPppd(String tty)223     void detachPppd(String tty);
224 
225     /**
226      * Load firmware for operation in the given mode. Currently the three
227      * modes supported are "AP", "STA" and "P2P".
228      */
wifiFirmwareReload(String wlanIface, String mode)229     void wifiFirmwareReload(String wlanIface, String mode);
230 
231     /**
232      * Start Wifi Access Point
233      */
startAccessPoint(in WifiConfiguration wifiConfig, String iface)234     void startAccessPoint(in WifiConfiguration wifiConfig, String iface);
235 
236     /**
237      * Stop Wifi Access Point
238      */
stopAccessPoint(String iface)239     void stopAccessPoint(String iface);
240 
241     /**
242      * Set Access Point config
243      */
setAccessPoint(in WifiConfiguration wifiConfig, String iface)244     void setAccessPoint(in WifiConfiguration wifiConfig, String iface);
245 
246     /**
247      ** DATA USAGE RELATED
248      **/
249 
250     /**
251      * Return global network statistics summarized at an interface level,
252      * without any UID-level granularity.
253      */
getNetworkStatsSummaryDev()254     NetworkStats getNetworkStatsSummaryDev();
getNetworkStatsSummaryXt()255     NetworkStats getNetworkStatsSummaryXt();
256 
257     /**
258      * Return detailed network statistics with UID-level granularity,
259      * including interface and tag details.
260      */
getNetworkStatsDetail()261     NetworkStats getNetworkStatsDetail();
262 
263     /**
264      * Return detailed network statistics for the requested UID,
265      * including interface and tag details.
266      */
getNetworkStatsUidDetail(int uid)267     NetworkStats getNetworkStatsUidDetail(int uid);
268 
269     /**
270      * Return summary of network statistics all tethering interfaces.
271      */
getNetworkStatsTethering()272     NetworkStats getNetworkStatsTethering();
273 
274     /**
275      * Set quota for an interface.
276      */
setInterfaceQuota(String iface, long quotaBytes)277     void setInterfaceQuota(String iface, long quotaBytes);
278 
279     /**
280      * Remove quota for an interface.
281      */
removeInterfaceQuota(String iface)282     void removeInterfaceQuota(String iface);
283 
284     /**
285      * Set alert for an interface; requires that iface already has quota.
286      */
setInterfaceAlert(String iface, long alertBytes)287     void setInterfaceAlert(String iface, long alertBytes);
288 
289     /**
290      * Remove alert for an interface.
291      */
removeInterfaceAlert(String iface)292     void removeInterfaceAlert(String iface);
293 
294     /**
295      * Set alert across all interfaces.
296      */
setGlobalAlert(long alertBytes)297     void setGlobalAlert(long alertBytes);
298 
299     /**
300      * Control network activity of a UID over interfaces with a quota limit.
301      */
setUidMeteredNetworkBlacklist(int uid, boolean enable)302     void setUidMeteredNetworkBlacklist(int uid, boolean enable);
setUidMeteredNetworkWhitelist(int uid, boolean enable)303     void setUidMeteredNetworkWhitelist(int uid, boolean enable);
setDataSaverModeEnabled(boolean enable)304     boolean setDataSaverModeEnabled(boolean enable);
305 
setUidCleartextNetworkPolicy(int uid, int policy)306     void setUidCleartextNetworkPolicy(int uid, int policy);
307 
308     /**
309      * Return status of bandwidth control module.
310      */
isBandwidthControlEnabled()311     boolean isBandwidthControlEnabled();
312 
313     /**
314      * Sets idletimer for an interface.
315      *
316      * This either initializes a new idletimer or increases its
317      * reference-counting if an idletimer already exists for given
318      * {@code iface}.
319      *
320      * {@code type} is the type of the interface, such as TYPE_MOBILE.
321      *
322      * Every {@code addIdleTimer} should be paired with a
323      * {@link removeIdleTimer} to cleanup when the network disconnects.
324      */
addIdleTimer(String iface, int timeout, int type)325     void addIdleTimer(String iface, int timeout, int type);
326 
327     /**
328      * Removes idletimer for an interface.
329      */
removeIdleTimer(String iface)330     void removeIdleTimer(String iface);
331 
332     /**
333      * Configure name servers, search paths, and resolver parameters for the given network.
334      */
setDnsConfigurationForNetwork(int netId, in String[] servers, String domains)335     void setDnsConfigurationForNetwork(int netId, in String[] servers, String domains);
336 
337     /**
338      * Bind name servers to a network in the DNS resolver.
339      */
setDnsServersForNetwork(int netId, in String[] servers, String domains)340     void setDnsServersForNetwork(int netId, in String[] servers, String domains);
341 
setFirewallEnabled(boolean enabled)342     void setFirewallEnabled(boolean enabled);
isFirewallEnabled()343     boolean isFirewallEnabled();
setFirewallInterfaceRule(String iface, boolean allow)344     void setFirewallInterfaceRule(String iface, boolean allow);
setFirewallEgressSourceRule(String addr, boolean allow)345     void setFirewallEgressSourceRule(String addr, boolean allow);
setFirewallEgressDestRule(String addr, int port, boolean allow)346     void setFirewallEgressDestRule(String addr, int port, boolean allow);
setFirewallUidRule(int chain, int uid, int rule)347     void setFirewallUidRule(int chain, int uid, int rule);
setFirewallUidRules(int chain, in int[] uids, in int[] rules)348     void setFirewallUidRules(int chain, in int[] uids, in int[] rules);
setFirewallChainEnabled(int chain, boolean enable)349     void setFirewallChainEnabled(int chain, boolean enable);
350 
351     /**
352      * Set all packets from users in ranges to go through VPN specified by netId.
353      */
addVpnUidRanges(int netId, in UidRange[] ranges)354     void addVpnUidRanges(int netId, in UidRange[] ranges);
355 
356     /**
357      * Clears the special VPN rules for users in ranges and VPN specified by netId.
358      */
removeVpnUidRanges(int netId, in UidRange[] ranges)359     void removeVpnUidRanges(int netId, in UidRange[] ranges);
360 
361     /**
362      * Start the clatd (464xlat) service on the given interface.
363      */
startClatd(String interfaceName)364     void startClatd(String interfaceName);
365 
366     /**
367      * Stop the clatd (464xlat) service on the given interface.
368      */
stopClatd(String interfaceName)369     void stopClatd(String interfaceName);
370 
371     /**
372      * Determine whether the clatd (464xlat) service has been started on the given interface.
373      */
isClatdStarted(String interfaceName)374     boolean isClatdStarted(String interfaceName);
375 
376     /**
377      * Start listening for mobile activity state changes.
378      */
registerNetworkActivityListener(INetworkActivityListener listener)379     void registerNetworkActivityListener(INetworkActivityListener listener);
380 
381     /**
382      * Stop listening for mobile activity state changes.
383      */
unregisterNetworkActivityListener(INetworkActivityListener listener)384     void unregisterNetworkActivityListener(INetworkActivityListener listener);
385 
386     /**
387      * Check whether the mobile radio is currently active.
388      */
isNetworkActive()389     boolean isNetworkActive();
390 
391     /**
392      * Setup a new physical network.
393      * @param permission null if no permissions required to access this network.  PERMISSION_NETWORK
394      *                   or PERMISSION_SYSTEM to set respective permission.
395      */
createPhysicalNetwork(int netId, String permission)396     void createPhysicalNetwork(int netId, String permission);
397 
398     /**
399      * Setup a new VPN.
400      */
createVirtualNetwork(int netId, boolean hasDNS, boolean secure)401     void createVirtualNetwork(int netId, boolean hasDNS, boolean secure);
402 
403     /**
404      * Remove a network.
405      */
removeNetwork(int netId)406     void removeNetwork(int netId);
407 
408     /**
409      * Add an interface to a network.
410      */
addInterfaceToNetwork(String iface, int netId)411     void addInterfaceToNetwork(String iface, int netId);
412 
413     /**
414      * Remove an Interface from a network.
415      */
removeInterfaceFromNetwork(String iface, int netId)416     void removeInterfaceFromNetwork(String iface, int netId);
417 
addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid)418     void addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid);
419 
setDefaultNetId(int netId)420     void setDefaultNetId(int netId);
clearDefaultNetId()421     void clearDefaultNetId();
422 
423     /**
424      * Set permission for a network.
425      * @param permission null to clear permissions. PERMISSION_NETWORK or PERMISSION_SYSTEM to set
426      *                   permission.
427      */
setNetworkPermission(int netId, String permission)428     void setNetworkPermission(int netId, String permission);
429 
setPermission(String permission, in int[] uids)430     void setPermission(String permission, in int[] uids);
clearPermission(in int[] uids)431     void clearPermission(in int[] uids);
432 
433     /**
434      * Allow UID to call protect().
435      */
allowProtect(int uid)436     void allowProtect(int uid);
437 
438     /**
439      * Deny UID from calling protect().
440      */
denyProtect(int uid)441     void denyProtect(int uid);
442 
addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes)443     void addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes);
removeInterfaceFromLocalNetwork(String iface)444     void removeInterfaceFromLocalNetwork(String iface);
removeRoutesFromLocalNetwork(in List<RouteInfo> routes)445     int removeRoutesFromLocalNetwork(in List<RouteInfo> routes);
446 
setAllowOnlyVpnForUids(boolean enable, in UidRange[] uidRanges)447     void setAllowOnlyVpnForUids(boolean enable, in UidRange[] uidRanges);
448 }
449