blob: 3499bae52062643d2c51d0831d5ef4614b1c55c4 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 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;
tom8bb16062014-09-12 14:47:46 -070017
alshabibdb774072015-04-20 13:13:51 -070018import org.onosproject.core.ApplicationId;
Brian O'Connorabafb502014-12-02 22:26:20 -080019import org.onosproject.core.GroupId;
20import org.onosproject.net.DeviceId;
tom8bb16062014-09-12 14:47:46 -070021
tom8bb16062014-09-12 14:47:46 -070022/**
23 * Represents a generalized match & action pair to be applied to
Sho SHIMIZUa19a2e52014-11-17 11:08:19 -080024 * an infrastructure device.
tom8bb16062014-09-12 14:47:46 -070025 */
Sho SHIMIZU5e5d4aa2015-01-26 16:12:11 -080026public interface FlowRule {
tom8bb16062014-09-12 14:47:46 -070027
alshabibba5ac482014-10-02 17:15:20 -070028 static final int MAX_TIMEOUT = 60;
alshabiba0e04982014-10-03 13:03:19 -070029 static final int MIN_PRIORITY = 0;
alshabiba7f7ca82014-09-22 11:41:23 -070030
sangho11c30ac2015-01-22 14:30:55 -080031 /**
32 * The FlowRule type is used to determine in which table the flow rule
33 * needs to be put for multi-table support switch.
34 * For single table switch, Default is used.
35 */
alshabibdb774072015-04-20 13:13:51 -070036 @Deprecated
sangho11c30ac2015-01-22 14:30:55 -080037 public static enum Type {
Saurav Dascbe6de32015-03-01 18:30:46 -080038 /* Default type - used in flow rule for single table switch
39 * NOTE: this setting should not be used as Table 0 in a multi-table pipeline*/
sangho11c30ac2015-01-22 14:30:55 -080040 DEFAULT,
41 /* Used in flow entry for IP table */
42 IP,
43 /* Used in flow entry for MPLS table */
44 MPLS,
45 /* Used in flow entry for ACL table */
alshabib9af70072015-02-09 14:34:16 -080046 ACL,
47
48 /* VLAN-to-MPLS table */
49 VLAN_MPLS,
50
51 /* VLAN table */
52 VLAN,
53
Saurav Dascbe6de32015-03-01 18:30:46 -080054 /* Ethtype table */
alshabib9af70072015-02-09 14:34:16 -080055 ETHER,
56
57 /* Class of Service table */
58 COS,
Saurav Dascbe6de32015-03-01 18:30:46 -080059
60 /* Table 0 in a multi-table pipeline */
61 FIRST,
sangho11c30ac2015-01-22 14:30:55 -080062 }
63
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070064 /**
65 * Returns the ID of this flow.
66 *
67 * @return the flow ID
68 */
69 FlowId id();
alshabib369d2942014-09-12 17:59:35 -070070
tom8bb16062014-09-12 14:47:46 -070071 /**
alshabiba68eb962014-09-24 20:34:13 -070072 * Returns the application id of this flow.
73 *
74 * @return an applicationId
75 */
alshabib92c65ad2014-10-08 21:56:05 -070076 short appId();
alshabiba68eb962014-09-24 20:34:13 -070077
78 /**
alshabib28204e52014-11-12 18:29:45 -080079 * Returns the group id of this flow.
80 *
81 * @return an groupId
82 */
Sho SHIMIZU75a5bd92014-11-25 11:22:56 -080083 GroupId groupId();
alshabib28204e52014-11-12 18:29:45 -080084
85 /**
tom8bb16062014-09-12 14:47:46 -070086 * Returns the flow rule priority given in natural order; higher numbers
87 * mean higher priorities.
88 *
89 * @return flow rule priority
90 */
91 int priority();
92
93 /**
94 * Returns the identity of the device where this rule applies.
95 *
96 * @return device identifier
97 */
98 DeviceId deviceId();
99
100 /**
101 * Returns the traffic selector that identifies what traffic this
102 * rule should apply to.
103 *
104 * @return traffic selector
105 */
106 TrafficSelector selector();
107
108 /**
109 * Returns the traffic treatment that applies to selected traffic.
110 *
111 * @return traffic treatment
112 */
alshabib369d2942014-09-12 17:59:35 -0700113 TrafficTreatment treatment();
tom8bb16062014-09-12 14:47:46 -0700114
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700115 /**
alshabibba5ac482014-10-02 17:15:20 -0700116 * Returns the timeout for this flow requested by an application.
Jonathan Hartbc4a7932014-10-21 11:46:00 -0700117 *
alshabibba5ac482014-10-02 17:15:20 -0700118 * @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
Jonathan Hartbc4a7932014-10-21 11:46:00 -0700122 /**
123 * Returns whether the flow is permanent i.e. does not time out.
124 *
125 * @return true if the flow is permanent, otherwise false
126 */
127 boolean isPermanent();
128
sangho11c30ac2015-01-22 14:30:55 -0800129 /**
alshabibdb774072015-04-20 13:13:51 -0700130 * Returns the table id for this rule.
131 *
132 * @return an integer.
133 */
134 int tableId();
135
136 /**
137 * A flowrule builder.
138 */
139 public interface Builder {
140
141 /**
142 * Assigns a cookie value to this flowrule. Mutually exclusive with the
143 * fromApp method. This method is intended to take a cookie value from
144 * the dataplane and not from the application.
145 *
146 * @param cookie a long value
147 * @return this
148 */
149 Builder withCookie(long cookie);
150
151 /**
152 * Assigns the application that built this flow rule to this object.
153 * The short value of the appId will be used as a basis for the
154 * cookie value computation. It is expected that application use this
155 * call to set their application id.
156 *
157 * @param appId an application id
158 * @return this
159 */
160 Builder fromApp(ApplicationId appId);
161
162 /**
163 * Sets the priority for this flow rule.
164 *
165 * @param priority an integer
166 * @return this
167 */
168 Builder withPriority(int priority);
169
170 /**
171 * Sets the deviceId for this flow rule.
172 *
173 * @param deviceId a device id
174 * @return this
175 */
176 Builder forDevice(DeviceId deviceId);
177
178 /**
179 * Sets the table id for this flow rule. Default value is 0.
180 *
181 * @param tableId an integer
182 * @return this
183 */
184 Builder forTable(int tableId);
185
186 /**
187 * Sets the selector (or match field) for this flow rule.
188 *
189 * @param selector a traffic selector
190 * @return this
191 */
192 Builder withSelector(TrafficSelector selector);
193
194 /**
195 * Sets the traffic treatment for this flow rule.
196 *
197 * @param treatment a traffic treatment
198 * @return this
199 */
200 Builder withTreatment(TrafficTreatment treatment);
201
202 /**
203 * Makes this rule permanent on the dataplane.
204 *
205 * @return this
206 */
207 Builder makePermanent();
208
209 /**
210 * Makes this rule temporary and timeout after the specified amount
211 * of time.
212 *
213 * @param timeout an integer
214 * @return this
215 */
216 Builder makeTemporary(int timeout);
217
218 /**
219 * Builds a flow rule object.
220 *
221 * @return a flow rule.
222 */
223 FlowRule build();
224
225 }
226
tom8bb16062014-09-12 14:47:46 -0700227}