2 * Copyright (c) 2015 Intel, Inc. 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.nx.api.NiciraConstants;
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.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshNp;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.np.grouping.NshNpValues;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.np.grouping.NshNpValuesBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValue;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshNpCaseValueBuilder;
25 public class NshNpCodec extends AbstractExperimenterMatchCodec {
27 private static final int VALUE_LENGTH = EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
28 private static final int NXM_FIELD_CODE = 3;
29 public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNshNp> SERIALIZER_KEY =
31 EncodeConstants.OF13_VERSION_ID,
32 NiciraConstants.NX_NSH_VENDOR_ID,
34 public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
35 createDeserializerKey(
36 EncodeConstants.OF13_VERSION_ID,
37 NiciraConstants.NX_NSH_VENDOR_ID,
41 protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) {
42 NshNpCaseValue nshNpCaseValue = (NshNpCaseValue) value;
43 NshNpValues nshNpValues = nshNpCaseValue.getNshNpValues();
44 outBuffer.writeByte(nshNpValues.getValue());
48 protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) {
49 Short value = message.readUnsignedByte();
50 NshNpValues nshNpValues = new NshNpValuesBuilder().setValue(value).build();
51 return new NshNpCaseValueBuilder().setNshNpValues(nshNpValues).build();
55 public int getNxmFieldCode() {
56 return NXM_FIELD_CODE;
60 protected long getExperimenterId() {
61 return NiciraConstants.NX_NSH_VENDOR_ID;
65 public int getValueLength() {
70 public Class<? extends MatchField> getNxmField() {
71 return NxmNxNshNp.class;