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
8 package org.opendaylight.openflowjava.nx.codec.match;
10 import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.openflowjava.nx.api.NiciraConstants;
14 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
15 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
16 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshNp;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.np.grouping.NshNpValues;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.np.grouping.NshNpValuesBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
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.NshNpCaseValue;
24 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 import org.opendaylight.yangtools.yang.common.Uint32;
27 public class NshNpCodec extends AbstractExperimenterMatchCodec {
29 private static final int VALUE_LENGTH = Byte.BYTES;
30 private static final int NXM_FIELD_CODE = 3;
31 public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNshNp> SERIALIZER_KEY =
33 EncodeConstants.OF13_VERSION_ID,
34 NiciraConstants.NX_NSH_VENDOR_ID,
36 public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
37 createDeserializerKey(
38 EncodeConstants.OF13_VERSION_ID,
39 NiciraConstants.NX_NSH_VENDOR_ID,
43 protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) {
44 NshNpCaseValue nshNpCaseValue = (NshNpCaseValue) value;
45 NshNpValues nshNpValues = nshNpCaseValue.getNshNpValues();
46 outBuffer.writeByte(nshNpValues.getValue().toJava());
50 protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) {
51 return new NshNpCaseValueBuilder()
52 .setNshNpValues(new NshNpValuesBuilder().setValue(readUint8(message)).build())
57 public int getNxmFieldCode() {
58 return NXM_FIELD_CODE;
62 protected Uint32 getExperimenterId() {
63 return NiciraConstants.NX_NSH_VENDOR_ID;
67 public int getValueLength() {
72 public Class<? extends MatchField> getNxmField() {
73 return NxmNxNshNp.class;