Search in sources :

Example 1 with MplsBos

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBos in project openflowplugin by opendaylight.

the class MplsBosEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final short mplsBos = (short) 1;
    final Match mplsBosMatch = new MatchBuilder().setProtocolMatchFields(new ProtocolMatchFieldsBuilder().setMplsBos(mplsBos).build()).build();
    // TODO: Why are we using short in models instead of boolean?
    assertMatch(mplsBosMatch, false, (out) -> assertEquals(out.readBoolean(), mplsBos != 0));
}
Also used : ProtocolMatchFieldsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 2 with MplsBos

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBos in project openflowplugin by opendaylight.

the class OfToSalMplsBosCase method process.

@Override
public Optional<MatchBuilder> process(@Nonnull MplsBosCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final MatchBuilder matchBuilder = data.getMatchBuilder();
    final ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = data.getProtocolMatchFieldsBuilder();
    MplsBos mplsBos = source.getMplsBos();
    if (mplsBos != null) {
        protocolMatchFieldsBuilder.setMplsBos(mplsBos.isBos() ? (short) 1 : (short) 0);
        matchBuilder.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
    }
    return Optional.of(matchBuilder);
}
Also used : ProtocolMatchFieldsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder) MplsBos(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBos) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)

Example 3 with MplsBos

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBos 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)

Example 4 with MplsBos

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBos in project openflowplugin by opendaylight.

the class MplsBosEntryDeserializerTest method deserializeEntry.

@Test
public void deserializeEntry() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final short mplsBos = 6;
    writeHeader(in, false);
    in.writeByte(mplsBos);
    ProtocolMatchFields match = deserialize(in).getProtocolMatchFields();
    assertEquals(mplsBos, match.getMplsBos().shortValue());
    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 5 with MplsBos

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBos in project openflowplugin by opendaylight.

the class MatchConvertor method toOfMplsBos.

private static MatchEntry toOfMplsBos(final Short mplsBos) {
    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
    matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
    matchEntryBuilder.setHasMask(false);
    matchEntryBuilder.setOxmMatchField(MplsBos.class);
    MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder();
    MplsBosBuilder mplsBosBuilder = new MplsBosBuilder();
    mplsBosBuilder.setBos(mplsBos != 0);
    mplsBosCaseBuilder.setMplsBos(mplsBosBuilder.build());
    matchEntryBuilder.setMatchEntryValue(mplsBosCaseBuilder.build());
    return matchEntryBuilder.build();
}
Also used : MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) MplsBosCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCaseBuilder) MplsBosBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBosBuilder)

Aggregations

ProtocolMatchFieldsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder)3 Test (org.junit.Test)2 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)1 ProtocolMatchFields (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields)1 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)1 MplsBosCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCaseBuilder)1 MplsBos (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBos)1 MplsBosBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBosBuilder)1