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