API changes for IPv6 MTU support
Change mtu->mtuV4 and add mtuV6 for DataProfile and DataCallResult Add mtu to RouteInfo and update test Test: atest FrameworksTelephonyTests Bug: 146668814 Change-Id: I43c7e088e46e40f38d8114548e0fc4e39d7f91cb
This commit is contained in:
@@ -105,6 +105,11 @@ public final class RouteInfo implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
private final int mType;
|
private final int mType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum transmission unit size for this route.
|
||||||
|
*/
|
||||||
|
private final int mMtu;
|
||||||
|
|
||||||
// Derived data members.
|
// Derived data members.
|
||||||
// TODO: remove these.
|
// TODO: remove these.
|
||||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||||
@@ -133,6 +138,31 @@ public final class RouteInfo implements Parcelable {
|
|||||||
@TestApi
|
@TestApi
|
||||||
public RouteInfo(@Nullable IpPrefix destination, @Nullable InetAddress gateway,
|
public RouteInfo(@Nullable IpPrefix destination, @Nullable InetAddress gateway,
|
||||||
@Nullable String iface, @RouteType int type) {
|
@Nullable String iface, @RouteType int type) {
|
||||||
|
this(destination, gateway, iface, type, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a RouteInfo object.
|
||||||
|
*
|
||||||
|
* If destination is null, then gateway must be specified and the
|
||||||
|
* constructed route is either the IPv4 default route <code>0.0.0.0</code>
|
||||||
|
* if the gateway is an instance of {@link Inet4Address}, or the IPv6 default
|
||||||
|
* route <code>::/0</code> if gateway is an instance of
|
||||||
|
* {@link Inet6Address}.
|
||||||
|
* <p>
|
||||||
|
* destination and gateway may not both be null.
|
||||||
|
*
|
||||||
|
* @param destination the destination prefix
|
||||||
|
* @param gateway the IP address to route packets through
|
||||||
|
* @param iface the interface name to send packets on
|
||||||
|
* @param type the type of this route
|
||||||
|
* @param mtu the maximum transmission unit size for this route
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@SystemApi
|
||||||
|
public RouteInfo(@Nullable IpPrefix destination, @Nullable InetAddress gateway,
|
||||||
|
@Nullable String iface, @RouteType int type, int mtu) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case RTN_UNICAST:
|
case RTN_UNICAST:
|
||||||
case RTN_UNREACHABLE:
|
case RTN_UNREACHABLE:
|
||||||
@@ -162,7 +192,7 @@ public final class RouteInfo implements Parcelable {
|
|||||||
} else {
|
} else {
|
||||||
// no destination, no gateway. invalid.
|
// no destination, no gateway. invalid.
|
||||||
throw new IllegalArgumentException("Invalid arguments passed in: " + gateway + "," +
|
throw new IllegalArgumentException("Invalid arguments passed in: " + gateway + "," +
|
||||||
destination);
|
destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: set mGateway to null if there is no gateway. This is more correct, saves space, and
|
// TODO: set mGateway to null if there is no gateway. This is more correct, saves space, and
|
||||||
@@ -177,10 +207,10 @@ public final class RouteInfo implements Parcelable {
|
|||||||
}
|
}
|
||||||
mHasGateway = (!gateway.isAnyLocalAddress());
|
mHasGateway = (!gateway.isAnyLocalAddress());
|
||||||
|
|
||||||
if ((destination.getAddress() instanceof Inet4Address &&
|
if ((destination.getAddress() instanceof Inet4Address
|
||||||
(gateway instanceof Inet4Address == false)) ||
|
&& !(gateway instanceof Inet4Address))
|
||||||
(destination.getAddress() instanceof Inet6Address &&
|
|| (destination.getAddress() instanceof Inet6Address
|
||||||
(gateway instanceof Inet6Address == false))) {
|
&& !(gateway instanceof Inet6Address))) {
|
||||||
throw new IllegalArgumentException("address family mismatch in RouteInfo constructor");
|
throw new IllegalArgumentException("address family mismatch in RouteInfo constructor");
|
||||||
}
|
}
|
||||||
mDestination = destination; // IpPrefix objects are immutable.
|
mDestination = destination; // IpPrefix objects are immutable.
|
||||||
@@ -188,6 +218,7 @@ public final class RouteInfo implements Parcelable {
|
|||||||
mInterface = iface; // Strings are immutable.
|
mInterface = iface; // Strings are immutable.
|
||||||
mType = type;
|
mType = type;
|
||||||
mIsHost = isHost();
|
mIsHost = isHost();
|
||||||
|
mMtu = mtu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -373,6 +404,17 @@ public final class RouteInfo implements Parcelable {
|
|||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the MTU size for this route.
|
||||||
|
*
|
||||||
|
* @return The MTU size, or 0 if it has not been set.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@SystemApi
|
||||||
|
public int getMtu() {
|
||||||
|
return mMtu;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if this route is a default route (ie, has no destination specified).
|
* Indicates if this route is a default route (ie, has no destination specified).
|
||||||
*
|
*
|
||||||
@@ -463,6 +505,7 @@ public final class RouteInfo implements Parcelable {
|
|||||||
val += " unknown type " + mType;
|
val += " unknown type " + mType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val += " mtu " + mMtu;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,7 +523,7 @@ public final class RouteInfo implements Parcelable {
|
|||||||
return Objects.equals(mDestination, target.getDestination()) &&
|
return Objects.equals(mDestination, target.getDestination()) &&
|
||||||
Objects.equals(mGateway, target.getGateway()) &&
|
Objects.equals(mGateway, target.getGateway()) &&
|
||||||
Objects.equals(mInterface, target.getInterface()) &&
|
Objects.equals(mInterface, target.getInterface()) &&
|
||||||
mType == target.getType();
|
mType == target.getType() && mMtu == target.getMtu();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -490,7 +533,7 @@ public final class RouteInfo implements Parcelable {
|
|||||||
return (mDestination.hashCode() * 41)
|
return (mDestination.hashCode() * 41)
|
||||||
+ (mGateway == null ? 0 :mGateway.hashCode() * 47)
|
+ (mGateway == null ? 0 :mGateway.hashCode() * 47)
|
||||||
+ (mInterface == null ? 0 :mInterface.hashCode() * 67)
|
+ (mInterface == null ? 0 :mInterface.hashCode() * 67)
|
||||||
+ (mType * 71);
|
+ (mType * 71) + (mMtu * 89);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -509,6 +552,7 @@ public final class RouteInfo implements Parcelable {
|
|||||||
dest.writeByteArray(gatewayBytes);
|
dest.writeByteArray(gatewayBytes);
|
||||||
dest.writeString(mInterface);
|
dest.writeString(mInterface);
|
||||||
dest.writeInt(mType);
|
dest.writeInt(mType);
|
||||||
|
dest.writeInt(mMtu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -527,8 +571,9 @@ public final class RouteInfo implements Parcelable {
|
|||||||
|
|
||||||
String iface = in.readString();
|
String iface = in.readString();
|
||||||
int type = in.readInt();
|
int type = in.readInt();
|
||||||
|
int mtu = in.readInt();
|
||||||
|
|
||||||
return new RouteInfo(dest, gateway, iface, type);
|
return new RouteInfo(dest, gateway, iface, type, mtu);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteInfo[] newArray(int size) {
|
public RouteInfo[] newArray(int size) {
|
||||||
|
|||||||
@@ -258,6 +258,16 @@ public class RouteInfoTest extends TestCase {
|
|||||||
assertParcelingIsLossless(r);
|
assertParcelingIsLossless(r);
|
||||||
|
|
||||||
r = new RouteInfo(Prefix("192.0.2.0/24"), null, "wlan0");
|
r = new RouteInfo(Prefix("192.0.2.0/24"), null, "wlan0");
|
||||||
assertParcelSane(r, 6);
|
assertParcelSane(r, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMtu() {
|
||||||
|
RouteInfo r;
|
||||||
|
r = new RouteInfo(Prefix("0.0.0.0/0"), Address("0.0.0.0"), "wlan0",
|
||||||
|
RouteInfo.RTN_UNICAST, 1500);
|
||||||
|
assertEquals(1500, r.getMtu());
|
||||||
|
|
||||||
|
r = new RouteInfo(Prefix("0.0.0.0/0"), Address("0.0.0.0"), "wlan0");
|
||||||
|
assertEquals(0, r.getMtu());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user