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.ActionsSerializer;
\r
8 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
\r
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
\r
12 * @author michal.polkorab
\r
15 public class PacketOutInputMessageFactory implements OFSerializer<PacketOutInput>{
\r
17 /** Code type of PacketOut message */
\r
18 public static final byte MESSAGE_TYPE = 13;
\r
19 private static final int MESSAGE_LENGTH = 30;
\r
20 private static final byte PADDING_IN_PACKET_OUT_MESSAGE = 6;
\r
21 private static PacketOutInputMessageFactory instance;
\r
23 private PacketOutInputMessageFactory() {
\r
24 // do nothing, just singleton
\r
28 * @return singleton factory
\r
30 public static synchronized PacketOutInputMessageFactory getInstance() {
\r
31 if (instance == null) {
\r
32 instance = new PacketOutInputMessageFactory();
\r
38 public void messageToBuffer(short version, ByteBuf out,
\r
39 PacketOutInput message) {
\r
40 ByteBufUtils.writeOFHeader(instance, message, out);
\r
41 out.writeInt(message.getBufferId().intValue());
\r
42 out.writeInt(message.getInPort().getValue().intValue());
\r
43 ByteBufUtils.padBuffer(PADDING_IN_PACKET_OUT_MESSAGE, out);
\r
44 ActionsSerializer.encodeActions(message.getActionsList(), out);
\r
45 // TODO - finish implementation after Action serialization is done
\r
46 //out.writeShort(message.getActions().size());
\r
47 //out.writeBytes(message.getData());
\r
51 public int computeLength(PacketOutInput message) {
\r
52 return MESSAGE_LENGTH;
\r
56 public byte getMessageType() {
\r
57 return MESSAGE_TYPE;
\r