Search in sources :

Example 1 with Ipv6Flabel

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6Flabel in project openflowplugin by opendaylight.

the class OF13MatchSerializerTest method testIpv6Flabel.

/**
 * Test for correct serialization of Ipv4Address match entry.
 */
@Test
public void testIpv6Flabel() {
    Match match = buildIpv6FLabelMatch(0x0f9e8dL, false, null);
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    matchSerializer.serialize(match, out);
    Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
    out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
    Assert.assertEquals("Wrong field and mask", 56, out.readUnsignedByte());
    out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
    byte[] label = new byte[4];
    out.readBytes(label);
    LOG.debug("label: {}", ByteBufUtils.bytesToHexString(label));
    Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[] { 0, 0x0f, (byte) 0x9e, (byte) 0x8d }, label);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match) Test(org.junit.Test)

Example 2 with Ipv6Flabel

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6Flabel in project openflowplugin by opendaylight.

the class OF13MatchSerializerTest method testIpv6FlabelWithMask.

/**
 * Test for correct serialization of Ipv4Address match entry.
 */
@Test
public void testIpv6FlabelWithMask() {
    Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[] { 0, 1, 2, 3 });
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    matchSerializer.serialize(match, out);
    Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
    out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
    Assert.assertEquals("Wrong field and mask", 57, out.readUnsignedByte());
    out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
    byte[] label = new byte[4];
    out.readBytes(label);
    Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[] { 0, 0x0f, (byte) 0x9e, (byte) 0x8d }, label);
    byte[] mask = new byte[4];
    out.readBytes(mask);
    Assert.assertArrayEquals("Wrong ipv6FLabel mask", new byte[] { 0, 1, 2, 3 }, mask);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match) Test(org.junit.Test)

Example 3 with Ipv6Flabel

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6Flabel in project openflowplugin by opendaylight.

the class OfToSalIpv6FlabelCase method process.

@Override
public Optional<MatchBuilder> process(@Nonnull Ipv6FlabelCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final MatchBuilder matchBuilder = data.getMatchBuilder();
    final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
    Ipv6Flabel ipv6Flabel = source.getIpv6Flabel();
    if (ipv6Flabel != null) {
        Ipv6LabelBuilder ipv6LabelBuilder = new Ipv6LabelBuilder();
        ipv6LabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(ipv6Flabel.getIpv6Flabel()));
        byte[] mask = ipv6Flabel.getMask();
        if (mask != null) {
            ipv6LabelBuilder.setFlabelMask(new Ipv6FlowLabel(ByteUtil.bytesToUnsignedInt(mask)));
        }
        ipv6MatchBuilder.setIpv6Label(ipv6LabelBuilder.build());
        matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
    }
    return Optional.of(matchBuilder);
}
Also used : Ipv6Flabel(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6Flabel) Ipv6LabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder) Ipv6FlowLabel(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match)2 Ipv6FlowLabel (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel)1 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)1 Ipv6LabelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder)1 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)1 Ipv6Flabel (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6Flabel)1