summaryrefslogtreecommitdiffstats
path: root/core/java/android/net
diff options
context:
space:
mode:
authorKazuhiro Ondo <kazuhiro.ondo@motorola.com>2011-05-11 14:55:19 -0500
committerWink Saville <wink@google.com>2011-05-11 16:02:00 -0700
commit8c0b528a4746228461ead10f0d477345b607fef1 (patch)
treeb9ebeff6f431081321dcb027f8f1b46f17b7a10c /core/java/android/net
parentdb08ff768b144c6ad8b326300d95c0c60e40f2eb (diff)
downloadframeworks_base-8c0b528a4746228461ead10f0d477345b607fef1.zip
frameworks_base-8c0b528a4746228461ead10f0d477345b607fef1.tar.gz
frameworks_base-8c0b528a4746228461ead10f0d477345b607fef1.tar.bz2
Fix initialization of RouteInfo
IPv6 gateway is not correctly set in RouteInfo Change-Id: I24b1ab71a64e3097c9ba641899240fc27847b86c
Diffstat (limited to 'core/java/android/net')
-rw-r--r--core/java/android/net/RouteInfo.java18
1 files changed, 15 insertions, 3 deletions
diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java
index 9c4e48b..39e708a 100644
--- a/core/java/android/net/RouteInfo.java
+++ b/core/java/android/net/RouteInfo.java
@@ -47,13 +47,25 @@ public class RouteInfo implements Parcelable {
public RouteInfo(LinkAddress destination, InetAddress gateway) {
if (destination == null) {
try {
- if ((gateway != null) || (gateway instanceof Inet4Address)) {
- destination = new LinkAddress(Inet4Address.ANY, 0);
+ if (gateway != null) {
+ if (gateway instanceof Inet4Address) {
+ destination = new LinkAddress(Inet4Address.ANY, 0);
+ } else {
+ destination = new LinkAddress(Inet6Address.ANY, 0);
+ }
} else {
- destination = new LinkAddress(Inet6Address.ANY, 0);
+ // no destination, no gateway. invalid.
+ throw new RuntimeException("Invalid arguments passed in.");
}
} catch (Exception e) {}
}
+ if (gateway == null) {
+ if (destination.getAddress() instanceof Inet4Address) {
+ gateway = Inet4Address.ANY;
+ } else {
+ gateway = Inet6Address.ANY;
+ }
+ }
mDestination = new LinkAddress(NetworkUtils.getNetworkPart(destination.getAddress(),
destination.getNetworkPrefixLength()), destination.getNetworkPrefixLength());
mGateway = gateway;