Charles Chan
Committed by Gerrit Code Review

Support metadata in forwarding objective

Change-Id: Iaa916a8b2749bec6b9db42fe3f3765b922bd921b
......@@ -44,6 +44,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
private final TrafficTreatment treatment;
private final Operation op;
private final Optional<ObjectiveContext> context;
private final TrafficSelector meta;
private final int id;
......@@ -58,6 +59,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
this.treatment = builder.treatment;
this.op = builder.op;
this.context = Optional.ofNullable(builder.context);
this.meta = builder.meta;
this.id = Objects.hash(selector, flag, permanent,
timeout, appId, priority, nextId,
......@@ -122,9 +124,14 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
}
@Override
public TrafficSelector meta() {
return meta;
}
@Override
public int hashCode() {
return Objects.hash(selector, flag, permanent, timeout, appId,
priority, nextId, treatment, op);
priority, nextId, treatment, op, meta);
}
@Override
......@@ -142,7 +149,8 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
&& Objects.equals(this.priority, other.priority)
&& Objects.equals(this.nextId, other.nextId)
&& Objects.equals(this.treatment, other.treatment)
&& Objects.equals(this.op, other.op);
&& Objects.equals(this.op, other.op)
&& Objects.equals(this.meta, other.meta);
}
return false;
}
......@@ -156,6 +164,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
.add("selector", selector())
.add("treatment", treatment())
.add("nextId", nextId())
.add("meta", meta())
.add("flag", flag())
.add("appId", appId())
.add("permanent", permanent())
......@@ -192,6 +201,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
private TrafficTreatment treatment;
private Operation op;
private ObjectiveContext context;
private TrafficSelector meta;
// Creates an empty builder
private Builder() {
......@@ -208,6 +218,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
this.nextId = objective.nextId();
this.treatment = objective.treatment();
this.op = objective.op();
this.meta = objective.meta();
}
@Override
......@@ -260,6 +271,12 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
}
@Override
public Builder withMeta(TrafficSelector meta) {
this.meta = meta;
return this;
}
@Override
public ForwardingObjective add() {
checkNotNull(selector, "Must have a selector");
checkNotNull(flag, "A flag must be set");
......
......@@ -83,7 +83,7 @@ public interface FilteringObjective extends Objective {
Collection<Criterion> conditions();
/**
* Auxiliary optional information provided to the device-driver.Typically
* Auxiliary optional information provided to the device driver. Typically
* conveys information about changes (treatments) to packets that are
* permitted into the pipeline by the PERMIT filtering condition.
*
......
......@@ -87,6 +87,16 @@ public interface ForwardingObjective extends Objective {
Flag flag();
/**
* Auxiliary optional information provided to the device driver. Typically
* conveys information about selectors (matches) that are intended to
* use this Forwarding 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 forwarding objective builder.
*/
interface Builder extends Objective.Builder {
......@@ -124,6 +134,14 @@ public interface ForwardingObjective extends Objective {
Builder withFlag(Flag flag);
/**
* Set meta information related to this forwarding objective.
*
* @param selector match conditions
* @return an objective builder
*/
Builder withMeta(TrafficSelector selector);
/**
* Builds the forwarding objective that will be added.
*
* @return a forwarding objective
......
......@@ -85,7 +85,7 @@ public interface NextObjective extends Objective {
Type type();
/**
* Auxiliary optional information provided to the device-driver.Typically
* Auxiliary optional information provided to the device driver. Typically
* conveys information about selectors (matches) that are intended to
* use this Next Objective.
*
......