2 * Copyright (c) 2016 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.openflowplugin.impl.protocol.serialization.instructions;
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer;
13 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
14 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
17 public abstract class AbstractInstructionSerializer implements OFSerializer<Instruction>,
18 HeaderSerializer<Instruction> {
21 public void serialize(Instruction input, ByteBuf outBuffer) {
22 outBuffer.writeShort(getType());
23 outBuffer.writeShort(getLength());
27 public void serializeHeader(Instruction input, ByteBuf outBuffer) {
28 outBuffer.writeShort(getType());
29 outBuffer.writeShort(InstructionConstants.INSTRUCTION_IDS_LENGTH);
35 * @return numeric representation of instruction type.
37 protected abstract int getType();
42 * @return instruction length.
44 protected abstract int getLength();