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
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.NxmNxTunGpeNp;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.tun.gpe.np.grouping.TunGpeNpValuesBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TunGpeNpCaseValue;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TunGpeNpCaseValueBuilder;
26 public class TunGpeNpCodec extends AbstractMatchCodec {
28 private static final int VALUE_LENGTH = 1;
29 private static final int NXM_FIELD_CODE = 111;
30 public static final MatchEntrySerializerKey<Nxm1Class, NxmNxTunGpeNp> SERIALIZER_KEY =
31 new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunGpeNp.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 TunGpeNpCaseValue tunGpeNpCaseValue = (TunGpeNpCaseValue) input.getMatchEntryValue();
39 outBuffer.writeByte(tunGpeNpCaseValue.getTunGpeNpValues().getValue());
43 public MatchEntry deserialize(ByteBuf message) {
44 MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message);
45 TunGpeNpCaseValueBuilder tunGpeNpCaseValueBuilder = new TunGpeNpCaseValueBuilder();
46 tunGpeNpCaseValueBuilder.setTunGpeNpValues(new TunGpeNpValuesBuilder()
47 .setValue(message.readUnsignedByte()).build());
48 matchEntriesBuilder.setMatchEntryValue(tunGpeNpCaseValueBuilder.build());
49 matchEntriesBuilder.setHasMask(false);
50 return matchEntriesBuilder.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 NxmNxTunGpeNp.class;
74 public Class<? extends OxmClassBase> getOxmClass() {
75 return Nxm1Class.class;