0fae6a619daf5fca81c0a4a38b870e52658e3474
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / action / AbstractEthertypeActionDeserializer.java
1 /*\r
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.action;\r
10 \r
11 import io.netty.buffer.ByteBuf;\r
12 \r
13 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;\r
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;\r
20 \r
21 /**\r
22  * @author michal.polkorab\r
23  *\r
24  */\r
25 public abstract class AbstractEthertypeActionDeserializer extends AbstractActionDeserializer {\r
26 \r
27     @Override\r
28     public Action deserialize(ByteBuf input) {\r
29         ActionBuilder builder = new ActionBuilder();\r
30         builder.setType(getType());\r
31         input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
32         EthertypeActionBuilder etherType = new EthertypeActionBuilder();\r
33         etherType.setEthertype(new EtherType(input.readUnsignedShort()));\r
34         builder.addAugmentation(EthertypeAction.class, etherType.build());\r
35         input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING);\r
36         return builder.build();\r
37     }\r
38 }\r