2 * Copyright (c) 2015 NetIDE Consortium 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
8 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
10 import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32;
11 import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint64;
13 import io.netty.buffer.ByteBuf;
14 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder;
21 * Translates RoleRequestInput messages.
23 * @author giuseppex.petralia@intel.com
25 public class RoleRequestInputMessageFactory implements OFDeserializer<RoleRequestInput> {
27 private static final byte PADDING = 4;
30 public RoleRequestInput deserialize(ByteBuf rawMessage) {
31 RoleRequestInputBuilder builder = new RoleRequestInputBuilder()
32 .setVersion(EncodeConstants.OF_VERSION_1_3)
33 .setXid(readUint32(rawMessage))
34 .setRole(ControllerRole.forValue(rawMessage.readInt()));
35 rawMessage.skipBytes(PADDING);
36 builder.setGenerationId(readUint64(rawMessage));
37 return builder.build();