blob: e72beed73ee219bcabcdbb2368f006ff6b19c51c [file] [log] [blame]
tom8bb16062014-09-12 14:47:46 -07001package org.onlab.onos.net.flow;
2
3import org.onlab.onos.net.DeviceId;
4
tom8bb16062014-09-12 14:47:46 -07005/**
6 * Represents a generalized match & action pair to be applied to
7 * an infrastucture device.
8 */
9public interface FlowRule {
10
alshabiba7f7ca82014-09-22 11:41:23 -070011
12 public enum FlowRuleState {
13 /**
14 * Indicates that this rule has been created.
15 */
16 CREATED,
17
18 /**
19 * Indicates that this rule has been submitted for addition.
20 * Not necessarily in the flow table.
21 */
22 PENDING_ADD,
23
24 /**
25 * Rule has been added which means it is in the flow table.
26 */
27 ADDED,
28
29 /**
30 * Flow has been marked for removal, might still be in flow table.
31 */
32 PENDING_REMOVE,
33
34 /**
35 * Flow has been removed from flow table and can be purged.
36 */
37 REMOVED
38 }
39
40 /**
41 * Returns the flow rule state.
42 *
43 * @return flow rule state
44 */
45 FlowRuleState state();
46
alshabib369d2942014-09-12 17:59:35 -070047 //TODO: build cookie value
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070048 /**
49 * Returns the ID of this flow.
50 *
51 * @return the flow ID
52 */
53 FlowId id();
alshabib369d2942014-09-12 17:59:35 -070054
tom8bb16062014-09-12 14:47:46 -070055 /**
56 * Returns the flow rule priority given in natural order; higher numbers
57 * mean higher priorities.
58 *
59 * @return flow rule priority
60 */
61 int priority();
62
63 /**
64 * Returns the identity of the device where this rule applies.
65 *
66 * @return device identifier
67 */
68 DeviceId deviceId();
69
70 /**
71 * Returns the traffic selector that identifies what traffic this
72 * rule should apply to.
73 *
74 * @return traffic selector
75 */
76 TrafficSelector selector();
77
78 /**
79 * Returns the traffic treatment that applies to selected traffic.
80 *
81 * @return traffic treatment
82 */
alshabib369d2942014-09-12 17:59:35 -070083 TrafficTreatment treatment();
tom8bb16062014-09-12 14:47:46 -070084
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070085 /**
86 * Returns the number of milliseconds this flow rule has been applied.
87 *
88 * @return number of millis
89 */
90 long lifeMillis();
91
92 /**
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070093 * Returns the number of packets this flow rule has matched.
94 *
95 * @return number of packets
96 */
97 long packets();
98
99 /**
100 * Returns the number of bytes this flow rule has matched.
101 *
102 * @return number of bytes
103 */
104 long bytes();
105
tom8bb16062014-09-12 14:47:46 -0700106}