2 * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.protocol.impl.deserialization.match;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder;
22 * Translates OxmEthDst messages.
24 * @author michal.polkorab
26 public class OxmEthDstDeserializer extends AbstractOxmMatchEntryDeserializer {
28 public MatchEntry deserialize(final ByteBuf input) {
29 MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input);
30 addEthDstValue(input, builder);
31 return builder.build();
34 private static void addEthDstValue(final ByteBuf input, final MatchEntryBuilder builder) {
35 EthDstCaseBuilder caseBuilder = new EthDstCaseBuilder();
36 EthDstBuilder ethBuilder = new EthDstBuilder();
37 ethBuilder.setMacAddress(OxmDeserializerHelper.convertMacAddress(input));
38 if (builder.isHasMask()) {
39 ethBuilder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.MAC_ADDRESS_LENGTH));
41 caseBuilder.setEthDst(ethBuilder.build());
42 builder.setMatchEntryValue(caseBuilder.build());
46 protected Class<? extends MatchField> getOxmField() {
51 protected Class<? extends OxmClassBase> getOxmClass() {
52 return OpenflowBasicClass.class;