Search in sources :

Example 81 with PortNumber

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber 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 82 with PortNumber

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber in project openflowplugin by opendaylight.

the class GetQueueConfigInputMessageFactoryTest method testGetQueueConfigInputMessage.

/**
 * Testing of {@link GetQueueConfigInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testGetQueueConfigInputMessage() throws Exception {
    GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setPort(new PortNumber(0x00010203L));
    GetQueueConfigInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    getQueueFactory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE, 16);
    Assert.assertEquals("Wrong port", 0x00010203, out.readUnsignedInt());
    out.skipBytes(PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE);
}
Also used : GetQueueConfigInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput) GetQueueConfigInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 83 with PortNumber

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber in project openflowplugin by opendaylight.

the class PortConvertor method convert.

@Override
public PortModInput convert(Port source, VersionConvertorData data) {
    PortConfig config = maskPortConfigFields(source.getConfiguration());
    PortConfigV10 configV10 = maskPortConfigV10Fields(source.getConfiguration());
    PortModInputBuilder portModInputBuilder = new PortModInputBuilder();
    portModInputBuilder.setAdvertise(getPortFeatures(source.getAdvertisedFeatures()));
    portModInputBuilder.setPortNo(new PortNumber(OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.get(data.getVersion()), source.getPortNumber())));
    portModInputBuilder.setConfig(config);
    portModInputBuilder.setMask(MoreObjects.firstNonNull(maskPortConfigFields(source.getMask()), new PortConfig(true, true, true, true)));
    portModInputBuilder.setHwAddress(new MacAddress(source.getHardwareAddress()));
    portModInputBuilder.setVersion(data.getVersion());
    portModInputBuilder.setConfigV10(configV10);
    portModInputBuilder.setMaskV10(MoreObjects.firstNonNull(maskPortConfigV10Fields(source.getMask()), new PortConfigV10(true, true, true, true, true, true, true)));
    portModInputBuilder.setAdvertiseV10(getPortFeaturesV10(source.getAdvertisedFeatures()));
    return portModInputBuilder.build();
}
Also used : PortConfigV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10) PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PortConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)

Example 84 with PortNumber

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber in project openflowplugin by opendaylight.

the class SalToOfOutputActionCase method process.

@Nonnull
@Override
public Optional<Action> process(@Nonnull final OutputActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
    final OutputAction outputAction = source.getOutputAction();
    final OutputActionBuilder outputBuilder = new OutputActionBuilder();
    if (outputAction.getMaxLength() != null) {
        outputBuilder.setMaxLength(outputAction.getMaxLength());
    } else {
        outputBuilder.setMaxLength(0);
    }
    final OpenflowVersion version = OpenflowVersion.get(data.getVersion());
    final String nodeConnectorId = outputAction.getOutputNodeConnector().getValue();
    final Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(version, nodeConnectorId);
    if (OpenflowPortsUtil.checkPortValidity(version, portNumber)) {
        outputBuilder.setPort(new PortNumber(portNumber));
    } else {
        LOG.error("Invalid Port specified {} for Output Action for OF version: {}", portNumber, version);
    }
    return Optional.of(new ActionBuilder().setActionChoice(new OutputActionCaseBuilder().setOutputAction(outputBuilder.build()).build()).build());
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) OutputAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) Nonnull(javax.annotation.Nonnull)

Example 85 with PortNumber

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber in project openflowplugin by opendaylight.

the class PacketOutConvertorTest method buildActionForNullTransmitPacketInputAction.

private static List<Action> buildActionForNullTransmitPacketInputAction(final NodeConnectorKey nodeConKey, final short version) {
    PortNumber outPort = getPortNumber(nodeConKey, version);
    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder outputActionCaseBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder();
    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder outputActionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder();
    outputActionBuilder.setPort(outPort);
    outputActionBuilder.setMaxLength(0xffff);
    outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
    ActionBuilder actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(outputActionCaseBuilder.build());
    List<Action> actions = new ArrayList<>();
    actions.add(actionBuilder.build());
    return actions;
}
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) ArrayList(java.util.ArrayList) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)

Aggregations

PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)98 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)81 Test (org.junit.Test)72 ArrayList (java.util.ArrayList)50 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)33 ByteBuf (io.netty.buffer.ByteBuf)29 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)29 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)26 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)23 BigInteger (java.math.BigInteger)21 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder)19 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)18 TransportAddressBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder)17 TcpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder)17 OutputActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder)17 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)16 UdpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder)16 SctpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder)14 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)13 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)12