1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
\r
2 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
\r
4 import io.netty.buffer.ByteBuf;
\r
6 import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
\r
7 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
\r
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
\r
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
\r
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
\r
13 * @author timotej.kubas
\r
14 * @author michal.polkorab
\r
16 public class MultipartReplyMessageFactory implements OFDeserializer<MultipartReplyMessage> {
\r
18 private static MultipartReplyMessageFactory instance;
\r
19 private static final byte PADDING_IN_MULTIPART_REPLY_HEADER = 4;
\r
21 private MultipartReplyMessageFactory() {
\r
26 * @return singleton factory
\r
28 public static MultipartReplyMessageFactory getInstance(){
\r
29 if (instance == null){
\r
30 instance = new MultipartReplyMessageFactory();
\r
36 public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) {
\r
37 MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
\r
38 builder.setVersion(version);
\r
39 builder.setXid(rawMessage.readUnsignedInt());
\r
40 builder.setType(MultipartType.forValue(rawMessage.readUnsignedShort()));
\r
41 builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) > 0));
\r
42 rawMessage.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);
\r
43 // TODO - implement body
\r
44 //mrmb.setBody(rawMessage.readBytes(rawMessage.readableBytes()).array());
\r
45 return builder.build();
\r