blob: 9b76f32867fa38e3eb4deff05bf3852769b7bc41 [file] [log] [blame]
tom8bb16062014-09-12 14:47:46 -07001package org.onlab.onos.net.flow;
2
alshabiba68eb962014-09-24 20:34:13 -07003import org.onlab.onos.ApplicationId;
tom8bb16062014-09-12 14:47:46 -07004import org.onlab.onos.net.DeviceId;
5
tom8bb16062014-09-12 14:47:46 -07006/**
7 * Represents a generalized match & action pair to be applied to
8 * an infrastucture device.
9 */
10public interface FlowRule {
11
alshabibba5ac482014-10-02 17:15:20 -070012 static final int MAX_TIMEOUT = 60;
alshabiba0e04982014-10-03 13:03:19 -070013 static final int MIN_PRIORITY = 0;
alshabiba7f7ca82014-09-22 11:41:23 -070014
15 public enum FlowRuleState {
16 /**
17 * Indicates that this rule has been created.
18 */
19 CREATED,
20
21 /**
22 * Indicates that this rule has been submitted for addition.
23 * Not necessarily in the flow table.
24 */
25 PENDING_ADD,
26
27 /**
28 * Rule has been added which means it is in the flow table.
29 */
30 ADDED,
31
32 /**
33 * Flow has been marked for removal, might still be in flow table.
34 */
35 PENDING_REMOVE,
36
37 /**
38 * Flow has been removed from flow table and can be purged.
39 */
40 REMOVED
41 }
42
43 /**
44 * Returns the flow rule state.
45 *
46 * @return flow rule state
47 */
48 FlowRuleState state();
49
alshabib369d2942014-09-12 17:59:35 -070050 //TODO: build cookie value
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070051 /**
52 * Returns the ID of this flow.
53 *
54 * @return the flow ID
55 */
56 FlowId id();
alshabib369d2942014-09-12 17:59:35 -070057
tom8bb16062014-09-12 14:47:46 -070058 /**
alshabiba68eb962014-09-24 20:34:13 -070059 * Returns the application id of this flow.
60 *
61 * @return an applicationId
62 */
63 ApplicationId appId();
64
65 /**
tom8bb16062014-09-12 14:47:46 -070066 * Returns the flow rule priority given in natural order; higher numbers
67 * mean higher priorities.
68 *
69 * @return flow rule priority
70 */
71 int priority();
72
73 /**
74 * Returns the identity of the device where this rule applies.
75 *
76 * @return device identifier
77 */
78 DeviceId deviceId();
79
80 /**
81 * Returns the traffic selector that identifies what traffic this
82 * rule should apply to.
83 *
84 * @return traffic selector
85 */
86 TrafficSelector selector();
87
88 /**
89 * Returns the traffic treatment that applies to selected traffic.
90 *
91 * @return traffic treatment
92 */
alshabib369d2942014-09-12 17:59:35 -070093 TrafficTreatment treatment();
tom8bb16062014-09-12 14:47:46 -070094
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070095 /**
96 * Returns the number of milliseconds this flow rule has been applied.
97 *
98 * @return number of millis
99 */
alshabiba0e04982014-10-03 13:03:19 -0700100 long life();
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700101
102 /**
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700103 * Returns the number of packets this flow rule has matched.
104 *
105 * @return number of packets
106 */
107 long packets();
108
109 /**
110 * Returns the number of bytes this flow rule has matched.
111 *
112 * @return number of bytes
113 */
114 long bytes();
115
alshabib6eb438a2014-10-01 16:39:37 -0700116 /**
alshabibba5ac482014-10-02 17:15:20 -0700117 * Returns the timeout for this flow requested by an application.
118 * @return integer value of the timeout
alshabib6eb438a2014-10-01 16:39:37 -0700119 */
alshabibba5ac482014-10-02 17:15:20 -0700120 int timeout();
alshabib6eb438a2014-10-01 16:39:37 -0700121
tom8bb16062014-09-12 14:47:46 -0700122}