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