2 * Copyright (c) 2015 Hewlett-Packard Enterprise 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.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
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.Nxm0Class;
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.openflowjava.nx.match.rev140421.NxmOfTcpDst;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.tcp.dst.grouping.TcpDstValuesBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpDstCaseValue;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpDstCaseValueBuilder;
24 import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
27 * Codec for the TcpDst message.
29 * @author Aswin Suryanarayanan.
31 public class TcpDstCodec extends AbstractMatchCodec {
33 private static final int VALUE_LENGTH = 2;
34 private static final int NXM_FIELD_CODE = 10;
35 public static final MatchEntrySerializerKey<Nxm0Class, NxmOfTcpDst> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
36 EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfTcpDst.class);
37 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
38 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
41 public void serialize(final MatchEntry input, final ByteBuf outBuffer) {
42 serializeHeader(input, outBuffer);
43 TcpDstCaseValue tcpDstCase = (TcpDstCaseValue) input.getMatchEntryValue();
44 outBuffer.writeShort(tcpDstCase.getTcpDstValues().getPort().getValue().toJava());
45 outBuffer.writeShort(tcpDstCase.getTcpDstValues().getMask().toJava());
49 public MatchEntry deserialize(final ByteBuf message) {
50 return deserializeHeaderToBuilder(message)
52 .setMatchEntryValue(new TcpDstCaseValueBuilder()
53 .setTcpDstValues(new TcpDstValuesBuilder()
54 .setPort(new PortNumber(ByteBufUtils.readUint16(message)))
55 .setMask(ByteBufUtils.readUint16(message))
62 public int getNxmFieldCode() {
63 return NXM_FIELD_CODE;
67 public int getOxmClassCode() {
68 return OxmMatchConstants.NXM_0_CLASS;
72 public int getValueLength() {
77 public Class<? extends MatchField> getNxmField() {
78 return NxmOfTcpDst.class;
82 public Class<? extends OxmClassBase> getOxmClass() {
83 return Nxm0Class.class;