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.ext.deserialization;
\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.ext.util.ExtConstants;
\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(ExtConstants.SIZE_OF_SHORT_IN_BYTES);
\r
33 builder.setType(Experimenter.class);
\r
34 input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES);
\r
35 ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();
\r
36 expBuilder.setExperimenter(input.readUnsignedInt());
\r
37 builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());
\r
38 return builder.build();
\r
42 public Instruction deserialize(ByteBuf input) {
\r
43 InstructionBuilder builder = new InstructionBuilder();
\r
44 input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES);
\r
45 builder.setType(Experimenter.class);
\r
46 input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES);
\r
47 ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();
\r
48 expBuilder.setExperimenter(input.readUnsignedInt());
\r
49 if (input.readableBytes() > 0) {
\r
50 byte[] data = new byte[input.readableBytes()];
\r
51 input.readBytes(data);
\r
52 expBuilder.setData(data);
\r
54 builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());
\r
55 return builder.build();
\r