2 * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
11 import io.netty.buffer.ByteBuf;
12 import java.util.Objects;
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
14 import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
15 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
22 public class Ipv6FlabelEntryDeserializer extends AbstractMatchEntryDeserializer {
25 public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
26 final boolean hasMask = processHeader(message);
27 final Ipv6LabelBuilder ipv6labelBuilder = new Ipv6LabelBuilder()
28 .setIpv6Flabel(new Ipv6FlowLabel(message.readUnsignedInt()));
31 final byte[] mask = OxmDeserializerHelper.convertMask(message, EncodeConstants.SIZE_OF_INT_IN_BYTES);
32 ipv6labelBuilder.setFlabelMask(new Ipv6FlowLabel(ByteUtil.bytesToUnsignedInt(mask)));
35 if (Objects.isNull(builder.getLayer3Match())) {
36 builder.setLayer3Match(new Ipv6MatchBuilder()
37 .setIpv6Label(ipv6labelBuilder.build())
39 } else if (builder.getLayer3Match() instanceof Ipv6Match
40 && Objects.isNull(((Ipv6Match) builder.getLayer3Match()).getIpv6Label())) {
41 final Ipv6Match match = (Ipv6Match) builder.getLayer3Match();
42 builder.setLayer3Match(new Ipv6MatchBuilder(match)
43 .setIpv6Label(ipv6labelBuilder.build())
46 throwErrorOnMalformed(builder, "layer3Match", "ipv6Label");