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;
12 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
13 import org.opendaylight.openflowjava.util.ByteBufUtils;
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
22 * @author michal.polkorab
25 public abstract class AbstractOxmMacAddressDeserializer extends AbstractOxmMatchEntryDeserializer
26 implements OFDeserializer<MatchEntries> {
29 public MatchEntries deserialize(ByteBuf input) {
30 MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);
31 addMacAddressAugmentation(builder, input);
32 if (builder.isHasMask()) {
33 OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.MAC_ADDRESS_LENGTH);
35 return builder.build();
38 private static void addMacAddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) {
39 MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder();
40 byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
41 input.readBytes(address);
42 macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));
43 builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build());