Bug 2756 - Action model update
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / action / OF10EnqueueActionDeserializer.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
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.action;
10
11 import io.netty.buffer.ByteBuf;
12
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
14 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.EnqueueCaseBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.enqueue._case.EnqueueActionBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;
23
24 /**
25  * @author michal.polkorab
26  *
27  */
28 public class OF10EnqueueActionDeserializer extends AbstractActionDeserializer {
29
30     @Override
31     public Action deserialize(ByteBuf input) {
32         ActionBuilder builder = new ActionBuilder();
33         input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
34         EnqueueCaseBuilder caseBuilder = new EnqueueCaseBuilder();
35         EnqueueActionBuilder actionBuilder = new EnqueueActionBuilder();
36         actionBuilder.setPort(new PortNumber((long) input.readUnsignedShort()));
37         input.skipBytes(ActionConstants.PADDING_IN_ENQUEUE_ACTION);
38         actionBuilder.setQueueId(new QueueId(input.readUnsignedInt()));
39         caseBuilder.setEnqueueAction(actionBuilder.build());
40         builder.setActionChoice(caseBuilder.build());
41         return builder.build();
42     }
43
44     @Override
45     protected ActionChoice getType() {
46         return new OutputActionCaseBuilder().build();
47     }
48
49 }