Merge "Bug 6110: Fixed bugs in statistics manager due to race condition." into stable...
[openflowplugin.git] / extension / openflowplugin-extension-nicira / src / main / java / org / opendaylight / openflowplugin / extension / vendor / nicira / convertor / action / RegMoveConvertor.java
1 /*
2  * Copyright (c) 2014, 2016 Cisco Systems, 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.openflowplugin.extension.vendor.nicira.convertor.action;
9
10 import org.opendaylight.openflowjava.nx.NiciraMatchCodecs;
11 import org.opendaylight.openflowjava.nx.codec.match.NxmHeader;
12 import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
13 import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
14 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
15 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException;
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.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegMove;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegMoveBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.reg.move.grouping.NxActionRegMove;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.reg.move.grouping.NxActionRegMoveBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg1;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg2;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg3;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg4;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg5;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg7;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.NxActionRegMoveGrouping;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.DstChoice;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpShaCase;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpShaCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpThaCase;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpThaCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxOfInPortCase;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxOfInPortCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc1Case;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc1CaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc2Case;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc2CaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc3Case;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc3CaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc4Case;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc4CaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNsiCase;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNsiCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCase;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxEncapEthSrcCase;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxEncapEthSrcCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxEncapEthDstCase;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxEncapEthDstCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshMdtypeCase;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshMdtypeCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshNpCase;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshNpCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunGpeNpCase;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunGpeNpCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCase;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIdCase;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIdCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4DstCase;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4DstCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4SrcCase;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4SrcCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpOpCase;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpOpCaseBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpSpaCase;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpSpaCaseBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpTpaCase;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpTpaCaseBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfEthDstCase;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfEthDstCaseBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfEthSrcCase;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfEthSrcCaseBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIcmpTypeCase;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIcmpTypeCaseBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpDstCase;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpDstCaseBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpSrcCase;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpSrcCaseBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfMplsLabelCase;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfMplsLabelCaseBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNotifFlowsStatisticsUpdateApplyActionsCaseBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionRegMoveNotifFlowsStatisticsUpdateWriteActionsCaseBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.get.flow.statistics.output.flow.and.statistics.map.list.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNotifDirectStatisticsUpdateApplyActionsCaseBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.get.flow.statistics.output.flow.and.statistics.map.list.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionRegMoveNotifDirectStatisticsUpdateWriteActionsCaseBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.group.desc.stats.updated.group.desc.stats.buckets.bucket.action.action.NxActionRegMoveNotifGroupDescStatsUpdatedCaseBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionRegMoveNodesNodeTableFlowWriteActionsCaseBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMove;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMoveBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Src;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.SrcBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.SrcChoice;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpShaCase;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpShaCaseBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpThaCase;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpThaCaseBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc1Case;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc1CaseBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc2Case;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc2CaseBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc3Case;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc3CaseBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc4Case;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc4CaseBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNsiCase;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNsiCaseBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNspCase;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNspCaseBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxEncapEthSrcCase;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxEncapEthSrcCaseBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxEncapEthDstCase;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxEncapEthDstCaseBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshMdtypeCase;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshMdtypeCaseBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshNpCase;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshNpCaseBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxOfMplsLabelCase;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunGpeNpCase;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunGpeNpCaseBuilder;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCase;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCaseBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCase;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCaseBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIpv4DstCase;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIpv4DstCaseBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIpv4SrcCase;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIpv4SrcCaseBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpOpCase;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpOpCaseBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpSpaCase;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpSpaCaseBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpTpaCase;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpTpaCaseBuilder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthDstCase;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthDstCaseBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthSrcCase;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthSrcCaseBuilder;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthTypeCase;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthTypeCaseBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfIpDstCase;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfIpDstCaseBuilder;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfIpSrcCase;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfIpSrcCaseBuilder;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxOfInPortCase;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxOfInPortCaseBuilder;
152
153 import com.google.common.base.Preconditions;
154
155 /**
156  * @author msunal
157  * @author Josh Hershberg (jhershbe@redhat.com)
158  */
159 public class RegMoveConvertor implements
160         ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action>,
161         ConvertorActionFromOFJava<Action, ActionPath> {
162
163     @Override
164     public org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action convert(Action input, ActionPath path) {
165         NxActionRegMove actionRegMove = ((ActionRegMove) input.getActionChoice()).getNxActionRegMove();
166         DstBuilder dstBuilder = new DstBuilder();
167         dstBuilder.setDstChoice(resolveDst(actionRegMove.getDst()));
168         dstBuilder.setStart(actionRegMove.getDstOfs());
169         dstBuilder.setEnd(actionRegMove.getDstOfs() + actionRegMove.getNBits() - 1);
170         SrcBuilder srcBuilder = new SrcBuilder();
171         srcBuilder.setSrcChoice(resolveSrc(actionRegMove.getSrc()));
172         srcBuilder.setStart(actionRegMove.getSrcOfs());
173         srcBuilder.setEnd(actionRegMove.getSrcOfs() + actionRegMove.getNBits() - 1);
174         NxRegMoveBuilder nxRegMoveBuilder = new NxRegMoveBuilder();
175         nxRegMoveBuilder.setDst(dstBuilder.build());
176         nxRegMoveBuilder.setSrc(srcBuilder.build());
177         return resolveAction(nxRegMoveBuilder.build(), path);
178     }
179
180     public static DstChoice resolveDst(long dstValue) {
181         Class<? extends NxmNxReg> potentialDst = resolveReg(dstValue);
182         if (potentialDst != null) {
183             return new DstNxRegCaseBuilder().setNxReg(potentialDst).build();
184         }
185         if (dstValue == NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong()) {
186             return new DstNxTunIdCaseBuilder().setNxTunId(true).build();
187         }
188         if (dstValue == NiciraMatchCodecs.ARP_SHA_CODEC.getHeaderWithoutHasMask().toLong()) {
189             return new DstNxArpShaCaseBuilder().setNxArpSha(true).build();
190         }
191         if (dstValue == NiciraMatchCodecs.ARP_THA_CODEC.getHeaderWithoutHasMask().toLong()) {
192             return new DstNxArpThaCaseBuilder().setNxArpTha(true).build();
193         }
194         if (dstValue == NiciraMatchCodecs.ARP_OP_CODEC.getHeaderWithoutHasMask().toLong()) {
195             return new DstOfArpOpCaseBuilder().setOfArpOp(true).build();
196         }
197         if (dstValue == NiciraMatchCodecs.ARP_SPA_CODEC.getHeaderWithoutHasMask().toLong()) {
198             return new DstOfArpSpaCaseBuilder().setOfArpSpa(true).build();
199         }
200         if (dstValue == NiciraMatchCodecs.ARP_TPA_CODEC.getHeaderWithoutHasMask().toLong()) {
201             return new DstOfArpTpaCaseBuilder().setOfArpTpa(true).build();
202         }
203         if (dstValue == NiciraMatchCodecs.NXM_OF_IN_PORT_CODEC.getHeaderWithoutHasMask().toLong()) {
204             return new DstNxOfInPortCaseBuilder().setOfInPort(true).build();
205         }
206         if (dstValue == NiciraMatchCodecs.OXM_OF_MPLS_LABEL.getHeaderWithoutHasMask().toLong()) {
207             return new DstOfMplsLabelCaseBuilder().setOfMplsLabel(true).build();
208         }
209         if (dstValue == NiciraMatchCodecs.ETH_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
210             return new DstOfEthDstCaseBuilder().setOfEthDst(true).build();
211         }
212         if (dstValue == NiciraMatchCodecs.ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
213             return new DstOfEthSrcCaseBuilder().setOfEthSrc(true).build();
214         }
215         if (dstValue == NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
216             return new DstNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(true).build();
217         }
218         if (dstValue == NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
219             return new DstNxTunIpv4SrcCaseBuilder().setNxTunIpv4Src(true).build();
220         }
221         if (dstValue == NiciraMatchCodecs.NSP_CODEC.getHeaderWithoutHasMask().toLong()) {
222             return new DstNxNspCaseBuilder().setNxNspDst(true).build();
223         }
224         if (dstValue == NiciraMatchCodecs.NSI_CODEC.getHeaderWithoutHasMask().toLong()) {
225             return new DstNxNsiCaseBuilder().setNxNsiDst(true).build();
226         }
227         if (dstValue == NiciraMatchCodecs.NSC1_CODEC.getHeaderWithoutHasMask().toLong()) {
228             return new DstNxNshc1CaseBuilder().setNxNshc1Dst(true).build();
229         }
230         if (dstValue == NiciraMatchCodecs.NSC2_CODEC.getHeaderWithoutHasMask().toLong()) {
231             return new DstNxNshc2CaseBuilder().setNxNshc2Dst(true).build();
232         }
233         if (dstValue == NiciraMatchCodecs.NSC3_CODEC.getHeaderWithoutHasMask().toLong()) {
234             return new DstNxNshc3CaseBuilder().setNxNshc3Dst(true).build();
235         }
236         if (dstValue == NiciraMatchCodecs.NSC4_CODEC.getHeaderWithoutHasMask().toLong()) {
237             return new DstNxNshc4CaseBuilder().setNxNshc4Dst(true).build();
238         }
239         if (dstValue == NiciraMatchCodecs.ENCAP_ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
240             return new DstNxEncapEthSrcCaseBuilder().setNxEncapEthSrc(true).build();
241         }
242         if (dstValue == NiciraMatchCodecs.ENCAP_ETH_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
243             return new DstNxEncapEthDstCaseBuilder().setNxEncapEthDst(true).build();
244         }
245         if (dstValue == NiciraMatchCodecs.NSH_MDTYPE_CODEC.getHeaderWithoutHasMask().toLong()) {
246             return new DstNxNshMdtypeCaseBuilder().setNxNshMdtype(true).build();
247         }
248         if (dstValue == NiciraMatchCodecs.NSH_NP_CODEC.getHeaderWithoutHasMask().toLong()) {
249             return new DstNxNshNpCaseBuilder().setNxNshNp(true).build();
250         }
251         if (dstValue == NiciraMatchCodecs.TUN_GPE_NP_CODEC.getHeaderWithoutHasMask().toLong()) {
252             return new DstNxTunGpeNpCaseBuilder().setNxTunGpeNp(true).build();
253         }
254         if (dstValue == NiciraMatchCodecs.IP_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
255             return new DstOfIpSrcCaseBuilder().setOfIpSrc(true).build();
256         }
257         if (dstValue == NiciraMatchCodecs.IP_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
258             return new DstOfIpDstCaseBuilder().setOfIpDst(true).build();
259         }
260         if (dstValue == NiciraMatchCodecs.ICMP_TYPE_CODEC.getHeaderWithoutHasMask().toLong()) {
261             return new DstOfIcmpTypeCaseBuilder().setOfIcmpType(true).build();
262         }
263
264         throw new CodecPreconditionException("Missing codec for " + new NxmHeader(dstValue));
265     }
266
267     static SrcChoice resolveSrc(long srcValue) {
268         Class<? extends NxmNxReg> potentialSrc = resolveReg(srcValue);
269         if (potentialSrc != null) {
270             return new SrcNxRegCaseBuilder().setNxReg(potentialSrc).build();
271         }
272         if (srcValue == NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong()) {
273             return new SrcNxTunIdCaseBuilder().setNxTunId(true).build();
274         }
275         if (srcValue == NiciraMatchCodecs.ARP_SHA_CODEC.getHeaderWithoutHasMask().toLong()) {
276             return new SrcNxArpShaCaseBuilder().setNxArpSha(true).build();
277         }
278         if (srcValue == NiciraMatchCodecs.ARP_THA_CODEC.getHeaderWithoutHasMask().toLong()) {
279             return new SrcNxArpThaCaseBuilder().setNxArpTha(true).build();
280         }
281         if (srcValue == NiciraMatchCodecs.ARP_OP_CODEC.getHeaderWithoutHasMask().toLong()) {
282             return new SrcOfArpOpCaseBuilder().setOfArpOp(true).build();
283         }
284         if (srcValue == NiciraMatchCodecs.ARP_SPA_CODEC.getHeaderWithoutHasMask().toLong()) {
285             return new SrcOfArpSpaCaseBuilder().setOfArpSpa(true).build();
286         }
287         if (srcValue == NiciraMatchCodecs.ARP_TPA_CODEC.getHeaderWithoutHasMask().toLong()) {
288             return new SrcOfArpTpaCaseBuilder().setOfArpTpa(true).build();
289         }
290         if (srcValue == NiciraMatchCodecs.NXM_OF_IN_PORT_CODEC.getHeaderWithoutHasMask().toLong()) {
291             return new SrcNxOfInPortCaseBuilder().setOfInPort(true).build();
292         }
293         if (srcValue == NiciraMatchCodecs.ETH_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
294             return new SrcOfEthDstCaseBuilder().setOfEthDst(true).build();
295         }
296         if (srcValue == NiciraMatchCodecs.ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
297             return new SrcOfEthSrcCaseBuilder().setOfEthSrc(true).build();
298         }
299         if (srcValue == NiciraMatchCodecs.ETH_TYPE_CODEC.getHeaderWithoutHasMask().toLong()) {
300             return new SrcOfEthTypeCaseBuilder().setOfEthType(true).build();
301         }
302         if (srcValue == NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
303             return new SrcNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(true).build();
304         }
305         if (srcValue == NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
306             return new SrcNxTunIpv4SrcCaseBuilder().setNxTunIpv4Src(true).build();
307         }
308         if (srcValue == NiciraMatchCodecs.NSP_CODEC.getHeaderWithoutHasMask().toLong()) {
309             return new SrcNxNspCaseBuilder().setNxNspDst(true).build();
310         }
311         if (srcValue == NiciraMatchCodecs.NSI_CODEC.getHeaderWithoutHasMask().toLong()) {
312             return new SrcNxNsiCaseBuilder().setNxNsiDst(true).build();
313         }
314         if (srcValue == NiciraMatchCodecs.NSC1_CODEC.getHeaderWithoutHasMask().toLong()) {
315             return new SrcNxNshc1CaseBuilder().setNxNshc1Dst(true).build();
316         }
317         if (srcValue == NiciraMatchCodecs.NSC2_CODEC.getHeaderWithoutHasMask().toLong()) {
318             return new SrcNxNshc2CaseBuilder().setNxNshc2Dst(true).build();
319         }
320         if (srcValue == NiciraMatchCodecs.NSC3_CODEC.getHeaderWithoutHasMask().toLong()) {
321             return new SrcNxNshc3CaseBuilder().setNxNshc3Dst(true).build();
322         }
323         if (srcValue == NiciraMatchCodecs.NSC4_CODEC.getHeaderWithoutHasMask().toLong()) {
324             return new SrcNxNshc4CaseBuilder().setNxNshc4Dst(true).build();
325         }
326         if (srcValue == NiciraMatchCodecs.ENCAP_ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
327             return new SrcNxEncapEthSrcCaseBuilder().setNxEncapEthSrc(true).build();
328         }
329         if (srcValue == NiciraMatchCodecs.ENCAP_ETH_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
330             return new SrcNxEncapEthDstCaseBuilder().setNxEncapEthDst(true).build();
331         }
332         if (srcValue == NiciraMatchCodecs.NSH_MDTYPE_CODEC.getHeaderWithoutHasMask().toLong()) {
333             return new SrcNxNshMdtypeCaseBuilder().setNxNshMdtype(true).build();
334         }
335         if (srcValue == NiciraMatchCodecs.NSH_NP_CODEC.getHeaderWithoutHasMask().toLong()) {
336             return new SrcNxNshNpCaseBuilder().setNxNshNp(true).build();
337         }
338         if (srcValue == NiciraMatchCodecs.TUN_GPE_NP_CODEC.getHeaderWithoutHasMask().toLong()) {
339             return new SrcNxTunGpeNpCaseBuilder().setNxTunGpeNp(true).build();
340         }
341         if (srcValue == NiciraMatchCodecs.IP_DST_CODEC.getHeaderWithoutHasMask().toLong()) {
342             return new SrcOfIpDstCaseBuilder().setOfIpDst(true).build();
343         }
344         if (srcValue == NiciraMatchCodecs.IP_SRC_CODEC.getHeaderWithoutHasMask().toLong()) {
345             return new SrcOfIpSrcCaseBuilder().setOfIpSrc(true).build();
346         }
347
348         throw new CodecPreconditionException("Missing codec for " + new NxmHeader(srcValue));
349     }
350
351     private static Class<? extends NxmNxReg> resolveReg(long value) {
352         if (value == NiciraMatchCodecs.REG0_CODEC.getHeaderWithoutHasMask().toLong()) {
353             return NxmNxReg0.class;
354         }
355         if (value == NiciraMatchCodecs.REG1_CODEC.getHeaderWithoutHasMask().toLong()) {
356             return NxmNxReg1.class;
357         }
358         if (value == NiciraMatchCodecs.REG2_CODEC.getHeaderWithoutHasMask().toLong()) {
359             return NxmNxReg2.class;
360         }
361         if (value == NiciraMatchCodecs.REG3_CODEC.getHeaderWithoutHasMask().toLong()) {
362             return NxmNxReg3.class;
363         }
364         if (value == NiciraMatchCodecs.REG4_CODEC.getHeaderWithoutHasMask().toLong()) {
365             return NxmNxReg4.class;
366         }
367         if (value == NiciraMatchCodecs.REG5_CODEC.getHeaderWithoutHasMask().toLong()) {
368             return NxmNxReg5.class;
369         }
370         if (value == NiciraMatchCodecs.REG6_CODEC.getHeaderWithoutHasMask().toLong()) {
371             return NxmNxReg6.class;
372         }
373         if (value == NiciraMatchCodecs.REG7_CODEC.getHeaderWithoutHasMask().toLong()) {
374             return NxmNxReg7.class;
375         }
376         return null;
377     }
378
379     private static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action resolveAction(
380             NxRegMove value, ActionPath path) {
381         switch (path) {
382             case NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION:
383                 return new NxActionRegMoveNodesNodeTableFlowWriteActionsCaseBuilder().setNxRegMove(value).build();
384             case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION:
385                 return new NxActionRegMoveNotifFlowsStatisticsUpdateWriteActionsCaseBuilder().setNxRegMove(value).build();
386             case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION:
387                 return new NxActionRegMoveNotifFlowsStatisticsUpdateApplyActionsCaseBuilder().setNxRegMove(value).build();
388             case GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION:
389                 return new NxActionRegMoveNotifGroupDescStatsUpdatedCaseBuilder().setNxRegMove(value).build();
390             case RPCFLOWSSTATISTICS_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION:
391                 return new NxActionRegMoveNotifDirectStatisticsUpdateWriteActionsCaseBuilder().setNxRegMove(value).build();
392             case RPCFLOWSSTATISTICS_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION:
393                 return new NxActionRegMoveNotifDirectStatisticsUpdateApplyActionsCaseBuilder().setNxRegMove(value).build();
394             default:
395                 throw new CodecPreconditionException(path);
396         }
397     }
398
399     @Override
400     public Action convert(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxActionArg) {
401         Preconditions.checkArgument(nxActionArg instanceof NxActionRegMoveGrouping);
402         NxActionRegMoveGrouping nxAction = (NxActionRegMoveGrouping) nxActionArg;
403
404         Dst dst = nxAction.getNxRegMove().getDst();
405         Src src = nxAction.getNxRegMove().getSrc();
406         ActionRegMoveBuilder actionRegMoveBuilder = new ActionRegMoveBuilder();
407         NxActionRegMoveBuilder nxActionRegMove = new NxActionRegMoveBuilder();
408
409         nxActionRegMove.setDst(resolveDst(dst.getDstChoice()));
410         nxActionRegMove.setDstOfs(dst.getStart());
411         nxActionRegMove.setSrc(resolveSrc(src.getSrcChoice()));
412         nxActionRegMove.setSrcOfs(src.getStart());
413         nxActionRegMove.setNBits(dst.getEnd() - dst.getStart() + 1);
414         actionRegMoveBuilder.setNxActionRegMove(nxActionRegMove.build());
415         return ActionUtil.createAction(actionRegMoveBuilder.build());
416     }
417
418     public static long resolveDst(DstChoice dstChoice) {
419         if (dstChoice instanceof DstNxRegCase) {
420             return resolveReg(((DstNxRegCase) dstChoice).getNxReg());
421         }
422         if (dstChoice instanceof DstNxTunIdCase) {
423             return NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong();
424         }
425         if (dstChoice instanceof DstNxArpShaCase) {
426             return NiciraMatchCodecs.ARP_SHA_CODEC.getHeaderWithoutHasMask().toLong();
427         }
428         if (dstChoice instanceof DstNxArpThaCase) {
429             return NiciraMatchCodecs.ARP_THA_CODEC.getHeaderWithoutHasMask().toLong();
430         }
431         if (dstChoice instanceof DstOfArpOpCase) {
432             return NiciraMatchCodecs.ARP_OP_CODEC.getHeaderWithoutHasMask().toLong();
433         }
434         if (dstChoice instanceof DstOfArpSpaCase) {
435             return NiciraMatchCodecs.ARP_SPA_CODEC.getHeaderWithoutHasMask().toLong();
436         }
437         if (dstChoice instanceof DstOfArpTpaCase) {
438             return NiciraMatchCodecs.ARP_TPA_CODEC.getHeaderWithoutHasMask().toLong();
439         }
440         if (dstChoice instanceof DstNxOfInPortCase) {
441             return NiciraMatchCodecs.NXM_OF_IN_PORT_CODEC.getHeaderWithoutHasMask().toLong();
442         }
443         if (dstChoice instanceof DstOfMplsLabelCase) {
444             return NiciraMatchCodecs.OXM_OF_MPLS_LABEL.getHeaderWithoutHasMask().toLong();
445         }
446         if (dstChoice instanceof DstNxTunIpv4DstCase) {
447             return NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong();
448         }
449         if (dstChoice instanceof DstNxTunIpv4SrcCase) {
450             return NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong();
451         }
452         if (dstChoice instanceof DstOfEthDstCase) {
453             return NiciraMatchCodecs.ETH_DST_CODEC.getHeaderWithoutHasMask().toLong();
454         }
455         if (dstChoice instanceof DstOfEthSrcCase) {
456             return NiciraMatchCodecs.ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong();
457         }
458         if (dstChoice instanceof DstNxTunIpv4DstCase) {
459             return NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong();
460         }
461         if (dstChoice instanceof DstNxTunIpv4SrcCase) {
462             return NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong();
463         }
464         if (dstChoice instanceof DstNxNspCase) {
465             return NiciraMatchCodecs.NSP_CODEC.getHeaderWithoutHasMask().toLong();
466         }
467         if (dstChoice instanceof DstNxNsiCase) {
468             return NiciraMatchCodecs.NSI_CODEC.getHeaderWithoutHasMask().toLong();
469         }
470         if (dstChoice instanceof DstNxNshc1Case) {
471             return  NiciraMatchCodecs.NSC1_CODEC.getHeaderWithoutHasMask().toLong();
472         }
473         if (dstChoice instanceof DstNxNshc2Case) {
474             return  NiciraMatchCodecs.NSC2_CODEC.getHeaderWithoutHasMask().toLong();
475         }
476         if (dstChoice instanceof DstNxNshc3Case) {
477             return  NiciraMatchCodecs.NSC3_CODEC.getHeaderWithoutHasMask().toLong();
478         }
479         if (dstChoice instanceof DstNxNshc4Case) {
480             return  NiciraMatchCodecs.NSC4_CODEC.getHeaderWithoutHasMask().toLong();
481         }
482         if (dstChoice instanceof DstOfIpSrcCase) {
483             return NiciraMatchCodecs.IP_SRC_CODEC.getHeaderWithoutHasMask().toLong();
484         }
485         if (dstChoice instanceof DstOfIpDstCase) {
486             return NiciraMatchCodecs.IP_DST_CODEC.getHeaderWithoutHasMask().toLong();
487         }
488         if (dstChoice instanceof DstOfIcmpTypeCase) {
489             return NiciraMatchCodecs.ICMP_TYPE_CODEC.getHeaderWithoutHasMask().toLong();
490         }
491         if (dstChoice instanceof DstNxEncapEthSrcCase) {
492             return  NiciraMatchCodecs.ENCAP_ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong();
493         }
494         if (dstChoice instanceof DstNxEncapEthDstCase) {
495             return  NiciraMatchCodecs.ENCAP_ETH_DST_CODEC.getHeaderWithoutHasMask().toLong();
496         }
497         if (dstChoice instanceof DstNxNshMdtypeCase) {
498             return  NiciraMatchCodecs.NSH_MDTYPE_CODEC.getHeaderWithoutHasMask().toLong();
499         }
500         if (dstChoice instanceof DstNxNshNpCase) {
501             return  NiciraMatchCodecs.NSH_NP_CODEC.getHeaderWithoutHasMask().toLong();
502         }
503         if (dstChoice instanceof DstNxTunGpeNpCase) {
504             return  NiciraMatchCodecs.TUN_GPE_NP_CODEC.getHeaderWithoutHasMask().toLong();
505         }
506
507
508         throw new CodecPreconditionException("Missing implementation of a case in dst-choice? " + dstChoice.getClass());
509     }
510
511     static long resolveSrc(SrcChoice srcChoice) {
512         if (srcChoice instanceof SrcNxRegCase) {
513             return resolveReg(((SrcNxRegCase) srcChoice).getNxReg());
514         }
515         if (srcChoice instanceof SrcNxTunIdCase) {
516             return NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong();
517         }
518         if (srcChoice instanceof SrcNxArpShaCase) {
519             return NiciraMatchCodecs.ARP_SHA_CODEC.getHeaderWithoutHasMask().toLong();
520         }
521         if (srcChoice instanceof SrcNxArpThaCase) {
522             return NiciraMatchCodecs.ARP_THA_CODEC.getHeaderWithoutHasMask().toLong();
523         }
524         if (srcChoice instanceof SrcOfArpOpCase) {
525             return NiciraMatchCodecs.ARP_OP_CODEC.getHeaderWithoutHasMask().toLong();
526         }
527         if (srcChoice instanceof SrcOfArpSpaCase) {
528             return NiciraMatchCodecs.ARP_SPA_CODEC.getHeaderWithoutHasMask().toLong();
529         }
530         if (srcChoice instanceof SrcOfArpTpaCase) {
531             return NiciraMatchCodecs.ARP_TPA_CODEC.getHeaderWithoutHasMask().toLong();
532         }
533         if (srcChoice instanceof SrcNxOfInPortCase) {
534             return NiciraMatchCodecs.NXM_OF_IN_PORT_CODEC.getHeaderWithoutHasMask().toLong();
535         }
536         if (srcChoice instanceof SrcNxOfMplsLabelCase) {
537             return NiciraMatchCodecs.OXM_OF_MPLS_LABEL.getHeaderWithoutHasMask().toLong();
538         }
539         if (srcChoice instanceof SrcNxTunIpv4DstCase) {
540             return NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong();
541         }
542         if (srcChoice instanceof SrcNxTunIpv4SrcCase) {
543             return NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong();
544         }
545         if (srcChoice instanceof SrcOfEthDstCase) {
546             return NiciraMatchCodecs.ETH_DST_CODEC.getHeaderWithoutHasMask().toLong();
547         }
548         if (srcChoice instanceof SrcOfEthSrcCase) {
549             return NiciraMatchCodecs.ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong();
550         }
551         if (srcChoice instanceof SrcOfEthTypeCase) {
552             return NiciraMatchCodecs.ETH_TYPE_CODEC.getHeaderWithoutHasMask().toLong();
553         }
554         if (srcChoice instanceof SrcNxTunIpv4DstCase) {
555             return NiciraMatchCodecs.TUN_IPV4_DST_CODEC.getHeaderWithoutHasMask().toLong();
556         }
557         if (srcChoice instanceof SrcNxTunIpv4SrcCase) {
558             return NiciraMatchCodecs.TUN_IPV4_SRC_CODEC.getHeaderWithoutHasMask().toLong();
559         }
560         if (srcChoice instanceof SrcNxNspCase) {
561             return NiciraMatchCodecs.NSP_CODEC.getHeaderWithoutHasMask().toLong();
562         }
563         if (srcChoice instanceof SrcNxNsiCase) {
564             return NiciraMatchCodecs.NSI_CODEC.getHeaderWithoutHasMask().toLong();
565         }
566         if (srcChoice instanceof SrcNxNshc1Case) {
567             return  NiciraMatchCodecs.NSC1_CODEC.getHeaderWithoutHasMask().toLong();
568         }
569         if (srcChoice instanceof SrcNxNshc2Case) {
570             return  NiciraMatchCodecs.NSC2_CODEC.getHeaderWithoutHasMask().toLong();
571         }
572         if (srcChoice instanceof SrcNxNshc3Case) {
573             return  NiciraMatchCodecs.NSC3_CODEC.getHeaderWithoutHasMask().toLong();
574         }
575         if (srcChoice instanceof SrcNxNshc4Case) {
576             return  NiciraMatchCodecs.NSC4_CODEC.getHeaderWithoutHasMask().toLong();
577         }
578         if (srcChoice instanceof SrcOfIpSrcCase) {
579             return NiciraMatchCodecs.IP_SRC_CODEC.getHeaderWithoutHasMask().toLong();
580         }
581         if (srcChoice instanceof SrcOfIpDstCase) {
582             return NiciraMatchCodecs.IP_DST_CODEC.getHeaderWithoutHasMask().toLong();
583         }
584         if (srcChoice instanceof SrcNxEncapEthSrcCase) {
585             return  NiciraMatchCodecs.ENCAP_ETH_SRC_CODEC.getHeaderWithoutHasMask().toLong();
586         }
587         if (srcChoice instanceof SrcNxEncapEthDstCase) {
588             return  NiciraMatchCodecs.ENCAP_ETH_DST_CODEC.getHeaderWithoutHasMask().toLong();
589         }
590         if (srcChoice instanceof SrcNxNshMdtypeCase) {
591             return  NiciraMatchCodecs.NSH_MDTYPE_CODEC.getHeaderWithoutHasMask().toLong();
592         }
593         if (srcChoice instanceof SrcNxNshNpCase) {
594             return  NiciraMatchCodecs.NSH_NP_CODEC.getHeaderWithoutHasMask().toLong();
595         }
596         if (srcChoice instanceof SrcNxTunGpeNpCase) {
597             return  NiciraMatchCodecs.TUN_GPE_NP_CODEC.getHeaderWithoutHasMask().toLong();
598         }
599
600         throw new CodecPreconditionException("Missing implementation of a case in src-choice? " + srcChoice.getClass());
601     }
602
603     private static long resolveReg(Class<? extends NxmNxReg> reg) {
604         if (reg.equals(NxmNxReg0.class)) {
605             return NiciraMatchCodecs.REG0_CODEC.getHeaderWithoutHasMask().toLong();
606         }
607         if (reg.equals(NxmNxReg1.class)) {
608             return NiciraMatchCodecs.REG1_CODEC.getHeaderWithoutHasMask().toLong();
609         }
610         if (reg.equals(NxmNxReg2.class)) {
611             return NiciraMatchCodecs.REG2_CODEC.getHeaderWithoutHasMask().toLong();
612         }
613         if (reg.equals(NxmNxReg3.class)) {
614             return NiciraMatchCodecs.REG3_CODEC.getHeaderWithoutHasMask().toLong();
615         }
616         if (reg.equals(NxmNxReg4.class)) {
617             return NiciraMatchCodecs.REG4_CODEC.getHeaderWithoutHasMask().toLong();
618         }
619         if (reg.equals(NxmNxReg5.class)) {
620             return NiciraMatchCodecs.REG5_CODEC.getHeaderWithoutHasMask().toLong();
621         }
622         if (reg.equals(NxmNxReg6.class)) {
623             return NiciraMatchCodecs.REG6_CODEC.getHeaderWithoutHasMask().toLong();
624         }
625         if (reg.equals(NxmNxReg7.class)) {
626             return NiciraMatchCodecs.REG7_CODEC.getHeaderWithoutHasMask().toLong();
627         }
628         throw new CodecPreconditionException("Missing codec for nxm_nx_reg?" + reg);
629     }
630
631 }