use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder in project openflowplugin by opendaylight.
the class Ipv6FlabelEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final Ipv6LabelBuilder ipv6labelBuilder = new Ipv6LabelBuilder().setIpv6Flabel(new Ipv6FlowLabel(message.readUnsignedInt()));
if (hasMask) {
final byte[] mask = OxmDeserializerHelper.convertMask(message, EncodeConstants.SIZE_OF_INT_IN_BYTES);
ipv6labelBuilder.setFlabelMask(new Ipv6FlowLabel(ByteUtil.bytesToUnsignedInt(mask)));
}
if (Objects.isNull(builder.getLayer3Match())) {
builder.setLayer3Match(new Ipv6MatchBuilder().setIpv6Label(ipv6labelBuilder.build()).build());
} else if (Ipv6Match.class.isInstance(builder.getLayer3Match()) && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6Label())) {
final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
builder.setLayer3Match(new Ipv6MatchBuilder(match).setIpv6Label(ipv6labelBuilder.build()).build());
} else {
throwErrorOnMalformed(builder, "layer3Match", "ipv6Label");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder in project openflowplugin by opendaylight.
the class Ipv6NdTargetEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
processHeader(message);
final Ipv6Address address = ByteBufUtils.readIetfIpv6Address(message);
if (Objects.isNull(builder.getLayer3Match())) {
builder.setLayer3Match(new Ipv6MatchBuilder().setIpv6NdTarget(address).build());
} else if (Ipv6Match.class.isInstance(builder.getLayer3Match()) && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6NdTarget())) {
final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
builder.setLayer3Match(new Ipv6MatchBuilder(match).setIpv6NdTarget(address).build());
} else {
throwErrorOnMalformed(builder, "layer3Match", "ipv6NdTarget");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder in project openflowplugin by opendaylight.
the class Ipv6LabelEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final long ipv6flowLabel = 358;
final long ipv6flowLabelMask = 100;
final Match ipv6flowLabelMatch = new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6Label(new Ipv6LabelBuilder().setIpv6Flabel(new Ipv6FlowLabel(ipv6flowLabel)).setFlabelMask(new Ipv6FlowLabel(ipv6flowLabelMask)).build()).build()).build();
assertMatch(ipv6flowLabelMatch, true, (out) -> {
assertEquals(out.readUnsignedInt(), ipv6flowLabel);
byte[] mask = new byte[4];
out.readBytes(mask);
assertArrayEquals(mask, ByteUtil.unsignedIntToBytes(ipv6flowLabelMask));
});
final Match ipv6exyHdrMatchNoMask = new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6Label(new Ipv6LabelBuilder().setIpv6Flabel(new Ipv6FlowLabel(ipv6flowLabel)).build()).build()).build();
assertMatch(ipv6exyHdrMatchNoMask, false, (out) -> assertEquals(out.readUnsignedInt(), ipv6flowLabel));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder in project openflowplugin by opendaylight.
the class MatchNormalizationUtilTest method normalizeIpv6Match.
@Test
public void normalizeIpv6Match() {
final Ipv6Prefix leftPrefix = new Ipv6Prefix("1E3D:5678:9ABC::/24");
final Ipv6Prefix rightPrefix = new Ipv6Prefix("1e3d:5600:0:0:0:0:0:0/24");
final MacAddress leftMac = new MacAddress("01:23:45:AB:CD:EF");
final MacAddress rightMac = new MacAddress("01:23:45:ab:cd:ef");
final Ipv6Address leftAddress = new Ipv6Address("1E3D:5678:9ABC::");
final Ipv6Address rightAddress = new Ipv6Address("1e3d:5678:9abc:0:0:0:0:0");
final MatchBuilder matchBuilder = MatchNormalizationUtil.normalizeIpv6Match(new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6NdSll(leftMac).setIpv6NdTll(leftMac).setIpv6NdTarget(leftAddress).setIpv6Source(leftPrefix).setIpv6Destination(leftPrefix).build()));
assertEquals(rightMac, Ipv6Match.class.cast(matchBuilder.getLayer3Match()).getIpv6NdSll());
assertEquals(rightMac, Ipv6Match.class.cast(matchBuilder.getLayer3Match()).getIpv6NdTll());
assertEquals(rightPrefix, Ipv6Match.class.cast(matchBuilder.getLayer3Match()).getIpv6Source());
assertEquals(rightPrefix, Ipv6Match.class.cast(matchBuilder.getLayer3Match()).getIpv6Destination());
assertEquals(rightAddress, Ipv6Match.class.cast(matchBuilder.getLayer3Match()).getIpv6NdTarget());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder in project openflowplugin by opendaylight.
the class SetNwSrcActionSerializer method buildAction.
@Override
protected SetFieldCase buildAction(Action input) {
final Address address = SetNwSrcActionCase.class.cast(input).getSetNwSrcAction().getAddress();
final SetFieldBuilder builder = new SetFieldBuilder();
if (Ipv4.class.isInstance(address)) {
builder.setLayer3Match(new Ipv4MatchBuilder().setIpv4Source(Ipv4.class.cast(address).getIpv4Address()).build());
} else if (Ipv6.class.isInstance(address)) {
builder.setLayer3Match(new Ipv6MatchBuilder().setIpv6Source(Ipv6.class.cast(address).getIpv6Address()).build());
}
return new SetFieldCaseBuilder().setSetField(builder.build()).build();
}
Aggregations