Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 17 | |
alshabib | db77407 | 2015-04-20 13:13:51 -0700 | [diff] [blame] | 18 | import org.onosproject.core.ApplicationId; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 19 | import org.onosproject.core.GroupId; |
| 20 | import org.onosproject.net.DeviceId; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 21 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 22 | /** |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 23 | * Represents a generalized match & action pair to be applied to an |
| 24 | * infrastructure device. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 25 | */ |
Sho SHIMIZU | 5e5d4aa | 2015-01-26 16:12:11 -0800 | [diff] [blame] | 26 | public interface FlowRule { |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 27 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 28 | static final int MAX_TIMEOUT = 60; |
alshabib | a0e0498 | 2014-10-03 13:03:19 -0700 | [diff] [blame] | 29 | static final int MIN_PRIORITY = 0; |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 30 | |
sangho | 11c30ac | 2015-01-22 14:30:55 -0800 | [diff] [blame] | 31 | /** |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 32 | * 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. |
Sho SHIMIZU | be63b23 | 2015-06-30 10:57:58 -0700 | [diff] [blame] | 35 | * |
| 36 | * @deprecated in Cardinal Release |
sangho | 11c30ac | 2015-01-22 14:30:55 -0800 | [diff] [blame] | 37 | */ |
alshabib | db77407 | 2015-04-20 13:13:51 -0700 | [diff] [blame] | 38 | @Deprecated |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 39 | static enum Type { |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 40 | /* |
| 41 | * Default type - used in flow rule for single table switch NOTE: this |
| 42 | * setting should not be used as Table 0 in a multi-table pipeline |
| 43 | */ |
sangho | 11c30ac | 2015-01-22 14:30:55 -0800 | [diff] [blame] | 44 | DEFAULT, |
| 45 | /* Used in flow entry for IP table */ |
| 46 | IP, |
| 47 | /* Used in flow entry for MPLS table */ |
| 48 | MPLS, |
| 49 | /* Used in flow entry for ACL table */ |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 50 | ACL, |
| 51 | |
| 52 | /* VLAN-to-MPLS table */ |
| 53 | VLAN_MPLS, |
| 54 | |
| 55 | /* VLAN table */ |
| 56 | VLAN, |
| 57 | |
Saurav Das | cbe6de3 | 2015-03-01 18:30:46 -0800 | [diff] [blame] | 58 | /* Ethtype table */ |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 59 | ETHER, |
| 60 | |
| 61 | /* Class of Service table */ |
| 62 | COS, |
Saurav Das | cbe6de3 | 2015-03-01 18:30:46 -0800 | [diff] [blame] | 63 | |
| 64 | /* Table 0 in a multi-table pipeline */ |
| 65 | FIRST, |
sangho | 11c30ac | 2015-01-22 14:30:55 -0800 | [diff] [blame] | 66 | } |
| 67 | |
Ayaka Koshibe | d4e53e1 | 2014-09-18 14:24:55 -0700 | [diff] [blame] | 68 | /** |
| 69 | * Returns the ID of this flow. |
| 70 | * |
| 71 | * @return the flow ID |
| 72 | */ |
| 73 | FlowId id(); |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 74 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 75 | /** |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 76 | * Returns the application id of this flow. |
| 77 | * |
| 78 | * @return an applicationId |
| 79 | */ |
alshabib | 92c65ad | 2014-10-08 21:56:05 -0700 | [diff] [blame] | 80 | short appId(); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 81 | |
| 82 | /** |
alshabib | 28204e5 | 2014-11-12 18:29:45 -0800 | [diff] [blame] | 83 | * Returns the group id of this flow. |
| 84 | * |
| 85 | * @return an groupId |
| 86 | */ |
Sho SHIMIZU | 75a5bd9 | 2014-11-25 11:22:56 -0800 | [diff] [blame] | 87 | GroupId groupId(); |
alshabib | 28204e5 | 2014-11-12 18:29:45 -0800 | [diff] [blame] | 88 | |
| 89 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 90 | * Returns the flow rule priority given in natural order; higher numbers |
| 91 | * mean higher priorities. |
| 92 | * |
| 93 | * @return flow rule priority |
| 94 | */ |
| 95 | int priority(); |
| 96 | |
| 97 | /** |
| 98 | * Returns the identity of the device where this rule applies. |
| 99 | * |
| 100 | * @return device identifier |
| 101 | */ |
| 102 | DeviceId deviceId(); |
| 103 | |
| 104 | /** |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 105 | * Returns the traffic selector that identifies what traffic this rule |
| 106 | * should apply to. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 107 | * |
| 108 | * @return traffic selector |
| 109 | */ |
| 110 | TrafficSelector selector(); |
| 111 | |
| 112 | /** |
| 113 | * Returns the traffic treatment that applies to selected traffic. |
| 114 | * |
| 115 | * @return traffic treatment |
| 116 | */ |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 117 | TrafficTreatment treatment(); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 118 | |
Ayaka Koshibe | d4e53e1 | 2014-09-18 14:24:55 -0700 | [diff] [blame] | 119 | /** |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 120 | * Returns the timeout for this flow requested by an application. |
Jonathan Hart | bc4a793 | 2014-10-21 11:46:00 -0700 | [diff] [blame] | 121 | * |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 122 | * @return integer value of the timeout |
alshabib | 6eb438a | 2014-10-01 16:39:37 -0700 | [diff] [blame] | 123 | */ |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 124 | int timeout(); |
alshabib | 6eb438a | 2014-10-01 16:39:37 -0700 | [diff] [blame] | 125 | |
Jonathan Hart | bc4a793 | 2014-10-21 11:46:00 -0700 | [diff] [blame] | 126 | /** |
| 127 | * Returns whether the flow is permanent i.e. does not time out. |
| 128 | * |
| 129 | * @return true if the flow is permanent, otherwise false |
| 130 | */ |
| 131 | boolean isPermanent(); |
| 132 | |
sangho | 11c30ac | 2015-01-22 14:30:55 -0800 | [diff] [blame] | 133 | /** |
alshabib | db77407 | 2015-04-20 13:13:51 -0700 | [diff] [blame] | 134 | * Returns the table id for this rule. |
| 135 | * |
| 136 | * @return an integer. |
| 137 | */ |
| 138 | int tableId(); |
| 139 | |
| 140 | /** |
| 141 | * A flowrule builder. |
| 142 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 143 | interface Builder { |
alshabib | db77407 | 2015-04-20 13:13:51 -0700 | [diff] [blame] | 144 | |
| 145 | /** |
| 146 | * Assigns a cookie value to this flowrule. Mutually exclusive with the |
| 147 | * fromApp method. This method is intended to take a cookie value from |
| 148 | * the dataplane and not from the application. |
| 149 | * |
| 150 | * @param cookie a long value |
| 151 | * @return this |
| 152 | */ |
| 153 | Builder withCookie(long cookie); |
| 154 | |
| 155 | /** |
| 156 | * Assigns the application that built this flow rule to this object. |
| 157 | * The short value of the appId will be used as a basis for the |
| 158 | * cookie value computation. It is expected that application use this |
| 159 | * call to set their application id. |
| 160 | * |
| 161 | * @param appId an application id |
| 162 | * @return this |
| 163 | */ |
| 164 | Builder fromApp(ApplicationId appId); |
| 165 | |
| 166 | /** |
| 167 | * Sets the priority for this flow rule. |
| 168 | * |
| 169 | * @param priority an integer |
| 170 | * @return this |
| 171 | */ |
| 172 | Builder withPriority(int priority); |
| 173 | |
| 174 | /** |
| 175 | * Sets the deviceId for this flow rule. |
| 176 | * |
| 177 | * @param deviceId a device id |
| 178 | * @return this |
| 179 | */ |
| 180 | Builder forDevice(DeviceId deviceId); |
| 181 | |
| 182 | /** |
| 183 | * Sets the table id for this flow rule. Default value is 0. |
| 184 | * |
| 185 | * @param tableId an integer |
| 186 | * @return this |
| 187 | */ |
| 188 | Builder forTable(int tableId); |
| 189 | |
| 190 | /** |
| 191 | * Sets the selector (or match field) for this flow rule. |
| 192 | * |
| 193 | * @param selector a traffic selector |
| 194 | * @return this |
| 195 | */ |
| 196 | Builder withSelector(TrafficSelector selector); |
| 197 | |
| 198 | /** |
| 199 | * Sets the traffic treatment for this flow rule. |
| 200 | * |
| 201 | * @param treatment a traffic treatment |
| 202 | * @return this |
| 203 | */ |
| 204 | Builder withTreatment(TrafficTreatment treatment); |
| 205 | |
| 206 | /** |
| 207 | * Makes this rule permanent on the dataplane. |
| 208 | * |
| 209 | * @return this |
| 210 | */ |
| 211 | Builder makePermanent(); |
| 212 | |
| 213 | /** |
| 214 | * Makes this rule temporary and timeout after the specified amount |
| 215 | * of time. |
| 216 | * |
| 217 | * @param timeout an integer |
| 218 | * @return this |
| 219 | */ |
| 220 | Builder makeTemporary(int timeout); |
| 221 | |
| 222 | /** |
| 223 | * Builds a flow rule object. |
| 224 | * |
| 225 | * @return a flow rule. |
| 226 | */ |
| 227 | FlowRule build(); |
| 228 | |
| 229 | } |
| 230 | |
jcc | 3d4e14a | 2015-04-21 11:32:05 +0800 | [diff] [blame] | 231 | /** |
| 232 | * Returns the third party original flow rule. |
| 233 | * |
| 234 | * @return FlowRuleExtPayLoad |
| 235 | */ |
| 236 | FlowRuleExtPayLoad payLoad(); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 237 | } |