Open Kilda Java Documentation
ReplaceSchemeOutputCommands.java
Go to the documentation of this file.
1 /* Copyright 2017 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.floodlight.test.standard;
17 
18 import static java.util.Collections.singletonList;
21 
22 import net.floodlightcontroller.util.FlowModUtils;
23 import org.projectfloodlight.openflow.protocol.OFFlowAdd;
24 import org.projectfloodlight.openflow.protocol.match.MatchField;
25 import org.projectfloodlight.openflow.types.OFBufferId;
26 import org.projectfloodlight.openflow.types.OFPort;
27 import org.projectfloodlight.openflow.types.OFVlanVidMatch;
28 import org.projectfloodlight.openflow.types.U64;
29 
30 import java.util.Arrays;
31 
33  @Override
34  public OFFlowAdd ingressMatchVlanIdFlowMod(int inputPort, int outputPort, int inputVlan, int transitVlan,
35  long meterId, long cookie) {
36  return ofFactory.buildFlowAdd()
37  .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
38  .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
39  .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
40  .setBufferId(OFBufferId.NO_BUFFER)
41  .setPriority(DEFAULT_RULE_PRIORITY)
42  .setMatch(ofFactory.buildMatch()
43  .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
44  .setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(inputVlan))
45  .build())
46  .setInstructions(Arrays.asList(
47  ofFactory.instructions().buildMeter().setMeterId(meterId).build(),
48  ofFactory.instructions().applyActions(Arrays.asList(
49  ofFactory.actions().buildSetField()
50  .setField(ofFactory.oxms().buildVlanVid()
51  .setValue(OFVlanVidMatch.ofVlan(transitVlan))
52  .build())
53  .build(),
54  ofFactory.actions().buildOutput()
55  .setMaxLen(0xFFFFFFFF)
56  .setPort(OFPort.of(outputPort))
57  .build()))
58  .createBuilder()
59  .build()))
60  .setXid(0L)
61  .build();
62 
63  }
64 
65  @Override
66  public OFFlowAdd egressPushFlowMod(int inputPort, int outputPort, int transitVlan, int outputVlan, long cookie) {
67  return ofFactory.buildFlowAdd()
68  .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
69  .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
70  .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
71  .setBufferId(OFBufferId.NO_BUFFER)
72  .setPriority(DEFAULT_RULE_PRIORITY)
73  .setMatch(ofFactory.buildMatch()
74  .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
75  .setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(transitVlan))
76  .build())
77  .setInstructions(singletonList(
78  ofFactory.instructions().applyActions(Arrays.asList(
79  ofFactory.actions().buildSetField()
80  .setField(ofFactory.oxms().buildVlanVid()
81  .setValue(OFVlanVidMatch.ofVlan(outputVlan))
82  .build())
83  .build(),
84  ofFactory.actions().buildOutput()
85  .setMaxLen(0xFFFFFFFF)
86  .setPort(OFPort.of(outputPort))
87  .build()))
88  .createBuilder()
89  .build()))
90  .setXid(0L)
91  .build();
92  }
93 
94  @Override
95  public OFFlowAdd egressPopFlowMod(int inputPort, int outputPort, int transitVlan, long cookie) {
96  return egressNoneFlowMod(inputPort, outputPort, transitVlan, cookie);
97  }
98 
99  @Override
100  public OFFlowAdd egressReplaceFlowMod(int inputPort, int outputPort, int inputVlan, int outputVlan, long cookie) {
101  return egressPushFlowMod(inputPort, outputPort, inputVlan, outputVlan, cookie);
102  }
103 }
OFFlowAdd egressPopFlowMod(int inputPort, int outputPort, int transitVlan, long cookie)
OFFlowAdd egressNoneFlowMod(int inputPort, int outputPort, int transitVlan, long cookie)
def build()
Definition: plan-e.py:73
OFFlowAdd egressReplaceFlowMod(int inputPort, int outputPort, int inputVlan, int outputVlan, long cookie)
OFFlowAdd egressPushFlowMod(int inputPort, int outputPort, int transitVlan, int outputVlan, long cookie)
net
Definition: plan-b.py:46
OFFlowAdd ingressMatchVlanIdFlowMod(int inputPort, int outputPort, int inputVlan, int transitVlan, long meterId, long cookie)