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.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.common.instruction.rev130731.ApplyActions;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
\r
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
\r
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
\r
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
\r
26 * @author michal.polkorab
\r
29 public abstract class AbstractInstructionDeserializer implements OFDeserializer<Instruction>,
\r
30 HeaderDeserializer<Instruction> {
\r
33 public Instruction deserializeHeader(ByteBuf rawMessage) {
\r
34 InstructionBuilder builder = processHeader(rawMessage);
\r
35 rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
\r
36 return builder.build();
\r
39 protected InstructionBuilder processHeader(ByteBuf input) {
\r
40 InstructionBuilder builder = new InstructionBuilder();
\r
41 int type = input.readUnsignedShort();
\r
44 builder.setType(GotoTable.class);
\r
47 builder.setType(WriteMetadata.class);
\r
50 builder.setType(WriteActions.class);
\r
53 builder.setType(ApplyActions.class);
\r
56 builder.setType(ClearActions.class);
\r
59 builder.setType(Meter.class);
\r
62 throw new IllegalStateException("Unknown instruction type received, type: " + type);
\r