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.openflowjava.util.ByteBufUtils;
10 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxArpTha;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.arp.tha.grouping.ArpThaValuesBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpThaCaseValue;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpThaCaseValueBuilder;
21 public class ArpThaCodec extends AbstractMatchCodec {
23 private static final int VALUE_LENGTH = 6;
24 private static final int NXM_FIELD_CODE = 18;
25 public static final MatchEntrySerializerKey<Nxm1Class, NxmNxArpTha> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
26 EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxArpTha.class);
27 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
28 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
31 public void serialize(MatchEntry input, ByteBuf outBuffer) {
32 serializeHeader(input, outBuffer);
33 ArpThaCaseValue arpThaCase = ((ArpThaCaseValue) input.getMatchEntryValue());
34 outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(arpThaCase.getArpThaValues().getMacAddress().getValue()));
38 public MatchEntry deserialize(ByteBuf message) {
39 MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
40 byte[] address = new byte[VALUE_LENGTH];
41 message.readBytes(address);
42 ArpThaCaseValueBuilder caseBuilder = new ArpThaCaseValueBuilder();
43 caseBuilder.setArpThaValues(new ArpThaValuesBuilder().setMacAddress(
44 new MacAddress(ByteBufUtils.macAddressToString(address))).build());
45 matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
46 return matchEntryBuilder.build();
50 public int getNxmFieldCode() {
51 return NXM_FIELD_CODE;
55 public int getOxmClassCode() {
56 return OxmMatchConstants.NXM_1_CLASS;
60 public int getValueLength() {
65 public Class<? extends MatchField> getNxmField() {
66 return NxmNxArpTha.class;
70 public Class<? extends OxmClassBase> getOxmClass() {
71 return Nxm1Class.class;