2 * Copyright (c) 2014, 2015 Cisco Systems, 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
9 package org.opendaylight.openflowjava.nx.codec.match;
11 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.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.NxmOfArpTpa;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.arp.tpa.grouping.ArpTpaValuesBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpTpaCaseValue;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpTpaCaseValueBuilder;
27 public class ArpTpaCodec extends AbstractMatchCodec {
29 private static final int VALUE_LENGTH = 4;
30 private static final int NXM_FIELD_CODE = 17;
31 public static final MatchEntrySerializerKey<Nxm0Class, NxmOfArpTpa> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
32 EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpTpa.class);
33 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
34 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
37 public void serialize(MatchEntry input, ByteBuf outBuffer) {
38 serializeHeader(input, outBuffer);
39 ArpTpaCaseValue arpTpaCase = ((ArpTpaCaseValue) input.getMatchEntryValue());
40 outBuffer.writeInt(arpTpaCase.getArpTpaValues().getValue().intValue());
44 public MatchEntry deserialize(ByteBuf message) {
45 MatchEntryBuilder matchEntriesBuilder = deserializeHeader(message);
46 ArpTpaCaseValueBuilder caseBuilder = new ArpTpaCaseValueBuilder();
47 caseBuilder.setArpTpaValues(new ArpTpaValuesBuilder().setValue(message.readUnsignedInt()).build());
48 matchEntriesBuilder.setMatchEntryValue(caseBuilder.build());
49 return matchEntriesBuilder.build();
53 public int getNxmFieldCode() {
54 return NXM_FIELD_CODE;
58 public int getOxmClassCode() {
59 return OxmMatchConstants.NXM_0_CLASS;
63 public int getValueLength() {
68 public Class<? extends MatchField> getNxmField() {
69 return NxmOfArpTpa.class;
73 public Class<? extends OxmClassBase> getOxmClass() {
74 return Nxm0Class.class;