History log of /libcore/luni/src/main/java/java/net/NetworkInterface.java
Revision Date Author Comments
5d930cadc8f62aee5f18e7921296fe66a54f18ab 24-Apr-2014 Elliott Hughes <enh@google.com> Groundwork towards making the Libcore.os functionality public.

Change-Id: Ie700aa16d91fba53fc5eb2555829cb74d84b12ad
671a834be6d345a7df01ba19407dd1c96509c785 29-Oct-2013 Narayan Kamath <narayan@google.com> Make getInetAddress generate less garbage.

This function is now on the critical path for URLConnection
since OkHttp calls it to figure out what the MTU for the
NetworkInterface is.

This function performs poorly when there are a large
number of interfaces available.

- Read /proc/net/if_inet6 exactly once, instead of
once per interface.
- List the contents of /sys/class/net exactly once,
and not once per interface.

Also adds a couple of tests for if_inet6 parsing.

TODO: Add a "zero copy" version of UnsafeByteSequence
and then move readIntFile over to that version.

(Cherry picked from ab6d858336e6db8b5117b78837fee2a9f35fdf2c)

Bug: b/11411129

Change-Id: Ieb1d5f0beaf462721f897a5f6376a4587f3aebaf
ab6d858336e6db8b5117b78837fee2a9f35fdf2c 29-Oct-2013 Narayan Kamath <narayan@google.com> Make getInetAddress generate less garbage.

This function is now on the critical path for URLConnection
since OkHttp calls it to figure out what the MTU for the
NetworkInterface is.

This function performs poorly when there are a large
number of interfaces available.

- Read /proc/net/if_inet6 exactly once, instead of
once per interface.
- List the contents of /sys/class/net exactly once,
and not once per interface.

Also adds a couple of tests for if_inet6 parsing.

TODO: Add a "zero copy" version of UnsafeByteSequence
and then move readIntFile over to that version.

bug: 11411129
Change-Id: Ieb1d5f0beaf462721f897a5f6376a4587f3aebaf
8ffa0b68c9fd3f722bee2bcd94b1d38151a0791d 13-May-2013 Elliott Hughes <enh@google.com> Un-@hide various APIs.

Bug: 3484927
Change-Id: I4cda326a31240135d883528d9cb976a9db084234
b0e6dc5464f959b3d42f37b32f4b01767f6fe506 12-Jul-2012 Elliott Hughes <enh@google.com> Fix NetworkInterface.getNetworkInterfaces /proc/net/if_inet6 parsing.

It turns out that some devices can have very large interface indexes,
and my code was incorrectly assuming they'd always fit in 8 bits.

Bug: http://code.google.com/p/android/issues/detail?id=34022
Change-Id: I388a46ffe45f9706a4e28fb3b2975c991a74d419
4bbc5de89764a9bcdb62c65be31e0f110578d427 07-Jan-2012 Elliott Hughes <enh@google.com> Cope with network interfaces disappearing while we're enumerating them.

Bug: 5833739
Change-Id: I2af2c3cd9dde66422786345cc22c9297b4b218ae
10914811ea02b4acc7ab1dc5a0ada1b54cdf2203 29-Oct-2011 Elliott Hughes <enh@google.com> Improve the documentation of toString methods in the java.net package.

A developer wanted to know why their InterfaceAddress string began with a "/",
which wasn't obvious from our crappy documentation. This kind of thing should
always include examples, so let's include some examples...

Change-Id: Ic0a555c880e7f2dd31e4801926523f1aa96461c8
0d4daefcf389b6433a0af481ef44a84a2546541a 21-May-2011 Elliott Hughes <enh@google.com> Suppress some FindBugs warnings.

Also globally replace "for(" with "for (".

Change-Id: I27fe17460e6745b9ca823f42e57c86fe8af31979
a37e971343883bb582a93ffbd9f0ba84f10e55ba 21-Apr-2011 Elliott Hughes <enh@google.com> Rewrite NetworkInterface.

This is part of the POSIX work, but also fixes a bug that asked for down
interfaces to be returned. Additionally, I found a few bugs while rewriting
this code. Most notably, we used to return a bogus broadcast address for
the loopback interface. The only difference I notice between us and the RI
when running on the host is that the RI claims that 127.0.0.1 has a prefix
length of 0 rather than 8. I believe that we are correct on this issue.

Bug: 4082343, 3107501
Change-Id: I677e0698e3a86676b4332b5d56fe514a99c3ddc0
c3d19477189eafcdfec5735f9e5e13ffdeaf963d 05-Apr-2011 Elliott Hughes <enh@google.com> Slightly simplify MulticastSocket.

Part of the code is actually a new public method in Java 7, and another part
is just compatibility cruft for IPv4-only stacks.

(I think there's plenty more to clean up in here, but I'm being cautious and
breaking it into separate changes, each of which have no effect on the tests.
My hope is to remove the use of SocketOptions.IP_MULTICAST_IF entirely, but
I'll settle for being able to justify why we still need it, if we do.)

Bug: 3107501
Bug: 3484927
Change-Id: Icb4b3c1180dcd8b5666a4a969353a881ca97888e
6186821cb13f4ac7ff50950c813394367e021eae 08-Feb-2011 Jesse Wilson <jessewilson@google.com> Move libcore.base classes to libcore.util and libcore.io.

Change-Id: I2340a9dbad3561fa681a8ab47d4f406e72c913e3
a9c6c9013b08934867f71b69a90efce0c1b66918 11-Jan-2011 Elliott Hughes <enh@google.com> Documentation improvements for socket options.

Bug: http://code.google.com/p/android/issues/detail?id=13898
Change-Id: I202a5404e7e828f074483a3f6365b4e3a941da7d
ad41624e761bcf1af9c8008eb45187fc13983717 07-Jan-2011 Elliott Hughes <enh@google.com> Retire SecurityManager.

This change removes all the code that was calling getSecurityManager, and
removes all use of AccessController.doPrivileged. It also changes the
implementation of AccessController so it doesn't actually do anything; it's
only there for source-level compatibility.

Bug: 2585285
Change-Id: I1f0295a4f12bce0316d8073011d8593fee116f71
693eacca9fa67ad79d1b35dbaad61c5ac1ac457c 10-Nov-2010 Elliott Hughes <enh@google.com> Stop allocating empty arrays.

Bug: 3166662
Change-Id: I151de373b2bf53786d19824336fa434c02b0b0e8
0d93c38cc3c7a5001aece8a18cafc6d1fc7551f3 04-Nov-2010 Elliott Hughes <enh@google.com> Add a public @hide InetAddress.isNumeric.

Some frameworks/base callers want to know whether they can call
getAllByName/getByName without incurring a DNS lookup. Rather than have them
write their own JNI to do the AI_NUMERICHOST getaddrinfo(3) call, let's just
offer them ours.

Why don't I fully expose getaddrinfo(3)? Because it doesn't map to Java API
very well, and no-one needs that yet. So for now, let's take the easy way out.

Also improve some misleading javadoc.

Bug: 3073384
Change-Id: Ia1990313306254598a4e1480cae356f68ceaaf22
7365de1056414750d0a7d1fdd26025fd247f0d04 12-Aug-2010 Jesse Wilson <jessewilson@google.com> Sorting imports.

Change-Id: I8347bc625480a1c37a1ed9976193ddfedeb00bbc
162a12c1442641a95fe95859fa4e561b22db049f 25-May-2010 Elliott Hughes <enh@google.com> Remove @hide from Java 6 API.

I've left the two new spi packages @hidden, because I think we shouldn't
support them without convincing demand from developers (and I don't
believe there could be such a thing --- they just don't make sense, and
if we add anything, it should be the ability to provide extra ICU data).

Also fix a handful of javadoc syntax errors in Arrays.java and TreeMap.java.

Bug: 2497395
Change-Id: I4176b72daff0face4ed6c7ee1d1f4267d52006b4
b1396870f92135aa140bd2b86221768dea5bc11d 25-May-2010 Elliott Hughes <enh@google.com> Remove the luni localized exception messages.

Also fix a bug I introduced in KXmlSerializer: s.isEmpty() is not
equivalent to "".equals(s) if s is allowed to be null.

Bug: 1251121
Change-Id: I41a0a98ffb49f214041c9110f824d327af5c34e8
80a7fbab52b96c9fd47c72f8987d1babe2cd001d 22-May-2010 Elliott Hughes <enh@google.com> Remove more localized exception messages.

I also accidentally mixed two unrelated changes in here: replacing "".equals
and equals("") with String.isEmpty, and removing some dead code in
org.apache.harmony.luni.util.Util.

Change-Id: I0aaad43290b083085b3095b624caf096de487223
f33eae7e84eb6d3b0f4e86b59605bb3de73009f3 13-May-2010 Elliott Hughes <enh@google.com> Remove all trailing whitespace from the dalvik team-maintained parts of libcore.

Gentlemen, you may now set your editors to "strip trailing whitespace"...

Change-Id: I85b2f6c80e5fbef1af6cab11789790b078c11b1b
fd6bb3510c2f94d636f3572dcf5f7f4dcd1a2726 13-May-2010 Elliott Hughes <enh@google.com> Remove //$NON-NLS-\d$ cruft.

Mostly done by perl(1), with manual cleanup of the few misspelled instances.
This makes our trailing whitespace slightly worse, but I'll fix all that with
a follow-on change.

Change-Id: I0b4ca98819be6f9519c4ba980d759bd1ee1a0303
edc2dae4345ea305f092ade00419685d77c8eee9 08-May-2010 Elliott Hughes <enh@google.com> Trivia.

Remove unused parameters from NetworkInterface's native methods.

Remove commented-out static initializers.

Fix FileChannel.force so that force(true) doesn't do _less_ than force(false).
Note that force(true) still doesn't do _more_ than force(false) because bionic
doesn't implement fdatasync(2). I've raised a bug against bionic about that.

Change-Id: Ia5e827638606a7919e3bcf324810747ee6bcbb9a
d2af45a6fd008ceb958ac74e5a50e582b8419e9c 05-Mar-2010 Elliott Hughes <enh@google.com> Implement the Java 6 NetworkInterface/InterfaceAddress functionality.

The Java bits are based on harmony's code (though only the bit that pulls
out the sub-interfaces is copied verbatim), but the native side is new
code, continuing our previous plan of (a) doing the least possible work
on the native side and (b) using the BSD getifaddrs(3) interface as our
portability layer.

This patch also updates our NetworkInterfaceTest to be the latest code
from harmony's java6 branch.

We pass all the harmony and jtreg tests, and visual inspection shows that
the untested (and hard to test) bits -- such as prefix length and hardware
address -- are correct.
381cd64da7ff16b9252d677197ed52a3e1bb6219 26-Nov-2009 Elliott Hughes <enh@google.com> DO NOT MERGE: backport the IPv6 NetworkInterface/multicast fixes.

This is a backport of the minimal changes from master (flan) to fix IPv6
multicasting. Specifically, it fixes NetworkInterface to report IPv6 addresses,
it fixes GenericIPMreq so we pass the interface indexes down to native code,
it replaces our old copy of harmony's MulticastSocketTest with the current
upstream version (to avoid bogus failures), and it brings back one small
"unrelated" fix to OSNetworkSystem.cpp that's necessary to prevent failures
in later parts of tests we used to fail too early to notice secondary
problems.

This passes all the (fixed) MulticastSocketTest tests, causes no regressions
in the whole net.AllTests suite, and fixes the user-submitted application
that started the investigation.

Bug: 1750581
b5fc5ecd3fe5315fc2756c0c25adc458cc8c8d91 20-Nov-2009 Elliott Hughes <enh@google.com> Rewrite NetworkInterface's JNI for IPv6.

The old ioctl SIOCGIFCONF implementation of getNetworkInterfaces only returns
IPv4 addresses. Now we've switched everything over to IPv6, that's not good
enough. This change (a) implements glibc/BSD-like getifaddrs(3)/freeifaddrs(3)
for Android, and (b) rewrites our getNetworkInterfaces to use that method. Of
particular note is that we now do more of the work in Java. The JNI hands back
a Java equivalent of getifaddrs(3)'s linked list of ifaddrs structs. The new
package-private java.net.InterfaceAddress class serves as Java's "struct
ifaddrs".

The old implementation was also broken: SIOCGIFCONF doesn't actually return
interface indexes from the kernel as the old code believed, so we were
pulling the address family out of the IPv4 address it returned, leading
us to assign the index 2 to all network interfaces. This caused all kinds of
weird behavior later.

I also had to fix GenericIPMreq so that its interface index field is actually
set. The native code gets passed one of these objects when setNetworkInterface
is called, so it's kind of important that the object identify which interface
it's supposed to correspond to.

I've also added missing copyright headers.

This fixes all of the harmony tests on the simulator and on the device. It
fixes several but not all of the jtreg MulticastSocket and IPv6 tests.
4fefecee9d4a5d2a4510f516b4015607b19e8d09 13-Nov-2009 Jean-Baptiste Queru <jbq@google.com> eclair snapshot
5839b909d9528b7726e678a4b696ed37df15d897 10-Oct-2009 Jesse Wilson <jessewilson@google.com> Udating luni to Harmony r823222.

Highlights:
- InputStream.skip concurrency issue
- "better" messages in bound exceptions for streams and arrays
- prefer fewer writes to underlying streams (using byte[] buffers)
- Rename subclasses to not reuse names from their superclasses
- PlatformAddressFactory.allocMap bugfix

Plus some spelling fixes, style fixes, serial version UIDs and other
boilerplate improvements.
f5597e626ecf7949d249dea08c1a2964d890ec11 25-Jul-2009 Jesse Wilson <jessewilson@google.com> Integrate luni module (but not tests) to Harmony r772995.

Notable changes
- Stripped "@since Android 1.0" from many files. Most files
are now 100% the same in Dalvik and Harmony.
- AbstractStringBuilder.reverse() supports surrogates
- AbstractStringBuilder shares less to waste less memory
- Bitset optimized
- BufferedInputStream changed to support unsynchronized close()
- BufferedOutputStream does flushInternal
- BufferedReader supports EBCDIC NEL
- Collections.synchronizedList().indexOf() does a copy for more concurrency
- Classes in nio module changed: DatagramChannelImpl, SocketChannelImpl
and ServerSocketChannelImpl (these depend on internal APIs changed in
this update)
- DataInputStream/DataOutputStream now use a small buffer to limit the
number of times the underlying stream is accessed
- Date now has a minutes offset, more efficient toString()
- ExposedByteArrayInputStream: new internal class
- DeleteOnExit moved to top-level class
- FileDescriptor.isValid() now non-native
- Float, Double lessThan optimized (fix for compare(-0.0F, 0.0F) still pending)
- FileURLConnection now guesses content types from streams
- HashMap iterator changes
- Hashtable iterator changes
- INetworkSystem
- removes bind2(), createMulticastSocket, sendStream(),
- renames createSocket to createStreamSocket
- JarURLConnection rewritten
- LinkedHashMap: new iterator
- Locale, Currency, TimeZone: now use ICU in Harmony, plain Java in Dalvik
- ObjectInputStream: Accessor objects in Harmony, direct native in Dalvik
- ProxyClassFile - many changes
- String - optimized ascii for toLowerCase, toUpperCase, compare
- Timer - rewritten
- TreeMap - rewritten
- URLClassLoader - new
- URLConnection - new guessContentTypeFromStream(), uses org.apache.harmony.awt.www.content
to lookup content type handlers
adc854b798c1cfe3bfd4c27d68d5cee38ca617da 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
1c0fed63c71ddb230f3b304aac12caffbedf2f21 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
dd828f42a5c83b4270d4fbf6fce2da1878f1e84a 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
fdb2704414a9ed92394ada0d1395e4db86889465 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution