History log of /libcore/luni/src/main/native/NetworkUtilities.cpp
Revision Date Author Comments
62e0b4793b755083e94aac458111ca347314addd 14-Jul-2016 Yi Kong <yikong@google.com> Import upstream change: Address internet addresses

Upstream change:

8015743: Address internet addresses
Reviewed-by: alanb, khazra, skoivu

http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/69a2dc92fefe

This refactors Inet6Address to use Inet6AddressHolder to record state.
No behaviour change is expected.

Bug: 29067535
Test: Passes CTS tests, art-test-host
Change-Id: If890b979f5c1c30a886e898eeb8af263340c6ea8
f0bbd898c9cf4c8977da077b703ff1e8286821dd 08-Feb-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Remove public InetAddress#getAddressInternal()

This method shouldn't be public + can be replaced by
the #getAddress method

Bug: 26689841
Change-Id: Ic18eecd53ac73c44b5d8acd062c7f1c65c48fb23
(cherry picked from commit 5858bc7e19fde536d55d9c1ffa6a60d617b328af)
68b18924acfe6325285eaf01f233ce4b27700763 08-Feb-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Remove public InetAddress#getAddressInternal()

This method shouldn't be public + can be replaced by
the #getAddress method

Bug: 26689841
Change-Id: Ic18eecd53ac73c44b5d8acd062c7f1c65c48fb23
5858bc7e19fde536d55d9c1ffa6a60d617b328af 08-Feb-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Remove public InetAddress#getAddressInternal()

This method shouldn't be public + can be replaced by
the #getAddress method

Bug: 26689841
Change-Id: Ic18eecd53ac73c44b5d8acd062c7f1c65c48fb23
f7ab2bc37debba91864bfec6572a3e7bbe994c58 06-May-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementation of java.net.*

- Add FileURLConnection.
- NetworkUtilities : Update field names in JNI.
- Suppress a few libcore tests that rely on internal implementation
details.
- Remove code that loads the net library (not needed on android).
- DatagramSocket : Add setNetworkInterface method.
- HttpCookie : make parse & field public
- Inet4Address / Inet6Address : Add getAddressInternal.
- InetAddress : Add methods required by frameworks/base, particularly
those required to deal with net-ids and scope ids.
- URI : Add UriCodec static members for AUTHORITY_ENCODER and friends.
- URL : Add toUriLenient
- URLStreamHandler : Add a toExternalForm variant that optionally
escapes illegal chars.
- Inet4AddressImpl.c : Unconditionally define HAS_GLIBC_GETHOSTBY_R

Change-Id: Ic51f863941f5d954ed6cf86309cc610e711d54bd
0ab1a26ca767ae36fbbe27b62893670b208fa494 07-Jul-2015 Neil Fuller <nfuller@google.com> Rearrange how AF_UNIX sockets are handled for accept()

Contains the following changes:
1) Introduction of UnixSocketAddress / removal of InetUnixAddress.
2) Os/Posix classes now take SocketAddress instead of InetSocketAddress.
3) Removal of native code that dealt with InetUnixAddress.
4) Introduction of OsConstants.UNIX_PATH_MAX to hold the maximum sun_path
size.
5) Update tests.

Bug: 3106438
Change-Id: I47a3618387f21599bfbfd0dc9a821839bf47b39b
d52f91aad5c154c72906f62336fd9ef0a7df127d 22-Mar-2013 Elliott Hughes <enh@google.com> Fix libcore translation of AF_UNSPEC InetAddress instances.

An AF_UNSPEC sockaddr may not have any data, but it does have two bytes
of ss_family.

Change-Id: Ia2423989db1a4094fc9bbfdb5565ee2074743747
482a3fc5635ac431b8a7476d7fe3397af4c2e8ec 21-Mar-2013 Elliott Hughes <enh@google.com> Add support for Unix domain sockets.

Bug: 6513075
Change-Id: I0b0166f59745ac8175b39d7796c093041b2df4fd
d3990f07b1523c74d201d5971c7c2451fbe92a33 18-Apr-2012 Elliott Hughes <enh@google.com> Fix a buffer overrun found by CTS (and pinpointed by valgrind).

CTS crashed because a sockaddr_in6 (28 bytes) had been allocated at the end of
page, and the next page wasn't mapped. sockaddr_storage is 128 bytes (because
it isn't just big enough for sockaddr_in and sockaddr_in6, it's big enough for
any kind of socket).

Bug: 6293344
Change-Id: I9bec5d4ddbb89969337d6978c8a45323a792a005
d8cec780b3b5177b5c1e500ea606f731a67fb53c 21-Jun-2011 Elliott Hughes <enh@google.com> Add a couple more missing calls to DeleteLocalRef.

Change-Id: I84176e57d775cf5e433078b726be9cda3c6d4934
8ecbb3f6a89983adb1a085469befc70488f4f04f 27-May-2011 Elliott Hughes <enh@google.com> Don't use mapped IPv4 addresses with MCAST_JOIN_GROUP.

This change is really a one-liner, but I did some cleanup too. This fixes most
of the Harmony multicast tests.

Change-Id: I37ff9c6ee6ee64de0500ef4b51638b3d3a6417ff
4728a015bcd3f432e000d1547c668e804015dc04 19-May-2011 Elliott Hughes <enh@google.com> More IPv6 sin6_scope_id fixes.

My earlier patch fixed the Java-to-native direction. This fixes the
native-to-Java direction, which didn't occur to us at the time.

I've also fixed the documentation so that public methods don't
define themselves in terms of a private method (that ought to
exist in the public API, but doesn't).

Change-Id: Ib16a5952bb69b0b96a66775304947f2a120a1dcf
23ec09188303a874b3b391f96ae0a29af002bff9 19-May-2011 Elliott Hughes <enh@google.com> Implement recvfrom(2).

This one's a little bit hairy because of multiple return values.

Bug: 3107501
Change-Id: I3bd35647d94bb6bc2192d6f31a39ecca07a3926e
e9f12043a1e2a29c60779cdb55c58eb156963570 11-May-2011 Elliott Hughes <enh@google.com> Add missing ScopedLocalRef usages.

The one in RealToString is strictly unnecessary, but the other missing ones
should have been there, and this seems like another instance of the "optional
braces" anti-pattern: you should need a specific reason _not_ to have a
ScopedLocalRef, and currently only our iovec code has such a reason (and it
was already explicitly manipulating its local frame correctly).

Change-Id: I24d4766a37bd9677db43da55b94da036a263c0c8
32b0fa4d1a31ef07bc4297c615f0fe50e9aa7c21 11-May-2011 Elliott Hughes <enh@google.com> DatagramSocket.disconnect is really a connect(2) of an AF_UNSPEC sockaddr.

Bug: 3107501
Change-Id: Ib04369b9ca63ff3fe7eb87dcbf2926fe704813e3
da15009528cc8300a6251f1d0931ac8657c9fc31 09-May-2011 Elliott Hughes <enh@google.com> Expose bind(2).

I've renamed the java.net.InetAddress to struct sockaddr conversion functions
too, after initially screwing up this patch by copy & pasting a usage of the
one that only one caller actually wants. Now the name's so ugly no-one will
be likely to use it by accident.

Bug: 3107501
Change-Id: I869a8d27fc40e462505e02bf25a67e771a403e92
4664da5cfc3f22a633ca2c7013a97c08a42e6ba7 07-May-2011 Elliott Hughes <enh@google.com> Simplify our AF_INET/AF_INET6 address situation.

Looks like there's just one special case (presentation to the user) where we
want an Inet4Address to be an AF_INET sockaddr_in rather than an IPv4-mapped
AF_INET6 sockaddr_in6.

Change-Id: Ib3bcc9b69a0fc27c7348b97cc81fb326ba1d5d9d
49ff8b8582bca20a1adbda1d957220526332a8ca 06-May-2011 Elliott Hughes <enh@google.com> More networking cleanup.

Move a bit more work into Java.

Change-Id: I656ec6e3c792ce9baed32662d65c45d75af1d371
c06e5e270b958aeb8060cd7f2576c0f1e6ac415e 05-May-2011 Elliott Hughes <enh@google.com> Set the sin6_scope_id field when translating an Inet6Address to a sockaddr.

This basically means link-local IPv6 addresses have never worked on Android.

Change-Id: I343493cbbde1e4441385487f054c4bdad5dcef52
1c039d71d3879f39e3a75b8788e656f7b4f88f08 05-May-2011 Elliott Hughes <enh@google.com> Add getaddrinfo(2).

This only supports the "node" side of getaddrinfo(2), not the "service" side.
There's also no support for AI_CANONNAME, so we currently return InetAddress[]
rather than anything equivalent to C's linked list of struct addrinfo.

Bug: 3107501
Change-Id: I8cf6baa3027a0fa05ac6e2f8fcc1dd8b576ff8c4
4f11ebea266eada830d507b8f011e811a8e5d7bc 20-Apr-2011 Elliott Hughes <enh@google.com> Add getnameinfo(3) (and gai_strerror(3)).

There's quite a large corresponding change to InetAddress, plus I've changed
the documentation for all the Permission classes to match the handful that
we'd already documented as legacy cruft.

Bug: http://b/3107501
Change-Id: Ia67aba79f0ab13e64085bd4a2df20ad0776bcc5b
51236bf3f42f234359ccbf1d09b41f7e09396889 09-Apr-2011 Elliott Hughes <enh@google.com> Use jniThrowExceptionFmt.

There were a couple of places where we were doing this manually.

Change-Id: Iea6201815e8b52e4caba13b789abedc0e173df79
8398239b31c6f6fb9b19788d0a4b9ff16a59caf7 01-Apr-2011 Elliott Hughes <enh@google.com> Make inetAddressToSocketAddress more available.

I should probably rename the NetworkUtilities.h methods to say something like
SockaddrStorage instead of SocketAddress, to avoid confusion with
java.net.SocketAddress, but that can come later.

Change-Id: Id878c2b865c284bb4a14f3db1eb15b3fa9ccc9e9
0a9d1ee45a9884a9616624d747172e18734e8fe0 31-Mar-2011 Elliott Hughes <enh@google.com> Add getsockname(2) and getsockopt(2).

Bug: 3107501
Change-Id: Ibb0d5a576ecb46e51dbda6051776145eec9e7fe1
acce5ff29455054faa08a10e1486a156b9d1553e 14-Aug-2010 Elliott Hughes <enh@google.com> Fix last few uses of "type *id" to be "type* id".

We don't want anyone calling us unreformed C programmers...

Change-Id: I79b12245b206495ca747b4027b2bca423c27aec0
440ba565fa5384bc23255fbc412f7b97fcbdccd9 04-Aug-2010 Elliott Hughes <enh@google.com> Rename setNonBlocking to setBlocking.

This makes the boolean argument less confusing.

Change-Id: Ic226f6d3c5afe8e15a95e74917656424f8a448fe
91ad12a4e7c9eeb19b48fa296b4ed87d6c7b612b 26-Jul-2010 Elliott Hughes <enh@google.com> Better detail messages for exceptions thrown when converting between byte[]/InetAddress.

Change-Id: I0e87b0ed6487f8434435027ee70ec294c98617e8
3b0a5b910110625c50dae6baa94d9adaf58ed46e 23-Jul-2010 Elliott Hughes <enh@google.com> Consistently use POSIX O_NONBLOCK instead of FIONBIO.

Change-Id: I395012f0e51e1928e720d09d0f44b7d5085b01a3
a9f5c16a864ff63ba63f810410f8a27c086d5d52 17-Jun-2010 Elliott Hughes <enh@google.com> Remove dynamic calls to FindClass.

Initially, I was just fixing a threading bug in NativeDecimalFormat.cpp where
we were bypassing GCC's built-in static initializer thread safety. This led me
to the question of how expensive FindClass is, which led me to creating a new
canonical cache of jclasses.

Here's the motivating benchmark, showing the cost of calling an empty regular
(non-native) method, an empty native method, a native method that calls
FindClass, a native method that calls FindClass and GetFieldID, and a native
method that calls FindClass and GetMethodID:

benchmark ns logarithmic runtime
NoArgsRegular 74 ||||||||||||||
NoArgsNative 428 XX|||||||||||||||||||
FindClass 3064 XXXXXXXXXXXXXXXX|||||||||||
FindClassGetField 3654 XXXXXXXXXXXXXXXXXXX|||||||||
FindClassGetMethod 5634 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Change-Id: I41ab2b347895f043a7e21d8fa19e4541e198c3fc
abf945fb9ce99d8c2769ac5b2691b2732fa59887 04-Jun-2010 Elliott Hughes <enh@google.com> Bullet-proof the lseek/read in Inflater.setFileInput.

Also document why that non-API method exists, and that we don't have
benchmarks to support the claimed optimization.

Also be more consistent about setting LOG_TAG, and fix a few old-school
copyright headers.

Change-Id: If9fdc4583eaf91275ed44e2dc56174819d1913d0
753dcd862b31e85766225590d90ba0b9f481176f 02-Jun-2010 Elliott Hughes <enh@google.com> Refactor some of the OSNetworkSystem stuff to more appropriate homes.

Also rewrite PlainDatagramSocketImpl.peek in terms of existing primitives
rather than requiring its own. I still don't see how it can get called, but
at least now it doesn't require its own native code.

Bug: 2686833

Change-Id: I0453add66dab4c7095ee2a3f51a49efbd1205598