Search in sources :

Example 6 with EchoRequestMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage in project openflowplugin by opendaylight.

the class EchoRequestMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
    builder.setData(data);
    EchoRequestMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24);
    byte[] readData = new byte[serializedBuffer.readableBytes()];
    serializedBuffer.readBytes(readData);
    Assert.assertArrayEquals("Wrong data", message.getData(), readData);
}
Also used : EchoRequestMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage) EchoRequestMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 7 with EchoRequestMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage in project openflowplugin by opendaylight.

the class OpenflowProtocolListenerInitialImpl method onEchoRequestMessage.

@Override
public void onEchoRequestMessage(final EchoRequestMessage echoRequestMessage) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("echo request received: {}", echoRequestMessage.getXid());
    }
    EchoReplyInputBuilder builder = new EchoReplyInputBuilder();
    builder.setVersion(echoRequestMessage.getVersion());
    builder.setXid(echoRequestMessage.getXid());
    builder.setData(echoRequestMessage.getData());
    connectionContext.getConnectionAdapter().echoReply(builder.build());
}
Also used : EchoReplyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder)

Example 8 with EchoRequestMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage in project openflowplugin by opendaylight.

the class EchoRequestMessageFactoryTest method testWithDataFieldSet.

/**
 * Testing {@link EchoRequestMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithDataFieldSet() {
    byte[] data = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
    ByteBuf bb = BufferHelper.buildBuffer(data);
    EchoRequestMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
}
Also used : EchoRequestMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage) ByteBuf(io.netty.buffer.ByteBuf) DefaultDeserializerFactoryTest(org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest) Test(org.junit.Test)

Example 9 with EchoRequestMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage in project openflowplugin by opendaylight.

the class EchoRequestMessageFactoryTest method testWithEmptyDataField.

/**
 * Testing {@link EchoRequestMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithEmptyDataField() {
    byte[] data = new byte[] {};
    ByteBuf bb = BufferHelper.buildBuffer();
    EchoRequestMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
}
Also used : EchoRequestMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage) ByteBuf(io.netty.buffer.ByteBuf) DefaultDeserializerFactoryTest(org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest) Test(org.junit.Test)

Example 10 with EchoRequestMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage in project openflowplugin by opendaylight.

the class MockPlugin method onEchoRequestMessage.

@Override
public void onEchoRequestMessage(final EchoRequestMessage notification) {
    LOGGER.debug("MockPlugin.onEchoRequestMessage() adapter: {}", adapter);
    new Thread(() -> {
        LOGGER.debug("MockPlugin.onEchoRequestMessage().run() started adapter: {}", adapter);
        EchoReplyInputBuilder replyBuilder = new EchoReplyInputBuilder();
        replyBuilder.setVersion((short) 4);
        replyBuilder.setXid(notification.getXid());
        EchoReplyInput echoReplyInput = replyBuilder.build();
        adapter.echoReply(echoReplyInput);
        LOGGER.debug("adapter.EchoReply(Input) sent : ", echoReplyInput.toString());
        LOGGER.debug("MockPlugin.onEchoRequestMessage().run() finished adapter: {}", adapter);
    }).start();
}
Also used : EchoReplyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder) EchoReplyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput)

Aggregations

Test (org.junit.Test)5 EchoReplyInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder)4 EchoRequestMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage)4 EchoRequestMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder)4 ByteBuf (io.netty.buffer.ByteBuf)3 EchoReplyInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput)3 DefaultDeserializerFactoryTest (org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest)2 ErrorMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder)1 ExperimenterMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder)1 FlowRemovedMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder)1 HelloMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder)1 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)1 PacketInMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder)1 PortStatusMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder)1 DisconnectEventBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder)1 SwitchIdleEventBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder)1 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)1