2 * Copyright (c) 2015 Cisco Systems, 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;
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.NxmNxNshc2;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._2.grouping.Nshc2ValuesBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValue;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValueBuilder;
27 public class Nshc2Codec extends AbstractMatchCodec {
29 private static final int VALUE_LENGTH = 4;
30 private static final int NXM_FIELD_CODE = 116;
31 public static final MatchEntrySerializerKey<Nxm1Class, NxmNxNshc2> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
32 EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNshc2.class);
33 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
34 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
37 public void serialize(MatchEntry input, ByteBuf outBuffer) {
38 serializeHeader(input, outBuffer);
39 Nshc2CaseValue csc1CaseValue = ((Nshc2CaseValue) input.getMatchEntryValue());
40 outBuffer.writeInt(csc1CaseValue.getNshc2Values().getNshc().intValue());
44 public MatchEntry deserialize(ByteBuf message) {
45 MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
46 Nshc2CaseValueBuilder nsc2CaseValueBuilder = new Nshc2CaseValueBuilder();
47 nsc2CaseValueBuilder.setNshc2Values(new Nshc2ValuesBuilder().setNshc(message.readUnsignedInt()).build());
48 matchEntryBuilder.setMatchEntryValue(nsc2CaseValueBuilder.build());
50 return matchEntryBuilder.build();
54 public int getNxmFieldCode() {
55 return NXM_FIELD_CODE;
59 public int getOxmClassCode() {
60 return OxmMatchConstants.NXM_1_CLASS;
64 public int getValueLength() {
69 public Class<? extends MatchField> getNxmField() {
70 return NxmNxNshc2.class;
74 public Class<? extends OxmClassBase> getOxmClass() {
75 return Nxm1Class.class;