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.Network; 23 import android.net.NetworkStats; 24 import android.net.RouteInfo; 25 import android.net.UidRange; 26 import android.net.wifi.WifiConfiguration; 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 * Returns a list of currently known network interfaces 50 */ listInterfaces()51 String[] listInterfaces(); 52 53 /** 54 * Retrieves the specified interface config 55 * 56 */ getInterfaceConfig(String iface)57 InterfaceConfiguration getInterfaceConfig(String iface); 58 59 /** 60 * Sets the configuration of the specified interface 61 */ setInterfaceConfig(String iface, in InterfaceConfiguration cfg)62 void setInterfaceConfig(String iface, in InterfaceConfiguration cfg); 63 64 /** 65 * Clear all IP addresses on the specified interface 66 */ clearInterfaceAddresses(String iface)67 void clearInterfaceAddresses(String iface); 68 69 /** 70 * Set interface down 71 */ setInterfaceDown(String iface)72 void setInterfaceDown(String iface); 73 74 /** 75 * Set interface up 76 */ setInterfaceUp(String iface)77 void setInterfaceUp(String iface); 78 79 /** 80 * Set interface IPv6 privacy extensions 81 */ setInterfaceIpv6PrivacyExtensions(String iface, boolean enable)82 void setInterfaceIpv6PrivacyExtensions(String iface, boolean enable); 83 84 /** 85 * Disable IPv6 on an interface 86 */ disableIpv6(String iface)87 void disableIpv6(String iface); 88 89 /** 90 * Enable IPv6 on an interface 91 */ enableIpv6(String iface)92 void enableIpv6(String iface); 93 94 /** 95 * Enables or enables IPv6 ND offload. 96 */ setInterfaceIpv6NdOffload(String iface, boolean enable)97 void setInterfaceIpv6NdOffload(String iface, boolean enable); 98 99 /** 100 * Retrieves the network routes currently configured on the specified 101 * interface 102 */ getRoutes(String iface)103 RouteInfo[] getRoutes(String iface); 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 Network Address Translation between two interfaces. 182 * The address and netmask of the external interface is used for 183 * the NAT'ed network. 184 */ enableNat(String internalInterface, String externalInterface)185 void enableNat(String internalInterface, String externalInterface); 186 187 /** 188 * Disables Network Address Translation between two interfaces. 189 */ disableNat(String internalInterface, String externalInterface)190 void disableNat(String internalInterface, String externalInterface); 191 192 /** 193 ** PPPD 194 **/ 195 196 /** 197 * Returns the list of currently known TTY devices on the system 198 */ listTtys()199 String[] listTtys(); 200 201 /** 202 * Attaches a PPP server daemon to the specified TTY with the specified 203 * local/remote addresses. 204 */ attachPppd(String tty, String localAddr, String remoteAddr, String dns1Addr, String dns2Addr)205 void attachPppd(String tty, String localAddr, String remoteAddr, String dns1Addr, 206 String dns2Addr); 207 208 /** 209 * Detaches a PPP server daemon from the specified TTY. 210 */ detachPppd(String tty)211 void detachPppd(String tty); 212 213 /** 214 * Load firmware for operation in the given mode. Currently the three 215 * modes supported are "AP", "STA" and "P2P". 216 */ wifiFirmwareReload(String wlanIface, String mode)217 void wifiFirmwareReload(String wlanIface, String mode); 218 219 /** 220 * Start Wifi Access Point 221 */ startAccessPoint(in WifiConfiguration wifiConfig, String iface)222 void startAccessPoint(in WifiConfiguration wifiConfig, String iface); 223 224 /** 225 * Stop Wifi Access Point 226 */ stopAccessPoint(String iface)227 void stopAccessPoint(String iface); 228 229 /** 230 * Set Access Point config 231 */ setAccessPoint(in WifiConfiguration wifiConfig, String iface)232 void setAccessPoint(in WifiConfiguration wifiConfig, String iface); 233 234 /** 235 ** DATA USAGE RELATED 236 **/ 237 238 /** 239 * Return global network statistics summarized at an interface level, 240 * without any UID-level granularity. 241 */ getNetworkStatsSummaryDev()242 NetworkStats getNetworkStatsSummaryDev(); getNetworkStatsSummaryXt()243 NetworkStats getNetworkStatsSummaryXt(); 244 245 /** 246 * Return detailed network statistics with UID-level granularity, 247 * including interface and tag details. 248 */ getNetworkStatsDetail()249 NetworkStats getNetworkStatsDetail(); 250 251 /** 252 * Return detailed network statistics for the requested UID, 253 * including interface and tag details. 254 */ getNetworkStatsUidDetail(int uid)255 NetworkStats getNetworkStatsUidDetail(int uid); 256 257 /** 258 * Return summary of network statistics all tethering interfaces. 259 */ getNetworkStatsTethering()260 NetworkStats getNetworkStatsTethering(); 261 262 /** 263 * Set quota for an interface. 264 */ setInterfaceQuota(String iface, long quotaBytes)265 void setInterfaceQuota(String iface, long quotaBytes); 266 267 /** 268 * Remove quota for an interface. 269 */ removeInterfaceQuota(String iface)270 void removeInterfaceQuota(String iface); 271 272 /** 273 * Set alert for an interface; requires that iface already has quota. 274 */ setInterfaceAlert(String iface, long alertBytes)275 void setInterfaceAlert(String iface, long alertBytes); 276 277 /** 278 * Remove alert for an interface. 279 */ removeInterfaceAlert(String iface)280 void removeInterfaceAlert(String iface); 281 282 /** 283 * Set alert across all interfaces. 284 */ setGlobalAlert(long alertBytes)285 void setGlobalAlert(long alertBytes); 286 287 /** 288 * Control network activity of a UID over interfaces with a quota limit. 289 */ setUidNetworkRules(int uid, boolean rejectOnQuotaInterfaces)290 void setUidNetworkRules(int uid, boolean rejectOnQuotaInterfaces); 291 292 /** 293 * Return status of bandwidth control module. 294 */ isBandwidthControlEnabled()295 boolean isBandwidthControlEnabled(); 296 297 /** 298 * Sets idletimer for an interface. 299 * 300 * This either initializes a new idletimer or increases its 301 * reference-counting if an idletimer already exists for given 302 * {@code iface}. 303 * 304 * {@code type} is the type of the interface, such as TYPE_MOBILE. 305 * 306 * Every {@code addIdleTimer} should be paired with a 307 * {@link removeIdleTimer} to cleanup when the network disconnects. 308 */ addIdleTimer(String iface, int timeout, int type)309 void addIdleTimer(String iface, int timeout, int type); 310 311 /** 312 * Removes idletimer for an interface. 313 */ removeIdleTimer(String iface)314 void removeIdleTimer(String iface); 315 316 /** 317 * Bind name servers to a network in the DNS resolver. 318 */ setDnsServersForNetwork(int netId, in String[] servers, String domains)319 void setDnsServersForNetwork(int netId, in String[] servers, String domains); 320 321 /** 322 * Flush the DNS cache associated with the specified network. 323 */ flushNetworkDnsCache(int netId)324 void flushNetworkDnsCache(int netId); 325 setFirewallEnabled(boolean enabled)326 void setFirewallEnabled(boolean enabled); isFirewallEnabled()327 boolean isFirewallEnabled(); setFirewallInterfaceRule(String iface, boolean allow)328 void setFirewallInterfaceRule(String iface, boolean allow); setFirewallEgressSourceRule(String addr, boolean allow)329 void setFirewallEgressSourceRule(String addr, boolean allow); setFirewallEgressDestRule(String addr, int port, boolean allow)330 void setFirewallEgressDestRule(String addr, int port, boolean allow); setFirewallUidRule(int uid, boolean allow)331 void setFirewallUidRule(int uid, boolean allow); 332 333 /** 334 * Set all packets from users in ranges to go through VPN specified by netId. 335 */ addVpnUidRanges(int netId, in UidRange[] ranges)336 void addVpnUidRanges(int netId, in UidRange[] ranges); 337 338 /** 339 * Clears the special VPN rules for users in ranges and VPN specified by netId. 340 */ removeVpnUidRanges(int netId, in UidRange[] ranges)341 void removeVpnUidRanges(int netId, in UidRange[] ranges); 342 343 /** 344 * Start the clatd (464xlat) service on the given interface. 345 */ startClatd(String interfaceName)346 void startClatd(String interfaceName); 347 348 /** 349 * Stop the clatd (464xlat) service on the given interface. 350 */ stopClatd(String interfaceName)351 void stopClatd(String interfaceName); 352 353 /** 354 * Determine whether the clatd (464xlat) service has been started on the given interface. 355 */ isClatdStarted(String interfaceName)356 boolean isClatdStarted(String interfaceName); 357 358 /** 359 * Start listening for mobile activity state changes. 360 */ registerNetworkActivityListener(INetworkActivityListener listener)361 void registerNetworkActivityListener(INetworkActivityListener listener); 362 363 /** 364 * Stop listening for mobile activity state changes. 365 */ unregisterNetworkActivityListener(INetworkActivityListener listener)366 void unregisterNetworkActivityListener(INetworkActivityListener listener); 367 368 /** 369 * Check whether the mobile radio is currently active. 370 */ isNetworkActive()371 boolean isNetworkActive(); 372 373 /** 374 * Setup a new physical network. 375 */ createPhysicalNetwork(int netId)376 void createPhysicalNetwork(int netId); 377 378 /** 379 * Setup a new VPN. 380 */ createVirtualNetwork(int netId, boolean hasDNS, boolean secure)381 void createVirtualNetwork(int netId, boolean hasDNS, boolean secure); 382 383 /** 384 * Remove a network. 385 */ removeNetwork(int netId)386 void removeNetwork(int netId); 387 388 /** 389 * Add an interface to a network. 390 */ addInterfaceToNetwork(String iface, int netId)391 void addInterfaceToNetwork(String iface, int netId); 392 393 /** 394 * Remove an Interface from a network. 395 */ removeInterfaceFromNetwork(String iface, int netId)396 void removeInterfaceFromNetwork(String iface, int netId); 397 addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid)398 void addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid); 399 setDefaultNetId(int netId)400 void setDefaultNetId(int netId); clearDefaultNetId()401 void clearDefaultNetId(); 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); 418 } 419