33c81495807f323aafcf5f6daec256ec9436ff3e
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / action / OF13PushPbbActionDeserializer.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.action;
9
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
12 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCaseBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbActionBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
19 import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
20
21 /**
22  * OF13PushPbbActionDeserializer.
23  *
24  * @author michal.polkorab
25  */
26 public class OF13PushPbbActionDeserializer extends AbstractActionDeserializer {
27     @Override
28     public Action deserialize(ByteBuf input) {
29         input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
30         final ActionBuilder builder = new ActionBuilder()
31                 .setActionChoice(new PushPbbCaseBuilder()
32                     .setPushPbbAction(new PushPbbActionBuilder()
33                         .setEthertype(new EtherType(ByteBufUtils.readUint16(input)))
34                         .build())
35                     .build());
36         input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);
37         return builder.build();
38     }
39
40     @Override
41     protected ActionChoice getType() {
42         return new PushPbbCaseBuilder().build();
43     }
44 }