Add PCSCF to LinkProperties.
Some applications or services are needed PCSCF address to register IMS server but there is no way to get it on Android Framework.
We have added PCSCF address to LinkProperties like attached diff files.
Test: get Linkproperties and check Pcscf addresses.
atest FrameworksNetTests
Change-Id: Ic2341a4ce2ed88d560325721766fc21f85f7ff86
Signed-off-by: Hongshik <hshik.kim@samsung.com>
This commit is contained in:
@@ -51,6 +51,8 @@ public final class LinkProperties implements Parcelable {
|
|||||||
private String mIfaceName;
|
private String mIfaceName;
|
||||||
private ArrayList<LinkAddress> mLinkAddresses = new ArrayList<>();
|
private ArrayList<LinkAddress> mLinkAddresses = new ArrayList<>();
|
||||||
private ArrayList<InetAddress> mDnses = new ArrayList<>();
|
private ArrayList<InetAddress> mDnses = new ArrayList<>();
|
||||||
|
// PCSCF addresses are addresses of SIP proxies that only exist for the IMS core service.
|
||||||
|
private ArrayList<InetAddress> mPcscfs = new ArrayList<InetAddress>();
|
||||||
private ArrayList<InetAddress> mValidatedPrivateDnses = new ArrayList<>();
|
private ArrayList<InetAddress> mValidatedPrivateDnses = new ArrayList<>();
|
||||||
private boolean mUsePrivateDns;
|
private boolean mUsePrivateDns;
|
||||||
private String mPrivateDnsServerName;
|
private String mPrivateDnsServerName;
|
||||||
@@ -168,6 +170,7 @@ public final class LinkProperties implements Parcelable {
|
|||||||
mValidatedPrivateDnses.addAll(source.mValidatedPrivateDnses);
|
mValidatedPrivateDnses.addAll(source.mValidatedPrivateDnses);
|
||||||
mUsePrivateDns = source.mUsePrivateDns;
|
mUsePrivateDns = source.mUsePrivateDns;
|
||||||
mPrivateDnsServerName = source.mPrivateDnsServerName;
|
mPrivateDnsServerName = source.mPrivateDnsServerName;
|
||||||
|
mPcscfs.addAll(source.mPcscfs);
|
||||||
mDomains = source.mDomains;
|
mDomains = source.mDomains;
|
||||||
mRoutes.addAll(source.mRoutes);
|
mRoutes.addAll(source.mRoutes);
|
||||||
mHttpProxy = (source.mHttpProxy == null) ? null : new ProxyInfo(source.mHttpProxy);
|
mHttpProxy = (source.mHttpProxy == null) ? null : new ProxyInfo(source.mHttpProxy);
|
||||||
@@ -503,6 +506,60 @@ public final class LinkProperties implements Parcelable {
|
|||||||
return Collections.unmodifiableList(mValidatedPrivateDnses);
|
return Collections.unmodifiableList(mValidatedPrivateDnses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given {@link InetAddress} to the list of PCSCF servers, if not present.
|
||||||
|
*
|
||||||
|
* @param pcscfServer The {@link InetAddress} to add to the list of PCSCF servers.
|
||||||
|
* @return true if the PCSCF server was added, false otherwise.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean addPcscfServer(InetAddress pcscfServer) {
|
||||||
|
if (pcscfServer != null && !mPcscfs.contains(pcscfServer)) {
|
||||||
|
mPcscfs.add(pcscfServer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the given {@link InetAddress} from the list of PCSCF servers.
|
||||||
|
*
|
||||||
|
* @param pcscf Server The {@link InetAddress} to remove from the list of PCSCF servers.
|
||||||
|
* @return true if the PCSCF server was removed, false otherwise.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean removePcscfServer(InetAddress pcscfServer) {
|
||||||
|
if (pcscfServer != null) {
|
||||||
|
return mPcscfs.remove(pcscfServer);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the PCSCF servers in this {@code LinkProperties} with
|
||||||
|
* the given {@link Collection} of {@link InetAddress} objects.
|
||||||
|
*
|
||||||
|
* @param addresses The {@link Collection} of PCSCF servers to set in this object.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void setPcscfServers(Collection<InetAddress> pcscfServers) {
|
||||||
|
mPcscfs.clear();
|
||||||
|
for (InetAddress pcscfServer: pcscfServers) {
|
||||||
|
addPcscfServer(pcscfServer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all the {@link InetAddress} for PCSCF servers on this link.
|
||||||
|
*
|
||||||
|
* @return An unmodifiable {@link List} of {@link InetAddress} for PCSCF servers on
|
||||||
|
* this link.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public List<InetAddress> getPcscfServers() {
|
||||||
|
return Collections.unmodifiableList(mPcscfs);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the DNS domain search path used on this link.
|
* Sets the DNS domain search path used on this link.
|
||||||
*
|
*
|
||||||
@@ -736,6 +793,7 @@ public final class LinkProperties implements Parcelable {
|
|||||||
mDnses.clear();
|
mDnses.clear();
|
||||||
mUsePrivateDns = false;
|
mUsePrivateDns = false;
|
||||||
mPrivateDnsServerName = null;
|
mPrivateDnsServerName = null;
|
||||||
|
mPcscfs.clear();
|
||||||
mDomains = null;
|
mDomains = null;
|
||||||
mRoutes.clear();
|
mRoutes.clear();
|
||||||
mHttpProxy = null;
|
mHttpProxy = null;
|
||||||
@@ -782,6 +840,12 @@ public final class LinkProperties implements Parcelable {
|
|||||||
resultJoiner.add(mPrivateDnsServerName);
|
resultJoiner.add(mPrivateDnsServerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mPcscfs.isEmpty()) {
|
||||||
|
resultJoiner.add("PcscfAddresses: [");
|
||||||
|
resultJoiner.add(TextUtils.join(",", mPcscfs));
|
||||||
|
resultJoiner.add("]");
|
||||||
|
}
|
||||||
|
|
||||||
if (!mValidatedPrivateDnses.isEmpty()) {
|
if (!mValidatedPrivateDnses.isEmpty()) {
|
||||||
final StringJoiner validatedPrivateDnsesJoiner =
|
final StringJoiner validatedPrivateDnsesJoiner =
|
||||||
new StringJoiner(",", "ValidatedPrivateDnsAddresses: [", "]");
|
new StringJoiner(",", "ValidatedPrivateDnsAddresses: [", "]");
|
||||||
@@ -927,6 +991,36 @@ public final class LinkProperties implements Parcelable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this link has an IPv4 PCSCF server.
|
||||||
|
*
|
||||||
|
* @return {@code true} if there is an IPv4 PCSCF server, {@code false} otherwise.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean hasIPv4PcscfServer() {
|
||||||
|
for (InetAddress ia : mPcscfs) {
|
||||||
|
if (ia instanceof Inet4Address) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this link has an IPv6 PCSCF server.
|
||||||
|
*
|
||||||
|
* @return {@code true} if there is an IPv6 PCSCF server, {@code false} otherwise.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean hasIPv6PcscfServer() {
|
||||||
|
for (InetAddress ia : mPcscfs) {
|
||||||
|
if (ia instanceof Inet6Address) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this link is provisioned for global IPv4 connectivity.
|
* Returns true if this link is provisioned for global IPv4 connectivity.
|
||||||
* This requires an IP address, default route, and DNS server.
|
* This requires an IP address, default route, and DNS server.
|
||||||
@@ -1073,6 +1167,19 @@ public final class LinkProperties implements Parcelable {
|
|||||||
? mValidatedPrivateDnses.containsAll(targetDnses) : false;
|
? mValidatedPrivateDnses.containsAll(targetDnses) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares this {@code LinkProperties} PCSCF addresses against the target
|
||||||
|
*
|
||||||
|
* @param target LinkProperties to compare.
|
||||||
|
* @return {@code true} if both are identical, {@code false} otherwise.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean isIdenticalPcscfs(LinkProperties target) {
|
||||||
|
Collection<InetAddress> targetPcscfs = target.getPcscfServers();
|
||||||
|
return (mPcscfs.size() == targetPcscfs.size()) ?
|
||||||
|
mPcscfs.containsAll(targetPcscfs) : false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares this {@code LinkProperties} Routes against the target
|
* Compares this {@code LinkProperties} Routes against the target
|
||||||
*
|
*
|
||||||
@@ -1172,6 +1279,7 @@ public final class LinkProperties implements Parcelable {
|
|||||||
&& isIdenticalDnses(target)
|
&& isIdenticalDnses(target)
|
||||||
&& isIdenticalPrivateDns(target)
|
&& isIdenticalPrivateDns(target)
|
||||||
&& isIdenticalValidatedPrivateDnses(target)
|
&& isIdenticalValidatedPrivateDnses(target)
|
||||||
|
&& isIdenticalPcscfs(target)
|
||||||
&& isIdenticalRoutes(target)
|
&& isIdenticalRoutes(target)
|
||||||
&& isIdenticalHttpProxy(target)
|
&& isIdenticalHttpProxy(target)
|
||||||
&& isIdenticalStackedLinks(target)
|
&& isIdenticalStackedLinks(target)
|
||||||
@@ -1288,6 +1396,7 @@ public final class LinkProperties implements Parcelable {
|
|||||||
+ mMtu * 51
|
+ mMtu * 51
|
||||||
+ ((null == mTcpBufferSizes) ? 0 : mTcpBufferSizes.hashCode())
|
+ ((null == mTcpBufferSizes) ? 0 : mTcpBufferSizes.hashCode())
|
||||||
+ (mUsePrivateDns ? 57 : 0)
|
+ (mUsePrivateDns ? 57 : 0)
|
||||||
|
+ mPcscfs.size() * 67
|
||||||
+ ((null == mPrivateDnsServerName) ? 0 : mPrivateDnsServerName.hashCode());
|
+ ((null == mPrivateDnsServerName) ? 0 : mPrivateDnsServerName.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1311,6 +1420,10 @@ public final class LinkProperties implements Parcelable {
|
|||||||
}
|
}
|
||||||
dest.writeBoolean(mUsePrivateDns);
|
dest.writeBoolean(mUsePrivateDns);
|
||||||
dest.writeString(mPrivateDnsServerName);
|
dest.writeString(mPrivateDnsServerName);
|
||||||
|
dest.writeInt(mPcscfs.size());
|
||||||
|
for (InetAddress d : mPcscfs) {
|
||||||
|
dest.writeByteArray(d.getAddress());
|
||||||
|
}
|
||||||
dest.writeString(mDomains);
|
dest.writeString(mDomains);
|
||||||
dest.writeInt(mMtu);
|
dest.writeInt(mMtu);
|
||||||
dest.writeString(mTcpBufferSizes);
|
dest.writeString(mTcpBufferSizes);
|
||||||
@@ -1360,6 +1473,12 @@ public final class LinkProperties implements Parcelable {
|
|||||||
}
|
}
|
||||||
netProp.setUsePrivateDns(in.readBoolean());
|
netProp.setUsePrivateDns(in.readBoolean());
|
||||||
netProp.setPrivateDnsServerName(in.readString());
|
netProp.setPrivateDnsServerName(in.readString());
|
||||||
|
addressCount = in.readInt();
|
||||||
|
for (int i = 0; i < addressCount; i++) {
|
||||||
|
try {
|
||||||
|
netProp.addPcscfServer(InetAddress.getByAddress(in.createByteArray()));
|
||||||
|
} catch (UnknownHostException e) { }
|
||||||
|
}
|
||||||
netProp.setDomains(in.readString());
|
netProp.setDomains(in.readString());
|
||||||
netProp.setMtu(in.readInt());
|
netProp.setMtu(in.readInt());
|
||||||
netProp.setTcpBufferSizes(in.readString());
|
netProp.setTcpBufferSizes(in.readString());
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ public class LinkPropertiesTest {
|
|||||||
private static InetAddress DNS1 = NetworkUtils.numericToInetAddress("75.208.7.1");
|
private static InetAddress DNS1 = NetworkUtils.numericToInetAddress("75.208.7.1");
|
||||||
private static InetAddress DNS2 = NetworkUtils.numericToInetAddress("69.78.7.1");
|
private static InetAddress DNS2 = NetworkUtils.numericToInetAddress("69.78.7.1");
|
||||||
private static InetAddress DNS6 = NetworkUtils.numericToInetAddress("2001:4860:4860::8888");
|
private static InetAddress DNS6 = NetworkUtils.numericToInetAddress("2001:4860:4860::8888");
|
||||||
|
private static InetAddress PCSCFV6 = NetworkUtils.numericToInetAddress(
|
||||||
|
"2001:0db8:85a3:0000:0000:8a2e:0370:1");
|
||||||
private static InetAddress GATEWAY1 = NetworkUtils.numericToInetAddress("75.208.8.1");
|
private static InetAddress GATEWAY1 = NetworkUtils.numericToInetAddress("75.208.8.1");
|
||||||
private static InetAddress GATEWAY2 = NetworkUtils.numericToInetAddress("69.78.8.1");
|
private static InetAddress GATEWAY2 = NetworkUtils.numericToInetAddress("69.78.8.1");
|
||||||
private static InetAddress GATEWAY61 = NetworkUtils.numericToInetAddress("fe80::6:0000:613");
|
private static InetAddress GATEWAY61 = NetworkUtils.numericToInetAddress("fe80::6:0000:613");
|
||||||
@@ -86,6 +88,9 @@ public class LinkPropertiesTest {
|
|||||||
assertTrue(source.isIdenticalValidatedPrivateDnses(target));
|
assertTrue(source.isIdenticalValidatedPrivateDnses(target));
|
||||||
assertTrue(target.isIdenticalValidatedPrivateDnses(source));
|
assertTrue(target.isIdenticalValidatedPrivateDnses(source));
|
||||||
|
|
||||||
|
assertTrue(source.isIdenticalPcscfs(target));
|
||||||
|
assertTrue(target.isIdenticalPcscfs(source));
|
||||||
|
|
||||||
assertTrue(source.isIdenticalRoutes(target));
|
assertTrue(source.isIdenticalRoutes(target));
|
||||||
assertTrue(target.isIdenticalRoutes(source));
|
assertTrue(target.isIdenticalRoutes(source));
|
||||||
|
|
||||||
@@ -128,6 +133,8 @@ public class LinkPropertiesTest {
|
|||||||
// set 2 dnses
|
// set 2 dnses
|
||||||
source.addDnsServer(DNS1);
|
source.addDnsServer(DNS1);
|
||||||
source.addDnsServer(DNS2);
|
source.addDnsServer(DNS2);
|
||||||
|
// set 1 pcscf
|
||||||
|
source.addPcscfServer(PCSCFV6);
|
||||||
// set 2 gateways
|
// set 2 gateways
|
||||||
source.addRoute(new RouteInfo(GATEWAY1));
|
source.addRoute(new RouteInfo(GATEWAY1));
|
||||||
source.addRoute(new RouteInfo(GATEWAY2));
|
source.addRoute(new RouteInfo(GATEWAY2));
|
||||||
@@ -141,6 +148,7 @@ public class LinkPropertiesTest {
|
|||||||
target.addLinkAddress(LINKADDRV6);
|
target.addLinkAddress(LINKADDRV6);
|
||||||
target.addDnsServer(DNS1);
|
target.addDnsServer(DNS1);
|
||||||
target.addDnsServer(DNS2);
|
target.addDnsServer(DNS2);
|
||||||
|
target.addPcscfServer(PCSCFV6);
|
||||||
target.addRoute(new RouteInfo(GATEWAY1));
|
target.addRoute(new RouteInfo(GATEWAY1));
|
||||||
target.addRoute(new RouteInfo(GATEWAY2));
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
target.setMtu(MTU);
|
target.setMtu(MTU);
|
||||||
@@ -154,6 +162,7 @@ public class LinkPropertiesTest {
|
|||||||
target.addLinkAddress(LINKADDRV6);
|
target.addLinkAddress(LINKADDRV6);
|
||||||
target.addDnsServer(DNS1);
|
target.addDnsServer(DNS1);
|
||||||
target.addDnsServer(DNS2);
|
target.addDnsServer(DNS2);
|
||||||
|
target.addPcscfServer(PCSCFV6);
|
||||||
target.addRoute(new RouteInfo(GATEWAY1));
|
target.addRoute(new RouteInfo(GATEWAY1));
|
||||||
target.addRoute(new RouteInfo(GATEWAY2));
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
target.setMtu(MTU);
|
target.setMtu(MTU);
|
||||||
@@ -167,6 +176,7 @@ public class LinkPropertiesTest {
|
|||||||
target.addLinkAddress(LINKADDRV6);
|
target.addLinkAddress(LINKADDRV6);
|
||||||
target.addDnsServer(DNS1);
|
target.addDnsServer(DNS1);
|
||||||
target.addDnsServer(DNS2);
|
target.addDnsServer(DNS2);
|
||||||
|
target.addPcscfServer(PCSCFV6);
|
||||||
target.addRoute(new RouteInfo(GATEWAY1));
|
target.addRoute(new RouteInfo(GATEWAY1));
|
||||||
target.addRoute(new RouteInfo(GATEWAY2));
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
target.setMtu(MTU);
|
target.setMtu(MTU);
|
||||||
@@ -179,6 +189,21 @@ public class LinkPropertiesTest {
|
|||||||
// change dnses
|
// change dnses
|
||||||
target.addDnsServer(NetworkUtils.numericToInetAddress("75.208.7.2"));
|
target.addDnsServer(NetworkUtils.numericToInetAddress("75.208.7.2"));
|
||||||
target.addDnsServer(DNS2);
|
target.addDnsServer(DNS2);
|
||||||
|
target.addPcscfServer(PCSCFV6);
|
||||||
|
target.addRoute(new RouteInfo(GATEWAY1));
|
||||||
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
|
target.setMtu(MTU);
|
||||||
|
assertFalse(source.equals(target));
|
||||||
|
|
||||||
|
target.clear();
|
||||||
|
target.setInterfaceName(NAME);
|
||||||
|
target.addLinkAddress(LINKADDRV4);
|
||||||
|
target.addLinkAddress(LINKADDRV6);
|
||||||
|
target.addDnsServer(NetworkUtils.numericToInetAddress("75.208.7.2"));
|
||||||
|
target.addDnsServer(DNS2);
|
||||||
|
// change pcscf
|
||||||
|
target.addPcscfServer(NetworkUtils.numericToInetAddress(
|
||||||
|
"2001::1"));
|
||||||
target.addRoute(new RouteInfo(GATEWAY1));
|
target.addRoute(new RouteInfo(GATEWAY1));
|
||||||
target.addRoute(new RouteInfo(GATEWAY2));
|
target.addRoute(new RouteInfo(GATEWAY2));
|
||||||
target.setMtu(MTU);
|
target.setMtu(MTU);
|
||||||
|
|||||||
Reference in New Issue
Block a user