Add dump info to IpSecService
Bug:38350824 Test: runtest frameworks-net Change-Id: Ifa11d55e9d337016ad865baada627db3aa8c2db3
This commit is contained in:
@@ -16,8 +16,10 @@
|
||||
package android.net;
|
||||
|
||||
import android.annotation.StringDef;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import com.android.internal.util.HexDump;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@@ -182,4 +184,17 @@ public final class IpSecAlgorithm implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder()
|
||||
.append("{mName=")
|
||||
.append(mName)
|
||||
.append(", mKey=")
|
||||
.append(Build.IS_DEBUGGABLE ? HexDump.toHexString(mKey) : "<hidden>")
|
||||
.append(", mTruncLenBits=")
|
||||
.append(mTruncLenBits)
|
||||
.append("}")
|
||||
.toString();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -47,9 +47,22 @@ public final class IpSecConfig implements Parcelable {
|
||||
|
||||
// Authentication Algorithm
|
||||
IpSecAlgorithm authentication;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder()
|
||||
.append("{spiResourceId=")
|
||||
.append(spiResourceId)
|
||||
.append(", encryption=")
|
||||
.append(encryption)
|
||||
.append(", authentication=")
|
||||
.append(authentication)
|
||||
.append("}")
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Flow[] flow = new Flow[] {new Flow(), new Flow()};
|
||||
final Flow[] flow = new Flow[] {new Flow(), new Flow()};
|
||||
|
||||
// For tunnel mode IPv4 UDP Encapsulation
|
||||
// IpSecTransform#ENCAP_ESP_*, such as ENCAP_ESP_OVER_UDP_IKE
|
||||
@@ -166,6 +179,35 @@ public final class IpSecConfig implements Parcelable {
|
||||
encapRemotePort = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder strBuilder = new StringBuilder();
|
||||
strBuilder
|
||||
.append("{mode=")
|
||||
.append(mode == IpSecTransform.MODE_TUNNEL ? "TUNNEL" : "TRANSPORT")
|
||||
.append(", localAddress=")
|
||||
.append(localAddress)
|
||||
.append(", remoteAddress=")
|
||||
.append(remoteAddress)
|
||||
.append(", network=")
|
||||
.append(network)
|
||||
.append(", encapType=")
|
||||
.append(encapType)
|
||||
.append(", encapLocalPortResourceId=")
|
||||
.append(encapLocalPortResourceId)
|
||||
.append(", encapRemotePort=")
|
||||
.append(encapRemotePort)
|
||||
.append(", nattKeepaliveInterval=")
|
||||
.append(nattKeepaliveInterval)
|
||||
.append(", flow[OUT]=")
|
||||
.append(flow[IpSecTransform.DIRECTION_OUT])
|
||||
.append(", flow[IN]=")
|
||||
.append(flow[IpSecTransform.DIRECTION_IN])
|
||||
.append("}");
|
||||
|
||||
return strBuilder.toString();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<IpSecConfig> CREATOR =
|
||||
new Parcelable.Creator<IpSecConfig>() {
|
||||
public IpSecConfig createFromParcel(Parcel in) {
|
||||
|
||||
@@ -67,10 +67,10 @@ public final class IpSecTransform implements AutoCloseable {
|
||||
public @interface TransformDirection {}
|
||||
|
||||
/** @hide */
|
||||
private static final int MODE_TUNNEL = 0;
|
||||
public static final int MODE_TUNNEL = 0;
|
||||
|
||||
/** @hide */
|
||||
private static final int MODE_TRANSPORT = 1;
|
||||
public static final int MODE_TRANSPORT = 1;
|
||||
|
||||
/** @hide */
|
||||
public static final int ENCAP_NONE = 0;
|
||||
|
||||
@@ -214,6 +214,21 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
* <p>Calls to this are always guarded by IpSecService#this
|
||||
*/
|
||||
protected abstract void releaseResources() throws RemoteException;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder()
|
||||
.append("{mResourceId=")
|
||||
.append(mResourceId)
|
||||
.append(", pid=")
|
||||
.append(pid)
|
||||
.append(", uid=")
|
||||
.append(uid)
|
||||
.append(", mReferenceCount=")
|
||||
.append(mReferenceCount.get())
|
||||
.append("}")
|
||||
.toString();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -240,6 +255,11 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
void remove(int key) {
|
||||
mArray.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return mArray.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private final class TransformRecord extends ManagedResource {
|
||||
@@ -309,6 +329,24 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
mSocket.removeReference();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder strBuilder = new StringBuilder();
|
||||
strBuilder
|
||||
.append("{super=")
|
||||
.append(super.toString())
|
||||
.append(", mSocket=")
|
||||
.append(mSocket)
|
||||
.append(", mSpis[OUT].mResourceId=")
|
||||
.append(mSpis[IpSecTransform.DIRECTION_OUT].mResourceId)
|
||||
.append(", mSpis[IN].mResourceId=")
|
||||
.append(mSpis[IpSecTransform.DIRECTION_IN].mResourceId)
|
||||
.append(", mConfig=")
|
||||
.append(mConfig)
|
||||
.append("}");
|
||||
return strBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private final class SpiRecord extends ManagedResource {
|
||||
@@ -372,6 +410,26 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
|
||||
mOwnedByTransform = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder strBuilder = new StringBuilder();
|
||||
strBuilder
|
||||
.append("{super=")
|
||||
.append(super.toString())
|
||||
.append(", mSpi=")
|
||||
.append(mSpi)
|
||||
.append(", mDirection=")
|
||||
.append(mDirection)
|
||||
.append(", mLocalAddress=")
|
||||
.append(mLocalAddress)
|
||||
.append(", mRemoteAddress=")
|
||||
.append(mRemoteAddress)
|
||||
.append(", mOwnedByTransform=")
|
||||
.append(mOwnedByTransform)
|
||||
.append("}");
|
||||
return strBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private final class UdpSocketRecord extends ManagedResource {
|
||||
@@ -399,6 +457,19 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
public FileDescriptor getSocket() {
|
||||
return mSocket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder()
|
||||
.append("{super=")
|
||||
.append(super.toString())
|
||||
.append(", mSocket=")
|
||||
.append(mSocket)
|
||||
.append(", mPort=")
|
||||
.append(mPort)
|
||||
.append("}")
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,11 +805,18 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
protected synchronized void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
mContext.enforceCallingOrSelfPermission(DUMP, TAG);
|
||||
// TODO: Add dump code to print out a log of all the resources being tracked
|
||||
pw.println("IpSecService Log:");
|
||||
|
||||
pw.println("IpSecService dump:");
|
||||
pw.println("NetdNativeService Connection: " + (isNetdAlive() ? "alive" : "dead"));
|
||||
pw.println();
|
||||
|
||||
pw.println("mTransformRecords:");
|
||||
pw.println(mTransformRecords);
|
||||
pw.println("mUdpSocketRecords:");
|
||||
pw.println(mUdpSocketRecords);
|
||||
pw.println("mSpiRecords:");
|
||||
pw.println(mSpiRecords);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user