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.ExperimenterInput;
\r
11 * @author michal.polkorab
\r
14 public class OF10VendorInputMessageFactory implements OFSerializer<ExperimenterInput> {
\r
16 private static final byte MESSAGE_TYPE = 4;
\r
17 private static final byte MESSAGE_LENGTH = 8;
\r
19 private static OF10VendorInputMessageFactory instance;
\r
21 private OF10VendorInputMessageFactory() {
\r
22 // do nothing, just singleton
\r
26 * @return singleton factory
\r
28 public static synchronized OF10VendorInputMessageFactory getInstance() {
\r
29 if (instance == null) {
\r
30 instance = new OF10VendorInputMessageFactory();
\r
36 public void messageToBuffer(short version, ByteBuf out,
\r
37 ExperimenterInput message) {
\r
38 ByteBufUtils.writeOFHeader(instance, message, out);
\r
39 out.writeInt(message.getExperimenter().intValue());
\r
40 byte[] data = message.getData();
\r
42 out.writeBytes(data);
\r
47 public int computeLength(ExperimenterInput message) {
\r
48 int length = MESSAGE_LENGTH + Integer.SIZE / Byte.SIZE;
\r
49 byte[] data = message.getData();
\r
51 length += data.length;
\r
57 public byte getMessageType() {
\r
58 return MESSAGE_TYPE;
\r