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.util.EncodeConstants;
13 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
14 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata;
19 public class WriteMetadataInstructionSerializer extends AbstractInstructionSerializer {
22 public void serialize(Instruction input, ByteBuf outBuffer) {
23 super.serialize(input, outBuffer);
24 final WriteMetadata writeMetadata = WriteMetadataCase.class.cast(input).getWriteMetadata();
25 outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA);
26 outBuffer.writeBytes(ByteUtil
27 .convertBigIntegerToNBytes(writeMetadata.getMetadata(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
28 outBuffer.writeBytes(ByteUtil
29 .convertBigIntegerToNBytes(writeMetadata.getMetadataMask(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
33 protected int getType() {
34 return InstructionConstants.WRITE_METADATA_TYPE;
38 protected int getLength() {
39 return InstructionConstants.WRITE_METADATA_LENGTH;