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