aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective')
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java48
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java65
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java55
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java25
4 files changed, 188 insertions, 5 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
index 0abf5abe..af481805 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
@@ -16,6 +16,7 @@
package org.onosproject.net.flowobjective;
import com.google.common.annotations.Beta;
+
import org.onosproject.core.ApplicationId;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
@@ -119,6 +120,53 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
return context;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hash(selector, flag, permanent,
+ timeout, appId, priority, nextId,
+ treatment, op);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof DefaultForwardingObjective)) {
+ return false;
+ }
+ final DefaultForwardingObjective other = (DefaultForwardingObjective) obj;
+ boolean nextEq = false, treatmentEq = false;
+ if (this.selector.equals(other.selector) &&
+ this.flag == other.flag &&
+ this.permanent == other.permanent &&
+ this.timeout == other.timeout &&
+ this.appId.equals(other.appId) &&
+ this.priority == other.priority &&
+ this.op == other.op) {
+ if (this.nextId != null && other.nextId != null) {
+ nextEq = this.nextId == other.nextId;
+ }
+ if (this.treatment != null && other.treatment != null) {
+ treatmentEq = this.treatment.equals(other.treatment);
+ }
+ if (nextEq && treatmentEq) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Returns a new builder.
*
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
index 20e89295..4701589f 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
@@ -18,6 +18,7 @@ package org.onosproject.net.flowobjective;
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
import org.onosproject.core.ApplicationId;
+import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import java.util.Collection;
@@ -39,6 +40,7 @@ public final class DefaultNextObjective implements NextObjective {
private final Integer id;
private final Operation op;
private final Optional<ObjectiveContext> context;
+ private final TrafficSelector meta;
private DefaultNextObjective(Builder builder) {
this.treatments = builder.treatments;
@@ -47,6 +49,7 @@ public final class DefaultNextObjective implements NextObjective {
this.id = builder.id;
this.op = builder.op;
this.context = Optional.ofNullable(builder.context);
+ this.meta = builder.meta;
}
@Override
@@ -94,6 +97,11 @@ public final class DefaultNextObjective implements NextObjective {
return context;
}
+ @Override
+ public TrafficSelector meta() {
+ return meta;
+ }
+
/**
* Returns a new builder.
*
@@ -111,6 +119,7 @@ public final class DefaultNextObjective implements NextObjective {
private List<TrafficTreatment> treatments;
private Operation op;
private ObjectiveContext context;
+ private TrafficSelector meta;
private final ImmutableList.Builder<TrafficTreatment> listBuilder
= ImmutableList.builder();
@@ -172,6 +181,12 @@ public final class DefaultNextObjective implements NextObjective {
}
@Override
+ public Builder setMeta(TrafficSelector meta) {
+ this.meta = meta;
+ return this;
+ }
+
+ @Override
public NextObjective add() {
treatments = listBuilder.build();
op = Operation.ADD;
@@ -218,5 +233,55 @@ public final class DefaultNextObjective implements NextObjective {
return new DefaultNextObjective(this);
}
+
+ @Override
+ public NextObjective addToExisting() {
+ treatments = listBuilder.build();
+ op = Operation.ADD_TO_EXISTING;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+ checkArgument(!treatments.isEmpty(), "Must have at least one treatment");
+
+ return new DefaultNextObjective(this);
+ }
+
+ @Override
+ public NextObjective removeFromExisting() {
+ treatments = listBuilder.build();
+ op = Operation.REMOVE_FROM_EXISTING;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+
+ return new DefaultNextObjective(this);
+ }
+
+ @Override
+ public NextObjective addToExisting(ObjectiveContext context) {
+ treatments = listBuilder.build();
+ op = Operation.ADD_TO_EXISTING;
+ this.context = context;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+ checkArgument(!treatments.isEmpty(), "Must have at least one treatment");
+
+ return new DefaultNextObjective(this);
+ }
+
+ @Override
+ public NextObjective removeFromExisting(ObjectiveContext context) {
+ treatments = listBuilder.build();
+ op = Operation.REMOVE_FROM_EXISTING;
+ this.context = context;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+
+ return new DefaultNextObjective(this);
+ }
+
}
+
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
index 1350d7a1..08916eb2 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
@@ -17,6 +17,7 @@ package org.onosproject.net.flowobjective;
import com.google.common.annotations.Beta;
import org.onosproject.core.ApplicationId;
+import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import java.util.Collection;
@@ -34,7 +35,7 @@ import java.util.Collection;
* - Failover
* - Simple
*
- * These types will indicate to the driver what the intended behaviour is.
+ * These types will indicate to the driver what the intended behavior is.
* For example, a broadcast next objective with a collection of output
* treatments will indicate to a driver that all output actions are expected
* to be executed simultaneously. The driver is then free to implement this
@@ -84,6 +85,16 @@ public interface NextObjective extends Objective {
Type type();
/**
+ * Auxiliary optional information provided to the device-driver.Typically
+ * conveys information about selectors (matches) that are intended to
+ * use this Next Objective.
+ *
+ * @return a selector intended to pass meta information to the device driver.
+ * Value may be null if no meta information is provided.
+ */
+ TrafficSelector meta();
+
+ /**
* A next step builder.
*/
interface Builder extends Objective.Builder {
@@ -131,6 +142,14 @@ public interface NextObjective extends Objective {
Builder withPriority(int priority);
/**
+ * Set meta information related to this next objective.
+ *
+ * @param selector match conditions
+ * @return an objective builder
+ */
+ Builder setMeta(TrafficSelector selector);
+
+ /**
* Builds the next objective that will be added.
*
* @return a next objective
@@ -162,6 +181,40 @@ public interface NextObjective extends Objective {
*/
NextObjective remove(ObjectiveContext context);
+ /**
+ * Build the next objective that will be added, with {@link Operation}
+ * ADD_TO_EXISTING.
+ *
+ * @return a next objective
+ */
+ NextObjective addToExisting();
+
+ /**
+ * Build the next objective that will be removed, with {@link Operation}
+ * REMOVE_FROM_EXISTING.
+ *
+ * @return a next objective
+ */
+ NextObjective removeFromExisting();
+
+ /**
+ * Builds the next objective that will be added, with {@link Operation}
+ * ADD_TO_EXISTING. The context will be used to notify the calling application.
+ *
+ * @param context an objective context
+ * @return a next objective
+ */
+ NextObjective addToExisting(ObjectiveContext context);
+
+ /**
+ * Builds the next objective that will be removed, with {@link Operation}
+ * REMOVE_FROM_EXISTING. The context will be used to notify the calling application.
+ *
+ * @param context an objective context
+ * @return a next objective
+ */
+ NextObjective removeFromExisting(ObjectiveContext context);
+
}
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
index 6ac7a7a2..b1d73a7c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
@@ -21,7 +21,7 @@ import org.onosproject.core.ApplicationId;
import java.util.Optional;
/**
- * Base representation of an flow description.
+ * Base representation of a flow-objective description.
*/
@Beta
public interface Objective {
@@ -35,14 +35,30 @@ public interface Objective {
*/
enum Operation {
/**
- * Adds the objective.
+ * Adds the objective. Can be used for any flow objective. For forwarding
+ * and filtering objectives, existing objectives with identical selector
+ * and priority fields (but different treatments or next) will be replaced.
+ * For next objectives, if modification is desired, ADD will not
+ * do anything - use ADD_TO_EXISTING.
*/
ADD,
/**
- * Removes the objective.
+ * Removes the objective. Can be used for any flow objective.
*/
- REMOVE
+ REMOVE,
+
+ /**
+ * Add to an existing Next Objective. Should not be used for any other
+ * objective.
+ */
+ ADD_TO_EXISTING,
+
+ /**
+ * Remove from an existing Next Objective. Should not be used for any
+ * other objective.
+ */
+ REMOVE_FROM_EXISTING
}
/**
@@ -129,6 +145,7 @@ public interface Objective {
* @return an objective builder
*/
Builder withPriority(int priority);
+
}
}