Skip to content
Snippets Groups Projects
Commit 8f77f016 authored by Patrick Rohr's avatar Patrick Rohr
Browse files

Add toString for more consistent logging to IaPrefixOption

toString() approximately follows the format of tcpdump logging ND
options.

Test: TH
Change-Id: Idce2024f44bba5427dc0f88128b87b367c09ccb6
parent 9f03f9e6
No related branches found
No related tags found
No related merge requests found
......@@ -110,19 +110,20 @@ public class IaPrefixOption extends Struct {
* 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 @@ public class IaPrefixOption extends Struct {
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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment