2 * Copyright (c) 2014 Red Hat, 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.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.NxmNxNsi;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsi.grouping.NsiValuesBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NsiCaseValue;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.NsiCaseValueBuilder;
26 public class NsiCodec extends AbstractMatchCodec {
28 private static final int VALUE_LENGTH = 1;
29 private static final int NXM_FIELD_CODE = 114;
30 public static final MatchEntrySerializerKey<Nxm1Class, NxmNxNsi> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
31 EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxNsi.class);
32 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
33 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
36 public void serialize(MatchEntry input, ByteBuf outBuffer) {
37 serializeHeader(input, outBuffer);
38 NsiCaseValue nsiCaseValue = ((NsiCaseValue) input.getMatchEntryValue());
39 outBuffer.writeByte(nsiCaseValue.getNsiValues().getNsi());
43 public MatchEntry deserialize(ByteBuf message) {
44 MatchEntryBuilder matchEntriesBuilder = deserializeHeader(message);
45 NsiCaseValueBuilder nsiCaseValueBuilder = new NsiCaseValueBuilder();
46 nsiCaseValueBuilder.setNsiValues(new NsiValuesBuilder().setNsi(message.readUnsignedByte()).build());
47 matchEntriesBuilder.setMatchEntryValue(nsiCaseValueBuilder.build());
48 matchEntriesBuilder.setHasMask(false);
49 return matchEntriesBuilder.build();
53 public int getNxmFieldCode() {
54 return NXM_FIELD_CODE;
58 public int getOxmClassCode() {
59 return OxmMatchConstants.NXM_1_CLASS;
63 public int getValueLength() {
68 public Class<? extends MatchField> getNxmField() {
69 return NxmNxNsi.class;
73 public Class<? extends OxmClassBase> getOxmClass() {
74 return Nxm1Class.class;