2 * Copyright (c) 2018 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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
14 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
16 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtTpSrc;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.CtTpSrcCaseValue;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.CtTpSrcCaseValueBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.tp.src.grouping.CtTpSrcValuesBuilder;
26 public class CtTpSrcCodec extends AbstractMatchCodec {
28 private static final int VALUE_LENGTH = 2;
29 private static final int NXM_FIELD_CODE = 124;
30 public static final MatchEntrySerializerKey<Nxm1Class, NxmNxCtTpSrc> SERIALIZER_KEY =
31 new MatchEntrySerializerKey<>(EncodeConstants.OF_VERSION_1_3, Nxm1Class.class, NxmNxCtTpSrc.class);
32 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
33 EncodeConstants.OF_VERSION_1_3, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
36 public void serialize(final MatchEntry input, final ByteBuf outBuffer) {
37 serializeHeader(input, outBuffer);
38 CtTpSrcCaseValue ctTpSrcCase = (CtTpSrcCaseValue)input.getMatchEntryValue();
39 outBuffer.writeShort(ctTpSrcCase.getCtTpSrcValues().getCtTpSrc().toJava());
43 public MatchEntry deserialize(final ByteBuf message) {
44 return deserializeHeaderToBuilder(message)
45 .setMatchEntryValue(new CtTpSrcCaseValueBuilder()
46 .setCtTpSrcValues(new CtTpSrcValuesBuilder().setCtTpSrc(readUint16(message)).build())
52 public int getNxmFieldCode() {
53 return NXM_FIELD_CODE;
57 public int getOxmClassCode() {
58 return OxmMatchConstants.NXM_1_CLASS;
62 public int getValueLength() {
67 public Class<? extends MatchField> getNxmField() {
68 return NxmNxCtTpSrc.class;
72 public Class<? extends OxmClassBase> getOxmClass() {
73 return Nxm1Class.class;