2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
\r
10 import io.netty.buffer.ByteBuf;
\r
12 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
\r
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry;
\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
\r
20 * @author michal.polkorab
\r
23 public abstract class AbstractOxmMetadataDeserializer extends AbstractOxmMatchEntryDeserializer
\r
24 implements OFDeserializer<MatchEntries> {
\r
27 public MatchEntries deserialize(ByteBuf input) {
\r
28 MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);
\r
29 addMetadataAugmentation(builder, input);
\r
30 if (builder.isHasMask()) {
\r
31 OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
\r
33 return builder.build();
\r
36 private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf input) {
\r
37 MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder();
\r
38 byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
\r
39 input.readBytes(metadataBytes);
\r
40 metadata.setMetadata(metadataBytes);
\r
41 builder.addAugmentation(MetadataMatchEntry.class, metadata.build());
\r