Search in sources :

Example 1 with EthernetDestination

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

the class EthernetDestinationEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    final boolean hasMask = processHeader(message);
    final EthernetMatch ethernetMatch = builder.getEthernetMatch();
    final EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
    ethernetDestinationBuilder.setAddress(OxmDeserializerHelper.convertMacAddress(message));
    if (hasMask) {
        ethernetDestinationBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
    }
    if (Objects.isNull(ethernetMatch)) {
        builder.setEthernetMatch(new EthernetMatchBuilder().setEthernetDestination(ethernetDestinationBuilder.build()).build());
    } else if (Objects.isNull(ethernetMatch.getEthernetDestination())) {
        builder.setEthernetMatch(new EthernetMatchBuilder(ethernetMatch).setEthernetDestination(ethernetDestinationBuilder.build()).build());
    } else {
        throwErrorOnMalformed(builder, "ethernetMatch", "ethernetDestination");
    }
}
Also used : EthernetDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 2 with EthernetDestination

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

the class EthernetDestinationEntryDeserializerTest method deserializeEntry.

@Test
public void deserializeEntry() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final MacAddress ethernetDestinationAddress = new MacAddress("00:01:02:03:04:05");
    final MacAddress ethernetDestinationAddressMask = new MacAddress("00:00:00:00:00:00");
    writeHeader(in, false);
    in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetDestinationAddress));
    assertEquals(ethernetDestinationAddress.getValue(), deserialize(in).getEthernetMatch().getEthernetDestination().getAddress().getValue());
    assertEquals(0, in.readableBytes());
    writeHeader(in, true);
    in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetDestinationAddress));
    in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetDestinationAddressMask));
    final EthernetDestination desAddress = deserialize(in).getEthernetMatch().getEthernetDestination();
    assertEquals(ethernetDestinationAddress.getValue(), desAddress.getAddress().getValue());
    assertEquals(ethernetDestinationAddressMask.getValue(), desAddress.getMask().getValue());
    assertEquals(0, in.readableBytes());
}
Also used : EthernetDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Test(org.junit.Test)

Example 3 with EthernetDestination

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

the class MatchConvertor method ethernetMatch.

private static void ethernetMatch(final List<MatchEntry> matchEntryList, final EthernetMatch ethernetMatch) {
    if (ethernetMatch == null) {
        return;
    }
    EthernetDestination ethernetDestination = ethernetMatch.getEthernetDestination();
    if (ethernetDestination != null) {
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(EthDst.class);
        EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
        EthDstBuilder ethDstBuilder = new EthDstBuilder();
        ethDstBuilder.setMacAddress(ethernetDestination.getAddress());
        boolean hasMask = ethernetDestination.getMask() != null;
        if (hasMask) {
            ethDstBuilder.setMask(ByteBufUtils.macAddressToBytes(ethernetDestination.getMask().getValue()));
        }
        ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
        matchEntryBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
        matchEntryBuilder.setHasMask(hasMask);
        matchEntryList.add(matchEntryBuilder.build());
    }
    EthernetSource ethernetSource = ethernetMatch.getEthernetSource();
    if (ethernetSource != null) {
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(EthSrc.class);
        EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
        EthSrcBuilder ethDstBuilder = new EthSrcBuilder();
        ethDstBuilder.setMacAddress(ethernetSource.getAddress());
        boolean hasMask = ethernetSource.getMask() != null;
        if (hasMask) {
            ethDstBuilder.setMask(ByteBufUtils.macAddressToBytes(ethernetSource.getMask().getValue()));
        }
        ethSrcCaseBuilder.setEthSrc(ethDstBuilder.build());
        matchEntryBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
        matchEntryBuilder.setHasMask(hasMask);
        matchEntryList.add(matchEntryBuilder.build());
    }
    if (ethernetMatch.getEthernetType() != null) {
        matchEntryList.add(toOfEthernetType(ethernetMatch.getEthernetType()));
    }
}
Also used : EthernetDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination) EthDstBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder) EthSrcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) EthernetSource(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource) EthDstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder) EthSrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder)

Aggregations

EthernetDestination (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 EthernetDestinationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder)1 EthernetSource (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource)1 EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)1 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)1 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)1 EthDstCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder)1 EthSrcCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder)1 EthDstBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder)1 EthSrcBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder)1