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.ITetheringStatsProvider; 24 import android.net.Network; 25 import android.net.NetworkStats; 26 import android.net.RouteInfo; 27 import android.net.UidRange; 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 * Set IPv6 autoconf address generation mode. 102 * This is a no-op if an unsupported mode is requested. 103 */ setIPv6AddrGenMode(String iface, int mode)104 void setIPv6AddrGenMode(String iface, int mode); 105 106 /** 107 * Add the specified route to the interface. 108 */ addRoute(int netId, in RouteInfo route)109 void addRoute(int netId, in RouteInfo route); 110 111 /** 112 * Remove the specified route from the interface. 113 */ removeRoute(int netId, in RouteInfo route)114 void removeRoute(int netId, in RouteInfo route); 115 116 /** 117 * Set the specified MTU size 118 */ setMtu(String iface, int mtu)119 void setMtu(String iface, int mtu); 120 121 /** 122 * Shuts down the service 123 */ shutdown()124 void shutdown(); 125 126 /** 127 ** TETHERING RELATED 128 **/ 129 130 /** 131 * Returns true if IP forwarding is enabled 132 */ getIpForwardingEnabled()133 boolean getIpForwardingEnabled(); 134 135 /** 136 * Enables/Disables IP Forwarding 137 */ setIpForwardingEnabled(boolean enabled)138 void setIpForwardingEnabled(boolean enabled); 139 140 /** 141 * Start tethering services with the specified dhcp server range 142 * arg is a set of start end pairs defining the ranges. 143 */ startTethering(in String[] dhcpRanges)144 void startTethering(in String[] dhcpRanges); 145 146 /** 147 * Stop currently running tethering services 148 */ stopTethering()149 void stopTethering(); 150 151 /** 152 * Returns true if tethering services are started 153 */ isTetheringStarted()154 boolean isTetheringStarted(); 155 156 /** 157 * Tethers the specified interface 158 */ tetherInterface(String iface)159 void tetherInterface(String iface); 160 161 /** 162 * Untethers the specified interface 163 */ untetherInterface(String iface)164 void untetherInterface(String iface); 165 166 /** 167 * Returns a list of currently tethered interfaces 168 */ listTetheredInterfaces()169 String[] listTetheredInterfaces(); 170 171 /** 172 * Sets the list of DNS forwarders (in order of priority) 173 */ setDnsForwarders(in Network network, in String[] dns)174 void setDnsForwarders(in Network network, in String[] dns); 175 176 /** 177 * Returns the list of DNS forwarders (in order of priority) 178 */ getDnsForwarders()179 String[] getDnsForwarders(); 180 181 /** 182 * Enables unidirectional packet forwarding from {@code fromIface} to 183 * {@code toIface}. 184 */ startInterfaceForwarding(String fromIface, String toIface)185 void startInterfaceForwarding(String fromIface, String toIface); 186 187 /** 188 * Disables unidirectional packet forwarding from {@code fromIface} to 189 * {@code toIface}. 190 */ stopInterfaceForwarding(String fromIface, String toIface)191 void stopInterfaceForwarding(String fromIface, String toIface); 192 193 /** 194 * Enables Network Address Translation between two interfaces. 195 * The address and netmask of the external interface is used for 196 * the NAT'ed network. 197 */ enableNat(String internalInterface, String externalInterface)198 void enableNat(String internalInterface, String externalInterface); 199 200 /** 201 * Disables Network Address Translation between two interfaces. 202 */ disableNat(String internalInterface, String externalInterface)203 void disableNat(String internalInterface, String externalInterface); 204 205 /** 206 * Registers a {@code ITetheringStatsProvider} to provide tethering statistics. 207 * All registered providers will be called in order, and their results will be added together. 208 * Netd is always registered as a tethering stats provider. 209 */ registerTetheringStatsProvider(ITetheringStatsProvider provider, String name)210 void registerTetheringStatsProvider(ITetheringStatsProvider provider, String name); 211 212 /** 213 * Unregisters a previously-registered {@code ITetheringStatsProvider}. 214 */ unregisterTetheringStatsProvider(ITetheringStatsProvider provider)215 void unregisterTetheringStatsProvider(ITetheringStatsProvider provider); 216 217 /** 218 * Reports that a tethering provider has reached a data limit. 219 * 220 * Currently triggers a global alert, which causes NetworkStatsService to poll counters and 221 * re-evaluate data usage. 222 * 223 * This does not take an interface name because: 224 * 1. The tethering offload stats provider cannot reliably determine the interface on which the 225 * limit was reached, because the HAL does not provide it. 226 * 2. Firing an interface-specific alert instead of a global alert isn't really useful since in 227 * all cases of interest, the system responds to both in the same way - it polls stats, and 228 * then notifies NetworkPolicyManagerService of the fact. 229 */ tetherLimitReached(ITetheringStatsProvider provider)230 void tetherLimitReached(ITetheringStatsProvider provider); 231 232 /** 233 ** PPPD 234 **/ 235 236 /** 237 * Returns the list of currently known TTY devices on the system 238 */ listTtys()239 String[] listTtys(); 240 241 /** 242 * Attaches a PPP server daemon to the specified TTY with the specified 243 * local/remote addresses. 244 */ attachPppd(String tty, String localAddr, String remoteAddr, String dns1Addr, String dns2Addr)245 void attachPppd(String tty, String localAddr, String remoteAddr, String dns1Addr, 246 String dns2Addr); 247 248 /** 249 * Detaches a PPP server daemon from the specified TTY. 250 */ detachPppd(String tty)251 void detachPppd(String tty); 252 253 /** 254 ** DATA USAGE RELATED 255 **/ 256 257 /** 258 * Return global network statistics summarized at an interface level, 259 * without any UID-level granularity. 260 */ getNetworkStatsSummaryDev()261 NetworkStats getNetworkStatsSummaryDev(); getNetworkStatsSummaryXt()262 NetworkStats getNetworkStatsSummaryXt(); 263 264 /** 265 * Return detailed network statistics with UID-level granularity, 266 * including interface and tag details. 267 */ getNetworkStatsDetail()268 NetworkStats getNetworkStatsDetail(); 269 270 /** 271 * Return detailed network statistics for the requested UID and interfaces, 272 * including interface and tag details. 273 * @param uid UID to obtain statistics for, or {@link NetworkStats#UID_ALL}. 274 * @param ifaces Interfaces to obtain statistics for, or {@link NetworkStats#INTERFACES_ALL}. 275 */ getNetworkStatsUidDetail(int uid, in String[] ifaces)276 NetworkStats getNetworkStatsUidDetail(int uid, in String[] ifaces); 277 278 /** 279 * Return summary of network statistics all tethering interfaces. 280 */ getNetworkStatsTethering(int how)281 NetworkStats getNetworkStatsTethering(int how); 282 283 /** 284 * Set quota for an interface. 285 */ setInterfaceQuota(String iface, long quotaBytes)286 void setInterfaceQuota(String iface, long quotaBytes); 287 288 /** 289 * Remove quota for an interface. 290 */ removeInterfaceQuota(String iface)291 void removeInterfaceQuota(String iface); 292 293 /** 294 * Set alert for an interface; requires that iface already has quota. 295 */ setInterfaceAlert(String iface, long alertBytes)296 void setInterfaceAlert(String iface, long alertBytes); 297 298 /** 299 * Remove alert for an interface. 300 */ removeInterfaceAlert(String iface)301 void removeInterfaceAlert(String iface); 302 303 /** 304 * Set alert across all interfaces. 305 */ setGlobalAlert(long alertBytes)306 void setGlobalAlert(long alertBytes); 307 308 /** 309 * Control network activity of a UID over interfaces with a quota limit. 310 */ setUidMeteredNetworkBlacklist(int uid, boolean enable)311 void setUidMeteredNetworkBlacklist(int uid, boolean enable); setUidMeteredNetworkWhitelist(int uid, boolean enable)312 void setUidMeteredNetworkWhitelist(int uid, boolean enable); setDataSaverModeEnabled(boolean enable)313 boolean setDataSaverModeEnabled(boolean enable); 314 setUidCleartextNetworkPolicy(int uid, int policy)315 void setUidCleartextNetworkPolicy(int uid, int policy); 316 317 /** 318 * Return status of bandwidth control module. 319 */ isBandwidthControlEnabled()320 boolean isBandwidthControlEnabled(); 321 322 /** 323 * Sets idletimer for an interface. 324 * 325 * This either initializes a new idletimer or increases its 326 * reference-counting if an idletimer already exists for given 327 * {@code iface}. 328 * 329 * {@code type} is the type of the interface, such as TYPE_MOBILE. 330 * 331 * Every {@code addIdleTimer} should be paired with a 332 * {@link removeIdleTimer} to cleanup when the network disconnects. 333 */ addIdleTimer(String iface, int timeout, int type)334 void addIdleTimer(String iface, int timeout, int type); 335 336 /** 337 * Removes idletimer for an interface. 338 */ removeIdleTimer(String iface)339 void removeIdleTimer(String iface); 340 341 /** 342 * Configure name servers, search paths, and resolver parameters for the given network. 343 */ setDnsConfigurationForNetwork(int netId, in String[] servers, in String[] domains, in int[] params, String tlsHostname, in String[] tlsServers)344 void setDnsConfigurationForNetwork(int netId, in String[] servers, in String[] domains, 345 in int[] params, String tlsHostname, in String[] tlsServers); 346 setFirewallEnabled(boolean enabled)347 void setFirewallEnabled(boolean enabled); isFirewallEnabled()348 boolean isFirewallEnabled(); setFirewallInterfaceRule(String iface, boolean allow)349 void setFirewallInterfaceRule(String iface, boolean allow); setFirewallUidRule(int chain, int uid, int rule)350 void setFirewallUidRule(int chain, int uid, int rule); setFirewallUidRules(int chain, in int[] uids, in int[] rules)351 void setFirewallUidRules(int chain, in int[] uids, in int[] rules); setFirewallChainEnabled(int chain, boolean enable)352 void setFirewallChainEnabled(int chain, boolean enable); 353 354 /** 355 * Set all packets from users in ranges to go through VPN specified by netId. 356 */ addVpnUidRanges(int netId, in UidRange[] ranges)357 void addVpnUidRanges(int netId, in UidRange[] ranges); 358 359 /** 360 * Clears the special VPN rules for users in ranges and VPN specified by netId. 361 */ removeVpnUidRanges(int netId, in UidRange[] ranges)362 void removeVpnUidRanges(int netId, in UidRange[] ranges); 363 364 /** 365 * Start the clatd (464xlat) service on the given interface. 366 */ startClatd(String interfaceName)367 void startClatd(String interfaceName); 368 369 /** 370 * Stop the clatd (464xlat) service on the given interface. 371 */ stopClatd(String interfaceName)372 void stopClatd(String interfaceName); 373 374 /** 375 * Determine whether the clatd (464xlat) service has been started on the given interface. 376 */ isClatdStarted(String interfaceName)377 boolean isClatdStarted(String interfaceName); 378 379 /** 380 * Start listening for mobile activity state changes. 381 */ registerNetworkActivityListener(INetworkActivityListener listener)382 void registerNetworkActivityListener(INetworkActivityListener listener); 383 384 /** 385 * Stop listening for mobile activity state changes. 386 */ unregisterNetworkActivityListener(INetworkActivityListener listener)387 void unregisterNetworkActivityListener(INetworkActivityListener listener); 388 389 /** 390 * Check whether the mobile radio is currently active. 391 */ isNetworkActive()392 boolean isNetworkActive(); 393 394 /** 395 * Setup a new physical network. 396 * @param permission null if no permissions required to access this network. PERMISSION_NETWORK 397 * or PERMISSION_SYSTEM to set respective permission. 398 */ createPhysicalNetwork(int netId, String permission)399 void createPhysicalNetwork(int netId, String permission); 400 401 /** 402 * Setup a new VPN. 403 */ createVirtualNetwork(int netId, boolean hasDNS, boolean secure)404 void createVirtualNetwork(int netId, boolean hasDNS, boolean secure); 405 406 /** 407 * Remove a network. 408 */ removeNetwork(int netId)409 void removeNetwork(int netId); 410 411 /** 412 * Add an interface to a network. 413 */ addInterfaceToNetwork(String iface, int netId)414 void addInterfaceToNetwork(String iface, int netId); 415 416 /** 417 * Remove an Interface from a network. 418 */ removeInterfaceFromNetwork(String iface, int netId)419 void removeInterfaceFromNetwork(String iface, int netId); 420 addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid)421 void addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid); 422 setDefaultNetId(int netId)423 void setDefaultNetId(int netId); clearDefaultNetId()424 void clearDefaultNetId(); 425 426 /** 427 * Set permission for a network. 428 * @param permission null to clear permissions. PERMISSION_NETWORK or PERMISSION_SYSTEM to set 429 * permission. 430 */ setNetworkPermission(int netId, String permission)431 void setNetworkPermission(int netId, String permission); 432 setPermission(String permission, in int[] uids)433 void setPermission(String permission, in int[] uids); clearPermission(in int[] uids)434 void clearPermission(in int[] uids); 435 436 /** 437 * Allow UID to call protect(). 438 */ allowProtect(int uid)439 void allowProtect(int uid); 440 441 /** 442 * Deny UID from calling protect(). 443 */ denyProtect(int uid)444 void denyProtect(int uid); 445 addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes)446 void addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes); removeInterfaceFromLocalNetwork(String iface)447 void removeInterfaceFromLocalNetwork(String iface); removeRoutesFromLocalNetwork(in List<RouteInfo> routes)448 int removeRoutesFromLocalNetwork(in List<RouteInfo> routes); 449 setAllowOnlyVpnForUids(boolean enable, in UidRange[] uidRanges)450 void setAllowOnlyVpnForUids(boolean enable, in UidRange[] uidRanges); 451 isNetworkRestricted(int uid)452 boolean isNetworkRestricted(int uid); 453 } 454