blob: 487659bb175ac1467eb712e1f4407569387fe0d6 [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
alshabiba7f7ca82014-09-22 11:41:23 -070012
13 public enum FlowRuleState {
14 /**
15 * Indicates that this rule has been created.
16 */
17 CREATED,
18
19 /**
20 * Indicates that this rule has been submitted for addition.
21 * Not necessarily in the flow table.
22 */
23 PENDING_ADD,
24
25 /**
26 * Rule has been added which means it is in the flow table.
27 */
28 ADDED,
29
30 /**
31 * Flow has been marked for removal, might still be in flow table.
32 */
33 PENDING_REMOVE,
34
35 /**
36 * Flow has been removed from flow table and can be purged.
37 */
38 REMOVED
39 }
40
41 /**
42 * Returns the flow rule state.
43 *
44 * @return flow rule state
45 */
46 FlowRuleState state();
47
alshabib369d2942014-09-12 17:59:35 -070048 //TODO: build cookie value
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070049 /**
50 * Returns the ID of this flow.
51 *
52 * @return the flow ID
53 */
54 FlowId id();
alshabib369d2942014-09-12 17:59:35 -070055
tom8bb16062014-09-12 14:47:46 -070056 /**
alshabiba68eb962014-09-24 20:34:13 -070057 * Returns the application id of this flow.
58 *
59 * @return an applicationId
60 */
61 ApplicationId appId();
62
63 /**
tom8bb16062014-09-12 14:47:46 -070064 * Returns the flow rule priority given in natural order; higher numbers
65 * mean higher priorities.
66 *
67 * @return flow rule priority
68 */
69 int priority();
70
71 /**
72 * Returns the identity of the device where this rule applies.
73 *
74 * @return device identifier
75 */
76 DeviceId deviceId();
77
78 /**
79 * Returns the traffic selector that identifies what traffic this
80 * rule should apply to.
81 *
82 * @return traffic selector
83 */
84 TrafficSelector selector();
85
86 /**
87 * Returns the traffic treatment that applies to selected traffic.
88 *
89 * @return traffic treatment
90 */
alshabib369d2942014-09-12 17:59:35 -070091 TrafficTreatment treatment();
tom8bb16062014-09-12 14:47:46 -070092
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070093 /**
94 * Returns the number of milliseconds this flow rule has been applied.
95 *
96 * @return number of millis
97 */
98 long lifeMillis();
99
100 /**
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700101 * Returns the number of packets this flow rule has matched.
102 *
103 * @return number of packets
104 */
105 long packets();
106
107 /**
108 * Returns the number of bytes this flow rule has matched.
109 *
110 * @return number of bytes
111 */
112 long bytes();
113
tom8bb16062014-09-12 14:47:46 -0700114}