Merge "Improve the nduser option log readability." into main

This commit is contained in:
Xiao Ma 2024-04-08 01:25:21 +00:00 • committed by Gerrit Code Review
commit 1cf1b5f785
2 changed files with 7 additions and 4 deletions

View file

@ -156,8 +156,9 @@ public class NduseroptMessage extends NetlinkMessage {
@Override
public String toString() {
return String.format("Nduseroptmsg(%d, %d, %d, %d, %d, %s)",
return String.format("Nduseroptmsg(family:%d, opts_len:%d, ifindex:%d, icmp_type:%d, "
+ "icmp_code:%d, srcaddr: %s, %s)",
family, opts_len, ifindex, Byte.toUnsignedInt(icmp_type),
Byte.toUnsignedInt(icmp_code), srcaddr.getHostAddress());
Byte.toUnsignedInt(icmp_code), srcaddr.getHostAddress(), option);
}
}

View file

@ -252,8 +252,10 @@ public class NduseroptMessageTest {
public void testToString() {
NduseroptMessage msg = parseNduseroptMessage(toBuffer(MSG_PREF64));
assertNotNull(msg);
assertEquals("Nduseroptmsg(10, 16, 1431655765, 134, 0, fe80:2:3:4:5:6:7:8%1431655765)",
msg.toString());
final String expected = "Nduseroptmsg(family:10, opts_len:16, ifindex:1431655765, "
+ "icmp_type:134, icmp_code:0, srcaddr: fe80:2:3:4:5:6:7:8%1431655765, "
+ "NdOptPref64(2001:db8:3:4:5:6::/96, 10064))";
assertEquals(expected, msg.toString());
}
// Convenience method to parse a NduseroptMessage that's not part of a netlink message.