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
8 package org.opendaylight.openflowplugin.impl.protocol.serialization.match;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
12 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
13 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6Label;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
18 public class Ipv6LabelEntrySerializer extends AbstractMatchEntrySerializer {
21 public void serialize(Match match, ByteBuf outBuffer) {
22 super.serialize(match, outBuffer);
23 final Ipv6Label ipv6Label = ((Ipv6Match) match.getLayer3Match()).getIpv6Label();
24 outBuffer.writeInt(ipv6Label.getIpv6Flabel().getValue().intValue());
26 if (getHasMask(match)) {
27 writeMask(ByteUtil.unsignedIntToBytes(
28 ipv6Label.getFlabelMask().getValue()),
35 public boolean matchTypeCheck(Match match) {
36 return match.getLayer3Match() != null
37 && match.getLayer3Match() instanceof Ipv6Match
38 && ((Ipv6Match) match.getLayer3Match()).getIpv6Label() != null;
42 protected boolean getHasMask(Match match) {
43 return ((Ipv6Match) match.getLayer3Match()).getIpv6Label().getFlabelMask() != null;
47 protected int getOxmFieldCode() {
48 return OxmMatchConstants.IPV6_FLABEL;
52 protected int getOxmClassCode() {
53 return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
57 protected int getValueLength() {
58 return EncodeConstants.SIZE_OF_INT_IN_BYTES;