2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
11 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
14 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
26 * @author michal.polkorab
29 public abstract class AbstractInstructionDeserializer implements OFDeserializer<Instruction>,
30 HeaderDeserializer<Instruction> {
33 public Instruction deserializeHeader(ByteBuf rawMessage) {
34 InstructionBuilder builder = processHeader(rawMessage);
35 rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
36 return builder.build();
39 protected InstructionBuilder processHeader(ByteBuf input) {
40 InstructionBuilder builder = new InstructionBuilder();
41 int type = input.readUnsignedShort();
44 builder.setType(GotoTable.class);
47 builder.setType(WriteMetadata.class);
50 builder.setType(WriteActions.class);
53 builder.setType(ApplyActions.class);
56 builder.setType(ClearActions.class);
59 builder.setType(Meter.class);
62 throw new IllegalStateException("Unknown instruction type received, type: " + type);