blob: 6497e110c1692fbe0e81f9c2ebfd2e283d9afc70 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
jcc3d4e14a2015-04-21 11:32:05 +08002 * Copyright 2014 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/**
jcc3d4e14a2015-04-21 11:32:05 +080023 * Represents a generalized match & action pair to be applied to an
24 * 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 /**
jcc3d4e14a2015-04-21 11:32:05 +080032 * The FlowRule type is used to determine in which table the flow rule needs
33 * to be put for multi-table support switch. For single table switch,
34 * Default is used.
sangho11c30ac2015-01-22 14:30:55 -080035 */
alshabibdb774072015-04-20 13:13:51 -070036 @Deprecated
sangho11c30ac2015-01-22 14:30:55 -080037 public static enum Type {
jcc3d4e14a2015-04-21 11:32:05 +080038 /*
39 * Default type - used in flow rule for single table switch NOTE: this
40 * setting should not be used as Table 0 in a multi-table pipeline
41 */
sangho11c30ac2015-01-22 14:30:55 -080042 DEFAULT,
43 /* Used in flow entry for IP table */
44 IP,
45 /* Used in flow entry for MPLS table */
46 MPLS,
47 /* Used in flow entry for ACL table */
alshabib9af70072015-02-09 14:34:16 -080048 ACL,
49
50 /* VLAN-to-MPLS table */
51 VLAN_MPLS,
52
53 /* VLAN table */
54 VLAN,
55
Saurav Dascbe6de32015-03-01 18:30:46 -080056 /* Ethtype table */
alshabib9af70072015-02-09 14:34:16 -080057 ETHER,
58
59 /* Class of Service table */
60 COS,
Saurav Dascbe6de32015-03-01 18:30:46 -080061
62 /* Table 0 in a multi-table pipeline */
63 FIRST,
sangho11c30ac2015-01-22 14:30:55 -080064 }
65
Ayaka Koshibed4e53e12014-09-18 14:24:55 -070066 /**
67 * Returns the ID of this flow.
68 *
69 * @return the flow ID
70 */
71 FlowId id();
alshabib369d2942014-09-12 17:59:35 -070072
tom8bb16062014-09-12 14:47:46 -070073 /**
alshabiba68eb962014-09-24 20:34:13 -070074 * Returns the application id of this flow.
75 *
76 * @return an applicationId
77 */
alshabib92c65ad2014-10-08 21:56:05 -070078 short appId();
alshabiba68eb962014-09-24 20:34:13 -070079
80 /**
alshabib28204e52014-11-12 18:29:45 -080081 * Returns the group id of this flow.
82 *
83 * @return an groupId
84 */
Sho SHIMIZU75a5bd92014-11-25 11:22:56 -080085 GroupId groupId();
alshabib28204e52014-11-12 18:29:45 -080086
87 /**
tom8bb16062014-09-12 14:47:46 -070088 * Returns the flow rule priority given in natural order; higher numbers
89 * mean higher priorities.
90 *
91 * @return flow rule priority
92 */
93 int priority();
94
95 /**
96 * Returns the identity of the device where this rule applies.
97 *
98 * @return device identifier
99 */
100 DeviceId deviceId();
101
102 /**
jcc3d4e14a2015-04-21 11:32:05 +0800103 * Returns the traffic selector that identifies what traffic this rule
104 * should apply to.
tom8bb16062014-09-12 14:47:46 -0700105 *
106 * @return traffic selector
107 */
108 TrafficSelector selector();
109
110 /**
111 * Returns the traffic treatment that applies to selected traffic.
112 *
113 * @return traffic treatment
114 */
alshabib369d2942014-09-12 17:59:35 -0700115 TrafficTreatment treatment();
tom8bb16062014-09-12 14:47:46 -0700116
Ayaka Koshibed4e53e12014-09-18 14:24:55 -0700117 /**
alshabibba5ac482014-10-02 17:15:20 -0700118 * Returns the timeout for this flow requested by an application.
Jonathan Hartbc4a7932014-10-21 11:46:00 -0700119 *
alshabibba5ac482014-10-02 17:15:20 -0700120 * @return integer value of the timeout
alshabib6eb438a2014-10-01 16:39:37 -0700121 */
alshabibba5ac482014-10-02 17:15:20 -0700122 int timeout();
alshabib6eb438a2014-10-01 16:39:37 -0700123
Jonathan Hartbc4a7932014-10-21 11:46:00 -0700124 /**
125 * Returns whether the flow is permanent i.e. does not time out.
126 *
127 * @return true if the flow is permanent, otherwise false
128 */
129 boolean isPermanent();
130
sangho11c30ac2015-01-22 14:30:55 -0800131 /**
alshabibdb774072015-04-20 13:13:51 -0700132 * Returns the table id for this rule.
133 *
134 * @return an integer.
135 */
136 int tableId();
137
138 /**
139 * A flowrule builder.
140 */
141 public interface Builder {
142
143 /**
144 * Assigns a cookie value to this flowrule. Mutually exclusive with the
145 * fromApp method. This method is intended to take a cookie value from
146 * the dataplane and not from the application.
147 *
148 * @param cookie a long value
149 * @return this
150 */
151 Builder withCookie(long cookie);
152
153 /**
154 * Assigns the application that built this flow rule to this object.
155 * The short value of the appId will be used as a basis for the
156 * cookie value computation. It is expected that application use this
157 * call to set their application id.
158 *
159 * @param appId an application id
160 * @return this
161 */
162 Builder fromApp(ApplicationId appId);
163
164 /**
165 * Sets the priority for this flow rule.
166 *
167 * @param priority an integer
168 * @return this
169 */
170 Builder withPriority(int priority);
171
172 /**
173 * Sets the deviceId for this flow rule.
174 *
175 * @param deviceId a device id
176 * @return this
177 */
178 Builder forDevice(DeviceId deviceId);
179
180 /**
181 * Sets the table id for this flow rule. Default value is 0.
182 *
183 * @param tableId an integer
184 * @return this
185 */
186 Builder forTable(int tableId);
187
188 /**
189 * Sets the selector (or match field) for this flow rule.
190 *
191 * @param selector a traffic selector
192 * @return this
193 */
194 Builder withSelector(TrafficSelector selector);
195
196 /**
197 * Sets the traffic treatment for this flow rule.
198 *
199 * @param treatment a traffic treatment
200 * @return this
201 */
202 Builder withTreatment(TrafficTreatment treatment);
203
204 /**
205 * Makes this rule permanent on the dataplane.
206 *
207 * @return this
208 */
209 Builder makePermanent();
210
211 /**
212 * Makes this rule temporary and timeout after the specified amount
213 * of time.
214 *
215 * @param timeout an integer
216 * @return this
217 */
218 Builder makeTemporary(int timeout);
219
220 /**
221 * Builds a flow rule object.
222 *
223 * @return a flow rule.
224 */
225 FlowRule build();
226
227 }
228
jcc3d4e14a2015-04-21 11:32:05 +0800229 /**
230 * Returns the third party original flow rule.
231 *
232 * @return FlowRuleExtPayLoad
233 */
234 FlowRuleExtPayLoad payLoad();
tom8bb16062014-09-12 14:47:46 -0700235}