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 org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
11 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
12 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
13 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
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.nxm.of.in.port.type.grouping.NxmOfInPortValuesBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.OfInPortCaseValue;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.OfInPortCaseValueBuilder;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 import io.netty.buffer.ByteBuf;
28 public class InPortCodec extends AbstractMatchCodec {
30 private static final int VALUE_LENGTH = 2;
31 private static final int NXM_FIELD_CODE = 0;
33 public static final MatchEntrySerializerKey<Nxm0Class, NxmOfInPort> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
34 EncodeConstants.OF13_VERSION_ID, Nxm0Class.class,
37 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
38 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS,
42 public void serialize(MatchEntry input, ByteBuf outBuffer) {
43 serializeHeader(input, outBuffer);
44 OfInPortCaseValue value = (OfInPortCaseValue) input.getMatchEntryValue();
45 outBuffer.writeInt(value.getNxmOfInPortValues().getValue());
49 public MatchEntry deserialize(ByteBuf message) {
50 MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
51 OfInPortCaseValueBuilder caseBuilder = new OfInPortCaseValueBuilder();
52 NxmOfInPortValuesBuilder valuesBuilder = new NxmOfInPortValuesBuilder();
53 valuesBuilder.setValue(message.readInt()).build();
54 caseBuilder.setNxmOfInPortValues(valuesBuilder.build());
55 matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
56 return matchEntryBuilder.build();
60 public int getNxmFieldCode() {
61 return NXM_FIELD_CODE;
65 public int getOxmClassCode() {
66 return OxmMatchConstants.NXM_0_CLASS;
70 public int getValueLength() {
75 public Class<? extends MatchField> getNxmField() {
76 return NxmOfInPort.class;
80 public Class<? extends OxmClassBase> getOxmClass() {
81 return Nxm0Class.class;