BUG-2825: use provided Ipv4/MacAddress factories
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / action / OF10SetNwDstActionDeserializer.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 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
13 import org.opendaylight.openflowjava.util.ByteBufUtils;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
19
20 /**
21  * @author michal.polkorab
22  *
23  */
24 public class OF10SetNwDstActionDeserializer extends AbstractActionDeserializer {
25
26     @Override
27     public Action deserialize(final ByteBuf input) {
28         ActionBuilder builder = new ActionBuilder();
29         input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
30         SetNwDstCaseBuilder caseBuilder = new SetNwDstCaseBuilder();
31         SetNwDstActionBuilder actionBuilder = new SetNwDstActionBuilder();
32         actionBuilder.setIpAddress(ByteBufUtils.readIetfIpv4Address(input));
33         caseBuilder.setSetNwDstAction(actionBuilder.build());
34         builder.setActionChoice(caseBuilder.build());
35         return builder.build();
36     }
37
38     @Override
39     protected ActionChoice getType() {
40         return new SetNwDstCaseBuilder().build();
41     }
42
43 }