/**@class android.net.NetworkUtils @extends java.lang.Object Native methods for managing network interfaces. {@hide} */ var NetworkUtils = { /**Setting bit 0 indicates reseting of IPv4 addresses required */ RESET_IPV4_ADDRESSES : "1", /**Setting bit 1 indicates reseting of IPv4 addresses required */ RESET_IPV6_ADDRESSES : "2", /**Reset all addresses */ RESET_ALL_ADDRESSES : "3", /**Reset IPv6 or IPv4 sockets that are connected via the named interface. @param {String} interfaceName is the interface to reset @param {Number} mask {@see #RESET_IPV4_ADDRESSES} and {@see #RESET_IPV6_ADDRESSES} */ resetConnections : function( ) {}, /**Start the DHCP client daemon, in order to have it request addresses for the named interface. This returns {@code true} if the DHCPv4 daemon starts, {@code false} otherwise. This call blocks until such time as a result is available or the default discovery timeout has been reached. Callers should check {@link #getDhcpResults} to determine whether DHCP succeeded or failed, and if it succeeded, to fetch the {@link android.net.DhcpResults}. @param {String} interfaceName the name of the interface to configure @return {Boolean} {@code true} for success, {@code false} for failure */ startDhcp : function( ) {}, /**Initiate renewal on the DHCP client daemon for the named interface. This returns {@code true} if the DHCPv4 daemon has been notified, {@code false} otherwise. This call blocks until such time as a result is available or the default renew timeout has been reached. Callers should check {@link #getDhcpResults} to determine whether DHCP succeeded or failed, and if it succeeded, to fetch the {@link android.net.DhcpResults}. @param {String} interfaceName the name of the interface to configure @return {Boolean} {@code true} for success, {@code false} for failure */ startDhcpRenew : function( ) {}, /**Start the DHCP client daemon, in order to have it request addresses for the named interface, and then configure the interface with those addresses. This call blocks until it obtains a result (either success or failure) from the daemon. @param {String} interfaceName the name of the interface to configure @param {Object {DhcpResults}} dhcpResults if the request succeeds, this object is filled in with the IP address information. @return {Boolean} {@code true} for success, {@code false} for failure */ runDhcp : function( ) {}, /**Initiate renewal on the DHCP client daemon. This call blocks until it obtains a result (either success or failure) from the daemon. @param {String} interfaceName the name of the interface to configure @param {Object {DhcpResults}} dhcpResults if the request succeeds, this object is filled in with the IP address information. @return {Boolean} {@code true} for success, {@code false} for failure */ runDhcpRenew : function( ) {}, /**Fetch results from the DHCP client daemon. This call returns {@code true} if if there are results available to be read, {@code false} otherwise. @param {String} interfaceName the name of the interface to configure @param {Object {DhcpResults}} dhcpResults if the request succeeds, this object is filled in with the IP address information. @return {Boolean} {@code true} for success, {@code false} for failure */ getDhcpResults : function( ) {}, /**Shut down the DHCP client daemon. @param {String} interfaceName the name of the interface for which the daemon should be stopped @return {Boolean} {@code true} for success, {@code false} for failure */ stopDhcp : function( ) {}, /**Release the current DHCP lease. @param {String} interfaceName the name of the interface for which the lease should be released @return {Boolean} {@code true} for success, {@code false} for failure */ releaseDhcpLease : function( ) {}, /**Return the last DHCP-related error message that was recorded. <p/>NOTE: This string is not localized, but currently it is only used in logging. @return {String} the most recent error message, if any */ getDhcpError : function( ) {}, /**Attaches a socket filter that accepts DHCP packets to the given socket. */ attachDhcpFilter : function( ) {}, /**Binds the current process to the network designated by {@code netId}. All sockets created in the future (and not explicitly bound via a bound {@link SocketFactory} (see {@link android.net.Network#getSocketFactory}) will be bound to this network. Note that if this {@code Network} ever disconnects all sockets created in this way will cease to work. This is by design so an application doesn't accidentally use sockets it thinks are still bound to a particular {@code Network}. Passing NETID_UNSET clears the binding. */ bindProcessToNetwork : function( ) {}, /**Return the netId last passed to {@link #bindProcessToNetwork}, or NETID_UNSET if {@link #unbindProcessToNetwork} has been called since {@link #bindProcessToNetwork}. */ getBoundNetworkForProcess : function( ) {}, /**Binds host resolutions performed by this process to the network designated by {@code netId}. {@link #bindProcessToNetwork} takes precedence over this setting. Passing NETID_UNSET clears the binding. @deprecated This is strictly for legacy usage to support startUsingNetworkFeature(). */ bindProcessToNetworkForHostResolution : function( ) {}, /**Explicitly binds {@code socketfd} to the network designated by {@code netId}. This overrides any binding via {@link #bindProcessToNetwork}. @return {Number} 0 on success or negative errno on failure. */ bindSocketToNetwork : function( ) {}, /**Protect {@code fd} from VPN connections. After protecting, data sent through this socket will go directly to the underlying network, so its traffic will not be forwarded through the VPN. */ protectFromVpn : function( ) {}, /**Protect {@code socketfd} from VPN connections. After protecting, data sent through this socket will go directly to the underlying network, so its traffic will not be forwarded through the VPN. */ protectFromVpn : function( ) {}, /**Determine if {@code uid} can access network designated by {@code netId}. @return {Boolean} {@code true} if {@code uid} can access network, {@code false} otherwise. */ queryUserAccess : function( ) {}, /**Convert a IPv4 address from an integer to an InetAddress. @param {Number} hostAddress an int corresponding to the IPv4 address in network byte order */ intToInetAddress : function( ) {}, /**Convert a IPv4 address from an InetAddress to an integer @param {Object {Inet4Address}} inetAddr is an InetAddress corresponding to the IPv4 address @return {Number} the IP address as an integer in network byte order */ inetAddressToInt : function( ) {}, /**Convert a network prefix length to an IPv4 netmask integer @param {Number} prefixLength @return {Number} the IPv4 netmask as an integer in network byte order */ prefixLengthToNetmaskInt : function( ) {}, /**Convert a IPv4 netmask integer to a prefix length @param {Number} netmask as an integer in network byte order @return {Number} the network prefix length */ netmaskIntToPrefixLength : function( ) {}, /**Convert an IPv4 netmask to a prefix length, checking that the netmask is contiguous. @param {Object {Inet4Address}} netmask as a {@code Inet4Address}. @return {Number} the network prefix length @throws IllegalArgumentException the specified netmask was not contiguous. @hide */ netmaskToPrefixLength : function( ) {}, /**Create an InetAddress from a string where the string must be a standard representation of a V4 or V6 address. Avoids doing a DNS lookup on failure but it will throw an IllegalArgumentException in that case. @param {String} addrString @return {Object {java.net.InetAddress}} the InetAddress @hide */ numericToInetAddress : function( ) {}, /**Masks a raw IP address byte array with the specified prefix length. */ maskRawAddress : function( ) {}, /**Get InetAddress masked with prefixLength. Will never return null. @param {Object {InetAddress}} address the IP address to mask with @param {Number} prefixLength the prefixLength used to mask the IP */ getNetworkPart : function( ) {}, /**Returns the implicit netmask of an IPv4 address, as was the custom before 1993. */ getImplicitNetmask : function( ) {}, /**Utility method to parse strings such as "192.0.2.5/24" or "2001:db8::cafe:d00d/64". @hide */ parseIpAndMask : function( ) {}, /**Check if IP address type is consistent between two InetAddress. @return {Boolean} true if both are the same type. False otherwise. */ addressTypeMatches : function( ) {}, /**Convert a 32 char hex string into a Inet6Address. throws a runtime exception if the string isn't 32 chars, isn't hex or can't be made into an Inet6Address @param {String} addrHexString a 32 character hex string representing an IPv6 addr @return {Object {java.net.InetAddress}} addr an InetAddress representation for the string */ hexToInet6Address : function( ) {}, /**Create a string array of host addresses from a collection of InetAddresses @param {Object {java.util.Collection}} addrs a Collection of InetAddresses @return {String} an array of Strings containing their host addresses */ makeStrings : function( ) {}, /**Trim leading zeros from IPv4 address strings Our base libraries will interpret that as octel.. Must leave non v4 addresses and host names alone. For example, 192.168.000.010 -> 192.168.0.10 TODO - fix base libraries and remove this function @param {String} addr a string representing an ip addr @return {String} a string propertly trimmed */ trimV4AddrZeros : function( ) {}, };