blob: d258a74ecf09919f48b28bbc5ef36e9c1b475db8 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow;
alshabib7b2748f2014-09-16 20:21:11 -070017
Brian O'Connora3e5cd52015-12-05 15:59:19 -080018import com.google.common.annotations.Beta;
Hyunsun Moon7bfbc1c2016-04-05 16:40:43 -070019import com.google.common.base.Charsets;
20import com.google.common.hash.Funnel;
21import com.google.common.hash.HashCode;
22import com.google.common.hash.HashFunction;
23import com.google.common.hash.Hashing;
Brian O'Connorabafb502014-12-02 22:26:20 -080024import org.onosproject.core.ApplicationId;
25import org.onosproject.core.DefaultGroupId;
26import org.onosproject.core.GroupId;
27import org.onosproject.net.DeviceId;
alshabib7b2748f2014-09-16 20:21:11 -070028
Jonathan Hart607b1ff2015-05-05 10:55:51 -070029import java.util.Objects;
30
31import static com.google.common.base.MoreObjects.toStringHelper;
32import static com.google.common.base.Preconditions.checkArgument;
33import static com.google.common.base.Preconditions.checkNotNull;
34
alshabib7b2748f2014-09-16 20:21:11 -070035public class DefaultFlowRule implements FlowRule {
36
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070037 private final DeviceId deviceId;
38 private final int priority;
alshabib7b2748f2014-09-16 20:21:11 -070039 private final TrafficSelector selector;
40 private final TrafficTreatment treatment;
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070041 private final long created;
42
alshabib219ebaa2014-09-22 15:41:24 -070043 private final FlowId id;
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070044
alshabibdb774072015-04-20 13:13:51 -070045 private final Short appId;
alshabiba68eb962014-09-24 20:34:13 -070046
alshabibba5ac482014-10-02 17:15:20 -070047 private final int timeout;
Jonathan Hartbc4a7932014-10-21 11:46:00 -070048 private final boolean permanent;
Murat Parlakisikc6759e82016-06-29 03:22:22 -070049 private final int hardTimeout;
50 private final FlowRemoveReason reason;
Sho SHIMIZU75a5bd92014-11-25 11:22:56 -080051 private final GroupId groupId;
alshabib6eb438a2014-10-01 16:39:37 -070052
alshabibdb774072015-04-20 13:13:51 -070053 private final Integer tableId;
jcc3d4e14a2015-04-21 11:32:05 +080054 private final FlowRuleExtPayLoad payLoad;
alshabib1c319ff2014-10-04 20:29:09 -070055
alshabib1c319ff2014-10-04 20:29:09 -070056 public DefaultFlowRule(FlowRule rule) {
57 this.deviceId = rule.deviceId();
58 this.priority = rule.priority();
59 this.selector = rule.selector();
60 this.treatment = rule.treatment();
61 this.appId = rule.appId();
alshabib28204e52014-11-12 18:29:45 -080062 this.groupId = rule.groupId();
alshabib1c319ff2014-10-04 20:29:09 -070063 this.id = rule.id();
64 this.timeout = rule.timeout();
Murat Parlakisikc6759e82016-06-29 03:22:22 -070065 this.hardTimeout = rule.hardTimeout();
66 this.reason = rule.reason();
Jonathan Hartbc4a7932014-10-21 11:46:00 -070067 this.permanent = rule.isPermanent();
alshabib219ebaa2014-09-22 15:41:24 -070068 this.created = System.currentTimeMillis();
alshabibdb774072015-04-20 13:13:51 -070069 this.tableId = rule.tableId();
jcc3d4e14a2015-04-21 11:32:05 +080070 this.payLoad = rule.payLoad();
alshabibdb774072015-04-20 13:13:51 -070071 }
72
73 private DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
74 TrafficTreatment treatment, Integer priority,
Murat Parlakisikc6759e82016-06-29 03:22:22 -070075 FlowId flowId, Boolean permanent, Integer timeout, Integer hardTimeout,
76 FlowRemoveReason reason, Integer tableId) {
alshabibdb774072015-04-20 13:13:51 -070077
78 this.deviceId = deviceId;
79 this.selector = selector;
80 this.treatment = treatment;
81 this.priority = priority;
82 this.appId = (short) (flowId.value() >>> 48);
83 this.id = flowId;
84 this.permanent = permanent;
85 this.timeout = timeout;
Murat Parlakisikc6759e82016-06-29 03:22:22 -070086 this.hardTimeout = hardTimeout;
87 this.reason = reason;
alshabibdb774072015-04-20 13:13:51 -070088 this.tableId = tableId;
89 this.created = System.currentTimeMillis();
90
91
92 //FIXME: fields below will be removed.
Jonathan Hart607b1ff2015-05-05 10:55:51 -070093 this.groupId = new DefaultGroupId(0);
jcc3d4e14a2015-04-21 11:32:05 +080094 this.payLoad = null;
95 }
alshabibdb774072015-04-20 13:13:51 -070096
Murat Parlakisikc6759e82016-06-29 03:22:22 -070097
98
jcc3d4e14a2015-04-21 11:32:05 +080099 /**
100 * Support for the third party flow rule. Creates a flow rule of flow table.
101 *
102 * @param deviceId the identity of the device where this rule applies
103 * @param selector the traffic selector that identifies what traffic this
104 * rule
105 * @param treatment the traffic treatment that applies to selected traffic
106 * @param priority the flow rule priority given in natural order
107 * @param appId the application id of this flow
108 * @param timeout the timeout for this flow requested by an application
109 * @param permanent whether the flow is permanent i.e. does not time out
110 * @param payLoad 3rd-party origin private flow
111 */
112 public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
113 TrafficTreatment treatment, int priority,
114 ApplicationId appId, int timeout, boolean permanent,
115 FlowRuleExtPayLoad payLoad) {
Murat Parlakisikc6759e82016-06-29 03:22:22 -0700116 this(deviceId, selector, treatment, priority, appId, timeout, 0, permanent, payLoad);
117 }
118
119
120 /**
121 * Support for the third party flow rule. Creates a flow rule of flow table.
122 *
123 * @param deviceId the identity of the device where this rule applies
124 * @param selector the traffic selector that identifies what traffic this
125 * rule
126 * @param treatment the traffic treatment that applies to selected traffic
127 * @param priority the flow rule priority given in natural order
128 * @param appId the application id of this flow
129 * @param timeout the timeout for this flow requested by an application
130 * @param hardTimeout the hard timeout located switch's flow table for this flow requested by an application
131 * @param permanent whether the flow is permanent i.e. does not time out
132 * @param payLoad 3rd-party origin private flow
133 */
134 public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
135 TrafficTreatment treatment, int priority,
136 ApplicationId appId, int timeout, int hardTimeout, boolean permanent,
137 FlowRuleExtPayLoad payLoad) {
alshabib1c319ff2014-10-04 20:29:09 -0700138
Kavitha Alagesan14dc5132016-06-13 17:25:18 +0530139 checkArgument(priority >= MIN_PRIORITY, "Priority cannot be less than " +
140 MIN_PRIORITY);
141 checkArgument(priority <= MAX_PRIORITY, "Priority cannot be greater than " +
142 MAX_PRIORITY);
jcc3d4e14a2015-04-21 11:32:05 +0800143
144 this.deviceId = deviceId;
145 this.priority = priority;
146 this.selector = selector;
147 this.treatment = treatment;
148 this.appId = appId.id();
149 this.groupId = new DefaultGroupId(0);
150 this.timeout = timeout;
Murat Parlakisikc6759e82016-06-29 03:22:22 -0700151 this.reason = FlowRemoveReason.NO_REASON;
152 this.hardTimeout = hardTimeout;
jcc3d4e14a2015-04-21 11:32:05 +0800153 this.permanent = permanent;
154 this.tableId = 0;
155 this.created = System.currentTimeMillis();
156 this.payLoad = payLoad;
157
158 /*
159 * id consists of the following. | appId (16 bits) | groupId (16 bits) |
160 * flowId (32 bits) |
161 */
162 this.id = FlowId.valueOf((((long) this.appId) << 48)
163 | (((long) this.groupId.id()) << 32)
164 | (this.hash() & 0xffffffffL));
165 }
166
167 /**
168 * Support for the third party flow rule. Creates a flow rule of group
169 * table.
170 *
171 * @param deviceId the identity of the device where this rule applies
172 * @param selector the traffic selector that identifies what traffic this
173 * rule
174 * @param treatment the traffic treatment that applies to selected traffic
175 * @param priority the flow rule priority given in natural order
176 * @param appId the application id of this flow
177 * @param groupId the group id of this flow
178 * @param timeout the timeout for this flow requested by an application
179 * @param permanent whether the flow is permanent i.e. does not time out
180 * @param payLoad 3rd-party origin private flow
181 *
182 */
183 public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
184 TrafficTreatment treatment, int priority,
185 ApplicationId appId, GroupId groupId, int timeout,
186 boolean permanent, FlowRuleExtPayLoad payLoad) {
Murat Parlakisikc6759e82016-06-29 03:22:22 -0700187 this(deviceId, selector, treatment, priority, appId, groupId, timeout, 0, permanent, payLoad);
188 }
189
190 /**
191 * Support for the third party flow rule. Creates a flow rule of group
192 * table.
193 *
194 * @param deviceId the identity of the device where this rule applies
195 * @param selector the traffic selector that identifies what traffic this
196 * rule
197 * @param treatment the traffic treatment that applies to selected traffic
198 * @param priority the flow rule priority given in natural order
199 * @param appId the application id of this flow
200 * @param groupId the group id of this flow
201 * @param timeout the timeout for this flow requested by an application
202 * @param hardTimeout the hard timeout located switch's flow table for this flow requested by an application
203 * @param permanent whether the flow is permanent i.e. does not time out
204 * @param payLoad 3rd-party origin private flow
205 *
206 */
207 public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
208 TrafficTreatment treatment, int priority,
209 ApplicationId appId, GroupId groupId, int timeout, int hardTimeout,
210 boolean permanent, FlowRuleExtPayLoad payLoad) {
jcc3d4e14a2015-04-21 11:32:05 +0800211
Kavitha Alagesan14dc5132016-06-13 17:25:18 +0530212 checkArgument(priority >= MIN_PRIORITY, "Priority cannot be less than " +
213 MIN_PRIORITY);
214 checkArgument(priority <= MAX_PRIORITY, "Priority cannot be greater than " +
215 MAX_PRIORITY);
jcc3d4e14a2015-04-21 11:32:05 +0800216
217 this.deviceId = deviceId;
218 this.priority = priority;
219 this.selector = selector;
220 this.treatment = treatment;
221 this.appId = appId.id();
222 this.groupId = groupId;
223 this.timeout = timeout;
Murat Parlakisikc6759e82016-06-29 03:22:22 -0700224 this.reason = FlowRemoveReason.NO_REASON;
225 this.hardTimeout = hardTimeout;
jcc3d4e14a2015-04-21 11:32:05 +0800226 this.permanent = permanent;
227 this.created = System.currentTimeMillis();
228 this.tableId = 0;
229 this.payLoad = payLoad;
230
231 /*
232 * id consists of the following. | appId (16 bits) | groupId (16 bits) |
233 * flowId (32 bits) |
234 */
235 this.id = FlowId.valueOf((((long) this.appId) << 48)
236 | (((long) this.groupId.id()) << 32)
237 | (this.hash() & 0xffffffffL));
alshabiba7f7ca82014-09-22 11:41:23 -0700238 }
239
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700240 @Override
241 public FlowId id() {
242 return id;
alshabib7b2748f2014-09-16 20:21:11 -0700243 }
244
245 @Override
alshabib92c65ad2014-10-08 21:56:05 -0700246 public short appId() {
alshabiba68eb962014-09-24 20:34:13 -0700247 return appId;
248 }
249
250 @Override
Sho SHIMIZU75a5bd92014-11-25 11:22:56 -0800251 public GroupId groupId() {
alshabib28204e52014-11-12 18:29:45 -0800252 return groupId;
253 }
254
255 @Override
alshabib7b2748f2014-09-16 20:21:11 -0700256 public int priority() {
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700257 return priority;
alshabib7b2748f2014-09-16 20:21:11 -0700258 }
259
260 @Override
261 public DeviceId deviceId() {
262 return deviceId;
263 }
264
265 @Override
266 public TrafficSelector selector() {
267 return selector;
268 }
269
270 @Override
271 public TrafficTreatment treatment() {
272 return treatment;
273 }
274
alshabiba7f7ca82014-09-22 11:41:23 -0700275 @Override
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700276 /*
277 * The priority and statistics can change on a given treatment and selector
278 *
279 * (non-Javadoc)
jcc3d4e14a2015-04-21 11:32:05 +0800280 *
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700281 * @see java.lang.Object#equals(java.lang.Object)
282 */
Ayaka Koshibe08eabaa2014-09-17 14:59:25 -0700283 public int hashCode() {
Thomas Vachuska711db552015-06-02 16:35:26 -0700284 return Objects.hash(deviceId, selector, tableId, payLoad);
alshabiba68eb962014-09-24 20:34:13 -0700285 }
286
Thomas Vachuska711db552015-06-02 16:35:26 -0700287 //FIXME do we need this method in addition to hashCode()?
288 private int hash() {
289 return Objects.hash(deviceId, selector, tableId, payLoad);
Ayaka Koshibe08eabaa2014-09-17 14:59:25 -0700290 }
291
292 @Override
293 /*
294 * The priority and statistics can change on a given treatment and selector
295 *
296 * (non-Javadoc)
jcc3d4e14a2015-04-21 11:32:05 +0800297 *
Ayaka Koshibe08eabaa2014-09-17 14:59:25 -0700298 * @see java.lang.Object#equals(java.lang.Object)
299 */
300 public boolean equals(Object obj) {
alshabiba7f7ca82014-09-22 11:41:23 -0700301 if (this == obj) {
Ayaka Koshibeb55524f2014-09-18 09:59:24 -0700302 return true;
Ayaka Koshibe08eabaa2014-09-17 14:59:25 -0700303 }
alshabib54ce5892014-09-23 17:50:51 -0700304 if (obj instanceof DefaultFlowRule) {
alshabib219ebaa2014-09-22 15:41:24 -0700305 DefaultFlowRule that = (DefaultFlowRule) obj;
306 return Objects.equals(deviceId, that.deviceId) &&
alshabibba5ac482014-10-02 17:15:20 -0700307 Objects.equals(priority, that.priority) &&
Saurav Dascbe6de32015-03-01 18:30:46 -0800308 Objects.equals(selector, that.selector) &&
jcc3d4e14a2015-04-21 11:32:05 +0800309 Objects.equals(tableId, that.tableId)
310 && Objects.equals(payLoad, that.payLoad);
alshabiba7f7ca82014-09-22 11:41:23 -0700311 }
Ayaka Koshibeb55524f2014-09-18 09:59:24 -0700312 return false;
Ayaka Koshibe08eabaa2014-09-17 14:59:25 -0700313 }
314
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700315 @Override
Jonathan Hartf44e42c2015-08-04 09:58:46 -0700316 public boolean exactMatch(FlowRule rule) {
317 return this.equals(rule) &&
318 Objects.equals(this.id, rule.id()) &&
319 Objects.equals(this.treatment, rule.treatment());
320 }
321
322 @Override
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700323 public String toString() {
324 return toStringHelper(this)
alshabib8ca53902014-10-07 13:11:17 -0700325 .add("id", Long.toHexString(id.value()))
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700326 .add("deviceId", deviceId)
327 .add("priority", priority)
alshabibba5ac482014-10-02 17:15:20 -0700328 .add("selector", selector.criteria())
Jian Lif0325112016-03-03 17:11:25 -0800329 .add("treatment", treatment == null ? "N/A" : treatment)
alshabib08d98982015-04-21 16:25:50 -0700330 .add("tableId", tableId)
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700331 .add("created", created)
Ray Milkeyd13a37b2015-06-12 11:55:17 -0700332 .add("payLoad", payLoad)
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700333 .toString();
334 }
Ayaka Koshibe08eabaa2014-09-17 14:59:25 -0700335
alshabib6eb438a2014-10-01 16:39:37 -0700336 @Override
alshabibba5ac482014-10-02 17:15:20 -0700337 public int timeout() {
alshabib58747a62014-10-07 11:05:30 -0700338 return timeout;
alshabib6eb438a2014-10-01 16:39:37 -0700339 }
340
Murat Parlakisikc6759e82016-06-29 03:22:22 -0700341
342
343 @Override
344 public int hardTimeout() {
345 return hardTimeout;
346 }
347
348 @Override
349 public FlowRemoveReason reason() {
350 return reason;
351 }
352
Jonathan Hartbc4a7932014-10-21 11:46:00 -0700353 @Override
354 public boolean isPermanent() {
355 return permanent;
356 }
357
sangho11c30ac2015-01-22 14:30:55 -0800358 @Override
alshabibdb774072015-04-20 13:13:51 -0700359 public int tableId() {
360 return tableId;
361 }
362
Brian O'Connora3e5cd52015-12-05 15:59:19 -0800363 @Beta
364 public long created() {
365 return created;
366 }
367
alshabibdb774072015-04-20 13:13:51 -0700368 public static Builder builder() {
369 return new Builder();
370 }
371
alshabibd17abc22015-04-21 18:26:35 -0700372 public static final class Builder implements FlowRule.Builder {
alshabibdb774072015-04-20 13:13:51 -0700373
374 private FlowId flowId;
Jonathan Hart65d551b2015-09-22 09:49:09 -0700375 private ApplicationId appId;
alshabibdb774072015-04-20 13:13:51 -0700376 private Integer priority;
377 private DeviceId deviceId;
378 private Integer tableId = 0;
Charles Chancc4754d2015-12-10 15:58:18 -0800379 private TrafficSelector selector = DefaultTrafficSelector.builder().build();
380 private TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
alshabibdb774072015-04-20 13:13:51 -0700381 private Integer timeout;
382 private Boolean permanent;
Murat Parlakisikc6759e82016-06-29 03:22:22 -0700383 private Integer hardTimeout = 0;
384 private FlowRemoveReason reason = FlowRemoveReason.NO_REASON;
alshabibdb774072015-04-20 13:13:51 -0700385
386 @Override
387 public FlowRule.Builder withCookie(long cookie) {
388 this.flowId = FlowId.valueOf(cookie);
389 return this;
390 }
391
392 @Override
393 public FlowRule.Builder fromApp(ApplicationId appId) {
Jonathan Hart65d551b2015-09-22 09:49:09 -0700394 this.appId = appId;
alshabibdb774072015-04-20 13:13:51 -0700395 return this;
396 }
397
398 @Override
399 public FlowRule.Builder withPriority(int priority) {
400 this.priority = priority;
401 return this;
402 }
403
404 @Override
405 public FlowRule.Builder forDevice(DeviceId deviceId) {
406 this.deviceId = deviceId;
407 return this;
408 }
409
410 @Override
411 public FlowRule.Builder forTable(int tableId) {
412 this.tableId = tableId;
413 return this;
414 }
415
416 @Override
417 public FlowRule.Builder withSelector(TrafficSelector selector) {
418 this.selector = selector;
419 return this;
420 }
421
422 @Override
423 public FlowRule.Builder withTreatment(TrafficTreatment treatment) {
Jonathan Hart24e296b2016-01-12 14:47:07 -0800424 this.treatment = checkNotNull(treatment);
alshabibdb774072015-04-20 13:13:51 -0700425 return this;
426 }
427
428 @Override
429 public FlowRule.Builder makePermanent() {
430 this.timeout = 0;
431 this.permanent = true;
432 return this;
433 }
434
435 @Override
436 public FlowRule.Builder makeTemporary(int timeout) {
437 this.permanent = false;
438 this.timeout = timeout;
439 return this;
440 }
441
442 @Override
Murat Parlakisikc6759e82016-06-29 03:22:22 -0700443 public FlowRule.Builder withHardTimeout(int timeout) {
444 this.permanent = false;
445 this.hardTimeout = timeout;
446 this.timeout = timeout;
447 return this;
448 }
449
450 @Override
451 public FlowRule.Builder withReason(FlowRemoveReason reason) {
452 this.reason = reason;
453 return this;
454 }
455
456 @Override
alshabibdb774072015-04-20 13:13:51 -0700457 public FlowRule build() {
alshabibb05be2d2016-04-11 12:52:36 -0700458 FlowId localFlowId;
Jian Li8bac5762016-02-09 17:23:09 -0800459 checkArgument((flowId != null) ^ (appId != null), "Either an application" +
alshabibdb774072015-04-20 13:13:51 -0700460 " id or a cookie must be supplied");
Jonathan Hart65d551b2015-09-22 09:49:09 -0700461 checkNotNull(selector, "Traffic selector cannot be null");
462 checkArgument(timeout != null || permanent != null, "Must either have " +
alshabibdb774072015-04-20 13:13:51 -0700463 "a timeout or be permanent");
Jonathan Hart65d551b2015-09-22 09:49:09 -0700464 checkNotNull(deviceId, "Must refer to a device");
465 checkNotNull(priority, "Priority cannot be null");
Saurav Das3ea46622015-04-22 14:01:34 -0700466 checkArgument(priority >= MIN_PRIORITY, "Priority cannot be less than " +
alshabibdb774072015-04-20 13:13:51 -0700467 MIN_PRIORITY);
Kavitha Alagesan14dc5132016-06-13 17:25:18 +0530468 checkArgument(priority <= MAX_PRIORITY, "Priority cannot be greater than " +
469 MAX_PRIORITY);
Jonathan Hart65d551b2015-09-22 09:49:09 -0700470 // Computing a flow ID based on appId takes precedence over setting
471 // the flow ID directly
472 if (appId != null) {
alshabibb05be2d2016-04-11 12:52:36 -0700473 localFlowId = computeFlowId(appId);
474 } else {
475 localFlowId = flowId;
Jonathan Hart65d551b2015-09-22 09:49:09 -0700476 }
477
alshabibdb774072015-04-20 13:13:51 -0700478 return new DefaultFlowRule(deviceId, selector, treatment, priority,
Murat Parlakisikc6759e82016-06-29 03:22:22 -0700479 localFlowId, permanent, timeout, hardTimeout, reason, tableId);
alshabibdb774072015-04-20 13:13:51 -0700480 }
481
482 private FlowId computeFlowId(ApplicationId appId) {
483 return FlowId.valueOf((((long) appId.id()) << 48)
484 | (hash() & 0xffffffffL));
485 }
486
487 private int hash() {
Hyunsun Moon7bfbc1c2016-04-05 16:40:43 -0700488 Funnel<TrafficSelector> selectorFunnel = (from, into) -> from.criteria()
Hyunsun Moon7bfbc1c2016-04-05 16:40:43 -0700489 .forEach(c -> into.putString(c.toString(), Charsets.UTF_8));
alshabibdb774072015-04-20 13:13:51 -0700490
Hyunsun Moon7bfbc1c2016-04-05 16:40:43 -0700491 HashFunction hashFunction = Hashing.murmur3_32();
492 HashCode hashCode = hashFunction.newHasher()
493 .putString(deviceId.toString(), Charsets.UTF_8)
494 .putObject(selector, selectorFunnel)
495 .putInt(priority)
496 .putInt(tableId)
497 .hash();
498
499 return hashCode.asInt();
500 }
alshabibdb774072015-04-20 13:13:51 -0700501 }
502
jcc3d4e14a2015-04-21 11:32:05 +0800503 @Override
504 public FlowRuleExtPayLoad payLoad() {
505 return payLoad;
506 }
507
alshabib7b2748f2014-09-16 20:21:11 -0700508}