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.serialization;
\r
11 import io.netty.buffer.ByteBuf;
\r
13 import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer;
\r
14 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
\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.common.instruction.rev130731.instructions.grouping.Instruction;
\r
21 * @author michal.polkorab
\r
23 public class OF13ExperimenterInstructionSerializer implements OFSerializer<Instruction>,
\r
24 HeaderSerializer<Instruction>{
\r
27 public void serializeHeader(Instruction instruction, ByteBuf outBuffer) {
\r
28 outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE);
\r
29 outBuffer.writeShort(ExtConstants.EXPERIMENTER_IDS_LENGTH);
\r
30 outBuffer.writeInt(instruction
\r
31 .getAugmentation(ExperimenterInstruction.class).getExperimenter().intValue());
\r
35 public void serialize(Instruction instruction, ByteBuf outBuffer) {
\r
36 int startIndex = outBuffer.writerIndex();
\r
37 outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE);
\r
38 int lengthIndex = outBuffer.writerIndex();
\r
39 outBuffer.writeShort(ExtConstants.EMPTY_LENGTH);
\r
40 ExperimenterInstruction experimenter =
\r
41 instruction.getAugmentation(ExperimenterInstruction.class);
\r
42 outBuffer.writeInt(experimenter.getExperimenter().intValue());
\r
43 if (experimenter.getData() != null) {
\r
44 outBuffer.writeBytes(experimenter.getData());
\r
46 outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex);
\r