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.api.extensibility.OFDeserializer;
16 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder;
22 * Translates RoleReply messages
23 * @author timotej.kubas
24 * @author michal.polkorab
26 public class RoleReplyMessageFactory implements OFDeserializer<RoleRequestOutput>{
28 private static final byte PADDING_IN_ROLE_REPLY_HEADER = 4;
31 public RoleRequestOutput deserialize(ByteBuf rawMessage) {
32 RoleRequestOutputBuilder builder = new RoleRequestOutputBuilder();
33 builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
34 builder.setXid(rawMessage.readUnsignedInt());
35 builder.setRole(ControllerRole.forValue((int) rawMessage.readUnsignedInt()));
36 rawMessage.skipBytes(PADDING_IN_ROLE_REPLY_HEADER);
37 byte[] generationID = new byte[8];
38 rawMessage.readBytes(generationID);
39 builder.setGenerationId(new BigInteger(1, generationID));
40 return builder.build();