Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
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 | |
Yafit Hadar | 5796d97 | 2015-10-15 13:16:11 +0300 | [diff] [blame] | 18 | import java.util.List; |
| 19 | |
Frank Wang | df38321 | 2017-06-23 09:17:41 +0800 | [diff] [blame] | 20 | import com.google.common.annotations.Beta; |
alshabib | 7b808c5 | 2015-06-26 14:22:24 -0700 | [diff] [blame] | 21 | import org.onlab.packet.EthType; |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 22 | import org.onlab.packet.IpAddress; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 23 | import org.onlab.packet.MacAddress; |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 24 | import org.onlab.packet.MplsLabel; |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 25 | import org.onlab.packet.TpPort; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 26 | import org.onlab.packet.VlanId; |
Jonathan Hart | 54b406b | 2015-03-06 16:24:14 -0800 | [diff] [blame] | 27 | import org.onosproject.core.GroupId; |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 28 | import org.onosproject.net.DeviceId; |
Jonathan Hart | 54b406b | 2015-03-06 16:24:14 -0800 | [diff] [blame] | 29 | import org.onosproject.net.PortNumber; |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 30 | import org.onosproject.net.flow.instructions.ExtensionTreatment; |
Jonathan Hart | 54b406b | 2015-03-06 16:24:14 -0800 | [diff] [blame] | 31 | import org.onosproject.net.flow.instructions.Instruction; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 32 | import org.onosproject.net.flow.instructions.Instructions; |
alshabib | 10c810b | 2015-08-18 16:59:04 -0700 | [diff] [blame] | 33 | import org.onosproject.net.meter.MeterId; |
Frank Wang | df38321 | 2017-06-23 09:17:41 +0800 | [diff] [blame] | 34 | import org.onosproject.net.pi.runtime.PiTableAction; |
alshabib | 55a55d9 | 2014-09-16 11:59:31 -0700 | [diff] [blame] | 35 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 36 | /** |
| 37 | * Abstraction of network traffic treatment. |
| 38 | */ |
| 39 | public interface TrafficTreatment { |
| 40 | |
| 41 | /** |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 42 | * Returns the list of treatment instructions that will be applied |
| 43 | * further down the pipeline. |
| 44 | * @return list of treatment instructions |
| 45 | */ |
| 46 | List<Instruction> deferred(); |
| 47 | |
| 48 | /** |
| 49 | * Returns the list of treatment instructions that will be applied |
| 50 | * immediately. |
| 51 | * @return list of treatment instructions |
| 52 | */ |
| 53 | List<Instruction> immediate(); |
| 54 | |
| 55 | /** |
Jonathan Hart | 8ef6d3b | 2015-03-08 21:21:27 -0700 | [diff] [blame] | 56 | * Returns the list of all instructions in the treatment, both immediate and |
| 57 | * deferred. |
| 58 | * |
| 59 | * @return list of treatment instructions |
| 60 | */ |
| 61 | List<Instruction> allInstructions(); |
| 62 | |
| 63 | /** |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 64 | * Returns the next table in the pipeline. |
| 65 | * @return a table transition; may be null. |
| 66 | */ |
| 67 | Instructions.TableTypeTransition tableTransition(); |
| 68 | |
| 69 | /** |
| 70 | * Whether the deferred treatment instructions will be cleared |
| 71 | * by the device. |
| 72 | * @return a boolean |
| 73 | */ |
Jonathan Hart | 4a0ba56 | 2015-03-23 17:23:33 -0700 | [diff] [blame] | 74 | boolean clearedDeferred(); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 75 | |
| 76 | /** |
Saurav Das | 86af8f1 | 2015-05-25 23:55:33 -0700 | [diff] [blame] | 77 | * Returns the metadata instruction if there is one. |
| 78 | * |
| 79 | * @return a metadata instruction that may be null |
| 80 | */ |
| 81 | Instructions.MetadataInstruction writeMetadata(); |
| 82 | |
| 83 | /** |
alshabib | 10c810b | 2015-08-18 16:59:04 -0700 | [diff] [blame] | 84 | * Returns the meter instruction if there is one. |
| 85 | * |
| 86 | * @return a meter instruction that may be null |
| 87 | */ |
| 88 | Instructions.MeterInstruction metered(); |
| 89 | |
| 90 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 91 | * Builder of traffic treatment entities. |
| 92 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 93 | interface Builder { |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 96 | * Adds an instruction to the builder. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 97 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 98 | * @param instruction an instruction |
| 99 | * @return a treatment builder |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 100 | */ |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 101 | Builder add(Instruction instruction); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 102 | |
| 103 | /** |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 104 | * Adds a drop instruction. |
| 105 | * |
| 106 | * @return a treatment builder |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 107 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 108 | Builder drop(); |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * Adds a punt-to-controller instruction. |
| 112 | * |
| 113 | * @return a treatment builder |
| 114 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 115 | Builder punt(); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 116 | |
| 117 | /** |
| 118 | * Set the output port. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 119 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 120 | * @param number the out port |
| 121 | * @return a treatment builder |
| 122 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 123 | Builder setOutput(PortNumber number); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * Sets the src l2 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 127 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 128 | * @param addr a macaddress |
| 129 | * @return a treatment builder |
| 130 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 131 | Builder setEthSrc(MacAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 132 | |
| 133 | /** |
| 134 | * Sets the dst l2 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 135 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 136 | * @param addr a macaddress |
| 137 | * @return a treatment builder |
| 138 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 139 | Builder setEthDst(MacAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 140 | |
| 141 | /** |
| 142 | * Sets the vlan id. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 143 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 144 | * @param id a vlanid |
| 145 | * @return a treatment builder |
| 146 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 147 | Builder setVlanId(VlanId id); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 148 | |
| 149 | /** |
| 150 | * Sets the vlan priority. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 151 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 152 | * @param pcp a vlan priority |
| 153 | * @return a treatment builder |
| 154 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 155 | Builder setVlanPcp(Byte pcp); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 156 | |
| 157 | /** |
| 158 | * Sets the src l3 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 159 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 160 | * @param addr an ip |
| 161 | * @return a treatment builder |
| 162 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 163 | Builder setIpSrc(IpAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 164 | |
| 165 | /** |
| 166 | * Sets the dst l3 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 167 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 168 | * @param addr an ip |
| 169 | * @return a treatment builder |
| 170 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 171 | Builder setIpDst(IpAddress addr); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 172 | |
| 173 | /** |
Pavlin Radoslavov | febe82c | 2015-02-11 19:08:15 -0800 | [diff] [blame] | 174 | * Decrement the TTL in IP header by one. |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 175 | * |
| 176 | * @return a treatment builder |
| 177 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 178 | Builder decNwTtl(); |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 179 | |
| 180 | /** |
| 181 | * Copy the TTL to outer protocol layer. |
| 182 | * |
| 183 | * @return a treatment builder |
| 184 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 185 | Builder copyTtlOut(); |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 186 | |
| 187 | /** |
| 188 | * Copy the TTL to inner protocol layer. |
| 189 | * |
| 190 | * @return a treatment builder |
| 191 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 192 | Builder copyTtlIn(); |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 193 | |
| 194 | /** |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 195 | * Push MPLS ether type. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 196 | * |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 197 | * @return a treatment builder |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 198 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 199 | Builder pushMpls(); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 200 | |
| 201 | /** |
| 202 | * Pops MPLS ether type. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 203 | * |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 204 | * @return a treatment builder |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 205 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 206 | Builder popMpls(); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 207 | |
| 208 | /** |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 209 | * Pops MPLS ether type and set the new ethertype. |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 210 | * |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 211 | * @param etherType an ether type |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 212 | * @return a treatment builder |
alshabib | 7b808c5 | 2015-06-26 14:22:24 -0700 | [diff] [blame] | 213 | */ |
| 214 | Builder popMpls(EthType etherType); |
| 215 | |
| 216 | /** |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 217 | * Sets the mpls label. |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 218 | * |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 219 | * @param mplsLabel MPLS label |
| 220 | * @return a treatment builder |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 221 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 222 | Builder setMpls(MplsLabel mplsLabel); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 223 | |
| 224 | /** |
Saurav Das | 73a7dd4 | 2015-08-19 22:20:31 -0700 | [diff] [blame] | 225 | * Sets the mpls bottom-of-stack indicator bit. |
| 226 | * |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 227 | * @param mplsBos boolean to set BOS=1 (true) or BOS=0 (false) |
Saurav Das | 73a7dd4 | 2015-08-19 22:20:31 -0700 | [diff] [blame] | 228 | * @return a treatment builder. |
| 229 | */ |
| 230 | Builder setMplsBos(boolean mplsBos); |
| 231 | |
| 232 | /** |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 233 | * Decrement MPLS TTL. |
| 234 | * |
| 235 | * @return a treatment builder |
| 236 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 237 | Builder decMplsTtl(); |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 238 | |
| 239 | /** |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 240 | * Sets the group ID. |
| 241 | * |
| 242 | * @param groupId group ID |
| 243 | * @return a treatment builder |
| 244 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 245 | Builder group(GroupId groupId); |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 246 | |
alshabib | 10c810b | 2015-08-18 16:59:04 -0700 | [diff] [blame] | 247 | /** |
Steffen Gebert | bbfdaaa | 2015-09-29 11:01:46 +0200 | [diff] [blame] | 248 | * Sets the Queue ID. |
| 249 | * |
| 250 | * @param queueId a queue ID |
| 251 | * @return a treatment builder |
| 252 | */ |
| 253 | Builder setQueue(long queueId); |
| 254 | |
| 255 | /** |
Steffen Gebert | ba2d3b7 | 2015-10-22 11:14:31 +0200 | [diff] [blame] | 256 | * Sets the Queue ID for a specific port. |
| 257 | * |
| 258 | * @param queueId a queue ID |
| 259 | * @param port a port number |
| 260 | * @return a treatment builder |
| 261 | */ |
| 262 | Builder setQueue(long queueId, PortNumber port); |
| 263 | |
| 264 | /** |
alshabib | 10c810b | 2015-08-18 16:59:04 -0700 | [diff] [blame] | 265 | * Sets a meter to be used by this flow. |
| 266 | * |
| 267 | * @param meterId a meter id |
| 268 | * @return a treatment builder |
| 269 | */ |
| 270 | Builder meter(MeterId meterId); |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 271 | |
| 272 | /** |
alshabib | d17abc2 | 2015-04-21 18:26:35 -0700 | [diff] [blame] | 273 | * Sets the next table id to transition to. |
| 274 | * |
| 275 | * @param tableId the table table |
| 276 | * @return a treatement builder |
| 277 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 278 | Builder transition(Integer tableId); |
alshabib | d17abc2 | 2015-04-21 18:26:35 -0700 | [diff] [blame] | 279 | |
| 280 | |
| 281 | /** |
Saurav Das | fbe25c5 | 2015-03-04 11:12:00 -0800 | [diff] [blame] | 282 | * Pops outermost VLAN tag. |
| 283 | * |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 284 | * @return a treatment builder |
Saurav Das | fbe25c5 | 2015-03-04 11:12:00 -0800 | [diff] [blame] | 285 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 286 | Builder popVlan(); |
Saurav Das | fbe25c5 | 2015-03-04 11:12:00 -0800 | [diff] [blame] | 287 | |
| 288 | /** |
Jonathan Hart | 54b406b | 2015-03-06 16:24:14 -0800 | [diff] [blame] | 289 | * Pushes a new VLAN tag. |
| 290 | * |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 291 | * @return a treatment builder |
Jonathan Hart | 54b406b | 2015-03-06 16:24:14 -0800 | [diff] [blame] | 292 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 293 | Builder pushVlan(); |
Jonathan Hart | 54b406b | 2015-03-06 16:24:14 -0800 | [diff] [blame] | 294 | |
| 295 | /** |
Konstantinos Kanonakis | 9215ff2 | 2016-11-04 13:28:11 -0500 | [diff] [blame] | 296 | * Pushes a new VLAN tag using the supplied Ethernet type. |
| 297 | * |
Ray Milkey | ef79434 | 2016-11-09 16:20:29 -0800 | [diff] [blame] | 298 | * @param ethType ethernet type |
Konstantinos Kanonakis | 9215ff2 | 2016-11-04 13:28:11 -0500 | [diff] [blame] | 299 | * @return a treatment builder |
| 300 | */ |
| 301 | Builder pushVlan(EthType ethType); |
| 302 | |
| 303 | /** |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 304 | * Any instructions preceded by this method call will be deferred. |
| 305 | * @return a treatment builder |
| 306 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 307 | Builder deferred(); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 308 | |
| 309 | /** |
| 310 | * Any instructions preceded by this method call will be immediate. |
| 311 | * @return a treatment builder |
| 312 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 313 | Builder immediate(); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 314 | |
| 315 | |
| 316 | /** |
| 317 | * Instructs the device to clear the deferred instructions set. |
| 318 | * @return a treatment builder |
| 319 | */ |
Sho SHIMIZU | 79906e4 | 2015-05-04 18:27:31 -0700 | [diff] [blame] | 320 | Builder wipeDeferred(); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 321 | |
| 322 | /** |
HelloONOS | af3b428 | 2017-06-27 16:27:31 +0900 | [diff] [blame] | 323 | * the instruction to clear not wipe the deferred instructions set. |
| 324 | * @return a treatment builder |
| 325 | */ |
| 326 | Builder notWipeDeferred(); |
| 327 | |
| 328 | /** |
Saurav Das | 86af8f1 | 2015-05-25 23:55:33 -0700 | [diff] [blame] | 329 | * Writes metadata to associate with a packet. |
| 330 | * <pre> |
| 331 | * {@code |
| 332 | * new_metadata = (old_metadata & ̃mask) | (value & mask) |
| 333 | * } |
| 334 | * </pre> |
| 335 | * |
| 336 | * @param value the metadata to write |
| 337 | * @param mask the masked bits for the value |
| 338 | * @return a treatment builder |
| 339 | */ |
| 340 | Builder writeMetadata(long value, long mask); |
| 341 | |
| 342 | /** |
Hyunsun Moon | a08c5d0 | 2015-07-14 17:53:00 -0700 | [diff] [blame] | 343 | * Sets the tunnel id. |
| 344 | * |
Jonathan Hart | 3e59464 | 2015-10-20 17:31:24 -0700 | [diff] [blame] | 345 | * @param tunnelId a tunnel id |
| 346 | * @return a treatment builder |
Hyunsun Moon | a08c5d0 | 2015-07-14 17:53:00 -0700 | [diff] [blame] | 347 | */ |
| 348 | Builder setTunnelId(long tunnelId); |
| 349 | |
| 350 | /** |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 351 | * Sets the src TCP port. |
| 352 | * |
| 353 | * @param port a port number |
| 354 | * @return a treatment builder |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 355 | */ |
| 356 | Builder setTcpSrc(TpPort port); |
| 357 | |
| 358 | /** |
| 359 | * Sets the dst TCP port. |
| 360 | * |
| 361 | * @param port a port number |
| 362 | * @return a treatment builder |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 363 | */ |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 364 | Builder setTcpDst(TpPort port); |
| 365 | |
| 366 | /** |
| 367 | * Sets the src UDP port. |
| 368 | * |
| 369 | * @param port a port number |
| 370 | * @return a treatment builder |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 371 | */ |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 372 | Builder setUdpSrc(TpPort port); |
| 373 | |
| 374 | /** |
| 375 | * Sets the dst UDP port. |
| 376 | * |
| 377 | * @param port a port number |
| 378 | * @return a treatment builder |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 379 | */ |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 380 | Builder setUdpDst(TpPort port); |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 381 | |
| 382 | /** |
lishuai | 3cce60b | 2015-12-01 19:35:16 +0800 | [diff] [blame] | 383 | * Sets the arp src ip address. |
| 384 | * |
| 385 | * @param addr an ip |
| 386 | * @return a treatment builder |
| 387 | */ |
| 388 | Builder setArpSpa(IpAddress addr); |
| 389 | |
| 390 | /** |
| 391 | * Sets the arp src mac address. |
| 392 | * |
| 393 | * @param addr a macaddress |
| 394 | * @return a treatment builder |
| 395 | */ |
| 396 | Builder setArpSha(MacAddress addr); |
| 397 | |
| 398 | /** |
| 399 | * Sets the arp operation. |
| 400 | * |
| 401 | * @param op the value of arp operation. |
| 402 | * @return a treatment builder. |
| 403 | */ |
| 404 | Builder setArpOp(short op); |
| 405 | |
| 406 | /** |
Frank Wang | df38321 | 2017-06-23 09:17:41 +0800 | [diff] [blame] | 407 | * Sets the protocol independent table action. |
| 408 | * |
| 409 | * @param piTableAction protocol-independent table action |
| 410 | * @return a treatment builder. |
| 411 | */ |
| 412 | @Beta |
| 413 | Builder piTableAction(PiTableAction piTableAction); |
| 414 | |
| 415 | /** |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 416 | * Uses an extension treatment. |
| 417 | * |
| 418 | * @param extension extension treatment |
| 419 | * @param deviceId device ID |
| 420 | * @return a treatment builder |
| 421 | */ |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 422 | Builder extension(ExtensionTreatment extension, DeviceId deviceId); |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 423 | |
| 424 | /** |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame] | 425 | * Add all instructions from another treatment. |
| 426 | * |
| 427 | * @param treatment another treatment |
| 428 | * @return a treatment builder |
| 429 | */ |
| 430 | Builder addTreatment(TrafficTreatment treatment); |
| 431 | |
| 432 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 433 | * Builds an immutable traffic treatment descriptor. |
Brian O'Connor | 6b52813 | 2015-03-10 16:39:52 -0700 | [diff] [blame] | 434 | * <p> |
| 435 | * If the treatment is empty when build() is called, it will add a default |
| 436 | * drop rule automatically. For a treatment that is actually empty, use |
| 437 | * {@link org.onosproject.net.flow.DefaultTrafficTreatment#emptyTreatment}. |
| 438 | * </p> |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 439 | * |
| 440 | * @return traffic treatment |
| 441 | */ |
| 442 | TrafficTreatment build(); |
Saurav Das | 86af8f1 | 2015-05-25 23:55:33 -0700 | [diff] [blame] | 443 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 444 | } |
Saurav Das | 86af8f1 | 2015-05-25 23:55:33 -0700 | [diff] [blame] | 445 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 446 | } |