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 { ...@@ -44,6 +44,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
44 private final TrafficTreatment treatment; 44 private final TrafficTreatment treatment;
45 private final Operation op; 45 private final Operation op;
46 private final Optional<ObjectiveContext> context; 46 private final Optional<ObjectiveContext> context;
47 + private final TrafficSelector meta;
47 48
48 private final int id; 49 private final int id;
49 50
...@@ -58,6 +59,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective { ...@@ -58,6 +59,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
58 this.treatment = builder.treatment; 59 this.treatment = builder.treatment;
59 this.op = builder.op; 60 this.op = builder.op;
60 this.context = Optional.ofNullable(builder.context); 61 this.context = Optional.ofNullable(builder.context);
62 + this.meta = builder.meta;
61 63
62 this.id = Objects.hash(selector, flag, permanent, 64 this.id = Objects.hash(selector, flag, permanent,
63 timeout, appId, priority, nextId, 65 timeout, appId, priority, nextId,
...@@ -122,9 +124,14 @@ public final class DefaultForwardingObjective implements ForwardingObjective { ...@@ -122,9 +124,14 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
122 } 124 }
123 125
124 @Override 126 @Override
127 + public TrafficSelector meta() {
128 + return meta;
129 + }
130 +
131 + @Override
125 public int hashCode() { 132 public int hashCode() {
126 return Objects.hash(selector, flag, permanent, timeout, appId, 133 return Objects.hash(selector, flag, permanent, timeout, appId,
127 - priority, nextId, treatment, op); 134 + priority, nextId, treatment, op, meta);
128 } 135 }
129 136
130 @Override 137 @Override
...@@ -142,7 +149,8 @@ public final class DefaultForwardingObjective implements ForwardingObjective { ...@@ -142,7 +149,8 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
142 && Objects.equals(this.priority, other.priority) 149 && Objects.equals(this.priority, other.priority)
143 && Objects.equals(this.nextId, other.nextId) 150 && Objects.equals(this.nextId, other.nextId)
144 && Objects.equals(this.treatment, other.treatment) 151 && Objects.equals(this.treatment, other.treatment)
145 - && Objects.equals(this.op, other.op); 152 + && Objects.equals(this.op, other.op)
153 + && Objects.equals(this.meta, other.meta);
146 } 154 }
147 return false; 155 return false;
148 } 156 }
...@@ -156,6 +164,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective { ...@@ -156,6 +164,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
156 .add("selector", selector()) 164 .add("selector", selector())
157 .add("treatment", treatment()) 165 .add("treatment", treatment())
158 .add("nextId", nextId()) 166 .add("nextId", nextId())
167 + .add("meta", meta())
159 .add("flag", flag()) 168 .add("flag", flag())
160 .add("appId", appId()) 169 .add("appId", appId())
161 .add("permanent", permanent()) 170 .add("permanent", permanent())
...@@ -192,6 +201,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective { ...@@ -192,6 +201,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
192 private TrafficTreatment treatment; 201 private TrafficTreatment treatment;
193 private Operation op; 202 private Operation op;
194 private ObjectiveContext context; 203 private ObjectiveContext context;
204 + private TrafficSelector meta;
195 205
196 // Creates an empty builder 206 // Creates an empty builder
197 private Builder() { 207 private Builder() {
...@@ -208,6 +218,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective { ...@@ -208,6 +218,7 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
208 this.nextId = objective.nextId(); 218 this.nextId = objective.nextId();
209 this.treatment = objective.treatment(); 219 this.treatment = objective.treatment();
210 this.op = objective.op(); 220 this.op = objective.op();
221 + this.meta = objective.meta();
211 } 222 }
212 223
213 @Override 224 @Override
...@@ -260,6 +271,12 @@ public final class DefaultForwardingObjective implements ForwardingObjective { ...@@ -260,6 +271,12 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
260 } 271 }
261 272
262 @Override 273 @Override
274 + public Builder withMeta(TrafficSelector meta) {
275 + this.meta = meta;
276 + return this;
277 + }
278 +
279 + @Override
263 public ForwardingObjective add() { 280 public ForwardingObjective add() {
264 checkNotNull(selector, "Must have a selector"); 281 checkNotNull(selector, "Must have a selector");
265 checkNotNull(flag, "A flag must be set"); 282 checkNotNull(flag, "A flag must be set");
......
...@@ -83,7 +83,7 @@ public interface FilteringObjective extends Objective { ...@@ -83,7 +83,7 @@ public interface FilteringObjective extends Objective {
83 Collection<Criterion> conditions(); 83 Collection<Criterion> conditions();
84 84
85 /** 85 /**
86 - * Auxiliary optional information provided to the device-driver.Typically 86 + * Auxiliary optional information provided to the device driver. Typically
87 * conveys information about changes (treatments) to packets that are 87 * conveys information about changes (treatments) to packets that are
88 * permitted into the pipeline by the PERMIT filtering condition. 88 * permitted into the pipeline by the PERMIT filtering condition.
89 * 89 *
......
...@@ -87,6 +87,16 @@ public interface ForwardingObjective extends Objective { ...@@ -87,6 +87,16 @@ public interface ForwardingObjective extends Objective {
87 Flag flag(); 87 Flag flag();
88 88
89 /** 89 /**
90 + * Auxiliary optional information provided to the device driver. Typically
91 + * conveys information about selectors (matches) that are intended to
92 + * use this Forwarding Objective.
93 + *
94 + * @return a selector intended to pass meta information to the device driver.
95 + * Value may be null if no meta information is provided.
96 + */
97 + TrafficSelector meta();
98 +
99 + /**
90 * A forwarding objective builder. 100 * A forwarding objective builder.
91 */ 101 */
92 interface Builder extends Objective.Builder { 102 interface Builder extends Objective.Builder {
...@@ -124,6 +134,14 @@ public interface ForwardingObjective extends Objective { ...@@ -124,6 +134,14 @@ public interface ForwardingObjective extends Objective {
124 Builder withFlag(Flag flag); 134 Builder withFlag(Flag flag);
125 135
126 /** 136 /**
137 + * Set meta information related to this forwarding objective.
138 + *
139 + * @param selector match conditions
140 + * @return an objective builder
141 + */
142 + Builder withMeta(TrafficSelector selector);
143 +
144 + /**
127 * Builds the forwarding objective that will be added. 145 * Builds the forwarding objective that will be added.
128 * 146 *
129 * @return a forwarding objective 147 * @return a forwarding objective
......
...@@ -85,7 +85,7 @@ public interface NextObjective extends Objective { ...@@ -85,7 +85,7 @@ public interface NextObjective extends Objective {
85 Type type(); 85 Type type();
86 86
87 /** 87 /**
88 - * Auxiliary optional information provided to the device-driver.Typically 88 + * Auxiliary optional information provided to the device driver. Typically
89 * conveys information about selectors (matches) that are intended to 89 * conveys information about selectors (matches) that are intended to
90 * use this Next Objective. 90 * use this Next Objective.
91 * 91 *
......