2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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 io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
12 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
14 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfInPort;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.OfInPortCaseValue;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.OfInPortCaseValueBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.in.port.type.grouping.NxmOfInPortValuesBuilder;
23 import org.opendaylight.yangtools.yang.common.Uint16;
25 public class InPortCodec extends AbstractMatchCodec {
27 private static final int VALUE_LENGTH = 2;
28 private static final int NXM_FIELD_CODE = 0;
30 public static final MatchEntrySerializerKey<Nxm0Class, NxmOfInPort> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
31 EncodeConstants.OF_VERSION_1_3, Nxm0Class.VALUE, NxmOfInPort.VALUE);
33 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
34 EncodeConstants.OF_VERSION_1_3, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
37 public void serialize(final MatchEntry input, final ByteBuf outBuffer) {
38 serializeHeader(input, outBuffer);
39 OfInPortCaseValue value = (OfInPortCaseValue) input.getMatchEntryValue();
40 outBuffer.writeInt(value.getNxmOfInPortValues().getValue().toJava());
44 public MatchEntry deserialize(final ByteBuf message) {
45 return deserializeHeaderToBuilder(message)
46 .setMatchEntryValue(new OfInPortCaseValueBuilder()
47 .setNxmOfInPortValues(new NxmOfInPortValuesBuilder()
48 .setValue(Uint16.valueOf(message.readInt()))
55 public int getNxmFieldCode() {
56 return NXM_FIELD_CODE;
60 public int getOxmClassCode() {
61 return OxmMatchConstants.NXM_0_CLASS;
65 public int getValueLength() {
70 public MatchField getNxmField() {
71 return NxmOfInPort.VALUE;
75 public OxmClassBase getOxmClass() {
76 return Nxm0Class.VALUE;