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