1 package org.opendaylight.openflowjava.nx.codec.match;
3 import io.netty.buffer.ByteBuf;
5 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
6 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
7 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
8 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfEthType;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.eth.type.grouping.EthTypeValuesBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
19 public class EthTypeCodec extends AbstractMatchCodec {
21 private static final int VALUE_LENGTH = 2;
22 private static final int NXM_FIELD_CODE = 3;
23 public static final MatchEntrySerializerKey<Nxm0Class, NxmOfEthType> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
24 EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthType.class);
25 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
26 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
29 public void serialize(MatchEntries input, ByteBuf outBuffer) {
30 serializeHeader(input, outBuffer);
31 Integer value = input.getAugmentation(OfjAugNxMatch.class).getEthTypeValues().getValue();
32 outBuffer.writeShort(value);
36 public MatchEntries deserialize(ByteBuf message) {
37 MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message);
38 OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder();
39 augNxMatchBuilder.setEthTypeValues(new EthTypeValuesBuilder().setValue(message.readUnsignedShort()).build());
40 matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build());
41 return matchEntriesBuilder.build();
45 public int getNxmFieldCode() {
46 return NXM_FIELD_CODE;
50 public int getOxmClassCode() {
51 return OxmMatchConstants.NXM_0_CLASS;
55 public int getValueLength() {
60 public Class<? extends MatchField> getNxmField() {
61 return NxmOfEthType.class;
65 public Class<? extends OxmClassBase> getOxmClass() {
66 return Nxm0Class.class;