Merge "Add toString() to Ipv6ForwardingRule"

This commit is contained in:
Nucca Chen
2022-10-14 07:27:03 +00:00
committed by Gerrit Code Review
2 changed files with 16 additions and 0 deletions

View File

@@ -1473,6 +1473,15 @@ public class BpfCoordinator {
// to Objects.hash() to avoid autoboxing overhead.
return Objects.hash(upstreamIfindex, downstreamIfindex, address, srcMac, dstMac);
}
@Override
public String toString() {
return "upstreamIfindex: " + upstreamIfindex
+ ", downstreamIfindex: " + downstreamIfindex
+ ", address: " + address.getHostAddress()
+ ", srcMac: " + srcMac
+ ", dstMac: " + dstMac;
}
}
/** Tethering client information class. */

View File

@@ -2092,4 +2092,11 @@ public class BpfCoordinatorTest {
assertNull(mBpfUpstream4Map.getValue(upstream4KeyB));
assertNull(mBpfDownstream4Map.getValue(downstream4KeyB));
}
@Test
public void testIpv6ForwardingRuleToString() throws Exception {
final Ipv6ForwardingRule rule = buildTestForwardingRule(UPSTREAM_IFINDEX, NEIGH_A, MAC_A);
assertEquals("upstreamIfindex: 1001, downstreamIfindex: 1003, address: 2001:db8::1, "
+ "srcMac: 12:34:56:78:90:ab, dstMac: 00:00:00:00:00:0a", rule.toString());
}
}