Default experimenter bundle migrated to ConfigSubsystem
[openflowjava.git] / openflow-protocol-ext / src / main / java / org / opendaylight / openflowjava / protocol / ext / deserialization / OF13ExperimenterInstructionDeserializer.java
1 /*\r
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\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
7  */\r
8 \r
9 package org.opendaylight.openflowjava.protocol.ext.deserialization;\r
10 \r
11 import io.netty.buffer.ByteBuf;\r
12 \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
21 \r
22 /**\r
23  * @author michal.polkorab\r
24  *\r
25  */\r
26 public class OF13ExperimenterInstructionDeserializer implements OFDeserializer<Instruction>,\r
27         HeaderDeserializer<Instruction> {\r
28 \r
29     @Override\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
39     }\r
40 \r
41     @Override\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
53         }\r
54         builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());\r
55         return builder.build();\r
56     }\r
57 \r
58 }\r