diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/android/net/ip/IpClient.java | 4 | ||||
-rw-r--r-- | src/android/net/util/NetworkStackUtils.java | 16 | ||||
-rw-r--r-- | src/com/android/server/connectivity/ipmemorystore/IpMemoryStoreDatabase.java | 55 |
3 files changed, 61 insertions, 14 deletions
diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java index 7a06af4..c1f178a 100644 --- a/src/android/net/ip/IpClient.java +++ b/src/android/net/ip/IpClient.java @@ -1389,8 +1389,8 @@ public class IpClient extends StateMachine { apfConfig.apfCapabilities = mConfiguration.mApfCapabilities; apfConfig.multicastFilter = mMulticastFiltering; // Get the Configuration for ApfFilter from Context - apfConfig.ieee802_3Filter = ApfCapabilities.getApfDrop8023Frames(mContext); - apfConfig.ethTypeBlackList = ApfCapabilities.getApfEthTypeBlackList(mContext); + apfConfig.ieee802_3Filter = ApfCapabilities.getApfDrop8023Frames(); + apfConfig.ethTypeBlackList = ApfCapabilities.getApfEtherTypeBlackList(); mApfFilter = ApfFilter.maybeCreate(mContext, apfConfig, mInterfaceParams, mCallback); // TODO: investigate the effects of any multicast filtering racing/interfering with the // rest of this IP configuration startup. diff --git a/src/android/net/util/NetworkStackUtils.java b/src/android/net/util/NetworkStackUtils.java index fedb8d1..670563c 100644 --- a/src/android/net/util/NetworkStackUtils.java +++ b/src/android/net/util/NetworkStackUtils.java @@ -17,6 +17,7 @@ package android.net.util; import android.annotation.NonNull; +import android.annotation.Nullable; import android.util.SparseArray; import java.io.FileDescriptor; @@ -81,4 +82,19 @@ public class NetworkStackUtils { } return false; } + + /** + * Look up the value of a property for a particular namespace from {@link DeviceConfig}. + * @param namespace The namespace containing the property to look up. + * @param name The name of the property to look up. + * @param defaultValue The value to return if the property does not exist or has no non-null + * value. + * @return the corresponding value, or defaultValue if none exists. + */ + @Nullable + public static String getDeviceConfigProperty(@NonNull String namespace, @NonNull String name, + @Nullable String defaultValue) { + // TODO: Link to DeviceConfig API once it is ready. + return defaultValue; + } } diff --git a/src/com/android/server/connectivity/ipmemorystore/IpMemoryStoreDatabase.java b/src/com/android/server/connectivity/ipmemorystore/IpMemoryStoreDatabase.java index 4d4ceed..b4eeefd 100644 --- a/src/com/android/server/connectivity/ipmemorystore/IpMemoryStoreDatabase.java +++ b/src/com/android/server/connectivity/ipmemorystore/IpMemoryStoreDatabase.java @@ -72,6 +72,10 @@ public class IpMemoryStoreDatabase { public static final String COLNAME_ASSIGNEDV4ADDRESS = "assignedV4Address"; public static final String COLTYPE_ASSIGNEDV4ADDRESS = "INTEGER"; + public static final String COLNAME_ASSIGNEDV4ADDRESSEXPIRY = "assignedV4AddressExpiry"; + // The lease expiry timestamp in uint of milliseconds + public static final String COLTYPE_ASSIGNEDV4ADDRESSEXPIRY = "BIGINT"; + // Please note that the group hint is only a *hint*, hence its name. The client can offer // this information to nudge the grouping in the decision it thinks is right, but it can't // decide for the memory store what is the same L3 network. @@ -86,13 +90,14 @@ public class IpMemoryStoreDatabase { public static final String COLTYPE_MTU = "INTEGER DEFAULT -1"; public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " - + TABLENAME + " (" - + COLNAME_L2KEY + " " + COLTYPE_L2KEY + " PRIMARY KEY NOT NULL, " - + COLNAME_EXPIRYDATE + " " + COLTYPE_EXPIRYDATE + ", " - + COLNAME_ASSIGNEDV4ADDRESS + " " + COLTYPE_ASSIGNEDV4ADDRESS + ", " - + COLNAME_GROUPHINT + " " + COLTYPE_GROUPHINT + ", " - + COLNAME_DNSADDRESSES + " " + COLTYPE_DNSADDRESSES + ", " - + COLNAME_MTU + " " + COLTYPE_MTU + ")"; + + TABLENAME + " (" + + COLNAME_L2KEY + " " + COLTYPE_L2KEY + " PRIMARY KEY NOT NULL, " + + COLNAME_EXPIRYDATE + " " + COLTYPE_EXPIRYDATE + ", " + + COLNAME_ASSIGNEDV4ADDRESS + " " + COLTYPE_ASSIGNEDV4ADDRESS + ", " + + COLNAME_ASSIGNEDV4ADDRESSEXPIRY + " " + COLTYPE_ASSIGNEDV4ADDRESSEXPIRY + ", " + + COLNAME_GROUPHINT + " " + COLTYPE_GROUPHINT + ", " + + COLNAME_DNSADDRESSES + " " + COLTYPE_DNSADDRESSES + ", " + + COLNAME_MTU + " " + COLTYPE_MTU + ")"; public static final String DROP_TABLE = "DROP TABLE IF EXISTS " + TABLENAME; } @@ -134,7 +139,7 @@ public class IpMemoryStoreDatabase { /** The SQLite DB helper */ public static class DbHelper extends SQLiteOpenHelper { // Update this whenever changing the schema. - private static final int SCHEMA_VERSION = 2; + private static final int SCHEMA_VERSION = 3; private static final String DATABASE_FILENAME = "IpMemoryStore.db"; public DbHelper(@NonNull final Context context) { @@ -153,10 +158,27 @@ public class IpMemoryStoreDatabase { @Override public void onUpgrade(@NonNull final SQLiteDatabase db, final int oldVersion, final int newVersion) { - // No upgrade supported yet. - db.execSQL(NetworkAttributesContract.DROP_TABLE); - db.execSQL(PrivateDataContract.DROP_TABLE); - onCreate(db); + try { + if (oldVersion < 2) { + // upgrade from version 1 to version 2 + // since we starts from version 2, do nothing here + } + + if (oldVersion < 3) { + // upgrade from version 2 to version 3 + final String sqlUpgradeAddressExpiry = "alter table" + + " " + NetworkAttributesContract.TABLENAME + " ADD" + + " " + NetworkAttributesContract.COLNAME_ASSIGNEDV4ADDRESSEXPIRY + + " " + NetworkAttributesContract.COLTYPE_ASSIGNEDV4ADDRESSEXPIRY; + db.execSQL(sqlUpgradeAddressExpiry); + } + } catch (SQLiteException e) { + Log.e(TAG, "Could not upgrade to the new version", e); + // create database with new version + db.execSQL(NetworkAttributesContract.DROP_TABLE); + db.execSQL(PrivateDataContract.DROP_TABLE); + onCreate(db); + } } /** Called when the database is downgraded */ @@ -204,6 +226,10 @@ public class IpMemoryStoreDatabase { values.put(NetworkAttributesContract.COLNAME_ASSIGNEDV4ADDRESS, inet4AddressToIntHTH(attributes.assignedV4Address)); } + if (null != attributes.assignedV4AddressExpiry) { + values.put(NetworkAttributesContract.COLNAME_ASSIGNEDV4ADDRESSEXPIRY, + attributes.assignedV4AddressExpiry); + } if (null != attributes.groupHint) { values.put(NetworkAttributesContract.COLNAME_GROUPHINT, attributes.groupHint); } @@ -251,6 +277,8 @@ public class IpMemoryStoreDatabase { final NetworkAttributes.Builder builder = new NetworkAttributes.Builder(); final int assignedV4AddressInt = getInt(cursor, NetworkAttributesContract.COLNAME_ASSIGNEDV4ADDRESS, 0); + final long assignedV4AddressExpiry = getLong(cursor, + NetworkAttributesContract.COLNAME_ASSIGNEDV4ADDRESSEXPIRY, 0); final String groupHint = getString(cursor, NetworkAttributesContract.COLNAME_GROUPHINT); final byte[] dnsAddressesBlob = getBlob(cursor, NetworkAttributesContract.COLNAME_DNSADDRESSES); @@ -258,6 +286,9 @@ public class IpMemoryStoreDatabase { if (0 != assignedV4AddressInt) { builder.setAssignedV4Address(intToInet4AddressHTH(assignedV4AddressInt)); } + if (0 != assignedV4AddressExpiry) { + builder.setAssignedV4AddressExpiry(assignedV4AddressExpiry); + } builder.setGroupHint(groupHint); if (null != dnsAddressesBlob) { builder.setDnsAddresses(decodeAddressList(dnsAddressesBlob)); |