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
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.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.openflowjava.nx.match.rev140421.NxmOfArpOp;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.ArpOpCaseValue;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.ArpOpCaseValueBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.arp.op.grouping.ArpOpValuesBuilder;
26 public class ArpOpCodec extends AbstractMatchCodec {
27 private static final int VALUE_LENGTH = 2;
28 private static final int NXM_FIELD_CODE = 15;
29 public static final MatchEntrySerializerKey<Nxm0Class, NxmOfArpOp> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
30 EncodeConstants.OF_VERSION_1_3, Nxm0Class.VALUE, NxmOfArpOp.VALUE);
31 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
32 EncodeConstants.OF_VERSION_1_3, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
35 public void serialize(final MatchEntry input, final ByteBuf outBuffer) {
36 serializeHeader(input, outBuffer);
37 ArpOpCaseValue arpOpCase = (ArpOpCaseValue) input.getMatchEntryValue();
38 outBuffer.writeShort(arpOpCase.getArpOpValues().getValue().toJava());
42 public MatchEntry deserialize(final ByteBuf message) {
43 return deserializeHeaderToBuilder(message)
44 .setMatchEntryValue(new ArpOpCaseValueBuilder()
45 .setArpOpValues(new ArpOpValuesBuilder().setValue(readUint16(message)).build())
51 public int getNxmFieldCode() {
52 return NXM_FIELD_CODE;
56 public int getOxmClassCode() {
57 return OxmMatchConstants.NXM_0_CLASS;
61 public int getValueLength() {
66 public MatchField getNxmField() {
67 return NxmOfArpOp.VALUE;
71 public OxmClassBase getOxmClass() {
72 return Nxm0Class.VALUE;