Bug 2756 - Action model update
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / action / OF10SetDlDstActionDeserializer.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.openflowjava.util.ByteBufUtils;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.dst._case.SetDlDstActionBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
22
23 /**
24  * @author michal.polkorab
25  *
26  */
27 public class OF10SetDlDstActionDeserializer extends AbstractActionDeserializer {
28
29     @Override
30     public Action deserialize(ByteBuf input) {
31         ActionBuilder builder = new ActionBuilder();
32         input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
33         SetDlDstCaseBuilder caseBuilder = new SetDlDstCaseBuilder();
34         SetDlDstActionBuilder actionBuilder = new SetDlDstActionBuilder();
35         byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
36         input.readBytes(address);
37         actionBuilder.setDlDstAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));
38         caseBuilder.setSetDlDstAction(actionBuilder.build());
39         builder.setActionChoice(caseBuilder.build());
40         input.skipBytes(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION);
41         return builder.build();
42     }
43
44     @Override
45     protected ActionChoice getType() {
46         return new SetDlDstCaseBuilder().build();
47     }
48
49 }