Make VersionAssignableFactory implement OFDeserializer
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / GetConfigReplyMessageFactory.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
9
10 import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16;
11 import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32;
12
13 import io.netty.buffer.ByteBuf;
14 import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder;
18
19 /**
20  * Translates GetConfigReply messages.
21  * OF protocol versions: 1.0, 1.3, 1.4, 1.5.
22  * @author michal.polkorab
23  * @author timotej.kubas
24  */
25 public class GetConfigReplyMessageFactory extends VersionAssignableFactory<GetConfigOutput> {
26
27     @Override
28     public GetConfigOutput deserialize(final ByteBuf rawMessage) {
29         GetConfigOutputBuilder builder = new GetConfigOutputBuilder();
30         builder.setVersion(getVersion());
31         builder.setXid(readUint32(rawMessage));
32         builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort()));
33         builder.setMissSendLen(readUint16(rawMessage));
34         return builder.build();
35     }
36 }