2 * Copyright (c) 2016 Ericsson, 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
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.NxmOfMplsLabel;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.oxm.of.mpls.label.grouping.MplsLabelValuesBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.OfMplsLabelCaseValue;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.OfMplsLabelCaseValueBuilder;
24 import io.netty.buffer.ByteBuf;
26 public class MplsLabelCodec extends AbstractMatchCodec {
28 private static final int VALUE_LENGTH = 4;
29 private static final int NXM_FIELD_CODE = 34;
31 public static final MatchEntrySerializerKey<Nxm0Class, NxmOfMplsLabel> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
32 EncodeConstants.OF13_VERSION_ID, Nxm0Class.class,
33 NxmOfMplsLabel.class);
35 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
36 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS,
40 public void serialize(MatchEntry input, ByteBuf outBuffer) {
41 serializeHeader(input, outBuffer);
42 OfMplsLabelCaseValue value = (OfMplsLabelCaseValue) input.getMatchEntryValue();
43 outBuffer.writeInt(value.getMplsLabelValues().getMplsLabel().intValue());
47 public MatchEntry deserialize(ByteBuf message) {
48 MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
49 OfMplsLabelCaseValueBuilder caseBuilder = new OfMplsLabelCaseValueBuilder();
50 MplsLabelValuesBuilder valuesBuilder = new MplsLabelValuesBuilder();
51 valuesBuilder.setMplsLabel(message.readLong()).build();
52 caseBuilder.setMplsLabelValues(valuesBuilder.build());
53 matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
54 return matchEntryBuilder.build();
58 public int getNxmFieldCode() {
59 return NXM_FIELD_CODE;
63 public int getOxmClassCode() {
64 return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
68 public int getValueLength() {
73 public Class<? extends MatchField> getNxmField() {
74 return NxmOfMplsLabel.class;
78 public Class<? extends OxmClassBase> getOxmClass() {
79 return Nxm0Class.class;