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
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
\r
11 import io.netty.buffer.ByteBuf;
\r
13 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
\r
14 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
\r
22 * @author michal.polkorab
\r
25 public class WriteMetadataInstructionDeserializer extends AbstractInstructionDeserializer {
\r
28 public Instruction deserialize(ByteBuf input) {
\r
29 InstructionBuilder builder = new InstructionBuilder();
\r
30 input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
\r
31 builder.setType(WriteMetadata.class);
\r
32 input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
\r
33 input.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA);
\r
34 MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder();
\r
35 byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
\r
36 input.readBytes(metadata);
\r
37 metadataBuilder.setMetadata(metadata);
\r
38 byte[] metadata_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
\r
39 input.readBytes(metadata_mask);
\r
40 metadataBuilder.setMetadataMask(metadata_mask);
\r
41 builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build());
\r
42 return builder.build();
\r