2 * Copyright (c) 2017 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;
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.opendaylight.openflow.oxm.rev150225.MatchField;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfIpDst;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.ip.dst.grouping.IpDstValuesBuilder;
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;
26 * @author Sridhar Gaddam (sgaddam@redhat.com)
28 public class Ipv6DstCodec extends AbstractMatchCodec {
30 private static final int VALUE_LENGTH = 16;
31 private static final int NXM_FIELD_CODE = 20;
32 public static final MatchEntrySerializerKey<Nxm1Class, NxmOfIpDst> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
33 EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmOfIpDst.class);
34 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
35 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
39 public MatchEntry deserialize(ByteBuf message) {
40 MatchEntryBuilder matchEntriesBuilder = deserializeHeader(message);
41 IpDstCaseValueBuilder caseBuilder = new IpDstCaseValueBuilder();
42 caseBuilder.setIpDstValues(new IpDstValuesBuilder().setValue(message.readUnsignedInt()).build());
43 matchEntriesBuilder.setMatchEntryValue(caseBuilder.build());
44 return matchEntriesBuilder.build();
48 public void serialize(MatchEntry input, ByteBuf outBuffer) {
49 serializeHeader(input, outBuffer);
50 IpDstCaseValue ipDstCase = ((IpDstCaseValue) input.getMatchEntryValue());
51 outBuffer.writeInt(ipDstCase.getIpDstValues().getValue().intValue());
55 public int getNxmFieldCode() {
56 return NXM_FIELD_CODE;
60 public int getOxmClassCode() {
61 return OxmMatchConstants.NXM_1_CLASS;
65 public int getValueLength() {
70 public Class<? extends MatchField> getNxmField() {
71 return NxmOfIpDst.class;
75 public Class<? extends OxmClassBase> getOxmClass() {
76 return Nxm1Class.class;