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
8 package org.opendaylight.openflowjava.nx.codec.match;
10 import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
14 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
16 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtMark;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.CtMarkCaseValue;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.CtMarkCaseValueBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.mark.grouping.CtMarkValuesBuilder;
30 * @author Bertrand Low.
32 public class CtMarkCodec extends AbstractMatchCodec {
33 private static final int VALUE_LENGTH = 4;
34 private static final int NXM_FIELD_CODE = 107;
36 public static final MatchEntrySerializerKey<Nxm1Class, NxmNxCtMark> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
37 EncodeConstants.OF_VERSION_1_3, Nxm1Class.VALUE, NxmNxCtMark.VALUE);
38 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
39 EncodeConstants.OF_VERSION_1_3, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
42 public void serialize(final MatchEntry input, final ByteBuf outBuffer) {
43 serializeHeader(input, outBuffer);
44 CtMarkCaseValue ctMarkCase = (CtMarkCaseValue) input.getMatchEntryValue();
45 outBuffer.writeInt(ctMarkCase.getCtMarkValues().getCtMark().intValue());
46 outBuffer.writeInt(ctMarkCase.getCtMarkValues().getMask().intValue());
50 public MatchEntry deserialize(final ByteBuf message) {
51 final MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
52 CtMarkCaseValueBuilder caseBuilder = new CtMarkCaseValueBuilder();
53 CtMarkValuesBuilder ctMarkValuesBuilder = new CtMarkValuesBuilder();
54 if (matchEntryBuilder.getHasMask()) {
55 ctMarkValuesBuilder.setMask(readUint32(message));
57 ctMarkValuesBuilder.setCtMark(readUint32(message));
58 caseBuilder.setCtMarkValues(ctMarkValuesBuilder.build());
59 matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
60 return matchEntryBuilder.build();
64 public int getNxmFieldCode() {
65 return NXM_FIELD_CODE;
69 public int getOxmClassCode() {
70 return OxmMatchConstants.NXM_1_CLASS;
74 public int getValueLength() {
79 public MatchField getNxmField() {
80 return NxmNxCtMark.VALUE;
84 public OxmClassBase getOxmClass() {
85 return Nxm1Class.VALUE;