Thomas Vachuska

ONOS-537 Provided maxLen setting to make sure packet data is sent with packet-in…

… message. Also added support for TrafficTreatment.Builder.punt();

Change-Id: I9f5577cf83b4d25c79459e56492be747a245397c
......@@ -37,6 +37,7 @@ public final class PortNumber {
public static final PortNumber FLOOD = new PortNumber(-5);
public static final PortNumber ALL = new PortNumber(-4);
public static final PortNumber LOCAL = new PortNumber(-2);
public static final PortNumber CONTROLLER = new PortNumber(-3);
private final long number;
......
......@@ -15,19 +15,18 @@
*/
package org.onosproject.net.flow;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
/**
* Default traffic treatment implementation.
......@@ -152,8 +151,13 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
}
@Override
public void drop() {
add(Instructions.createDrop());
public Builder drop() {
return add(Instructions.createDrop());
}
@Override
public Builder punt() {
return add(Instructions.createOutput(PortNumber.CONTROLLER));
}
@Override
......
......@@ -49,9 +49,18 @@ public interface TrafficTreatment {
Builder add(Instruction instruction);
/**
* Adds a drop instruction and does not return a builder.
* Adds a drop instruction.
*
* @return a treatment builder
*/
public Builder drop();
/**
* Adds a punt-to-controller instruction.
*
* @return a treatment builder
*/
public void drop();
public Builder punt();
/**
* Set the output port.
......@@ -111,18 +120,21 @@ public interface TrafficTreatment {
/**
* Push MPLS ether type.
*
* @return a treatment builder.
*/
public Builder pushMpls();
/**
* Pops MPLS ether type.
*
* @return a treatment builder.
*/
public Builder popMpls();
/**
* Sets the mpls label.
*
* @param mplsLabel MPLS label.
* @return a treatment builder.
*/
......
......@@ -15,11 +15,8 @@
*/
package org.onosproject.provider.of.flow.impl;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import org.onlab.packet.Ip4Address;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.instructions.Instruction;
......@@ -30,13 +27,13 @@ import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanId
import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
import org.onlab.packet.Ip4Address;
import org.projectfloodlight.openflow.protocol.OFFactory;
import org.projectfloodlight.openflow.protocol.OFFlowAdd;
import org.projectfloodlight.openflow.protocol.OFFlowDelete;
import org.projectfloodlight.openflow.protocol.OFFlowMod;
import org.projectfloodlight.openflow.protocol.OFFlowModFlags;
import org.projectfloodlight.openflow.protocol.action.OFAction;
import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
import org.projectfloodlight.openflow.protocol.match.Match;
import org.projectfloodlight.openflow.types.IPv4Address;
import org.projectfloodlight.openflow.types.MacAddress;
......@@ -48,12 +45,18 @@ import org.projectfloodlight.openflow.types.VlanVid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
/**
* Flow mod builder for OpenFlow 1.0.
*/
public class FlowModBuilderVer10 extends FlowModBuilder {
private static final Logger log = LoggerFactory.getLogger(FlowModBuilderVer10.class);
private static final int OFPCML_NO_BUFFER = 0xffff;
private final TrafficTreatment treatment;
......@@ -151,8 +154,12 @@ public class FlowModBuilderVer10 extends FlowModBuilder {
break;
case OUTPUT:
OutputInstruction out = (OutputInstruction) i;
acts.add(factory().actions().buildOutput().setPort(
OFPort.of((int) out.port().toLong())).build());
OFActionOutput.Builder action = factory().actions().buildOutput()
.setPort(OFPort.of((int) out.port().toLong()));
if (out.port().equals(PortNumber.CONTROLLER)) {
action.setMaxLen(OFPCML_NO_BUFFER);
}
acts.add(action.build());
break;
case L0MODIFICATION:
case GROUP:
......