use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInMessage in project openflowplugin by opendaylight.
the class OF10PacketInMessageFactory method deserialize.
@Override
public PacketInMessage deserialize(final ByteBuf rawMessage) {
PacketInMessageBuilder builder = new PacketInMessageBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setBufferId(rawMessage.readUnsignedInt());
builder.setTotalLen(rawMessage.readUnsignedShort());
builder.setInPort(rawMessage.readUnsignedShort());
builder.setReason(PacketInReason.forValue(rawMessage.readUnsignedByte()));
rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER);
int remainingBytes = rawMessage.readableBytes();
if (remainingBytes > 0) {
final byte[] buf = new byte[remainingBytes];
rawMessage.readBytes(buf);
builder.setData(buf);
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInMessage in project openflowplugin by opendaylight.
the class PacketInMessageFactoryTest method test.
/**
* Testing {@link PacketInMessageFactory} for correct translation into POJO.
*/
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 04 00 01 02 03 04 05 06 07 00 01 00 0C" + " 80 00 02 04 00 00 00 01 00 00 00 00 00 00 01 02 03 04");
PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());
Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue());
Assert.assertEquals("Wrong reason", PacketInReason.OFPRACTION, builtByFactory.getReason());
Assert.assertEquals("Wrong tableID", new TableId(4L), builtByFactory.getTableId());
Assert.assertEquals("Wrong cookie", 0x0001020304050607L, builtByFactory.getCookie().longValue());
Assert.assertArrayEquals("Wrong data", ByteBufUtils.hexStringToBytes("01 02 03 04"), builtByFactory.getData());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInMessage in project openflowplugin by opendaylight.
the class DeviceContextImplTest method testProcessPacketInMessageFutureSuccess.
@Test
public void testProcessPacketInMessageFutureSuccess() {
final PacketInMessage mockedPacketInMessage = mock(PacketInMessage.class);
final NotificationPublishService mockedNotificationPublishService = mock(NotificationPublishService.class);
final ListenableFuture stringListenableFuture = Futures.immediateFuture("dummy value");
when(mockedNotificationPublishService.offerNotification(any(PacketReceived.class))).thenReturn(stringListenableFuture);
deviceContext.setNotificationPublishService(mockedNotificationPublishService);
deviceContext.processPacketInMessage(mockedPacketInMessage);
verify(messageSpy).spyMessage(any(Class.class), eq(MessageSpy.StatisticsGroup.FROM_SWITCH));
verify(messageSpy).spyMessage(any(Class.class), eq(MessageSpy.StatisticsGroup.FROM_SWITCH_PUBLISHED_SUCCESS));
}
Aggregations