Search in sources :

Example 1 with ProtocolMatchFields

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields in project openflowplugin by opendaylight.

the class PbbEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    final boolean hasMask = processHeader(message);
    final long pbb = message.readUnsignedMedium();
    final PbbBuilder pbbBuilder = new PbbBuilder().setPbbIsid(pbb);
    if (hasMask) {
        pbbBuilder.setPbbMask((long) message.readUnsignedMedium());
    }
    if (Objects.isNull(builder.getProtocolMatchFields())) {
        builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder().setPbb(pbbBuilder.build()).build());
    } else if (Objects.isNull(builder.getProtocolMatchFields().getPbb())) {
        builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder(builder.getProtocolMatchFields()).setPbb(pbbBuilder.build()).build());
    } else {
        throwErrorOnMalformed(builder, "protocolMatchFields", "pbb");
    }
}
Also used : ProtocolMatchFieldsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder) PbbBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder)

Example 2 with ProtocolMatchFields

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields in project openflowplugin by opendaylight.

the class MplsLabelEntryDeserializerTest method deserializeEntry.

@Test
public void deserializeEntry() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final int mplsLabel = 10;
    writeHeader(in, false);
    in.writeInt(mplsLabel);
    ProtocolMatchFields match = deserialize(in).getProtocolMatchFields();
    assertEquals(mplsLabel, match.getMplsLabel().intValue());
    assertEquals(0, in.readableBytes());
}
Also used : ProtocolMatchFields(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 3 with ProtocolMatchFields

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields in project openflowplugin by opendaylight.

the class PbbEntryDeserializerTest method deserializeEntry.

@Test
public void deserializeEntry() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final long pbb = 6;
    final long pbbMask = 5;
    writeHeader(in, false);
    in.writeMedium((int) pbb);
    ProtocolMatchFields match = deserialize(in).getProtocolMatchFields();
    assertEquals(pbb, match.getPbb().getPbbIsid().longValue());
    assertEquals(0, in.readableBytes());
    writeHeader(in, true);
    in.writeMedium((int) pbb);
    in.writeMedium((int) pbbMask);
    match = deserialize(in).getProtocolMatchFields();
    assertEquals(pbb, match.getPbb().getPbbIsid().longValue());
    assertEquals(pbbMask, match.getPbb().getPbbMask().longValue());
    assertEquals(0, in.readableBytes());
}
Also used : ProtocolMatchFields(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 4 with ProtocolMatchFields

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields in project openflowplugin by opendaylight.

the class MatchConvertor method convert.

@Override
public List<MatchEntry> convert(final Match source, final VersionConvertorData data) {
    List<MatchEntry> result = new ArrayList<>();
    if (source == null) {
        return result;
    }
    final ExtensionConverterProvider extensionConvertorProvider = OFSessionUtil.getExtensionConvertorProvider();
    inPortMatch(result, source.getInPort());
    inPhyPortMatch(result, source.getInPhyPort());
    metadataMatch(result, source.getMetadata());
    ethernetMatch(result, source.getEthernetMatch());
    vlanMatch(result, source.getVlanMatch());
    ipMatch(result, source.getIpMatch());
    layer4Match(result, source.getLayer4Match(), getConvertorExecutor(), extensionConvertorProvider);
    icmpv4Match(result, source.getIcmpv4Match());
    icmpv6Match(result, source.getIcmpv6Match());
    layer3Match(result, source.getLayer3Match(), getConvertorExecutor(), extensionConvertorProvider);
    protocolMatchFields(result, source.getProtocolMatchFields());
    tunnelMatch(result, source.getTunnel());
    tcpFlagsMatch(result, source.getTcpFlagsMatch());
    /*
         * TODO: EXTENSION PROPOSAL (source, MD-SAL to OFJava)
         * - we might need version for conversion and for key
         */
    Optional<GeneralExtensionListGrouping> extensionListOpt = ExtensionResolvers.getMatchExtensionResolver().getExtension(source);
    if (extensionListOpt.isPresent()) {
        List<ExtensionList> extensionListList = extensionListOpt.get().getExtensionList();
        for (ExtensionList extensionItem : extensionListList) {
            // TODO: get real version
            ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionItem.getExtensionKey(), OFConstants.OFP_VERSION_1_3);
            ConvertorToOFJava<MatchEntry> convertor = extensionConvertorProvider.getConverter(key);
            if (convertor == null) {
                throw new IllegalStateException("No converter found for key: " + key.toString());
            }
            MatchEntry ofMatch = convertor.convert(extensionItem.getExtension());
            result.add(ofMatch);
        }
    }
    return result;
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) ExtensionConverterProvider(org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider) ExtensionList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList) ArrayList(java.util.ArrayList) GeneralExtensionListGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionListGrouping) ConverterExtensionKey(org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey)

Example 5 with ProtocolMatchFields

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields in project openflowplugin by opendaylight.

the class MplsBosEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    processHeader(message);
    final short mplsBos = message.readUnsignedByte();
    if (Objects.isNull(builder.getProtocolMatchFields())) {
        builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder().setMplsBos(mplsBos).build());
    } else if (Objects.isNull(builder.getProtocolMatchFields().getMplsBos())) {
        builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder(builder.getProtocolMatchFields()).setMplsBos(mplsBos).build());
    } else {
        throwErrorOnMalformed(builder, "protocolMatchFields", "mplsBos");
    }
}
Also used : ProtocolMatchFieldsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)4 ProtocolMatchFields (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields)4 ProtocolMatchFieldsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder)4 ArrayList (java.util.ArrayList)1 ConverterExtensionKey (org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey)1 ExtensionConverterProvider (org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider)1 PbbBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder)1 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)1 GeneralExtensionListGrouping (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionListGrouping)1 ExtensionList (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList)1