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.experimenters;
\r
11 import io.netty.buffer.ByteBuf;
\r
13 import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
\r
14 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
\r
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstructionBuilder;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;
\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
\r
23 * @author michal.polkorab
\r
26 public class OF13ExperimenterInstructionDeserializer implements OFDeserializer<Instruction>,
\r
27 HeaderDeserializer<Instruction> {
\r
30 public Instruction deserializeHeader(ByteBuf input) {
\r
31 InstructionBuilder builder = new InstructionBuilder();
\r
32 input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
\r
33 builder.setType(Experimenter.class);
\r
34 input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
\r
35 ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();
\r
36 expBuilder.setExperimenter(input.readUnsignedInt());
\r
37 return builder.build();
\r
41 public Instruction deserialize(ByteBuf input) {
\r
42 InstructionBuilder builder = new InstructionBuilder();
\r
43 input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
\r
44 builder.setType(Experimenter.class);
\r
45 input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
\r
46 ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();
\r
47 expBuilder.setExperimenter(input.readUnsignedInt());
\r
48 if (input.readableBytes() > 0) {
\r
49 byte[] data = new byte[input.readableBytes()];
\r
50 input.readBytes(data);
\r
51 expBuilder.setData(data);
\r
53 builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());
\r
54 return builder.build();
\r