Add getRtmFamily for RtNetlinkRouteMessage
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink.RtNetlinkRouteMessageTest Change-Id: Ifdf5afc4f58ff55bd20cc60e23b17c3138754392
This commit is contained in:
parent
08622b8ecb
commit
6000558538
2 changed files with 29 additions and 0 deletions
|
|
@ -98,6 +98,13 @@ public class RtNetlinkRouteMessage extends NetlinkMessage {
|
|||
mSinceLastUseMillis = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rtnetlink family.
|
||||
*/
|
||||
public short getRtmFamily() {
|
||||
return mRtmsg.family;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the route is resolved. This is always true for unicast,
|
||||
* and may be false only for multicast routes.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@
|
|||
|
||||
package com.android.net.module.util.netlink;
|
||||
|
||||
import static android.system.OsConstants.AF_INET6;
|
||||
import static android.system.OsConstants.NETLINK_ROUTE;
|
||||
import static com.android.net.module.util.netlink.NetlinkConstants.RTNL_FAMILY_IP6MR;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
|
@ -342,4 +344,24 @@ public class RtNetlinkRouteMessageTest {
|
|||
+ "}";
|
||||
assertEquals(expected, routeMsg.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRtmFamily_RTNL_FAMILY_IP6MR() {
|
||||
final ByteBuffer byteBuffer = toByteBuffer(RTM_NEWROUTE_MULTICAST_IPV6_HEX);
|
||||
byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.
|
||||
final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer, NETLINK_ROUTE);
|
||||
final RtNetlinkRouteMessage routeMsg = (RtNetlinkRouteMessage) msg;
|
||||
|
||||
assertEquals(RTNL_FAMILY_IP6MR, routeMsg.getRtmFamily());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRtmFamily_AF_INET6() {
|
||||
final ByteBuffer byteBuffer = toByteBuffer(RTM_NEWROUTE_HEX);
|
||||
byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // For testing.
|
||||
final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer, NETLINK_ROUTE);
|
||||
final RtNetlinkRouteMessage routeMsg = (RtNetlinkRouteMessage) msg;
|
||||
|
||||
assertEquals(AF_INET6, routeMsg.getRtmFamily());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue