Fix ActionNxConntrack.NxNat problems with xtendbeans (with a test)
[genius.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / genius / mdsalutil / actions / ActionMoveShaToTha.java
1 /*
2  * Copyright (c) 2016 Red Hat, Inc. 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.genius.mdsalutil.actions;
9
10 import org.opendaylight.genius.mdsalutil.ActionInfo;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpThaCaseBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMoveBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.SrcBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpShaCaseBuilder;
20
21 /**
22  * Move Source Hardware address to Destination address, to where the ARP
23  * response need to be addressed to.
24  */
25 public class ActionMoveShaToTha extends ActionInfo {
26
27     public ActionMoveShaToTha() {
28         this(0);
29     }
30
31     public ActionMoveShaToTha(int actionKey) {
32         super(actionKey);
33     }
34
35     @Override
36     public Action buildAction() {
37         return buildAction(getActionKey());
38     }
39
40     @Override
41     public Action buildAction(int newActionKey) {
42         // Length of the SHA is 6 byte, hence the end offset bit is 47
43         return new ActionBuilder()
44             .setAction(new NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder()
45                 .setNxRegMove(new NxRegMoveBuilder()
46                     .setSrc(new SrcBuilder()
47                         .setSrcChoice(new SrcNxArpShaCaseBuilder().setNxArpSha(true).build())
48                         .setStart(0)
49                         .setEnd(47)
50                         .build())
51                     .setDst(new DstBuilder()
52                         .setDstChoice(new DstNxArpThaCaseBuilder().setNxArpTha(true).build())
53                         .setStart(0)
54                         .setEnd(47)
55                         .build())
56                     .build())
57                 .build())
58             .setKey(new ActionKey(newActionKey))
59             .build();
60     }
61 }