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.Nxm0Class;
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.NxmOfEthDst;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.eth.dst.grouping.EthDstValuesBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.EthDstCaseValue;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.EthDstCaseValueBuilder;
21 public class EthDstCodec extends AbstractMatchCodec {
23 private static final int VALUE_LENGTH = 6;
24 private static final int NXM_FIELD_CODE = 1;
25 public static final MatchEntrySerializerKey<Nxm0Class, NxmOfEthDst> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
26 EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthDst.class);
27 public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
28 EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
31 public void serialize(MatchEntry input, ByteBuf outBuffer) {
32 serializeHeader(input, outBuffer);
33 EthDstCaseValue ethDstCase = ((EthDstCaseValue) input.getMatchEntryValue());
34 outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(ethDstCase.getEthDstValues().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 EthDstCaseValueBuilder caseBuilder = new EthDstCaseValueBuilder();
43 caseBuilder.setEthDstValues(new EthDstValuesBuilder().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_0_CLASS;
60 public int getValueLength() {
65 public Class<? extends MatchField> getNxmField() {
66 return NxmOfEthDst.class;
70 public Class<? extends OxmClassBase> getOxmClass() {
71 return Nxm0Class.class;