1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
2 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
4 import io.netty.buffer.ByteBuf;
6 import java.math.BigInteger;
8 import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
9 import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
16 * Translates FlowRemoved messages
17 * @author michal.polkorab
18 * @author timotej.kubas
20 public class FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage> {
22 private static FlowRemovedMessageFactory instance;
24 private FlowRemovedMessageFactory() {
29 * @return singleton factory
31 public static synchronized FlowRemovedMessageFactory getInstance(){
33 instance = new FlowRemovedMessageFactory();
39 public FlowRemovedMessage bufferToMessage(ByteBuf rawMessage, short version) {
40 FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
41 builder.setVersion(version);
42 builder.setXid(rawMessage.readUnsignedInt());
43 byte[] cookie = new byte[Long.SIZE/Byte.SIZE];
44 rawMessage.readBytes(cookie);
45 builder.setCookie(new BigInteger(cookie));
46 builder.setPriority(rawMessage.readUnsignedShort());
47 builder.setReason(FlowRemovedReason.forValue(rawMessage.readUnsignedByte()));
48 builder.setTableId(new TableId((long)rawMessage.readUnsignedByte()));
49 builder.setDurationSec(rawMessage.readUnsignedInt());
50 builder.setDurationNsec(rawMessage.readUnsignedInt());
51 builder.setIdleTimeout(rawMessage.readUnsignedShort());
52 builder.setHardTimeout(rawMessage.readUnsignedShort());
53 byte[] packet_count = new byte[Long.SIZE/Byte.SIZE];
54 rawMessage.readBytes(packet_count);
55 builder.setPacketCount(new BigInteger(packet_count));
56 byte[] byte_count = new byte[Long.SIZE/Byte.SIZE];
57 rawMessage.readBytes(byte_count);
58 builder.setByteCount(new BigInteger(byte_count));
59 builder.setMatch(MatchDeserializer.createMatch(rawMessage));
60 return builder.build();