2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
11 import io.netty.buffer.ByteBuf;
13 import java.math.BigInteger;
15 import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
16 import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
23 * Translates FlowRemoved messages
24 * @author michal.polkorab
25 * @author timotej.kubas
27 public class FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage> {
29 private static FlowRemovedMessageFactory instance;
31 private FlowRemovedMessageFactory() {
36 * @return singleton factory
38 public static synchronized FlowRemovedMessageFactory getInstance(){
40 instance = new FlowRemovedMessageFactory();
46 public FlowRemovedMessage bufferToMessage(ByteBuf rawMessage, short version) {
47 FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
48 builder.setVersion(version);
49 builder.setXid(rawMessage.readUnsignedInt());
50 byte[] cookie = new byte[Long.SIZE/Byte.SIZE];
51 rawMessage.readBytes(cookie);
52 builder.setCookie(new BigInteger(cookie));
53 builder.setPriority(rawMessage.readUnsignedShort());
54 builder.setReason(FlowRemovedReason.forValue(rawMessage.readUnsignedByte()));
55 builder.setTableId(new TableId((long)rawMessage.readUnsignedByte()));
56 builder.setDurationSec(rawMessage.readUnsignedInt());
57 builder.setDurationNsec(rawMessage.readUnsignedInt());
58 builder.setIdleTimeout(rawMessage.readUnsignedShort());
59 builder.setHardTimeout(rawMessage.readUnsignedShort());
60 byte[] packet_count = new byte[Long.SIZE/Byte.SIZE];
61 rawMessage.readBytes(packet_count);
62 builder.setPacketCount(new BigInteger(packet_count));
63 byte[] byte_count = new byte[Long.SIZE/Byte.SIZE];
64 rawMessage.readBytes(byte_count);
65 builder.setByteCount(new BigInteger(byte_count));
66 builder.setMatch(MatchDeserializer.createMatch(rawMessage));
67 return builder.build();