use of android.net.netlink.NetlinkMessage in project android_frameworks_base by DirtyUnicorns.
the class NetlinkErrorMessageTest method testParseNlmErrorOk.
public void testParseNlmErrorOk() {
final ByteBuffer byteBuffer = ByteBuffer.wrap(NLM_ERROR_OK);
// For testing.
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer);
assertNotNull(msg);
assertTrue(msg instanceof NetlinkErrorMessage);
final NetlinkErrorMessage errorMsg = (NetlinkErrorMessage) msg;
final StructNlMsgHdr hdr = errorMsg.getHeader();
assertNotNull(hdr);
assertEquals(36, hdr.nlmsg_len);
assertEquals(NetlinkConstants.NLMSG_ERROR, hdr.nlmsg_type);
assertEquals(0, hdr.nlmsg_flags);
assertEquals(13606, hdr.nlmsg_seq);
assertEquals(4196, hdr.nlmsg_pid);
final StructNlMsgErr err = errorMsg.getNlMsgError();
assertNotNull(err);
assertEquals(0, err.error);
assertNotNull(err.msg);
assertEquals(48, err.msg.nlmsg_len);
assertEquals(NetlinkConstants.RTM_NEWNEIGH, err.msg.nlmsg_type);
assertEquals((NLM_F_REQUEST | NLM_F_ACK | NLM_F_REPLACE), err.msg.nlmsg_flags);
assertEquals(13606, err.msg.nlmsg_seq);
assertEquals(0, err.msg.nlmsg_pid);
}
use of android.net.netlink.NetlinkMessage in project android_frameworks_base by DirtyUnicorns.
the class RtNetlinkNeighborMessageTest method testParseRtmNewNeigh.
public void testParseRtmNewNeigh() {
final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_NEWNEIGH);
// For testing.
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer);
assertNotNull(msg);
assertTrue(msg instanceof RtNetlinkNeighborMessage);
final RtNetlinkNeighborMessage neighMsg = (RtNetlinkNeighborMessage) msg;
final StructNlMsgHdr hdr = neighMsg.getHeader();
assertNotNull(hdr);
assertEquals(88, hdr.nlmsg_len);
assertEquals(NetlinkConstants.RTM_NEWNEIGH, hdr.nlmsg_type);
assertEquals(0, hdr.nlmsg_flags);
assertEquals(0, hdr.nlmsg_seq);
assertEquals(0, hdr.nlmsg_pid);
final StructNdMsg ndmsgHdr = neighMsg.getNdHeader();
assertNotNull(ndmsgHdr);
assertEquals((byte) OsConstants.AF_INET6, ndmsgHdr.ndm_family);
assertEquals(21, ndmsgHdr.ndm_ifindex);
assertEquals(StructNdMsg.NUD_STALE, ndmsgHdr.ndm_state);
final InetAddress destination = neighMsg.getDestination();
assertNotNull(destination);
assertEquals(InetAddress.parseNumericAddress("fe80::86c9:b2ff:fe6a:ed4b"), destination);
}
use of android.net.netlink.NetlinkMessage in project android_frameworks_base by ResurrectionRemix.
the class RtNetlinkNeighborMessageTest method testParseRtmGetNeighResponse.
public void testParseRtmGetNeighResponse() {
final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_GETNEIGH_RESPONSE);
// For testing.
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
int messageCount = 0;
while (byteBuffer.remaining() > 0) {
final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer);
assertNotNull(msg);
assertTrue(msg instanceof RtNetlinkNeighborMessage);
final RtNetlinkNeighborMessage neighMsg = (RtNetlinkNeighborMessage) msg;
final StructNlMsgHdr hdr = neighMsg.getHeader();
assertNotNull(hdr);
assertEquals(NetlinkConstants.RTM_NEWNEIGH, hdr.nlmsg_type);
assertEquals(StructNlMsgHdr.NLM_F_MULTI, hdr.nlmsg_flags);
assertEquals(0, hdr.nlmsg_seq);
assertEquals(11070, hdr.nlmsg_pid);
messageCount++;
}
// TODO: add more detailed spot checks.
assertEquals(14, messageCount);
}
use of android.net.netlink.NetlinkMessage in project android_frameworks_base by ResurrectionRemix.
the class NetlinkErrorMessageTest method testParseNlmErrorOk.
public void testParseNlmErrorOk() {
final ByteBuffer byteBuffer = ByteBuffer.wrap(NLM_ERROR_OK);
// For testing.
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer);
assertNotNull(msg);
assertTrue(msg instanceof NetlinkErrorMessage);
final NetlinkErrorMessage errorMsg = (NetlinkErrorMessage) msg;
final StructNlMsgHdr hdr = errorMsg.getHeader();
assertNotNull(hdr);
assertEquals(36, hdr.nlmsg_len);
assertEquals(NetlinkConstants.NLMSG_ERROR, hdr.nlmsg_type);
assertEquals(0, hdr.nlmsg_flags);
assertEquals(13606, hdr.nlmsg_seq);
assertEquals(4196, hdr.nlmsg_pid);
final StructNlMsgErr err = errorMsg.getNlMsgError();
assertNotNull(err);
assertEquals(0, err.error);
assertNotNull(err.msg);
assertEquals(48, err.msg.nlmsg_len);
assertEquals(NetlinkConstants.RTM_NEWNEIGH, err.msg.nlmsg_type);
assertEquals((NLM_F_REQUEST | NLM_F_ACK | NLM_F_REPLACE), err.msg.nlmsg_flags);
assertEquals(13606, err.msg.nlmsg_seq);
assertEquals(0, err.msg.nlmsg_pid);
}
use of android.net.netlink.NetlinkMessage in project android_frameworks_base by ResurrectionRemix.
the class RtNetlinkNeighborMessageTest method testParseRtmNewNeigh.
public void testParseRtmNewNeigh() {
final ByteBuffer byteBuffer = ByteBuffer.wrap(RTM_NEWNEIGH);
// For testing.
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
final NetlinkMessage msg = NetlinkMessage.parse(byteBuffer);
assertNotNull(msg);
assertTrue(msg instanceof RtNetlinkNeighborMessage);
final RtNetlinkNeighborMessage neighMsg = (RtNetlinkNeighborMessage) msg;
final StructNlMsgHdr hdr = neighMsg.getHeader();
assertNotNull(hdr);
assertEquals(88, hdr.nlmsg_len);
assertEquals(NetlinkConstants.RTM_NEWNEIGH, hdr.nlmsg_type);
assertEquals(0, hdr.nlmsg_flags);
assertEquals(0, hdr.nlmsg_seq);
assertEquals(0, hdr.nlmsg_pid);
final StructNdMsg ndmsgHdr = neighMsg.getNdHeader();
assertNotNull(ndmsgHdr);
assertEquals((byte) OsConstants.AF_INET6, ndmsgHdr.ndm_family);
assertEquals(21, ndmsgHdr.ndm_ifindex);
assertEquals(StructNdMsg.NUD_STALE, ndmsgHdr.ndm_state);
final InetAddress destination = neighMsg.getDestination();
assertNotNull(destination);
assertEquals(InetAddress.parseNumericAddress("fe80::86c9:b2ff:fe6a:ed4b"), destination);
}
Aggregations