1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
\r
2 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
\r
4 import io.netty.buffer.ByteBuf;
\r
6 import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
\r
7 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
\r
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
\r
11 * @author michal.polkorab
\r
14 public class PacketOutInputMessageFactory implements OFSerializer<PacketOutInput>{
\r
16 /** Code type of PacketOut message */
\r
17 public static final byte MESSAGE_TYPE = 13;
\r
18 private static final int MESSAGE_LENGTH = 8;
\r
19 private static final byte PADDING_IN_PACKET_OUT_MESSAGE = 6;
\r
20 private static PacketOutInputMessageFactory instance;
\r
22 private PacketOutInputMessageFactory() {
\r
23 // do nothing, just singleton
\r
27 * @return singleton factory
\r
29 public static PacketOutInputMessageFactory getInstance() {
\r
30 if (instance == null) {
\r
31 instance = new PacketOutInputMessageFactory();
\r
37 public void messageToBuffer(short version, ByteBuf out,
\r
38 PacketOutInput message) {
\r
39 ByteBufUtils.writeOFHeader(instance, message, out);
\r
40 out.writeInt(message.getBufferId().intValue());
\r
41 out.writeInt(message.getInPort().getValue().intValue());
\r
42 // TODO - finish implementation after Action serialization is done
\r
43 //out.writeShort(message.getActions().size());
\r
44 ByteBufUtils.padBuffer(PADDING_IN_PACKET_OUT_MESSAGE, out);
\r
49 public int computeLength() {
\r
50 return MESSAGE_LENGTH;
\r
54 public byte getMessageType() {
\r
55 return MESSAGE_TYPE;
\r