Search in sources :

Example 1 with EthernetSource

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

the class EthernetSourceEntryDeserializerTest method deserializeEntry.

@Test
public void deserializeEntry() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final MacAddress ethernetSourceAddress = new MacAddress("00:01:02:03:04:05");
    final MacAddress ethernetSourceAddressMask = new MacAddress("00:00:00:00:00:00");
    writeHeader(in, false);
    in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetSourceAddress));
    assertEquals(ethernetSourceAddress.getValue(), deserialize(in).getEthernetMatch().getEthernetSource().getAddress().getValue());
    assertEquals(0, in.readableBytes());
    writeHeader(in, true);
    in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetSourceAddress));
    in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetSourceAddressMask));
    final EthernetSource desAddress = deserialize(in).getEthernetMatch().getEthernetSource();
    assertEquals(ethernetSourceAddress.getValue(), desAddress.getAddress().getValue());
    assertEquals(ethernetSourceAddressMask.getValue(), desAddress.getMask().getValue());
    assertEquals(0, in.readableBytes());
}
Also used : EthernetSource(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource) 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 2 with EthernetSource

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

the class EthernetSourceEntryDeserializer method deserializeEntry.

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

Example 3 with EthernetSource

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource 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

EthernetSource (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource)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 EthernetDestination (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination)1 EthernetSourceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder)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