diff options
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/flow')
6 files changed, 178 insertions, 12 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java index a628725c..6174cef6 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java @@ -237,6 +237,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { case NOACTION: case OUTPUT: case GROUP: + case QUEUE: case L0MODIFICATION: case L2MODIFICATION: case L3MODIFICATION: @@ -381,6 +382,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { } @Override + public Builder setQueue(long queueId) { + return add(Instructions.setQueue(queueId)); + } + + @Override public TrafficTreatment.Builder meter(MeterId meterId) { return add(Instructions.meterTraffic(meterId)); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java index 33753afa..c7fe8b85 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java @@ -190,14 +190,14 @@ public interface TrafficTreatment { /** * Push MPLS ether type. * - * @return a treatment builder. + * @return a treatment builder */ Builder pushMpls(); /** * Pops MPLS ether type. * - * @return a treatment builder. + * @return a treatment builder */ Builder popMpls(); @@ -205,7 +205,7 @@ public interface TrafficTreatment { * Pops MPLS ether type and set the new ethertype. * * @param etherType an ether type - * @return a treatment builder. + * @return a treatment builder * @deprecated in Drake Release */ @Deprecated @@ -215,22 +215,22 @@ public interface TrafficTreatment { * Pops MPLS ether type and set the new ethertype. * * @param etherType an ether type - * @return a treatment builder. + * @return a treatment builder */ Builder popMpls(EthType etherType); /** * Sets the mpls label. * - * @param mplsLabel MPLS label. - * @return a treatment builder. + * @param mplsLabel MPLS label + * @return a treatment builder */ Builder setMpls(MplsLabel mplsLabel); /** * Sets the mpls bottom-of-stack indicator bit. * - * @param mplsBos boolean to set BOS=1 (true) or BOS=0 (false). + * @param mplsBos boolean to set BOS=1 (true) or BOS=0 (false) * @return a treatment builder. */ Builder setMplsBos(boolean mplsBos); @@ -261,6 +261,14 @@ public interface TrafficTreatment { Builder group(GroupId groupId); /** + * Sets the Queue ID. + * + * @param queueId a queue ID + * @return a treatment builder + */ + Builder setQueue(long queueId); + + /** * Sets a meter to be used by this flow. * * @param meterId a meter id @@ -280,14 +288,14 @@ public interface TrafficTreatment { /** * Pops outermost VLAN tag. * - * @return a treatment builder. + * @return a treatment builder */ Builder popVlan(); /** * Pushes a new VLAN tag. * - * @return a treatment builder. + * @return a treatment builder */ Builder pushVlan(); @@ -327,8 +335,8 @@ public interface TrafficTreatment { /** * Sets the tunnel id. * - * @param tunnelId a tunnel id. - * @return a treatment builder. + * @param tunnelId a tunnel id + * @return a treatment builder */ Builder setTunnelId(long tunnelId); diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpPaCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpPaCriterion.java new file mode 100644 index 00000000..ba5a03d8 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpPaCriterion.java @@ -0,0 +1,80 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.net.flow.criteria; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +import org.onlab.packet.Ip4Address; + +/** + * Implementation of arp spa or tpa address criterion. + */ +public final class ArpPaCriterion implements Criterion { + private final Ip4Address ip; + private final Type type; + + /** + * Constructor. + * + * @param ip the Ip4 Address to match. + * @param type the match type. Should be one of the following: + * Type.ARP_SPA, Type.ARP_TPA + */ + ArpPaCriterion(Ip4Address ip, Type type) { + this.ip = ip; + this.type = type; + } + + @Override + public Type type() { + return this.type; + } + + /** + * Gets the Ip4 Address to match. + * + * @return the Ip4 Address to match + */ + public Ip4Address ip() { + return this.ip; + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("ip", ip).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type().ordinal(), ip); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof ArpPaCriterion) { + ArpPaCriterion that = (ArpPaCriterion) obj; + return Objects.equals(ip, that.ip) && + Objects.equals(type, that.type); + } + return false; + } +}
\ No newline at end of file diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java index ae940bdc..778d50a5 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java @@ -16,6 +16,7 @@ package org.onosproject.net.flow.criteria; import org.onlab.packet.EthType; +import org.onlab.packet.Ip4Address; import org.onlab.packet.Ip6Address; import org.onlab.packet.IpPrefix; import org.onlab.packet.MacAddress; @@ -25,11 +26,11 @@ import org.onlab.packet.VlanId; import org.onosproject.net.IndexedLambda; import org.onosproject.net.Lambda; import org.onosproject.net.OchSignal; +import org.onosproject.net.OchSignalType; import org.onosproject.net.OduSignalId; import org.onosproject.net.OduSignalType; import org.onosproject.net.PortNumber; import org.onosproject.net.flow.criteria.Criterion.Type; -import org.onosproject.net.OchSignalType; /** * Factory class to create various traffic selection criteria. @@ -508,6 +509,16 @@ public final class Criteria { return new OduSignalTypeCriterion(signalType); } + /** + * Creates a match on IPv4 source field using the specified value. + * + * @param ip ipv4 source value + * @return match criterion + */ + public static Criterion matchArpTpa(Ip4Address ip) { + return new ArpPaCriterion(ip, Type.ARP_TPA); + } + public static Criterion dummy() { return new DummyCriterion(); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java index eddbbb71..2f6a1cc1 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java @@ -49,6 +49,12 @@ public interface Instruction { GROUP, /** + * Signifies that the traffic should be enqueued to an already-configured + queue on a port. + */ + QUEUE, + + /** * Signifies that traffic should be metered according to a meter. */ METER, diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java index 26981e5e..8868bf7c 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java @@ -94,6 +94,17 @@ public final class Instructions { return new GroupInstruction(groupId); } + /** + * Creates a set-queue instruction. + * + * @param queueId Queue Id + * @return set-queue instruction + */ + public static SetQueueInstruction setQueue(final long queueId) { + checkNotNull(queueId, "queue ID cannot be null"); + return new SetQueueInstruction(queueId); + } + public static MeterInstruction meterTraffic(final MeterId meterId) { checkNotNull(meterId, "meter id cannot be null"); return new MeterInstruction(meterId); @@ -625,6 +636,50 @@ public final class Instructions { } /** + * Set-Queue Instruction. + */ + public static final class SetQueueInstruction implements Instruction { + private final long queueId; + + private SetQueueInstruction(long queueId) { + this.queueId = queueId; + } + + public long queueId() { + return queueId; + } + + @Override + public Type type() { + return Type.QUEUE; + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("queueId", queueId).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type().ordinal(), queueId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof SetQueueInstruction) { + SetQueueInstruction that = (SetQueueInstruction) obj; + return Objects.equals(queueId, that.queueId); + + } + return false; + } + } + + /** * A meter instruction. */ public static final class MeterInstruction implements Instruction { |