Merge "Also dump the last APF program to be installed." into nyc-dev
This commit is contained in:
@@ -90,6 +90,7 @@ public class ApfFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final String TAG = "ApfFilter";
|
private static final String TAG = "ApfFilter";
|
||||||
|
private static final boolean DBG = true;
|
||||||
private static final boolean VDBG = false;
|
private static final boolean VDBG = false;
|
||||||
|
|
||||||
private final ConnectivityService mConnectivityService;
|
private final ConnectivityService mConnectivityService;
|
||||||
@@ -205,6 +206,10 @@ public class ApfFilter {
|
|||||||
// For debugging only. How many times this RA was seen.
|
// For debugging only. How many times this RA was seen.
|
||||||
int seenCount = 0;
|
int seenCount = 0;
|
||||||
|
|
||||||
|
// For debugging only. Returns the hex representation of the last matching packet.
|
||||||
|
String getLastMatchingPacket() {
|
||||||
|
return HexDump.toHexString(mPacket.array(), 0, mPacket.capacity(), false /* lowercase */);
|
||||||
|
}
|
||||||
|
|
||||||
private String IPv6AddresstoString(int pos) {
|
private String IPv6AddresstoString(int pos) {
|
||||||
try {
|
try {
|
||||||
@@ -454,7 +459,7 @@ public class ApfFilter {
|
|||||||
private long mLastInstalledProgramMinLifetime;
|
private long mLastInstalledProgramMinLifetime;
|
||||||
|
|
||||||
// For debugging only. The length in bytes of the last program.
|
// For debugging only. The length in bytes of the last program.
|
||||||
private long mLastInstalledProgramLength;
|
private byte[] mLastInstalledProgram;
|
||||||
|
|
||||||
private void installNewProgram() {
|
private void installNewProgram() {
|
||||||
if (mRas.size() == 0) return;
|
if (mRas.size() == 0) return;
|
||||||
@@ -495,7 +500,7 @@ public class ApfFilter {
|
|||||||
}
|
}
|
||||||
mLastTimeInstalledProgram = curTime();
|
mLastTimeInstalledProgram = curTime();
|
||||||
mLastInstalledProgramMinLifetime = programMinLifetime;
|
mLastInstalledProgramMinLifetime = programMinLifetime;
|
||||||
mLastInstalledProgramLength = program.length;
|
mLastInstalledProgram = program;
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
hexDump("Installing filter: ", program, program.length);
|
hexDump("Installing filter: ", program, program.length);
|
||||||
} else {
|
} else {
|
||||||
@@ -515,7 +520,7 @@ public class ApfFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void hexDump(String msg, byte[] packet, int length) {
|
private void hexDump(String msg, byte[] packet, int length) {
|
||||||
log(msg + HexDump.toHexString(packet, 0, length));
|
log(msg + HexDump.toHexString(packet, 0, length, false /* lowercase */));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processRa(byte[] packet, int length) {
|
private void processRa(byte[] packet, int length) {
|
||||||
@@ -608,7 +613,7 @@ public class ApfFilter {
|
|||||||
|
|
||||||
pw.println(String.format(
|
pw.println(String.format(
|
||||||
"Last program length %d, installed %ds ago, lifetime %d",
|
"Last program length %d, installed %ds ago, lifetime %d",
|
||||||
mLastInstalledProgramLength, curTime() - mLastTimeInstalledProgram,
|
mLastInstalledProgram.length, curTime() - mLastTimeInstalledProgram,
|
||||||
mLastInstalledProgramMinLifetime));
|
mLastInstalledProgramMinLifetime));
|
||||||
|
|
||||||
pw.println("RA filters:");
|
pw.println("RA filters:");
|
||||||
@@ -618,8 +623,22 @@ public class ApfFilter {
|
|||||||
pw.increaseIndent();
|
pw.increaseIndent();
|
||||||
pw.println(String.format(
|
pw.println(String.format(
|
||||||
"Seen: %d, last %ds ago", ra.seenCount, curTime() - ra.mLastSeen));
|
"Seen: %d, last %ds ago", ra.seenCount, curTime() - ra.mLastSeen));
|
||||||
|
if (DBG) {
|
||||||
|
pw.println("Last match:");
|
||||||
|
pw.increaseIndent();
|
||||||
|
pw.println(ra.getLastMatchingPacket());
|
||||||
pw.decreaseIndent();
|
pw.decreaseIndent();
|
||||||
}
|
}
|
||||||
pw.decreaseIndent();
|
pw.decreaseIndent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DBG) {
|
||||||
|
pw.println("Last program:");
|
||||||
|
pw.increaseIndent();
|
||||||
|
pw.println(HexDump.toHexString(mLastInstalledProgram, false /* lowercase */));
|
||||||
|
pw.decreaseIndent();
|
||||||
|
}
|
||||||
|
|
||||||
|
pw.decreaseIndent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user