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