2 * Copyright (c) 2017 NEC Corporation 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.openflowjava.nx.codec.match;
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
13 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
15 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtMark;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.mark.grouping.CtMarkValuesBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtMarkCaseValue;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtMarkCaseValueBuilder;
29 * @author Bertrand Low.
31 public class CtMarkCodec extends AbstractMatchCodec {
33 private static final int VALUE_LENGTH = 8;
34 private static final int NXM_FIELD_CODE = 107;
35 public static final MatchEntrySerializerKey<Nxm1Class, NxmNxCtMark> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
36 EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxCtMark.class);
37 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
38 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
41 public void serialize(MatchEntry input, ByteBuf outBuffer) {
42 serializeHeader(input, outBuffer);
43 CtMarkCaseValue ctMarkCase = (CtMarkCaseValue) input.getMatchEntryValue();
44 outBuffer.writeInt(ctMarkCase.getCtMarkValues().getCtMark().intValue());
45 outBuffer.writeInt(ctMarkCase.getCtMarkValues().getMask().intValue());
49 public MatchEntry deserialize(ByteBuf message) {
50 final MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
51 CtMarkCaseValueBuilder caseBuilder = new CtMarkCaseValueBuilder();
52 CtMarkValuesBuilder ctMarkValuesBuilder = new CtMarkValuesBuilder();
53 if (matchEntryBuilder.isHasMask()) {
54 ctMarkValuesBuilder.setMask(message.readUnsignedInt());
56 ctMarkValuesBuilder.setCtMark(message.readUnsignedInt());
57 caseBuilder.setCtMarkValues(ctMarkValuesBuilder.build());
58 matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
59 return matchEntryBuilder.build();
63 public int getNxmFieldCode() {
64 return NXM_FIELD_CODE;
68 public int getOxmClassCode() {
69 return OxmMatchConstants.NXM_1_CLASS;
73 public int getValueLength() {
78 public Class<? extends MatchField> getNxmField() {
79 return NxmNxCtMark.class;
83 public Class<? extends OxmClassBase> getOxmClass() {
84 return Nxm1Class.class;