Search in sources :

Example 6 with PacketOutInput

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

the class PacketOutInputMessageFactoryTest method test.

@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 01 00 00 00 01 00 00 28 00 00 00 00 00 00 00 11 00 08 00 19 00 00 00 12 00 08 00 00 00 00 00 12 " + "00 08 00 00 00 00 00 12 00 08 00 00 00 00 00 12 00 08 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 10 " + "11 12 13 14");
    PacketOutInput deserializedMessage = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(deserializedMessage);
    Assert.assertEquals("Wrong buffer Id", 256L, deserializedMessage.getBufferId().longValue());
    Assert.assertEquals("Wrong In Port", new PortNumber(256L), deserializedMessage.getInPort());
    Assert.assertEquals("Wrong Numbers of actions", createAction(), deserializedMessage.getAction());
    byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
    Assert.assertArrayEquals("Wrong data", data, deserializedMessage.getData());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) PacketOutInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput) Test(org.junit.Test)

Example 7 with PacketOutInput

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

the class PacketOutConvertorTest method toPacketOutInputAllParmTest.

/**
 * Test for PacketOutConvertor.
 */
@Test
public void toPacketOutInputAllParmTest() {
    org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder ab = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    OutputActionBuilder output = new OutputActionBuilder();
    output.setMaxLength(OFConstants.OFPCML_NO_BUFFER);
    Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
    output.setOutputNodeConnector(value);
    ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
    ab.setOrder(0);
    ab.setKey(new ActionKey(0));
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList = new ArrayList<>();
    actionList.add(ab.build());
    Long bufferId = 0xfL;
    Long valueForCookie = 0xeL;
    ConnectionCookie connCook = new ConnectionCookie(valueForCookie);
    String nodeId = "node:1";
    NodeRef ref = createNodeRef(nodeId);
    String portO = "0xfffffffd";
    NodeConnectorKey egrConKey = PacketOutConvertorTest.createNodeConnKey(nodeId, portO);
    NodeConnectorRef egressConfRef = new NodeConnectorRef(createNodeConnRef(nodeId, egrConKey));
    String inPort = "2";
    NodeConnectorKey ingrConKey = PacketOutConvertorTest.createNodeConnKey(nodeId, inPort);
    NodeConnectorRef ingressConRef = new NodeConnectorRef(createNodeConnRef(nodeId, ingrConKey));
    String string = new String("sendOutputMsg_TEST");
    byte[] msg = string.getBytes();
    byte[] payload = msg;
    TransmitPacketInputBuilder transmitPacketInputBuilder = new TransmitPacketInputBuilder();
    transmitPacketInputBuilder.setAction(actionList);
    transmitPacketInputBuilder.setBufferId(bufferId);
    transmitPacketInputBuilder.setConnectionCookie(connCook);
    transmitPacketInputBuilder.setEgress(egressConfRef);
    transmitPacketInputBuilder.setIngress(ingressConRef);
    transmitPacketInputBuilder.setNode(ref);
    transmitPacketInputBuilder.setPayload(payload);
    final TransmitPacketInput transmitPacketInput = transmitPacketInputBuilder.build();
    Short version = (short) 0x04;
    byte[] datapathIdByte = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    for (int i = 0; i < datapathIdByte.length; i++) {
        datapathIdByte[i] = 1;
    }
    BigInteger datapathId = new BigInteger(1, datapathIdByte);
    Long xid = 0xfffffL;
    PacketOutConvertorData data = new PacketOutConvertorData(version);
    data.setXid(xid);
    data.setDatapathId(datapathId);
    PacketOutInput message = convert(transmitPacketInput, data);
    Assert.assertEquals(transmitPacketInput.getBufferId(), message.getBufferId());
    Assert.assertEquals(Long.valueOf(inPort), message.getInPort().getValue());
    Assert.assertEquals(version, message.getVersion());
    Assert.assertEquals(xid, message.getXid());
    ActionConvertorData actionConvertorData = new ActionConvertorData(version);
    actionConvertorData.setDatapathId(datapathId);
    Optional<List<Action>> actionsOptional = convertorManager.convert(actionList, actionConvertorData);
    List<Action> actions = actionsOptional.orElse(Collections.emptyList());
    Assert.assertEquals(actions, message.getAction());
    Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData());
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) ArrayList(java.util.ArrayList) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) PacketOutConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) ArrayList(java.util.ArrayList) List(java.util.List) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) ActionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData) ActionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) BigInteger(java.math.BigInteger) ConnectionCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.ConnectionCookie) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) PacketOutInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput) Test(org.junit.Test)

Example 8 with PacketOutInput

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

the class PacketOutConvertorTest method toPacketOutInputAllParmNullTest.

/**
 * Test for {@link PacketOutConvertor} with null parameters.
 */
@Test
public void toPacketOutInputAllParmNullTest() {
    TransmitPacketInputBuilder transmitPacketInputBuilder = new TransmitPacketInputBuilder();
    Long bufferId = null;
    String nodeId = "0";
    String port = "0";
    NodeRef ref = createNodeRef(nodeId);
    NodeConnectorKey nodeConnKey = PacketOutConvertorTest.createNodeConnKey(nodeId, port);
    NodeConnectorRef egressConfRef = new NodeConnectorRef(createNodeConnRef(nodeId, nodeConnKey));
    transmitPacketInputBuilder.setBufferId(bufferId);
    transmitPacketInputBuilder.setConnectionCookie(null);
    transmitPacketInputBuilder.setAction(null);
    transmitPacketInputBuilder.setNode(ref);
    transmitPacketInputBuilder.setPayload(null);
    transmitPacketInputBuilder.setEgress(egressConfRef);
    transmitPacketInputBuilder.setIngress(null);
    TransmitPacketInput transmitPacketInput = transmitPacketInputBuilder.build();
    Short version = (short) 0x04;
    Long xid = null;
    PacketOutConvertorData data = new PacketOutConvertorData(version);
    PacketOutInput message = convert(transmitPacketInput, data);
    // FIXME : this has to be fixed along with actions changed in openflowjava
    Assert.assertEquals(buildActionForNullTransmitPacketInputAction(nodeConnKey, version), message.getAction());
    Assert.assertEquals(OFConstants.OFP_NO_BUFFER, message.getBufferId());
    Assert.assertEquals(new PortNumber(0xfffffffdL), message.getInPort());
    Assert.assertEquals(version, message.getVersion());
    Assert.assertEquals(xid, message.getXid());
    Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData());
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) PacketOutConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) PacketOutInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput) Test(org.junit.Test)

Example 9 with PacketOutInput

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

the class OF10PacketOutInputMessageFactory method deserialize.

@Override
public PacketOutInput deserialize(ByteBuf rawMessage) {
    PacketOutInputBuilder builder = new PacketOutInputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setBufferId(rawMessage.readUnsignedInt());
    builder.setInPort(new PortNumber((long) rawMessage.readUnsignedShort()));
    final int actions_len = rawMessage.readShort();
    CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);
    List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, actions_len, rawMessage, keyMaker, registry);
    builder.setAction(actions);
    byte[] data = new byte[rawMessage.readableBytes()];
    rawMessage.readBytes(data);
    builder.setData(data);
    return builder.build();
}
Also used : PacketOutInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) CodeKeyMaker(org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)

Example 10 with PacketOutInput

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

the class OF10PacketOutInputMessageFactoryTest method test.

@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 01 00 01 01 00 10 00 00 00 08 " + "00 2a 00 32 00 03 00 08 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
    PacketOutInput deserializedMessage = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV10(deserializedMessage);
    Assert.assertEquals("Wrong bufferId ", 256L, deserializedMessage.getBufferId().longValue());
    Assert.assertEquals("Wrong inPort ", new PortNumber(257L), deserializedMessage.getInPort());
    Assert.assertEquals("Wrong action ", createActionList().get(0), deserializedMessage.getAction().get(0));
    Assert.assertEquals("Wrong action ", createActionList().get(1), deserializedMessage.getAction().get(1));
    Assert.assertArrayEquals("Wrong data ", ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"), deserializedMessage.getData());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) PacketOutInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput) Test(org.junit.Test)

Aggregations

PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)10 PacketOutInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput)10 Test (org.junit.Test)9 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)8 PacketOutInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder)7 ByteBuf (io.netty.buffer.ByteBuf)6 ArrayList (java.util.ArrayList)6 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)4 PacketOutConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData)3 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)3 TransmitPacketInput (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput)3 List (java.util.List)2 CodeKeyMaker (org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker)2 ActionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)2 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)2 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)2 OutputActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder)2 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder)2 TransmitPacketInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder)2 BigInteger (java.math.BigInteger)1