• 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.INetworkManagementEventObserver;
22 import android.net.ITetheringStatsProvider;
23 import android.net.Network;
24 import android.net.NetworkStats;
25 import android.net.RouteInfo;
26 import android.net.UidRange;
27 import android.os.INetworkActivityListener;
28 
29 /**
30  * @hide
31  */
32 interface INetworkManagementService
33 {
34     /**
35      ** GENERAL
36      **/
37 
38     /**
39      * Register an observer to receive events.
40      */
41     @UnsupportedAppUsage
registerObserver(INetworkManagementEventObserver obs)42     void registerObserver(INetworkManagementEventObserver obs);
43 
44     /**
45      * Unregister an observer from receiving events.
46      */
47     @UnsupportedAppUsage
unregisterObserver(INetworkManagementEventObserver obs)48     void unregisterObserver(INetworkManagementEventObserver obs);
49 
50     /**
51      * Returns a list of currently known network interfaces
52      */
listInterfaces()53     String[] listInterfaces();
54 
55     /**
56      * Retrieves the specified interface config
57      *
58      */
59     @UnsupportedAppUsage
getInterfaceConfig(String iface)60     InterfaceConfiguration getInterfaceConfig(String iface);
61 
62     /**
63      * Sets the configuration of the specified interface
64      */
65     @UnsupportedAppUsage
setInterfaceConfig(String iface, in InterfaceConfiguration cfg)66     void setInterfaceConfig(String iface, in InterfaceConfiguration cfg);
67 
68     /**
69      * Clear all IP addresses on the specified interface
70      */
71     @UnsupportedAppUsage
clearInterfaceAddresses(String iface)72     void clearInterfaceAddresses(String iface);
73 
74     /**
75      * Set interface down
76      */
setInterfaceDown(String iface)77     void setInterfaceDown(String iface);
78 
79     /**
80      * Set interface up
81      */
setInterfaceUp(String iface)82     void setInterfaceUp(String iface);
83 
84     /**
85      * Set interface IPv6 privacy extensions
86      */
87     @UnsupportedAppUsage
setInterfaceIpv6PrivacyExtensions(String iface, boolean enable)88     void setInterfaceIpv6PrivacyExtensions(String iface, boolean enable);
89 
90     /**
91      * Disable IPv6 on an interface
92      */
93     @UnsupportedAppUsage
disableIpv6(String iface)94     void disableIpv6(String iface);
95 
96     /**
97      * Enable IPv6 on an interface
98      */
99     @UnsupportedAppUsage
enableIpv6(String iface)100     void enableIpv6(String iface);
101 
102     /**
103      * Set IPv6 autoconf address generation mode.
104      * This is a no-op if an unsupported mode is requested.
105      */
106     @UnsupportedAppUsage
setIPv6AddrGenMode(String iface, int mode)107     void setIPv6AddrGenMode(String iface, int mode);
108 
109     /**
110      * Add the specified route to the interface.
111      */
addRoute(int netId, in RouteInfo route)112     void addRoute(int netId, in RouteInfo route);
113 
114     /**
115      * Remove the specified route from the interface.
116      */
removeRoute(int netId, in RouteInfo route)117     void removeRoute(int netId, in RouteInfo route);
118 
119     /**
120      * Set the specified MTU size
121      */
setMtu(String iface, int mtu)122     void setMtu(String iface, int mtu);
123 
124     /**
125      * Shuts down the service
126      */
shutdown()127     void shutdown();
128 
129     /**
130      ** TETHERING RELATED
131      **/
132 
133     /**
134      * Returns true if IP forwarding is enabled
135      */
136     @UnsupportedAppUsage
getIpForwardingEnabled()137     boolean getIpForwardingEnabled();
138 
139     /**
140      * Enables/Disables IP Forwarding
141      */
142     @UnsupportedAppUsage
setIpForwardingEnabled(boolean enabled)143     void setIpForwardingEnabled(boolean enabled);
144 
145     /**
146      * Start tethering services with the specified dhcp server range
147      * arg is a set of start end pairs defining the ranges.
148      */
149     @UnsupportedAppUsage
startTethering(in String[] dhcpRanges)150     void startTethering(in String[] dhcpRanges);
151 
152     /**
153      * Stop currently running tethering services
154      */
155     @UnsupportedAppUsage
stopTethering()156     void stopTethering();
157 
158     /**
159      * Returns true if tethering services are started
160      */
161     @UnsupportedAppUsage
isTetheringStarted()162     boolean isTetheringStarted();
163 
164     /**
165      * Tethers the specified interface
166      */
167     @UnsupportedAppUsage
tetherInterface(String iface)168     void tetherInterface(String iface);
169 
170     /**
171      * Untethers the specified interface
172      */
173     @UnsupportedAppUsage
untetherInterface(String iface)174     void untetherInterface(String iface);
175 
176     /**
177      * Returns a list of currently tethered interfaces
178      */
listTetheredInterfaces()179     String[] listTetheredInterfaces();
180 
181     /**
182      * Sets the list of DNS forwarders (in order of priority)
183      */
setDnsForwarders(in Network network, in String[] dns)184     void setDnsForwarders(in Network network, in String[] dns);
185 
186     /**
187      * Returns the list of DNS forwarders (in order of priority)
188      */
getDnsForwarders()189     String[] getDnsForwarders();
190 
191     /**
192      * Enables unidirectional packet forwarding from {@code fromIface} to
193      * {@code toIface}.
194      */
startInterfaceForwarding(String fromIface, String toIface)195     void startInterfaceForwarding(String fromIface, String toIface);
196 
197     /**
198      * Disables unidirectional packet forwarding from {@code fromIface} to
199      * {@code toIface}.
200      */
stopInterfaceForwarding(String fromIface, String toIface)201     void stopInterfaceForwarding(String fromIface, String toIface);
202 
203     /**
204      *  Enables Network Address Translation between two interfaces.
205      *  The address and netmask of the external interface is used for
206      *  the NAT'ed network.
207      */
208     @UnsupportedAppUsage
enableNat(String internalInterface, String externalInterface)209     void enableNat(String internalInterface, String externalInterface);
210 
211     /**
212      *  Disables Network Address Translation between two interfaces.
213      */
214     @UnsupportedAppUsage
disableNat(String internalInterface, String externalInterface)215     void disableNat(String internalInterface, String externalInterface);
216 
217     /**
218      * Registers a {@code ITetheringStatsProvider} to provide tethering statistics.
219      * All registered providers will be called in order, and their results will be added together.
220      * Netd is always registered as a tethering stats provider.
221      */
registerTetheringStatsProvider(ITetheringStatsProvider provider, String name)222     void registerTetheringStatsProvider(ITetheringStatsProvider provider, String name);
223 
224     /**
225      * Unregisters a previously-registered {@code ITetheringStatsProvider}.
226      */
unregisterTetheringStatsProvider(ITetheringStatsProvider provider)227     void unregisterTetheringStatsProvider(ITetheringStatsProvider provider);
228 
229     /**
230      * Reports that a tethering provider has reached a data limit.
231      *
232      * Currently triggers a global alert, which causes NetworkStatsService to poll counters and
233      * re-evaluate data usage.
234      *
235      * This does not take an interface name because:
236      * 1. The tethering offload stats provider cannot reliably determine the interface on which the
237      *    limit was reached, because the HAL does not provide it.
238      * 2. Firing an interface-specific alert instead of a global alert isn't really useful since in
239      *    all cases of interest, the system responds to both in the same way - it polls stats, and
240      *    then notifies NetworkPolicyManagerService of the fact.
241      */
tetherLimitReached(ITetheringStatsProvider provider)242     void tetherLimitReached(ITetheringStatsProvider provider);
243 
244     /**
245      ** DATA USAGE RELATED
246      **/
247 
248     /**
249      * Return global network statistics summarized at an interface level,
250      * without any UID-level granularity.
251      */
getNetworkStatsSummaryDev()252     NetworkStats getNetworkStatsSummaryDev();
getNetworkStatsSummaryXt()253     NetworkStats getNetworkStatsSummaryXt();
254 
255     /**
256      * Return detailed network statistics with UID-level granularity,
257      * including interface and tag details.
258      */
getNetworkStatsDetail()259     NetworkStats getNetworkStatsDetail();
260 
261     /**
262      * Return detailed network statistics for the requested UID and interfaces,
263      * including interface and tag details.
264      * @param uid UID to obtain statistics for, or {@link NetworkStats#UID_ALL}.
265      * @param ifaces Interfaces to obtain statistics for, or {@link NetworkStats#INTERFACES_ALL}.
266      */
getNetworkStatsUidDetail(int uid, in String[] ifaces)267     NetworkStats getNetworkStatsUidDetail(int uid, in String[] ifaces);
268 
269     /**
270      * Return summary of network statistics all tethering interfaces.
271      */
getNetworkStatsTethering(int how)272     NetworkStats getNetworkStatsTethering(int how);
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      */
311     @UnsupportedAppUsage
isBandwidthControlEnabled()312     boolean isBandwidthControlEnabled();
313 
314     /**
315      * Sets idletimer for an interface.
316      *
317      * This either initializes a new idletimer or increases its
318      * reference-counting if an idletimer already exists for given
319      * {@code iface}.
320      *
321      * {@code type} is the type of the interface, such as TYPE_MOBILE.
322      *
323      * Every {@code addIdleTimer} should be paired with a
324      * {@link removeIdleTimer} to cleanup when the network disconnects.
325      */
addIdleTimer(String iface, int timeout, int type)326     void addIdleTimer(String iface, int timeout, int type);
327 
328     /**
329      * Removes idletimer for an interface.
330      */
removeIdleTimer(String iface)331     void removeIdleTimer(String iface);
332 
setFirewallEnabled(boolean enabled)333     void setFirewallEnabled(boolean enabled);
isFirewallEnabled()334     boolean isFirewallEnabled();
setFirewallInterfaceRule(String iface, boolean allow)335     void setFirewallInterfaceRule(String iface, boolean allow);
setFirewallUidRule(int chain, int uid, int rule)336     void setFirewallUidRule(int chain, int uid, int rule);
setFirewallUidRules(int chain, in int[] uids, in int[] rules)337     void setFirewallUidRules(int chain, in int[] uids, in int[] rules);
setFirewallChainEnabled(int chain, boolean enable)338     void setFirewallChainEnabled(int chain, boolean enable);
339 
340     /**
341      * Set all packets from users in ranges to go through VPN specified by netId.
342      */
addVpnUidRanges(int netId, in UidRange[] ranges)343     void addVpnUidRanges(int netId, in UidRange[] ranges);
344 
345     /**
346      * Clears the special VPN rules for users in ranges and VPN specified by netId.
347      */
removeVpnUidRanges(int netId, in UidRange[] ranges)348     void removeVpnUidRanges(int netId, in UidRange[] ranges);
349 
350     /**
351      * Start listening for mobile activity state changes.
352      */
registerNetworkActivityListener(INetworkActivityListener listener)353     void registerNetworkActivityListener(INetworkActivityListener listener);
354 
355     /**
356      * Stop listening for mobile activity state changes.
357      */
unregisterNetworkActivityListener(INetworkActivityListener listener)358     void unregisterNetworkActivityListener(INetworkActivityListener listener);
359 
360     /**
361      * Check whether the mobile radio is currently active.
362      */
isNetworkActive()363     boolean isNetworkActive();
364 
365     /**
366      * Add an interface to a network.
367      */
addInterfaceToNetwork(String iface, int netId)368     void addInterfaceToNetwork(String iface, int netId);
369 
370     /**
371      * Remove an Interface from a network.
372      */
removeInterfaceFromNetwork(String iface, int netId)373     void removeInterfaceFromNetwork(String iface, int netId);
374 
addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid)375     void addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid);
376 
setDefaultNetId(int netId)377     void setDefaultNetId(int netId);
clearDefaultNetId()378     void clearDefaultNetId();
379 
380     /**
381      * Set permission for a network.
382      * @param permission PERMISSION_NONE to clear permissions.
383      *                   PERMISSION_NETWORK or PERMISSION_SYSTEM to set permission.
384      */
setNetworkPermission(int netId, int permission)385     void setNetworkPermission(int netId, int permission);
386 
387     /**
388      * Allow UID to call protect().
389      */
allowProtect(int uid)390     void allowProtect(int uid);
391 
392     /**
393      * Deny UID from calling protect().
394      */
denyProtect(int uid)395     void denyProtect(int uid);
396 
addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes)397     void addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes);
removeInterfaceFromLocalNetwork(String iface)398     void removeInterfaceFromLocalNetwork(String iface);
removeRoutesFromLocalNetwork(in List<RouteInfo> routes)399     int removeRoutesFromLocalNetwork(in List<RouteInfo> routes);
400 
setAllowOnlyVpnForUids(boolean enable, in UidRange[] uidRanges)401     void setAllowOnlyVpnForUids(boolean enable, in UidRange[] uidRanges);
402 
isNetworkRestricted(int uid)403     boolean isNetworkRestricted(int uid);
404 }
405