Add toString for more consistent logging to IaPrefixOption
toString() approximately follows the format of tcpdump logging ND
options.
Test: TH
Change-Id: Idce2024f44bba5427dc0f88128b87b367c09ccb6
diff --git a/staticlibs/device/com/android/net/module/util/structs/IaPrefixOption.java b/staticlibs/device/com/android/net/module/util/structs/IaPrefixOption.java
index c11bd4e..ecdd440 100644
--- a/staticlibs/device/com/android/net/module/util/structs/IaPrefixOption.java
+++ b/staticlibs/device/com/android/net/module/util/structs/IaPrefixOption.java
@@ -110,19 +110,20 @@
* Note: an expired prefix can still be valid.
*/
public boolean isValid() {
- if (preferred < 0 || valid < 0) {
- Log.w(TAG, "IA_PD option with invalid lifetime, preferred lifetime " + preferred
- + ", valid lifetime " + valid);
+ if (preferred < 0) {
+ Log.w(TAG, "Invalid preferred lifetime: " + this);
+ return false;
+ }
+ if (valid < 0) {
+ Log.w(TAG, "Invalid valid lifetime: " + this);
return false;
}
if (preferred > valid) {
- Log.w(TAG, "IA_PD option with preferred lifetime " + preferred
- + " greater than valid lifetime " + valid);
+ Log.w(TAG, "Invalid lifetime. Preferred lifetime > valid lifetime: " + this);
return false;
}
if (prefixLen > 64) {
- Log.w(TAG, "IA_PD option with prefix length " + prefixLen
- + " longer than 64");
+ Log.w(TAG, "Invalid prefix length: " + this);
return false;
}
return true;
@@ -144,4 +145,10 @@
length /* 25 + IAPrefix options length */, preferred, valid, prefixLen, prefix);
return ByteBuffer.wrap(option.writeToBytes(ByteOrder.BIG_ENDIAN));
}
+
+ @Override
+ public String toString() {
+ return "IA Prefix, length " + length + ": " + mIpPrefix + ", pref " + preferred + ", valid "
+ + valid;
+ }
}