use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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);
}
Aggregations