2 * Copyright (c) 2016 Red Hat, 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 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.openflowjava.nx.match.rev140421.NxmOfIpDst;
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.Nxm0Class;
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.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.IpDstCaseValue;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.IpDstCaseValueBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.ip.dst.grouping.IpDstValuesBuilder;
27 * @author Josh Hershberg (jhershbe@redhat.com)
29 public class IpDstCodec extends AbstractMatchCodec {
31 private static final int VALUE_LENGTH = 4;
32 private static final int NXM_FIELD_CODE = 8;
33 public static final MatchEntrySerializerKey<Nxm0Class, NxmOfIpDst> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
34 EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfIpDst.class);
35 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
36 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
40 public MatchEntry deserialize(ByteBuf message) {
41 MatchEntryBuilder matchEntriesBuilder = deserializeHeader(message);
42 IpDstCaseValueBuilder caseBuilder = new IpDstCaseValueBuilder();
43 caseBuilder.setIpDstValues(new IpDstValuesBuilder().setValue(message.readUnsignedInt()).build());
44 matchEntriesBuilder.setMatchEntryValue(caseBuilder.build());
45 return matchEntriesBuilder.build();
49 public void serialize(MatchEntry input, ByteBuf outBuffer) {
50 serializeHeader(input, outBuffer);
51 IpDstCaseValue ipDstCase = ((IpDstCaseValue) input.getMatchEntryValue());
52 outBuffer.writeInt(ipDstCase.getIpDstValues().getValue().intValue());
56 public int getNxmFieldCode() {
57 return NXM_FIELD_CODE;
61 public int getOxmClassCode() {
62 return OxmMatchConstants.NXM_0_CLASS;
66 public int getValueLength() {
71 public Class<? extends MatchField> getNxmField() {
72 return NxmOfIpDst.class;
76 public Class<? extends OxmClassBase> getOxmClass() {
77 return Nxm0Class.class;