* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.openflowplugin.learningswitch;
-import com.google.common.collect.ImmutableList;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Map;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
/**
* Returns a {@link FlowBuilder} forwarding all packets to controller port.
*/
- public static FlowBuilder createDirectMacToMacFlow(final Uint8 tableId, final int priority, final MacAddress srcMac,
- final MacAddress dstMac, final NodeConnectorRef dstPort) {
+ public static FlowBuilder createDirectMacToMacFlow(final Uint8 tableId, final Uint16 priority,
+ final MacAddress srcMac, final MacAddress dstMac, final NodeConnectorRef dstPort) {
FlowBuilder macToMacFlow = new FlowBuilder()
.setTableId(tableId)
.setFlowName("mac2mac");
.build();
// Create an Apply Action
- ApplyActions applyActions = new ApplyActionsBuilder().setAction(ImmutableList.of(outputToControllerAction))
+ ApplyActions applyActions = new ApplyActionsBuilder()
+ .setAction(Map.of(outputToControllerAction.key(), outputToControllerAction))
.build();
// Wrap our Apply Action in an Instruction
.setEthernetMatch(ethernetMatch)
.build())
.setInstructions(new InstructionsBuilder()
- .setInstruction(ImmutableList.of(applyActionsInstruction))
+ .setInstruction(Map.of(applyActionsInstruction.key(), applyActionsInstruction))
.build())
.setPriority(priority)
.setBufferId(OFConstants.OFP_NO_BUFFER)
- .setHardTimeout(0)
- .setIdleTimeout(0)
+ .setHardTimeout(Uint16.ZERO)
+ .setIdleTimeout(Uint16.ZERO)
.setFlags(new FlowModFlags(false, false, false, false, false));
return macToMacFlow;
/**
* Returns a{@link FlowBuilder} forwarding all packets to controller port.
*/
- public static FlowBuilder createFwdAllToControllerFlow(final Uint8 tableId, final int priority,
+ public static FlowBuilder createFwdAllToControllerFlow(final Uint8 tableId, final Uint16 priority,
final FlowId flowId) {
// Create output action -> send to controller
OutputActionBuilder output = new OutputActionBuilder();
Uri controllerPort = new Uri(OutputPortValues.CONTROLLER.toString());
output.setOutputNodeConnector(controllerPort);
- ActionBuilder ab = new ActionBuilder();
- ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
- ab.setOrder(0);
- ab.withKey(new ActionKey(0));
-
- List<Action> actionList = new ArrayList<>();
- actionList.add(ab.build());
+ Action action = new ActionBuilder()
+ .setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build())
+ .withKey(new ActionKey(0))
+ .build();
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
- aab.setAction(actionList);
+ ApplyActionsBuilder aab = new ApplyActionsBuilder().setAction(Map.of(action.key(), action));
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
- ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
- ib.setOrder(0);
- ib.withKey(new InstructionKey(0));
+ Instruction instruction = new InstructionBuilder()
+ .setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build())
+ .withKey(new InstructionKey(0))
+ .build();
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<>();
- instructions.add(ib.build());
- isb.setInstruction(instructions);
+ InstructionsBuilder isb = new InstructionsBuilder()
+ .setInstruction(Map.of(instruction.key(), instruction));
MatchBuilder matchBuilder = new MatchBuilder();
FlowBuilder allToCtrlFlow = new FlowBuilder().setTableId(tableId).setFlowName("allPacketsToCtrl").setId(flowId)
.setInstructions(isb.build())
.setPriority(priority)
.setBufferId(OFConstants.OFP_NO_BUFFER)
- .setHardTimeout(0)
- .setIdleTimeout(0)
+ .setHardTimeout(Uint16.ZERO)
+ .setIdleTimeout(Uint16.ZERO)
.setFlags(new FlowModFlags(false, false, false, false, false));
return allToCtrlFlow;
*/
package org.opendaylight.openflowplugin.learningswitch;
-import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.HashMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(LearningSwitchHandlerSimpleImpl.class);
private static final byte[] ETH_TYPE_IPV4 = new byte[] { 0x08, 0x00 };
- private static final int DIRECT_FLOW_PRIORITY = 512;
+ private static final Uint16 DIRECT_FLOW_PRIORITY = Uint16.valueOf(512);
private final DataTreeChangeListenerRegistrationHolder registrationPublisher;
private final FlowCommitWrapper dataStoreAccessor;
FlowKey flowKey = new FlowKey(flowId);
InstanceIdentifier<Flow> flowPath = InstanceIdentifierUtils.createFlowPath(tablePath, flowKey);
- int priority = 0;
+ Uint16 priority = Uint16.ZERO;
// create flow in table with id = 0, priority = 4 (other params are
// defaulted in OFDataStoreUtil)
FlowBuilder allToCtrlFlow = FlowUtils.createFwdAllToControllerFlow(
Uint8 tableId = InstanceIdentifierUtils.getTableId(tablePath);
FlowBuilder srcToDstFlow = FlowUtils.createDirectMacToMacFlow(tableId, DIRECT_FLOW_PRIORITY, srcMac,
dstMac, destNodeConnector);
- srcToDstFlow.setCookie(new FlowCookie(BigInteger.valueOf(flowCookieInc.getAndIncrement())));
+ srcToDstFlow.setCookie(new FlowCookie(Uint64.valueOf(flowCookieInc.getAndIncrement())));
dataStoreAccessor.writeFlowToConfig(flowPath, srcToDstFlow.build());
}