2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow;
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.List;
15 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
16 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.action.ActionUtil;
17 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.action.ResubmitConvertor;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActionsBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionResubmitBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.resubmit.grouping.NxActionResubmitBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg1;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg2;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg3;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg4;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg5;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.ExtensionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.DstChoice;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpShaCaseBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxArpThaCaseBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc1CaseBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc2CaseBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCaseBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIdCaseBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4DstCaseBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpOpCaseBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpSpaCaseBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpTpaCaseBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfEthDstCaseBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegLoadNodesNodeGroupBucketsBucketActionsCaseBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder;
119 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.NxActionOutputRegNodesNodeTableFlowApplyActionsCaseBuilder;
120 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.NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder;
121 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;
122 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.NxActionSetNshc1NodesNodeTableFlowApplyActionsCaseBuilder;
123 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.NxActionSetNshc2NodesNodeTableFlowApplyActionsCaseBuilder;
124 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.NxActionSetNshc3NodesNodeTableFlowApplyActionsCaseBuilder;
125 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.NxActionSetNshc4NodesNodeTableFlowApplyActionsCaseBuilder;
126 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.NxActionSetNsiNodesNodeTableFlowApplyActionsCaseBuilder;
127 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.NxActionSetNspNodesNodeTableFlowApplyActionsCaseBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.NxOutputReg;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.NxOutputRegBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMove;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMoveBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.SrcBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._1.grouping.NxSetNshc1;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._1.grouping.NxSetNshc1Builder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._2.grouping.NxSetNshc2;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._2.grouping.NxSetNshc2Builder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._3.grouping.NxSetNshc3;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._3.grouping.NxSetNshc3Builder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._4.grouping.NxSetNshc4;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nshc._4.grouping.NxSetNshc4Builder;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsi.grouping.NxSetNsi;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsi.grouping.NxSetNsiBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsp.grouping.NxSetNsp;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsp.grouping.NxSetNspBuilder;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.SrcChoice;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxArpShaCaseBuilder;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCaseBuilder;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCaseBuilder;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIpv4DstCaseBuilder;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfArpSpaCaseBuilder;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfEthSrcCaseBuilder;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshc1Key;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshc2Key;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshc3Key;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshc4Key;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNsiKey;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNspKey;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg0Key;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg1Key;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg2Key;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg3Key;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg4Key;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg5Key;
169 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg6Key;
170 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg7Key;
171 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxTunIdKey;
172 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxTunIpv4DstKey;
173 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._1.grouping.NxmNxNshc1Builder;
174 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._2.grouping.NxmNxNshc2Builder;
175 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._3.grouping.NxmNxNshc3Builder;
176 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._4.grouping.NxmNxNshc4Builder;
177 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsi.grouping.NxmNxNsiBuilder;
178 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsp.grouping.NxmNxNspBuilder;
179 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.reg.grouping.NxmNxRegBuilder;
180 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.id.grouping.NxmNxTunIdBuilder;
181 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.ipv4.dst.grouping.NxmNxTunIpv4DstBuilder;
182 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
184 import com.google.common.collect.ImmutableList;
185 import com.google.common.net.InetAddresses;
188 * Utilities for constructing OpenFlow flows
190 public final class FlowUtils {
195 public static final Long ARP = 0x0806L;
199 public static final Long IPv4 = 0x0800L;
203 public static final Long IPv6 = 0x86DDL;
207 public static final Integer VLAN = 0x8100;
210 * Creates an Instance Identifier (path) for node with specified id
212 * @param nodeId the ID of the node
213 * @return the {@link InstanceIdentifier}
215 public static InstanceIdentifier<Node> createNodePath(final NodeId nodeId) {
216 return InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(nodeId)).build();
220 * Creates a table path from a node ID and table ID
222 * @param nodeId the ID of the node
223 * @param tableId the ID of the table
224 * @return the {@link InstanceIdentifier}
226 public static InstanceIdentifier<Table> createTablePath(final NodeId nodeId, final short tableId) {
227 return createNodePath(nodeId).builder()
228 .augmentation(FlowCapableNode.class)
229 .child(Table.class, new TableKey(tableId))
234 * Creates a group path from a node ID and group ID
236 * @param nodeId the Id of the node
237 * @param groupId the ID of the group table
238 * @return the {@link InstanceIdentifier}
240 public static InstanceIdentifier<Group> createGroupPath(final NodeId nodeId, final GroupId groupId) {
241 return createNodePath(nodeId).builder()
242 .augmentation(FlowCapableNode.class)
243 .child(Group.class, new GroupKey(groupId))
247 public static InstanceIdentifier<Group> createGroupPath(final NodeId nodeId, final Long groupId) {
248 return createGroupPath(nodeId, new GroupId(groupId));
252 * Creates a group path from a node ID and group ID
254 * @param nodeId the Id of the node
255 * @param groupId the ID of the group table
256 * @param bucketId the ID of the bucket in the group table
257 * @return the {@link InstanceIdentifier}
259 public static InstanceIdentifier<Bucket> createBucketPath(final NodeId nodeId, final GroupId groupId,
260 final BucketId bucketId) {
261 return createNodePath(nodeId).builder()
262 .augmentation(FlowCapableNode.class)
263 .child(Group.class, new GroupKey(groupId))
264 .child(Buckets.class)
265 .child(Bucket.class, new BucketKey(bucketId))
270 * Creates a path for particular flow, by appending flow-specific information
273 * @param table the table iid
274 * @param flowKey the flow key
275 * @return the {@link InstanceIdentifier}
277 public static InstanceIdentifier<Flow> createFlowPath(final InstanceIdentifier<Table> table,
278 final FlowKey flowKey) {
279 return table.child(Flow.class, flowKey);
283 * Creates a path for particular flow, by appending flow-specific information
286 * @param table the table iid
287 * @param flowId the flow id
288 * @return the {@link InstanceIdentifier}
290 public static InstanceIdentifier<Flow> createFlowPath(final InstanceIdentifier<Table> table, final FlowId flowId) {
291 return createFlowPath(table, new FlowKey(flowId));
294 public static Instructions gotoTableInstructions(short tableId) {
295 return new InstructionsBuilder().setInstruction(
296 ImmutableList.of(new InstructionBuilder().setOrder(0)
297 .setInstruction(gotoTableIns(tableId))
301 public static Instruction gotoTableIns(short tableId) {
302 return new GoToTableCaseBuilder().setGoToTable(new GoToTableBuilder().setTableId(tableId).build()).build();
305 public static ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList(
307 ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> alist =
310 for (Action action : actions) {
311 alist.add(new ActionBuilder().setOrder(count++).setAction(action).build());
316 public static ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList(
317 List<ActionBuilder> actions) {
318 ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> alist =
321 for (ActionBuilder action : actions) {
322 alist.add(action.setOrder(count++).build());
327 public static Instruction applyActionIns(Action... actions) {
328 return new ApplyActionsCaseBuilder()
329 .setApplyActions(new ApplyActionsBuilder().setAction(actionList(actions)).build()).build();
332 public static Instruction applyActionIns(List<ActionBuilder> actions) {
333 return new ApplyActionsCaseBuilder()
334 .setApplyActions(new ApplyActionsBuilder().setAction(actionList(actions)).build()).build();
337 public static Instruction writeActionIns(List<ActionBuilder> actions) {
338 return new WriteActionsCaseBuilder()
339 .setWriteActions(new WriteActionsBuilder().setAction(actionList(actions)).build()).build();
342 public static Instruction writeActionIns(Action... actions) {
343 return new WriteActionsCaseBuilder()
344 .setWriteActions(new WriteActionsBuilder().setAction(actionList(actions)).build()).build();
347 public static Instructions instructions(Instruction... instructions) {
348 ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> ins =
351 for (Instruction i : instructions) {
352 ins.add(new InstructionBuilder().setOrder(order++).setInstruction(i).build());
354 return new InstructionsBuilder().setInstruction(ins).build();
357 public static Instructions dropInstructions() {
358 return instructions(applyActionIns(dropAction()));
361 public static Action dropAction() {
362 return new DropActionCaseBuilder().setDropAction(new DropActionBuilder().build()).build();
365 public static Action createActionResubmit(Integer port, final short toTable) {
366 NxActionResubmitBuilder resubmit = new NxActionResubmitBuilder().setTable(toTable);
369 resubmit.setInPort(port);
372 ActionResubmitBuilder actionResubmitBuilder = new ActionResubmitBuilder();
373 actionResubmitBuilder.setNxActionResubmit(resubmit.build());
375 ResubmitConvertor convertor = new ResubmitConvertor();
377 ActionPath.NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION;
379 return convertor.convert(ActionUtil.createAction(actionResubmitBuilder.build()), ap);
382 public static Action outputAction(NodeConnectorId id) {
383 return new OutputActionCaseBuilder()
384 .setOutputAction(new OutputActionBuilder().setOutputNodeConnector(new Uri(id.getValue())).build()).build();
387 public static Action groupAction(Long id) {
388 return new GroupActionCaseBuilder().setGroupAction(new GroupActionBuilder().setGroupId(id).build()).build();
391 public static Action setDlSrcAction(MacAddress mac) {
392 return new SetDlSrcActionCaseBuilder().setSetDlSrcAction(new SetDlSrcActionBuilder().setAddress(mac).build())
396 public static Action setDlDstAction(MacAddress mac) {
397 return new SetDlDstActionCaseBuilder().setSetDlDstAction(new SetDlDstActionBuilder().setAddress(mac).build())
401 public static VlanMatch vlanMatch(int vlanId, boolean vlanIdPresent) {
402 return new VlanMatchBuilder()
403 .setVlanId(new VlanIdBuilder().setVlanId(new VlanId(vlanId)).setVlanIdPresent(vlanIdPresent).build())
407 public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder> pushVlanActions(
409 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder> actions =
411 actions.add(new ActionBuilder().setAction(pushVlanAction()).setOrder(0));
412 actions.add(new ActionBuilder().setAction(setVlanId(vlanId)).setOrder(1));
416 public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction popVlanInstruction(
418 List<ActionBuilder> actionBuilders = new ArrayList<>();
419 actionBuilders.add(new ActionBuilder().setAction(popVlanAction()).setOrder(0));
420 return new InstructionBuilder()
421 .setInstruction(new ApplyActionsCaseBuilder()
422 .setApplyActions(new ApplyActionsBuilder().setAction(actionList(actionBuilders)).build()).build())
427 public static Action setIpv4DstAction(Ipv4Address ipAddress) {
428 Ipv4Builder ipDest = new Ipv4Builder();
429 Ipv4Prefix prefixdst = new Ipv4Prefix(new Ipv4Prefix(ipAddress.getValue() + "/32"));
430 ipDest.setIpv4Address(prefixdst);
431 SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
432 setNwDstActionBuilder.setAddress(ipDest.build());
433 return new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build();
436 public static Action setIpv6DstAction(Ipv6Address ipAddress) {
437 Ipv6Builder ipDest = new Ipv6Builder();
438 Ipv6Prefix prefixdst = new Ipv6Prefix(new Ipv6Prefix(ipAddress.getValue() + "/128"));
439 ipDest.setIpv6Address(prefixdst);
440 SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
441 setNwDstActionBuilder.setAddress(ipDest.build());
442 return new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build();
445 public static Action setIpv4SrcAction(Ipv4Address ipAddress) {
446 Ipv4Builder ipSrc = new Ipv4Builder();
447 Ipv4Prefix prefixdst = new Ipv4Prefix(new Ipv4Prefix(ipAddress.getValue() + "/32"));
448 ipSrc.setIpv4Address(prefixdst);
449 SetNwSrcActionBuilder setNwSrcActionBuilder = new SetNwSrcActionBuilder();
450 setNwSrcActionBuilder.setAddress(ipSrc.build());
451 return new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwSrcActionBuilder.build()).build();
454 public static Action setIpv6SrcAction(Ipv6Address ipAddress) {
455 Ipv6Builder ipSrc = new Ipv6Builder();
456 Ipv6Prefix prefixdst = new Ipv6Prefix(new Ipv6Prefix(ipAddress.getValue() + "/128"));
457 ipSrc.setIpv6Address(prefixdst);
458 SetNwSrcActionBuilder setNwSrcActionBuilder = new SetNwSrcActionBuilder();
459 setNwSrcActionBuilder.setAddress(ipSrc.build());
460 return new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwSrcActionBuilder.build()).build();
463 public static Action decNwTtlAction() {
464 return new DecNwTtlCaseBuilder().setDecNwTtl(new DecNwTtlBuilder().build()).build();
467 public static Action nxLoadRegAction(DstChoice dstChoice, BigInteger value, int endOffset, boolean groupBucket) {
468 NxRegLoad r = new NxRegLoadBuilder().setDst(
469 new DstBuilder().setDstChoice(dstChoice)
476 return new NxActionRegLoadNodesNodeGroupBucketsBucketActionsCaseBuilder().setNxRegLoad(r).build();
478 return new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegLoad(r).build();
482 public static Action nxSetNsiAction(Short nsi) {
483 NxSetNsi newNsi = new NxSetNsiBuilder().setNsi(nsi).build();
484 return new NxActionSetNsiNodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNsi(newNsi).build();
487 public static Action nxSetNspAction(Long nsp) {
488 NxSetNsp newNsp = new NxSetNspBuilder().setNsp(nsp).build();
489 return new NxActionSetNspNodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNsp(newNsp).build();
492 public static Action nxLoadRegAction(DstChoice dstChoice, BigInteger value) {
493 return nxLoadRegAction(dstChoice, value, 31, false);
496 public static Action nxLoadRegAction(Class<? extends NxmNxReg> reg, BigInteger value) {
497 return nxLoadRegAction(new DstNxRegCaseBuilder().setNxReg(reg).build(), value);
500 public static Action nxLoadNshc1RegAction(Long value) {
501 NxSetNshc1 newNshc1 = new NxSetNshc1Builder().setNshc(value).build();
502 return new NxActionSetNshc1NodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNshc1(newNshc1).build();
505 public static Action nxLoadNshc2RegAction(Long value) {
506 NxSetNshc2 newNshc2 = new NxSetNshc2Builder().setNshc(value).build();
507 return new NxActionSetNshc2NodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNshc2(newNshc2).build();
510 public static Action nxLoadNshc3RegAction(Long value) {
511 NxSetNshc3 newNshc3 = new NxSetNshc3Builder().setNshc(value).build();
512 return new NxActionSetNshc3NodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNshc3(newNshc3).build();
515 public static Action nxLoadNshc4RegAction(Long value) {
516 NxSetNshc4 newNshc4 = new NxSetNshc4Builder().setNshc(value).build();
517 return new NxActionSetNshc4NodesNodeTableFlowApplyActionsCaseBuilder().setNxSetNshc4(newNshc4).build();
520 public static Action nxLoadTunIPv4Action(String ipAddress, boolean groupBucket) {
521 int ip = InetAddresses.coerceToInteger(InetAddresses.forString(ipAddress));
522 long ipl = ip & 0xffffffffL;
523 return nxLoadRegAction(new DstNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(Boolean.TRUE).build(),
524 BigInteger.valueOf(ipl), 31, groupBucket);
527 public static Action nxLoadArpOpAction(BigInteger value) {
528 return nxLoadRegAction(new DstOfArpOpCaseBuilder().setOfArpOp(Boolean.TRUE).build(), value, 15, false);
531 public static Action nxLoadArpShaAction(BigInteger value) {
532 return nxLoadRegAction(new DstNxArpShaCaseBuilder().setNxArpSha(Boolean.TRUE).build(), value, 47, false);
535 public static Action nxLoadArpSpaAction(BigInteger value) {
536 return nxLoadRegAction(new DstOfArpSpaCaseBuilder().setOfArpSpa(Boolean.TRUE).build(), value);
539 public static Action nxLoadArpSpaAction(String ipAddress) {
540 int ip = InetAddresses.coerceToInteger(InetAddresses.forString(ipAddress));
541 long ipl = ip & 0xffffffffL;
542 return nxLoadArpSpaAction(BigInteger.valueOf(ipl));
545 public static Action nxMoveRegAction(SrcChoice srcChoice, DstChoice dstChoice, int endOffset, boolean groupBucket) {
546 NxRegMove r = new NxRegMoveBuilder().setSrc(
547 new SrcBuilder().setSrcChoice(srcChoice)
551 .setDst(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder().setDstChoice(
556 .setDst(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder()
557 .setDstChoice(dstChoice).setStart(0).setEnd(endOffset).build())
560 return new NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder().setNxRegMove(r).build();
562 return new NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegMove(r).build();
566 public static Action nxMoveRegAction(SrcChoice srcChoice, DstChoice dstChoice) {
567 return nxMoveRegAction(srcChoice, dstChoice, 31, false);
570 public static Action nxMoveRegTunDstToNshc1() {
571 return nxMoveRegAction(new SrcNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(Boolean.TRUE).build(),
572 new DstNxNshc1CaseBuilder().setNxNshc1Dst(Boolean.TRUE).build(), 31, false);
575 public static Action nxMoveTunIdtoNshc2() {
576 return nxMoveRegAction(new SrcNxTunIdCaseBuilder().setNxTunId(Boolean.TRUE).build(),
577 new DstNxNshc2CaseBuilder().setNxNshc2Dst(Boolean.TRUE).build(), 31, false);
580 public static Action nxMoveRegTunIdAction(Class<? extends NxmNxReg> src, boolean groupBucket) {
581 return nxMoveRegAction(new SrcNxRegCaseBuilder().setNxReg(src).build(),
582 new DstNxTunIdCaseBuilder().setNxTunId(Boolean.TRUE).build(), 31, groupBucket);
585 public static Action nxLoadTunIdAction(BigInteger tunnelId, boolean groupBucket) {
586 return nxLoadRegAction(new DstNxTunIdCaseBuilder().setNxTunId(Boolean.TRUE).build(), tunnelId, 31, groupBucket);
589 public static Action nxMoveArpShaToArpThaAction() {
590 return nxMoveRegAction(new SrcNxArpShaCaseBuilder().setNxArpSha(Boolean.TRUE).build(),
591 new DstNxArpThaCaseBuilder().setNxArpTha(Boolean.TRUE).build(), 47, false);
594 public static Action nxMoveEthSrcToEthDstAction() {
595 return nxMoveRegAction(new SrcOfEthSrcCaseBuilder().setOfEthSrc(Boolean.TRUE).build(),
596 new DstOfEthDstCaseBuilder().setOfEthDst(Boolean.TRUE).build(), 47, false);
599 public static Action nxMoveArpSpaToArpTpaAction() {
600 return nxMoveRegAction(new SrcOfArpSpaCaseBuilder().setOfArpSpa(Boolean.TRUE).build(),
601 new DstOfArpTpaCaseBuilder().setOfArpTpa(Boolean.TRUE).build());
604 public static Action nxOutputRegAction(SrcChoice srcChoice) {
605 NxOutputReg r = new NxOutputRegBuilder().setSrc(
606 new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.SrcBuilder().setSrcChoice(
612 return new NxActionOutputRegNodesNodeTableFlowApplyActionsCaseBuilder().setNxOutputReg(r).build();
615 public static Action nxOutputRegAction(Class<? extends NxmNxReg> reg) {
616 return nxOutputRegAction(new SrcNxRegCaseBuilder().setNxReg(reg).build());
619 public static class RegMatch {
621 final Class<? extends NxmNxReg> reg;
624 public RegMatch(Class<? extends NxmNxReg> reg, Long value) {
630 public static RegMatch of(Class<? extends NxmNxReg> reg, Long value) {
631 return new RegMatch(reg, value);
635 public static void addNxRegMatch(MatchBuilder match, RegMatch... matches) {
636 ArrayList<ExtensionList> extensions = new ArrayList<>();
637 for (RegMatch rm : matches) {
638 Class<? extends ExtensionKey> key;
639 if (NxmNxReg0.class.equals(rm.reg)) {
640 key = NxmNxReg0Key.class;
641 } else if (NxmNxReg1.class.equals(rm.reg)) {
642 key = NxmNxReg1Key.class;
643 } else if (NxmNxReg2.class.equals(rm.reg)) {
644 key = NxmNxReg2Key.class;
645 } else if (NxmNxReg3.class.equals(rm.reg)) {
646 key = NxmNxReg3Key.class;
647 } else if (NxmNxReg4.class.equals(rm.reg)) {
648 key = NxmNxReg4Key.class;
649 } else if (NxmNxReg5.class.equals(rm.reg)) {
650 key = NxmNxReg5Key.class;
651 } else if (NxmNxReg6.class.equals(rm.reg)) {
652 key = NxmNxReg6Key.class;
654 key = NxmNxReg7Key.class;
656 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
657 .setNxmNxReg(new NxmNxRegBuilder().setReg(rm.reg).setValue(rm.value).build()).build();
658 extensions.add(new ExtensionListBuilder().setExtensionKey(key)
659 .setExtension(new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class, am).build())
662 GeneralAugMatchNodesNodeTableFlow m =
663 new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(extensions).build();
664 match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
667 public static void addNxNshc1RegMatch(MatchBuilder match, Long value) {
668 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
669 .setNxmNxNshc1(new NxmNxNshc1Builder().setValue(value).build()).build();
670 GeneralAugMatchNodesNodeTableFlow m = addExtensionKeyAugmentationMatcher(NxmNxNshc1Key.class, am, match);
671 match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
674 public static void addNxNshc2RegMatch(MatchBuilder match, Long value) {
675 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
676 .setNxmNxNshc2(new NxmNxNshc2Builder().setValue(value).build()).build();
677 GeneralAugMatchNodesNodeTableFlow m = addExtensionKeyAugmentationMatcher(NxmNxNshc2Key.class, am, match);
678 match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
681 public static void addNxNshc3RegMatch(MatchBuilder match, Long value) {
682 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
683 .setNxmNxNshc3(new NxmNxNshc3Builder().setValue(value).build()).build();
684 GeneralAugMatchNodesNodeTableFlow m = addExtensionKeyAugmentationMatcher(NxmNxNshc3Key.class, am, match);
685 match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
688 public static void addNxNshc4RegMatch(MatchBuilder match, Long value) {
689 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
690 .setNxmNxNshc4(new NxmNxNshc4Builder().setValue(value).build()).build();
691 GeneralAugMatchNodesNodeTableFlow m = addExtensionKeyAugmentationMatcher(NxmNxNshc4Key.class, am, match);
692 match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
695 public static void addNxTunIdMatch(MatchBuilder match, int tunId) {
696 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
697 .setNxmNxTunId(new NxmNxTunIdBuilder().setValue(BigInteger.valueOf(tunId)).build()).build();
698 GeneralAugMatchNodesNodeTableFlow m = addExtensionKeyAugmentationMatcher(NxmNxTunIdKey.class, am, match);
699 match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
702 public static void addNxTunIpv4DstMatch(MatchBuilder match, Ipv4Address ipv4Address) {
703 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
704 .setNxmNxTunIpv4Dst(new NxmNxTunIpv4DstBuilder().setIpv4Address(ipv4Address).build()).build();
705 GeneralAugMatchNodesNodeTableFlow m = addExtensionKeyAugmentationMatcher(NxmNxTunIpv4DstKey.class, am, match);
706 match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
709 public static void addNxNsiMatch(MatchBuilder match, short nsi) {
710 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
711 .setNxmNxNsi(new NxmNxNsiBuilder().setNsi(nsi).build()).build();
712 GeneralAugMatchNodesNodeTableFlow m = addExtensionKeyAugmentationMatcher(NxmNxNsiKey.class, am, match);
713 match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
716 public static void addNxNspMatch(MatchBuilder match, Long nsp) {
717 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
718 .setNxmNxNsp(new NxmNxNspBuilder().setValue(nsp).build()).build();
719 GeneralAugMatchNodesNodeTableFlow m = addExtensionKeyAugmentationMatcher(NxmNxNspKey.class, am, match);
720 match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, m);
723 public static EthernetMatch ethernetMatch(MacAddress srcMac, MacAddress dstMac, Long etherType) {
724 EthernetMatchBuilder emb = new EthernetMatchBuilder();
726 emb.setEthernetSource(new EthernetSourceBuilder().setAddress(srcMac).build());
728 emb.setEthernetDestination(new EthernetDestinationBuilder().setAddress(dstMac).build());
729 if (etherType != null)
730 emb.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(etherType)).build());
734 private static Action pushVlanAction() {
735 return new PushVlanActionCaseBuilder()
736 .setPushVlanAction(new PushVlanActionBuilder().setEthernetType(VLAN).build()).build();
739 private static Action popVlanAction() {
740 return new PopVlanActionCaseBuilder().setPopVlanAction(new PopVlanActionBuilder().build()).build();
743 private static Action setVlanId(int vlanId) {
744 return new SetVlanIdActionCaseBuilder()
745 .setSetVlanIdAction(new SetVlanIdActionBuilder().setVlanId(new VlanId(vlanId)).build()).build();
748 private static List<ExtensionList> getExistingGeneralAugMatchNodesNodeTableFlow(MatchBuilder match) {
749 ArrayList<ExtensionList> extensions = new ArrayList<>();
750 if (match.getAugmentation(GeneralAugMatchNodesNodeTableFlow.class) != null) {
751 List<ExtensionList> existingExtensions =
752 match.getAugmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList();
753 if (existingExtensions != null && !existingExtensions.isEmpty()) {
754 extensions.addAll(existingExtensions);
760 private static GeneralAugMatchNodesNodeTableFlow addExtensionKeyAugmentationMatcher(
761 Class<? extends ExtensionKey> key, NxAugMatchNodesNodeTableFlow am, MatchBuilder match) {
762 List<ExtensionList> extensions = getExistingGeneralAugMatchNodesNodeTableFlow(match);
763 extensions.add(new ExtensionListBuilder().setExtensionKey(key)
764 .setExtension(new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class, am).build())
766 return new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(extensions).build();
770 * Parse an OF port number from a node connector ID
773 * @return the port number
775 public static long getOfPortNum(NodeConnectorId id) {
776 String cnid = id.getValue();
777 int ci = cnid.lastIndexOf(':');
778 if (ci < 0 || (ci + 1 >= cnid.length()))
779 throw new NumberFormatException("Invalid node connector ID " + cnid);
780 return Long.parseLong(cnid.substring(ci + 1));