16 package org.openkilda.floodlight.test.standard;
18 import static java.util.Collections.singletonList;
22 import static org.projectfloodlight.openflow.protocol.OFMeterFlags.BURST;
23 import static org.projectfloodlight.openflow.protocol.OFMeterFlags.KBPS;
24 import static org.projectfloodlight.openflow.protocol.OFMeterModCommand.ADD;
26 import net.floodlightcontroller.util.FlowModUtils;
28 import org.projectfloodlight.openflow.protocol.OFFactory;
29 import org.projectfloodlight.openflow.protocol.OFFlowAdd;
30 import org.projectfloodlight.openflow.protocol.OFMeterMod;
31 import org.projectfloodlight.openflow.protocol.match.MatchField;
32 import org.projectfloodlight.openflow.types.EthType;
33 import org.projectfloodlight.openflow.types.OFBufferId;
34 import org.projectfloodlight.openflow.types.OFPort;
35 import org.projectfloodlight.openflow.types.OFVlanVidMatch;
36 import org.projectfloodlight.openflow.types.U64;
38 import java.util.Arrays;
39 import java.util.HashSet;
44 OFFlowAdd
egressReplaceFlowMod(
int inputPort,
int outputPort,
int inputVlan,
int outputVlan,
long cookie);
46 OFFlowAdd
egressPopFlowMod(
int inputPort,
int outputPort,
int transitVlanId,
long cookie);
48 OFFlowAdd
egressPushFlowMod(
int inputPort,
int outputPort,
int transitVlanId,
int outputVlan,
long cookie);
50 OFFlowAdd
egressNoneFlowMod(
int inputPort,
int outputPort,
int transitVlanId,
long cookie);
53 long meterId,
long cookie);
56 long meterId,
long cookie);
59 long meterId,
long cookie) {
63 default OFFlowAdd
ingressNoneFlowMod(
int inputPort,
int outputPort,
int transitVlan,
long meterId,
long cookie) {
67 default OFFlowAdd
ingressPushFlowMod(
int inputPort,
int outputPort,
int transitVlan,
long meterId,
long cookie) {
71 default OFFlowAdd
ingressPopFlowMod(
int inputPort,
int outputPort,
int inputVlan,
int transitVlan,
72 long meterId,
long cookie) {
76 default OFFlowAdd
transitFlowMod(
int inputPort,
int outputPort,
int transitVlan,
long cookie) {
78 .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
79 .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
80 .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
81 .setBufferId(OFBufferId.NO_BUFFER)
82 .setPriority(DEFAULT_RULE_PRIORITY)
84 .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
85 .setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(transitVlan))
87 .setInstructions(singletonList(
88 ofFactory.instructions().applyActions(singletonList(
90 .setMaxLen(0xFFFFFFFF)
91 .setPort(OFPort.of(outputPort))
100 long meterId,
long cookie) {
102 .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
103 .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
104 .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
105 .setBufferId(OFBufferId.NO_BUFFER)
106 .setPriority(DEFAULT_RULE_PRIORITY)
108 .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
109 .setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(inputVlan))
111 .setInstructions(Arrays.asList(
112 ofFactory.instructions().buildMeter().setMeterId(meterId).build(),
113 ofFactory.instructions().applyActions(Arrays.asList(
115 .setField(
ofFactory.oxms().buildVlanVid()
116 .setValue(OFVlanVidMatch.ofVlan(outputVlan))
120 .setMaxLen(0xFFFFFFFF)
121 .setPort(OFPort.of(outputPort))
131 .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
132 .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
133 .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
134 .setBufferId(OFBufferId.NO_BUFFER)
135 .setPriority(DEFAULT_RULE_PRIORITY)
137 .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
139 .setInstructions(Arrays.asList(
140 ofFactory.instructions().buildMeter().setMeterId(meterId).build(),
141 ofFactory.instructions().applyActions(singletonList(
143 .setMaxLen(0xFFFFFFFF)
144 .setPort(OFPort.of(outputPort))
152 default OFFlowAdd
oneSwitchPopFlowMod(
int inputPort,
int outputPort,
int inputVlan,
long meterId,
long cookie) {
154 .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
155 .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
156 .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
157 .setBufferId(OFBufferId.NO_BUFFER)
158 .setPriority(DEFAULT_RULE_PRIORITY)
160 .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
161 .setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(inputVlan))
163 .setInstructions(Arrays.asList(
164 ofFactory.instructions().buildMeter().setMeterId(meterId).build(),
165 ofFactory.instructions().applyActions(Arrays.asList(
168 .setMaxLen(0xFFFFFFFF)
169 .setPort(OFPort.of(outputPort))
177 default OFFlowAdd
oneSwitchPushFlowMod(
int inputPort,
int outputPort,
int outputVlan,
long meterId,
long cookie) {
179 .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
180 .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
181 .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
182 .setBufferId(OFBufferId.NO_BUFFER)
183 .setPriority(DEFAULT_RULE_PRIORITY)
185 .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
187 .setInstructions(Arrays.asList(
188 ofFactory.instructions().buildMeter().setMeterId(meterId).build(),
189 ofFactory.instructions().applyActions(Arrays.asList(
191 .setEthertype(EthType.of(ETH_TYPE))
194 .setField(
ofFactory.oxms().buildVlanVid()
195 .setValue(OFVlanVidMatch.ofVlan(outputVlan))
199 .setMaxLen(0xFFFFFFFF)
200 .setPort(OFPort.of(outputPort))
208 default OFMeterMod
installMeter(
long bandwidth,
long burstSize,
long meterId) {
212 .setMeters(singletonList(
ofFactory.meterBands()
215 .setBurstSize(burstSize).build()))
216 .setFlags(
new HashSet<>(Arrays.asList(KBPS, BURST)))
default OFFlowAdd ingressPopFlowMod(int inputPort, int outputPort, int inputVlan, int transitVlan, long meterId, long cookie)
OFFlowAdd egressPushFlowMod(int inputPort, int outputPort, int transitVlanId, int outputVlan, long cookie)
default OFFlowAdd oneSwitchReplaceFlowMod(int inputPort, int outputPort, int inputVlan, int outputVlan, long meterId, long cookie)
default OFMeterMod installMeter(long bandwidth, long burstSize, long meterId)
OFFlowAdd ingressNoMatchVlanIdFlowMod(int inputPort, int outputPort, int transitVlan, long meterId, long cookie)
OFFlowAdd egressPopFlowMod(int inputPort, int outputPort, int transitVlanId, long cookie)
static final int ETH_TYPE
static final int DEFAULT_RULE_PRIORITY
default OFFlowAdd ingressNoneFlowMod(int inputPort, int outputPort, int transitVlan, long meterId, long cookie)
default OFFlowAdd oneSwitchPushFlowMod(int inputPort, int outputPort, int outputVlan, long meterId, long cookie)
default OFFlowAdd oneSwitchNoneFlowMod(int inputPort, int outputPort, long meterId, long cookie)
default OFFlowAdd transitFlowMod(int inputPort, int outputPort, int transitVlan, long cookie)
default OFFlowAdd oneSwitchPopFlowMod(int inputPort, int outputPort, int inputVlan, long meterId, long cookie)
default OFFlowAdd ingressReplaceFlowMod(int inputPort, int outputPort, int inputVlan, int transitVlan, long meterId, long cookie)
default OFFlowAdd ingressPushFlowMod(int inputPort, int outputPort, int transitVlan, long meterId, long cookie)
OFFlowAdd ingressMatchVlanIdFlowMod(int inputPort, int outputPort, int inputVlan, int transitVlan, long meterId, long cookie)
OFFlowAdd egressNoneFlowMod(int inputPort, int outputPort, int transitVlanId, long cookie)
static final long FLOW_COOKIE_MASK
OFFlowAdd egressReplaceFlowMod(int inputPort, int outputPort, int inputVlan, int outputVlan, long cookie)